akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	string s;cin>>s;
	s = "?"+s;
	int cont = 0;
	int maxi = 0;
	for(char &c:s){
		if(c == 'R')cont++;
		else{
			maxi = max(maxi, cont);
			cont = 0;
		
		}
	
	}	
	cout<<max(maxi, cont)<<"\n";

	return 0;	
}


Measured memory_bytes: 3664
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<math.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    double n,k;
    cin>>n>>k;
    double ans=0;
    rep1(i,(int)n){
        double j=i;
        int aa= ceil(log2(k/j));
        if(aa<0) aa=0;
        ans+=pow(0.5,(double)aa)*(1.0/n);
    }
    cout<<setprecision(13)<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[5];
		for(int i = 0; i < 5; i++) {
			a[i] = sc.nextInt();
		}
		int ans = 0;
		int[] b = new int[5];
		int min = 10;
		int idx = 0;
		for(int i = 0; i < 5; i++) {
			b[i] = a[i] % 10;
			if(b[i] < min && b[i] != 0) {
				min = b[i];
				idx = i;
			}
		}
		for(int i = 0; i < 5; i++) {
			if(i != idx) {
				ans += (a[i]/10 + 1) * 10;
				if(b[i] == 0) {
					ans -= 10;
				}
			}
		}
		ans += a[idx];
		System.out.println(ans);
		sc.close();
	}
	
}



Measured memory_bytes: 21844
#include <stdio.h>

int cnt, n;
int G[100001];

int main()
{
	int i, x;
	scanf("%d", &n);
	for(i=1; i<=n; i++)
	{
		scanf("%d", &x);
		G[i] = x;		
	}
	
	for(i=1; i<=n; i++)
		if (i == G[G[i]])
			cnt++;

	printf("%d",cnt/2);
	return 0;   
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define MAX_N (100)

using namespace std;

long dp[MAX_N + 1][MAX_N + 1][3 * MAX_N + 1] = {};

int main() {
  // read inputs
  long N, W, ws[MAX_N], vs[MAX_N];
  scanf("%ld %ld", &N, &W);
  for (int i = 0; i < N; i++) {
    scanf("%ld %ld", &ws[i], &vs[i]);
  }

  // subtract ws[0] from all elements of ws
  const long w0 = ws[0];
  for (int i = 0; i < N; i++) {
    ws[i] -= w0;
  }

  // solve dp
  for (int i = 0; i < N; i++) {
    const long w = ws[i], v = vs[i];
    // printf("i = %d, w = %ld, v = %ld\n", i, w, v);
    for (int n = 1; n <= i + 1; n++) {
      for (int j = 0; j <= 3 * N; j++) {
        dp[i + 1][n][j] =
            max(dp[i][n][j], j >= w ? dp[i][n - 1][j - w] + v : 0);
        // printf("%ld ", dp[i + 1][n][j]);
      }
    //   printf("\n");
    }
  }
  long ans = 0;
  for (int n = 0; n <= N; n++) {
    if (W - n * w0 >= 0) {
      ans = max(ans, dp[N][n][min(W - n * w0, 3 * N)]);
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define REP(...) _overload3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n;
    cin>>n;
    vi a(n),b(n);
    REP(i,n){
        cin>>a[i]>>b[i];
    }
    ll ans=0;
    REPR(i,n-1){
        int p=(a[i]+ans)%b[i];
        ans+=(p?b[i]-p:0);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

int main()
{
    int N;
    std::cin >> N;
    std::vector<char> c(N);
    int n_red = 0;
    for (auto &&e : c)
    {
        std::cin >> e;
        if (e == 'R')
            n_red++;
    }
    int r_diff = 0;
    for (int i = 0; i < n_red; i++)
    {
        if (c[i] == 'W')
            r_diff++;
    }
    int w_diff = 0;
    for (int i = n_red; i < N; i++)
    {
        if (c[i] == 'R')
            w_diff++;
    }
    std::cout << std::max(r_diff, w_diff) << std::endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007
using namespace std;

long mod_inv(long n) {
    long ans = 1l;
    long mod = MOD - 2;
    for (; mod > 0; mod >>= 1) {
        if (mod & 1) {
            ans *= n;
            ans %= MOD;
        }
        n *= n;
        n %= MOD;
    }
    return ans;
}


long comb(int n, int k) {
    long ans = 1l;
    k = min(n - k, k);
    n++;
    for (long i = 1; i <= k; i++) {
        ans *= n - i;
        ans %= MOD;
        ans *= mod_inv(i);
        ans %= MOD;
    }
    return ans;
}

vector<long> factorize(long m) {
    vector<long> res;
    long a = 0l;
    while (m % 2 == 0) {
        a++;
        m /= 2;
    }
    res.push_back(a);
    for (long i = 3l; i <= m; i += 2) {
        long a = 0l;
        for (; m % i == 0; m /= i) {
            a++;
        }
        res.push_back(a);
    }
    return res;
}


int main() {
    int n, m;
    cin >> n >> m;
    vector<long> v = factorize(m);
    transform(v.begin(), v.end(), v.begin(), [n](long k) {
            return comb(k + n - 1, k);
            });
    long ans = 1l;
    for (long x: v) {
        ans *= x;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 262616
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;


class Program {
    

    internal static void Main(string[] args)
    {
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int A = inp[0];
        int B = inp[1];
        int X = inp[2];

        if ((A + B) >= X && A <= X) {
            WriteLine("YES");
        } else {
            WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define mprint(x) printf(FORMATCONVERSION(x),(x))
#define FORMATCONVERSION(x) _Generic((x),\
                                    int:"%d",unsigned int:"%u",\
                                    double:"%lf",long long int:"%lld",\
                                    unsigned long long int:"%llu",\
                                    char :"%c",char*:"%s")
 
int main(void){
    int n,m;
    scanf("%d %d",&n,&m);
    if(n < m){
        for(int i = 0;i < m;i++){
            mprint(n);
        }
    }else{
        for(int i = 0;i < n;i++){
            mprint(m);
        }
    }
    return 0;
}

Measured memory_bytes: 128
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

a,b,c,k = map(int, read().split())


v = 0
while b <= a:
    b *= 2
    v += 1

while c <= b:
    c *= 2
    v += 1

if v <= k:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }


    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
	int64_t A;
	int N, ans;
	cin >> N;
	ans = 10000;
	for(int i = 0; i < N; i++) {
		cin >> A;
		int j = 0;
		for(; !(A & 1); j++) {
			A >>= 1;
		}
		ans = min(ans, j);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")


signed main(){
	cout<<fixed<<setprecision(7);
	int n, m,  a, b, c, ma = 1010110;
	int count = 0;
	bool flag = false;
	string str;
	
	cin>>n;
	rep(i,n){
		cin>>a;
		count= 0;
		while(a%2 == 0){
			count++;
			a/=2;
		}
		ma = min(ma,count);
	}

	
	cout<<ma<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld; typedef long long ll; typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------
const int MX = 201010;
int dp[MX], p[MX];

int main(){
	int n; cin >> n;
	FOR(i,1,n) cin >> p[i];

	int lng=0;
	FOR(i,1,n){
		dp[p[i]] = dp[p[i]-1] + 1;
		chmax(lng,dp[p[i]]);
	}

	cout << n - lng << endl;
	
    return 0;
}

Measured memory_bytes: 1792
n,k,s = map(int,input().split())
#一旦s+1で全部埋める。
o = [s + 1] * n
#sがaの最大値の10^9の時はまずいので、1で埋めなおす
if(s == 10**9):o = [1] * n
#k個だけ、sで埋めなおす
for i in range(k):o[i] = s
#あとは出すだけ。
print(*o)

Measured memory_bytes: 10756
N, D = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
s = 0
for i in range(N - 1) :
    for j in range(i + 1, N) :
        l = 0.0
        for d in range(D) :
            l += (x[i][d] - x[j][d]) ** 2
        length = l ** (1/2)
        if length.is_integer() :
            s += 1
print(s)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;

int N;
int a[101];
vector<int> answer;
bool iend;

void func(int* b,int n) {
	if (iend) {
		return;
	}

	if (n == 0) {
		while (!answer.empty()) {
			cout << answer.back() << endl;
			answer.pop_back();
		}
		iend = true;
		return;
	}

	int tmp = -1;

	for (int i = n; i >= 1; i--) {
		if (b[i] == i) {
			tmp = i;
			break;
		}
	}

	if (tmp == -1) {
		cout << -1 << endl;
		iend = true;
	}

	answer.push_back(tmp);
	int c[101];
	for (int j = 0; j <= n; j++) {
		if (j < tmp) c[j] = b[j];
		else c[j] = b[j + 1];
	}
	func(c, n - 1);

	return;
}


int main() { 
	iend = false;

	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}

	func(a, N);

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		if(a >= 3200) {
			System.out.println(s);
		} else {
			System.out.println("red");
		}
	}
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int k=n;
    int sum=0;
    while(n!=0){
        sum+=(n%10);
        n/=10;
    }
    if(k%sum==0){cout<<"Yes";}
    else cout<<"No";







    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,K,C,T[N],ans;
int main()
{
		scanf("%d%d%d",&n,&C,&K);
		for (i=1;i<=n;++i) scanf("%d",&T[i]);
		sort(T+1,T+n+1);
		for (i=1;i<=n;i=j)
		{
				for (j=i;j<=n&&j<i+C&&T[j]-T[i]<=K;++j);
				++ans;
		}
		printf("%d\n",ans);
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


int main() {
	int N;
	string S1, S2;
	cin >> N >> S1 >> S2;
	mint ans = 0;
	vector<int>X;
	for (int k = 0; k < S1.size(); ++k) {
		if (S1[k] ==S2[k]) {
			X.push_back(1);
		}
		else {
			X.push_back(0);
			++k;
		}
	}
	for (int i = 0;i<X.size();++i) {
		if (0 ==i) {
			if (1 == X[i]) {
				ans = 3;
			}
			else {
				ans = 6;
			}
		}
		else {
			if (1 == X[i]) {
				if (1== X[i-1]) {
					ans *= 2;
				}
				else {
					ans *= 1;
				}
			}
			else {
				if (1 == X[i - 1]) {
					ans *= 2;
				}
				else {
					ans *= 3;
				}
			}
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void) {
    int N, x, i;
    char S[100];
    scanf("%d%s", &N, S);
    x=0;
    for (i=0; i<=N-3; i++) {
        if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') x++;
    }
    printf("%d", x);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> perm(N);
    {
        vector<pair<long, long>> p(N);
        for(auto& i : p)cin >> i.first >> i.second;
        sort(p.begin(), p.end());
        vector<unsigned long> idx(N);
        iota(idx.begin(), idx.end(), 0UL);
        sort(idx.begin(), idx.end(), [&p](auto i, auto j){return p[i].second < p[j].second;});
        for(unsigned long i = 0; i < N; ++i)perm[idx[i]] = i;
    }

    constexpr unsigned long MOD = 998244353;
    vector<unsigned long> binary(N + 1);
    binary[0] = 1;
    for(unsigned long i = 0; i < N; ++i)binary[i + 1] = binary[i] * 2 - (binary[i] > 499122176) * MOD;

    vector<unsigned long> fenwick_tree(N);
    auto que = [&fenwick_tree, &N](unsigned long i){
        unsigned long r = i;
        unsigned long ret{fenwick_tree[i]};
        while(i &= i + 1)ret += fenwick_tree[--i];
        i = r;
        while(i < N){
            ++fenwick_tree[i];
            i |= i + 1;
        }
        return ret;
    };

    vector<unsigned long> coef(N + 1);
    for(unsigned long i = 0; i < N; ++i){
        auto q = que(perm[i]);
        ++coef[q];
        ++coef[i - q];
        ++coef[perm[i] - q];
        ++coef[N - i - perm[i] + q - 1];
    }

    cout << inner_product(binary.begin(), binary.end(), coef.begin(), (N + MOD - 4) * (binary[N] - 1) % MOD, plus<>(), [&MOD](auto a, auto b){return a * b % MOD;}) % MOD << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
template< typename T >
struct segment_tree {
  int sz;
  vector<T> seg;
  const function<T(T, T)> o;
  const T id;
  segment_tree(int n, const function<T(T, T)> o, const T &id)
    : o(o)
    , id(id)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, id);
  }
  void update(int k, const T &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = o(seg[2 * k], seg[2 * k + 1]);
    }
  }
  T find(int a, int b) {
    T L = id, R = id;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = o(L, seg[a++]);
      if(b & 1) R = o(seg[--b], R);
    }
    return o(L, R);
  }
  T operator[](const int &k) const {
    return seg[k + sz];
  }
  void print() {
    cout << "segment_tree:" << endl;
    int crr = 1;
    for (int p = sz; p; p >>= 1) {
      for (int i = 0; i < sz; i++) {
        cout
            << setw(12)
            << (i % p == 0 ? to_string(seg[crr++]) : "")
            << (i < sz - 1 ? "" : "\n");
      }
    }
    cout << endl;
  }
};
int main() {
  int n, q;
  cin >> n >> q;
  segment_tree<int> sgt(n, [](int a, int b) {return min(a, b);}, INT_MAX);
  while (q--) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c) cout << sgt.find(x, y + 1) << endl;
    else sgt.update(x, y);
  }
  return 0;
}


Measured memory_bytes: 3900
#include<stdio.h>
#include<algorithm>
using namespace std;
long long A[100005],QS[100005];
main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    sort(A,A+n);
    QS[0] = A[0];
    for(int i=1;i<n;i++)
    {
        QS[i] = QS[i-1]+A[i];
    }
    for(int i=n-2;i>=0;i--)
    {
        if(QS[i]*2 < A[i+1])
        {
            printf("%d",n-i-1);
            return 0;
        }
    }
    printf("%d",n);
}


Measured memory_bytes: 1664
use strict;
use warnings;
use utf8;

my ($N) = split /\s/, <STDIN>;
my ($A) = split /\s/, <STDIN>;
my ($B) = split /\s/, <STDIN>;
my ($C) = split /\s/, <STDIN>;
my ($D) = split /\s/, <STDIN>;
my ($E) = split /\s/, <STDIN>;

#my ($ANS) = split /\s/, <STDIN>;


my @x;
push @x, $A, $B, $C, $D, $E;

my @z = sort {$a <=> $b} @x;

#printf "%s\n", $N;
#printf "%s\n", join " ", @x;

my $j = $N / $z[0];
my $k = int($j);
if ($j == $k) {
    printf "%s\n", 4 + $j;
} else {
    printf "%s\n", 4 + $k + 1;
}

#printf "%s\n", $N / $z[0];
#printf "%s\n", int(0.5 + $N / $z[0]);
#printf "%s\n", int(((10 * $N) / $z[0]) / 10) + $z[0];
#printf "%s-\n", $ANS;




Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
int main(){
	int n;
	while(scanf("%d",&n),n){
		int m=0,v[4][2] = {{0,-1},{-1,0},{1,-1},{-1,-1}},map[66049] = {0};
		for(int y=1;y<=n;y++)
			for(int x=1;x<=n;x++)scanf("%1d",map+x+257*y);

		for(int i=0;i<4;i++){
			int dp[257][257] = {{0}};
			for(int k=1;k<=n;k++)
				for(int j=1;j<=n;j++)m = std::max(m,dp[j][k] = map[j+k*257]?map[j+257*k] + dp[j+v[i][0]][k+v[i][1]]:0);
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

#define REP(var, i, j) for (int var=(i); var<(j); var++)

//定数
const int MAX_R = 10;
const int MAX_C = 10000;
//入力
int R, C;
int lol[MAX_R+2][MAX_C+2];

int main(){
    queue<int> res;
    while (cin >> R && cin >> C && R != 0 && C != 0){
        REP(i, 0, R){
            REP(j, 0, C){
                cin >> lol[i][j];
            }
        }
        int ans = 0;
        REP(k, 0, (1<<R)){
            int sum = 0;
            REP(j, 0, C){
                int cnt = 0;
                REP(i, 0, R){
                    cnt += lol[i][j]^(((1<<i)&k)>>i);
                }
                sum += max(cnt, R-cnt);
            }
            ans = max(ans, sum);
        }
        res.push(ans);
    }

    while(res.size()){
        cout << res.front() << endl;
        res.pop();
    }
}


Measured memory_bytes: 3476
s=list(input())
a,b,c,d=s[0],s[1],s[2],s[3]
op=['+','-']
ans='=7'
for i in op:
    for j in op:
        for k in op:
            if eval(a+i+b+j+c+k+d)==7:
                print(a+i+b+j+c+k+d+ans)
                exit()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

int main(){
    string n,t; cin >> n >>t;
    int ans = 0;
    rep(i,n.size()){
        if(n[i]==t[i]){
            ans++;
        }
    }
    cout << ans<<endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
using namespace std;
 
int n, k;
typedef  long long ll;
int main(){

    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    //printf("%s", s.c_str());
    if(s[0] == s[2]){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 305
const int mod=998244353;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int dp[N][N][N],n,ans;
bool ok[N][N][N];
char s[N];
#define ck(x) (x>=mod?x-mod:x)
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=0;i<n;++i){
		ok[i][0][0]=true;
		for(int j=0;j<=i;++j){
			for(int k=0;k<=i;++k){
				if(!ok[i][j][k])continue;
				if(s[i+1]=='0'||s[i+2]=='0')ok[i+2][j+1][k]=true;
				if(s[i+1]=='1'||s[i+2]=='1')ok[i+2][j][k+1]=true;
				if(j|k)ok[i+1][j][k]=true;
				if(s[i+1]=='0'&&k)ok[i+1][j+1][k-1]=true;
				if(s[i+1]=='1'&&j)ok[i+1][j-1][k+1]=true;
			}
		}
	}
	dp[n][0][0]=1;
	for(int i=n;i>=1;--i){
		for(int j=0;j<=n;++j){
			for(int k=0;k<=n;++k){
				const int t=dp[i][j][k];
				if(!t)continue;
				dp[i-1][j][k]=ck(dp[i-1][j][k]+t);
				if(s[i]=='0')dp[i][j][k+1]=ck(dp[i][j][k+1]+t);
				else dp[i][j+1][k]=ck(dp[i][j+1][k]+t);
			}
		}
	}
	for(int i=0;i<=n;++i){
		for(int j=0;j<=i;++j){
			for(int k=0;k<=i;++k){
				if(ok[i][j][k])ans=ck(ans+dp[i][j][k]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 120988
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,t,m,i,f=0,j,k,x,r;
    ll ans=0;
    cin >> n >> m ;
    ll a[m];
    rep(i,m) 
    {
        cin >> a[i] ;
        ans+=a[i];
    }
    if(ans>n) cout << -1 ;
    else cout << n-ans ;
    return 0;
}

Measured memory_bytes: 3664
n, x, m = map(int, input().split())
mn = min(n, m)
P = [] # pre_sum
sum_p = 0 # sum of pre + cycle
X = [-1] * m # for cycle check & pre_len
for i in range(mn):
    if X[x] > -1:
        cyc_times, nxt_len = divmod(n-X[x], len(P) - X[x])
        cyc = (sum_p - P[X[x]]) * cyc_times
        remain = P[X[x] + nxt_len]
        print(cyc + remain)
        exit()
    P.append(sum_p)
    sum_p += x
    X[x] = i
    x = x*x % m
print(sum_p)


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    if(a.at(0)==b.at(2)&&a.at(1)==b.at(1)&&a.at(2)==b.at(0)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

ll gcd(ll a, ll b) {
  return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

int main () {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

template<typename T> T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int x;
    cin >> x;
    int y = x;
    while (y % 360 != 0) y += x;
    cout << y / x << endl;
    return 0;
}

Measured memory_bytes: 3620
// fahadmd16(IIEST Shibpur)

#include<bits/stdc++.h>
#include <algorithm>
using namespace std;

#define ll                          long long
#define pb                          push_back
#define pf                          push_front
#define eb                          emplace_back
#define mp                          make_pair
#define ff                          first
#define ss                          second
#define db                          double
#define pll                         pair<ll, ll>
#define ALL(a)                      (a).begin(),(a).end()
#define endl                        "\n"

#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define ford(i, n) for (ll i = n - 1; i >= 0; i--)
#define forab(i, a, b) for(ll i = a; i < b; i++)
#define eps 1e-10

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)


#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;


const ll sz = 1e5 + 3;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9;


typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;

ll power(ll n, ll k, ll m) {
    ll ans = 1;
    while (k) {
        if (k & 1)ans = (ans * n) % m;
        k /= 2;
        n = (n * n) % m;
    }
    return ans;
}

void solver() {
    ll n; cin >> n;
    db pi = 2 * acos(0.0);
    cout << fixed << setprecision(5) << 2 * pi*n << endl;

}


int main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    IOS;
    ll T = 1; //cin >> T;
    forn1(i, T + 1) {
        // clock_t z = clock();
        solver();
        // debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
    }
    return 0;
}


Measured memory_bytes: 3800
S=input()

def isKaibun(SS):
  #print(SS)
  for i in range(len(SS)):
    if SS[i]!=SS[-i-1]:
      return False
  return True

N=len(S)
if not isKaibun(S):
  print("No")
elif not isKaibun(S[:(N-1)//2]):
  print("No")
elif not isKaibun(S[(N+1)//2:]):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#define MAX 33*21
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
int d[MAX][MAX];
int n,m,t,p,cmd,line;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
void up(int sy,int border){
  int end = border + 1 + (border-sy);
  for(int x=0;x<MAX;x++){
    for(int y=sy;y<=border;y++){
      ll ady = end - (y-sy);
      d[ady][x] += d[y][x];
      d[y][x] = 0;
    }
  }
}
void right(int sx,int border){
  int end = border + 1 + (border-sx);
  for(int y=0;y<MAX;y++){
    for(int x=sx;x<=border;x++){
      ll adx = end - (x-sx);
      d[y][adx] += d[y][x];
      d[y][x] = 0;
    }
  }
}
signed main(){
  int ans=0,most_l,most_u,x,y;
  cin >> n >> m >> t >> p;
  while(n!=0&&m!=0){
    most_l = most_u = 0;
    fill(d[0],d[MAX],0);
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
        d[i][j] = 1;
      }
    }
    for(int i=0;i<t;i++){
      cin >> cmd >> line;
      if(cmd==1){
        right(most_l,most_l+line-1);
        most_l += line;
      }else{
        up(most_u,most_u+line-1);
        most_u += line;
      }
    }
    for(int i=0;i<p;i++){
      cin >> x >> y;
      ans = d[most_u+y][most_l+x];
      cout << ans << endl;
    }
    cin >> n >> m >> t >> p;
  }
}



Measured memory_bytes: 4980
#include <bits/stdc++.h>
#define EB emplace_back

typedef long long ll;
typedef std::pair <ll, ll> pr;
const int N = 131154, L = 500000;

int n;
int p[N], lc[N], rc[N];
ll dep[N];
pr g[L], h[L], tmp[L];
std::vector <pr> f[N];

inline void link(int x, int px) {(lc[px] ? rc[px] : lc[px]) = x;}

inline bool check(ll v) {
	int i, j, x, l, r, L, R, cg, ch; ll lim;
	for (x = n; x; --x) {
		f[x].clear(), l = lc[x], r = rc[x];
		if (!(l || r)) {f[x].EB(dep[x], dep[x]); continue;}
		assert(l && r);
		L = f[l].size(), R = f[r].size(), lim = v + 2 * dep[x];
		for (cg = ch = j = i = 0; i < L; ++i) {
			for (; j < R && f[l][i].first + f[r][j].second > lim; ++j);
			if (j == R) break;
			g[cg++] = pr(f[l][i].second, f[r][j].first);
			h[ch++] = pr(f[r][j].first, f[l][i].second);
		}
		std::reverse(g, g + cg), j = std::merge(g, g + cg, h, h + ch, tmp) - tmp;
		if (!j) return false;
		for (f[x].EB(*tmp), i = 1; i < j; ++i)
			if (tmp[i].second < f[x].back().second) f[x].EB(tmp[i]);
	}
	return true;
}

int main() {
	int i; ll L = 0, R = 0, M;
	scanf("%d", &n);
	for (i = 2; i <= n; ++i)
		scanf("%d%lld", p + i, dep + i), link(i, p[i]), R += dep[i], dep[i] += dep[ p[i] ];
	for (; L < R; check(M = (L + R) / 2) ? R = M : (L = M + 1));
	printf("%lld\n", L);
	return 0;
}

Measured memory_bytes: 36216
#include <bits/stdc++.h>
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int n, l;
    cin >> n >> l;
    int eaten = 65536;
    for(int i=l;i<l+n;i++) if(abs(eaten) > abs(i)) eaten = i;
    int64_t sum = 0;
    for(int i=l;i<l+n;i++) sum += i;

    cout << sum - eaten << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
	

	string s;
	cin >> s;
	int n = s.size();
	vll t(n+1,0);
	
	int x = 1;
	rep(i,n){
		t[i+1] = (t[i] + int(s[n-1-i]-'0')*x)%2019;
		x = (x*10)%2019;
	}
	
	int cnt[2031] = {};
	rep(i,n+1)cnt[t[i]]++;

	int ans = 0;
	rep(i,2024)ans += cnt[i]*(cnt[i]-1)/2;

	cout << ans << endl;

	rep(i,n+1)cerr << t[n-i] << " ";
	cerr << endl;



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://abc174.contest.atcoder.jp/tasks/abc174_b
// rm -r -f test;oj d https://atcoder.jp/contests/abc164/tasks/abc164_d

Measured memory_bytes: 5184
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

char S[101010],T[101010];
ll nxt[101010][40],Sn,Tn,alp[30];
ll i, j, k, ans;



int main(){
    scanf("%s%s", S,T);
    for (Sn = 0; S[Sn];Sn++)
        ;
    for (Tn = 0; T[Tn];Tn++)
        ;
    
    fornum(i,0,30){
        alp[i] = -1e9;
    }
    for (i = Sn - 1; i >= 0;i--){
        alp[S[i] - 'a'] = i+Sn;
    }
    for (i = Sn - 1; i >= 0; i--)
    {
        alp[S[i] - 'a'] = i;
        fornum(j, 0, 30)
        {
            nxt[i][j] = alp[j] - i + 1;
        }
        
    }
    fornum(i,0,Tn){
        ll a = nxt[ans % Sn][T[i] - 'a'];
        if(a<0){
            printf("-1");
            return 0;
        }
        ans += a;
        //printf("%lld\n", ans);
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 31744
package main

import "fmt"

const (
	N_NONE = iota
	N_A
	N_AB
	N_ABC
)

func main() {
	var s string
	fmt.Scanln(&s)

	modN := int64(1000000000 + 7)
	mod := func(n int64) int64 {
		return n % modN
	}

	cur := []int64{1, 0, 0, 0}
	var next []int64
	var pattern int64

	for i := 0; i < len(s); i++ {
		if s[i] == '?' {
			pattern = 3
		} else {
			pattern = 1
		}

		next = make([]int64, len(cur))
		for j := N_NONE; j <= N_ABC; j++ {
			next[j] = mod(cur[j] * pattern)
		}

		for _, j := range transitions(s[i]) {
			next[j] = mod(next[j] + cur[j-1])
		}

		cur = next
	}

	fmt.Println(next[N_ABC])
}

func transitions(c byte) []int64 {
	switch c {
	case 'A':
		return []int64{N_A}
	case 'B':
		return []int64{N_AB}
	case 'C':
		return []int64{N_ABC}
	case '?':
		return []int64{N_A, N_AB, N_ABC}
	}
	panic("unexpected char")
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<double> x(10), y(10);
/* function */
double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
/* main */
int main(){
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    vector<int> v(N);
    for (int i = 0; i < N; i++) v[i] = i;
    double ans = 0.0;
    do {
        for (int i = 0; i < N - 1; i++) ans += dist(v[i], v[i+1]);
    } while (next_permutation(v.begin(), v.end()));
    int fact = 1;
    for (int i = 2; i <= N; i++) fact *= i;
    cout << fixed << setprecision(10) << ans / fact << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;

int main()
{
	int n;
	cin>>n;
	cout<<n/500*1000+(n%500)/5*5<<endl; 
	return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int arr[3][3], n, i, j, x;
	int mark[3][3];
	fo(i, 0, 3) {
		fo(j, 0, 3)
		cin >> arr[i][j];
	} 
	cin >> n;
	map <int, int> mp;
	fo(i, 0, n) {
		cin >> x;
		mp[x]++;
	}
	fo(i, 0, 3) {
		fo(j, 0, 3) 
		mark[i][j] = (mp[arr[i][j]] > 0 ? 1 : 0);
	}
	fo(i, 0, 3) {
		int sum = 0;
		fo(j, 0, 3) {
			sum += mark[i][j];
		}
		if(sum == 3) {
			cout << "Yes";
			return 0;
		}
	}
	fo(j, 0, 3) {
		int sum = 0;
		fo(i, 0, 3) {
			sum += mark[i][j];
		}
		if(sum == 3) {
			cout << "Yes";
			return 0;
		}
	}
	int sum = 0;
	fo(i, 0, 3)
	sum += mark[i][i];
	
	if(sum == 3) {
		cout << "Yes";
		return 0;
	}
	sum = 0;
	fo(i, 0, 3)
	sum += mark[3 - 1 - i][i];
	if(sum == 3) {
		cout << "Yes";
		return 0;
	} 
	cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int x, y; cin >> x >> y;
    vector<int> a(5);
    a[3] = 100000;
    a[2] = 200000;
    a[1] = 300000;
    cout << a[x] + a[y] + (x == y && y == 1 ? 400000 : 0) << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, a[200010];
    int xr = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        xr ^= a[i];
    }
    for (int i = 0; i < n; i++)
    {
        if (i)
            cout << " ";
        cout << (a[i] ^ xr);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4368
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    vector<string> img;
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        img.push_back(s);
    }
    for (int i = 0; i < img.size(); ++i) {
        cout << img[i] << endl;
        cout << img[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;p<b;p++)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()

#define INF 0x3f3f3f3f


int main() {
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n,i,sum=0ll;
    cin>>n;
    ll last_3 = n - n%3,last_5 = n - n%5,last_15 = n - n%15;
    //ll sum = ((n/3)/2)*(3+last_3) + ((n/5)/2)*(5+last_5) + ((n/15)/2)*(15+last_15);
    for(i=1 ; i<=n ; i++)if(i%3 && i%5)sum+=i;
    cout<<(sum);
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define what_is(x) cerr << #x <<" is " << x << endl;
typedef long long ll;
const double PI = 3.14159265358979;
const ll INF =  1e15 + 7;
const ll MOD = 998244353;
const ll nax = 1010;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc = 1;
	// cin >> tc;
	while (tc--) {
		int a, b;
		cin  >> a >> b;
		cout << a  * b;
	}
	return 0;
}




















Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    int N;
    cin >>N;
    vi tmp(N,0);

    rep(i,0,N){
        cin>>tmp[i];
    }
    int ans=0;
    int maxx=0;
    rep(i,1,N){
        if(tmp[i-1]>=tmp[i]){
            ans++;
        }else{
            maxx=max(maxx,ans);
            ans=0;
        }
    }
    maxx=max(maxx,ans);
    cout<<maxx<<endl;

    
    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int f[26];
const int N=2e5+4;
int32_t main()
{
	string s;
	cin>>s;
	int n=s.length();
	int ans=1;
	for(int i=0;i<n;i++)
	{
		int cur=s[i]-'a';
		int len=i+1;
		
		ans+=i-f[cur];
		f[cur]++;
	}
	cout<<ans;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;

int dp[1005];

const char domino[15][15][15] = {
    {}, // 0
    {}, // 1
    {}, // 2
    {}, // 3
    {"aacd", "bbcd", "efgg", "efhh"}, // 4
    {"aabbc", "dee.c", "d..fg", "j..fg", "jiihh"}, // 5
    {}, // 6
    {"aabbcc.", "dd.ee.f", "..h..gf", "..h..gm", "ii.jj.m", "..k..ln", "..k..ln"} // 7
};

char ans[1005][1005];

int main(){
    int N;
    scanf("%d", &N);
    memset(ans, 0, sizeof(ans));
    if(N < 3){printf("-1"); return 0;}
    if(N == 3){
        printf("aa.\n..b\n..b\n");
        return 0;
    }else if(N == 6){
        printf("aa....\n..b...\n..b...\n...aa.\n.....b\n.....b\n");
        return 0;
    }

    dp[0] = 0;
    dp[1] = 1001;
    dp[2] = 1001;
    dp[3] = 1001;
    dp[4] = 1;
    dp[5] = 1;
    dp[6] = 1001;
    dp[7] = 1;
    for(int i = 8; i <= N; i ++){
        dp[i] = N;
        for(int j: {4,5,7}){
            //printf("i=%d j=%d\n", i, j);
            dp[i] = min(dp[i], 1+dp[i-j]);
        }
        //printf("dp[%d]=%d\n", i, dp[i]);
    }

    for(int i = 0; i < N; i ++){
        for(int j = 0; j < N; j ++){
            ans[i][j] = '.';
        }
    }

    int n = N;
    while(n){
        for(int j: {4,5,7}){
            if(dp[n] == dp[n-j]+1){
                //printf("n=%d j=%d\n", n, j);
                for(int i = n-j; i < n; i ++){
                    for(int k = n-j; k < n; k ++){
                        ans[i][k] = domino[j][i-(n-j)][k-(n-j)];
                    }
                }
                n -= j;
                break;
            }
        }
    }

    for(int i = 0; i < N; i ++){
        printf("%s\n", ans[i]);
    }
}


Measured memory_bytes: 2176
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,area1=0,area2=0;
  cin>>a>>b>>c>>d;
  area1=a*b;
  area2=c*d;
  if(area1>area2)
    cout<<area1;
  else if(area2>area1)
    cout<<area2;
  else
    cout<<area1;  
		return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>

int check(int *a, int x)
{
	int i = 0;
	while (a[i])
	{
		if (x == a[i])
			return 1;
		i++;
	}
	return (0);
}

// int		main(void)
// {
// 	int n,m,x;
// 	scanf("%d%d%d", &n, &m, &x);
// 	int a[m];
// 	int i = 0;
// 	int count1 = 0;
// 	int count2 = 0;
// 	while (i < m)
// 		scanf("%d", &a[i++]);
// 	i = x;
// 	int zero = a[0] - 1;
// 	if (x < n)
// 	{
// 		while (i < x)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i++;
// 		}
// 	}
// 	else
// 	{
// 		while (i > n)
// 		{
// 			if (check(a, i))
// 				count1++;
// 			i--;
// 		}
// 	}
// 	i = x;
// 	while (i > zero)
// 	{
// 		if (check(a, i))
// 			count2++;
// 		i--;
// 	}
// 	if (count1 < count2)
// 		printf("%d\n", count1);
// 	else
// 		printf("%d\n", count2);
// 	return (0);
// }

int		main(void)
{
	int n,m,x;
	scanf("%d%d%d", &n, &m, &x);
	int a[m];
	int i = 0;
	int count1 = 0;
	int count2 = 0;
	while (i < m)
		scanf("%d", &a[i++]);
	i = 0;
	int zero = a[0] - 1;
	while (i < m)
	{
		if(x < a[i])
			count1++;
		else
			count2++;
		i++;
	}
	// i = x;
	// while (i > zero)
	// {
	// 	if (check(a, i))
	// 		count2++;
	// 	i--;
	// }
	if (count1 < count2)
		printf("%d\n", count1);
	else
		printf("%d\n", count2);
	return (0);
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<map>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;


int main(){
	A:;
	int n,m;
	cin>>n>>m;
	if(n==0)return 0;
	
	int sina[101];
	rep(i,m){
		cin>>sina[i];
	}
	
	int st = 0, en = 1500000;
	
	while(1){
		int half = (st+en)/2;
		
		int dan = 0;
		int sum = 0;
		int ind = 0;
		
		bool erflg = false;
		
		//printf("%d %d %d\n",st,en,half);
		while(1){
			//printf("%d %d %d\n",dan,sum,ind);
			if(ind >= m)break;
			if(dan > n)break;
			if(sum+sina[ind]<=half){
				sum += sina[ind];
				ind++;
			}else{
				sum = 0;
				dan++;
			}
			
		}
		
		if(dan>=n){
			st = half;
		}else{
			en = half;
		}
		
		if(st+1 >= en)break;
	}
	
	printf("%d\n",en);
	
	goto A;
}

Measured memory_bytes: 1144