akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


//naosu
long int gcd(long int a,long int b){
  long int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


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


long int f(long int n,long int c,long int d){
  long int cnt=n/c+n/d-n/lcm(c,d);
  return n-cnt;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int a,b,k;
  scanf("%d%d%d",&a,&b,&k);

  if(b-a+1<=2*k){
    for(int i=a;i<=b;i++){
      printf("%d\n",i);
    }
  }

  else{
    for(int i=a;i<a+k;i++){
      printf("%d\n",i);
    }
    for(int i=b-k+1;i<=b;i++){
      printf("%d\n",i);
    }
  }

  return 0;
}

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

using ll = long long;
using v1 = vector<int>;

int main(){
	ll a, b, x;
	cin >> a >> b >> x;
	ll m = a%x;
	if(m != 0){
		a -=  m;
		cout << (b-a)/x << endl;
	}else{
		cout << (b-a)/x+1 << endl;
	}
	/*ll c = 0;
	for(a; a<=b; ++a){
		if(a%x==0) c++;
	}
	cout << c << endl;*/
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1e9+7;
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;

queue<pair<long double, long double> > p;
const long double h = sqrt(3)/2.0;

void fractale(){
    pair<long double, long double> l, r, temp;
    do {
        l = p.front(); p.pop();
        r = p.front(); p.pop();
        long double theta = atan2(r.second-l.second, r.first-l.first);
        long double leng = sqrt((r.second-l.second)*(r.second-l.second)+(r.first-l.first)*(r.first-l.first));
        p.push(l);
        temp = make_pair(l.first+(r.first-l.first)/3.0, l.second+(r.second-l.second)/3.0);
        p.push(temp);
        p.push(temp);
        temp = make_pair(l.first+(r.first-l.first)/2.0-leng*h*sin(theta)/3.0, l.second+(r.second-l.second)/2.0+leng*h*cos(theta)/3.0);
        p.push(temp);
        p.push(temp);
        temp = make_pair(l.first+2*(r.first-l.first)/3.0, l.second+2*(r.second-l.second)/3.0);
        p.push(temp);
        p.push(temp);
        p.push(r);
    } while (r.first != 100);
}

int main(){
    int n;
    cin >> n;
    pair<long double, long double> temp = make_pair(0.0, 0.0);
    p.push(temp);
    temp = make_pair(100.0, 0.0);
    p.push(temp);
    for (int i = 0; i < n; i++){
        fractale();
    }
    cout << fixed << setprecision(8);
    cout << p.front().first << " " << p.front().second << endl;
    p.pop();
    if (n > 0){
        do {
            cout << p.front().first << " " << p.front().second << endl;
            p.pop(); p.pop();
        } while (p.front().first != 100);
    }
    cout << p.front().first << " " << p.front().second << endl;
}



Measured memory_bytes: 3820
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

class DMazeMaster {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    int h, w;
    in >> h >> w;
    vector<string> grid(h);
    forn(i, h)in >> grid[i];

    int ans = 0;

    for (int i = 0; i < h; ++i)
      for (int j = 0; j < w; ++j) {
        if (grid[i][j] == '.') {

          queue<pair<int, int> > q;
          q.push({i, j});
          vector<vector<int> > dist(h, vector<int>(w, -1));
          dist[i][j] = 0;

          while (!q.empty()) {
            auto p = q.front();
            q.pop();

            for (int x = -1; x <= 1; x++)
              for (int y = -1; y <= 1; ++y) {
                if (abs(x) + abs(y) <= 1) {
                  if (x == 0 && y == 0)continue;
                  int nx = p.first + x;
                  int ny = p.second + y;
                  if (min(nx, ny) >= 0 && nx < h && ny < w && grid[nx][ny] != '#' && dist[nx][ny] == -1) {
                    dist[nx][ny] = dist[p.first][p.second] + 1;
                    q.push({nx, ny});
                  }
                }
              }
          }
          for (auto row: dist)for (auto col : row)ans = max(ans, col);
        }
      }
    out << ans << endl;
  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  DMazeMaster solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(100009);
  for(int i = 0; i < n; i++){
    int k;
    cin >> k;
    a.at(k)++;
  }
  
  int mi = 0;
  for(int i = 1; i < 100007; i++) mi += max(0, a.at(i) - 1);
  mi = (mi+1) / 2 * 2;
  
  cout << n - mi << endl;
}

Measured memory_bytes: 3772
#include<iostream>
 
using namespace std;
 
int main(){
  int H,N;
  cin >> H >> N;
  int sum=0;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    sum += tmp;
  }
  
  if(H<=sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 256
import itertools

n = input()
a = list(map(int, input().split()))
q = input()
 
aset = set()
for i in range(1, len(a) + 1):
    aset |= set(sum(combi) for combi in itertools.combinations(a, i))
 
for m in map(int, input().split()):
    print('yes' if m in aset else 'no')

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

using namespace std;

typedef long long ll;
const int maxn = (int) 1e5 + 1;

int n;
int a, q;
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(a != i){
            q++;
        }
    }
    if(q > 2){
        cout << "NO";
    }
    else {
        cout << "YES";
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

H, W = map(int, raw_input().split())
S = [raw_input() for _ in range(H)]

used = [[False] * W for _ in range(H)]

def func(y, x, c):
    if y < 0 or x < 0 or y >= H or x >= W:
        return 0, 0
    if used[y][x] or S[y][x] == c:
        return 0, 0

    used[y][x] = True

    rw, rb = 0, 0
    if S[y][x] == '.':
        rw = 1
    else:
        rb = 1
    ret = func(y - 1, x, S[y][x])
    rw += ret[0]
    rb += ret[1]
    ret = func(y + 1, x, S[y][x])
    rw += ret[0]
    rb += ret[1]
    ret = func(y, x - 1, S[y][x])
    rw += ret[0]
    rb += ret[1]
    ret = func(y, x + 1, S[y][x])
    rw += ret[0]
    rb += ret[1]
    return rw, rb

ans = 0

for i in range(H):
    for j in range(W):
        ret = func(i, j, ' ')
        ans += ret[0] * ret[1]

print ans

Measured memory_bytes: 140664
#include <cstdio>
#include <cstdlib>

int main(void) {
    char l2[128];
    int N = 0;
    int K = 0;
    scanf("%d%d", &N, &K);
    scanf("%c", l2);
    int answer = 0;
    for (int i=0; i<N; ++i) {
        int tmp;
        scanf("%d", &tmp);
        if (tmp >= K) {
            answer++;
        }
    }
    printf("%d", answer);
    return 0;
}

Measured memory_bytes: 128
import sys
import fractions

def in_ctrl():
    _input = [_.rstrip() for _ in sys.stdin.readlines()]
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    N = int(_input[0])
    S = _input[1]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return N,S


def out_ctrl(s):
    print(s)


if __name__ == "__main__":
    N,S = in_ctrl()
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    R = list(map(bool,list(map(int,list(S.replace('R','1').replace('G','0').replace('B','0'))))))
    G = list(map(bool,list(map(int,list(S.replace('R','0').replace('G','1').replace('B','0'))))))
    B = list(map(bool,list(map(int,list(S.replace('R','0').replace('G','0').replace('B','1'))))))
    R_cum, G_cum, B_cum = {}, {}, {}
    for i,r in enumerate(R):
        if r:
            for j,g in enumerate(G[i+1:]):
                if g:
                    if i+j+2 not in B_cum:
                        B_cum[i+j+2] = sum(B[i+j+2:])
                    if i+2*j+2 < N:
                        cnt += B_cum[i+j+2] - B[i+2*j+2]
                    else:
                        cnt += B_cum[i+j+2]
            for j,g in enumerate(B[i+1:]):
                if g:
                    if i+j+2 not in G_cum:
                        G_cum[i+j+2] = sum(G[i+j+2:])
                    if i+2*j+2 < N:
                        cnt += G_cum[i+j+2] - G[i+2*j+2]
                    else:
                        cnt += G_cum[i+j+2]
    for i,r in enumerate(G):
        if r:
            for j,g in enumerate(R[i+1:]):
                if g:
                    if i+j+2 not in B_cum:
                        B_cum[i+j+2] = sum(B[i+j+2:])
                    if i+2*j+2 < N:
                        cnt += B_cum[i+j+2] - B[i+2*j+2]
                    else:
                        cnt += B_cum[i+j+2]
            for j,b in enumerate(B[i+1:]):
                if b:
                    if i+j+2 not in R_cum:
                        R_cum[i+j+2] = sum(R[i+j+2:])
                    if i+2*j+2 < N:
                        cnt += R_cum[i+j+2] - R[i+2*j+2]
                    else:
                        cnt += R_cum[i+j+2]
    for i,r in enumerate(B):
        if r:
            for j,g in enumerate(R[i+1:]):
                if g:
                    if i+j+2 not in G_cum:
                        G_cum[i+j+2] = sum(G[i+j+2:])
                    if i+2*j+2 < N:
                        cnt += G_cum[i+j+2] - G[i+2*j+2]
                    else:
                        cnt += G_cum[i+j+2]
            for j,b in enumerate(G[i+1:]):
                if b:
                    if i+j+2 not in R_cum:
                        R_cum[i+j+2] = sum(R[i+j+2:])
                    if i+2*j+2 < N:
                        cnt += R_cum[i+j+2] - R[i+2*j+2]
                    else:
                        cnt += R_cum[i+j+2]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    out_ctrl(cnt)

Measured memory_bytes: 76236
h, w = list(map(int, input().split()))
n = int(input())
colors = list(map(int, input().split()))
ans = [[0] * w for i in range(h)]
color_stock = []
for i in range(len(colors)):
    for j in range(colors[i]):
        color_stock.append(i+1)


for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            c = color_stock.pop()
            ans[i][j] = c
    else:
        for j in range(w, 0, -1):
            c = color_stock.pop()
            ans[i][j-1] = c

for i in range(h):
    print(' '.join(map(str, ans[i])))


Measured memory_bytes: 9400
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define MOD 1000000007LL

vector<ll> fact(100001);

tuple<ll, ll, ll> exgcd(ll a, ll b) {
    if (b == 0)
        return make_tuple(a, 1, 0);
    ll g, x, y;
    tie(g, x, y) = exgcd(b, a%b);
    return make_tuple(g, y, x-(a/b)*y);
}

ll moddiv(ll a, ll b)
{
    ll bb;
    tie(ignore,bb,ignore)=exgcd(b,MOD);
    if(bb<0) b+=MOD;
    return (a*bb)%MOD;
}

ll comb(ll a, ll b)
{
    ll ret=fact[a];
    ret=moddiv(ret,fact[b]);
    ret=moddiv(ret,fact[a-b]);
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);

    fact[0]=1;
    for(int i=1; i<=100000; i++) fact[i]=(fact[i-1]*i)%MOD;

    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    ll answer=0;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end());
    for(int i=n-1; i>=k-1; i--){
        ll c=comb(i,k-1);
        answer+=((c*a[i])%MOD+MOD)%MOD;
        answer-=((c*a[n-1-i])%MOD+MOD)%MOD;
        answer=(answer+MOD)%MOD;
    }
    cout<<answer;

    return 0;
}


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

int main(void){
    int w,h,n;
    cin >> w >> h >> n;
    vector<vector<bool>> vec(w+1,vector<bool>(h+1,true));

    for(int i=0;i<n;i++){
        int x,y,a;
        cin >> x >> y >> a;
        if(a==1){
            for(int j=0;j<x;j++){
                for(int k=0;k<h+1;k++){
                    vec.at(j).at(k) = false;
                }
            }
        }else if(a==2){
            for(int j=x+1;j<w+1;j++){
                for(int k=0;k<h+1;k++){
                    vec.at(j).at(k) = false;
                }
            }
        }else if(a==3){
            for(int j=0;j<w+1;j++){
                for(int k=0;k<y;k++){
                    vec.at(j).at(k) = false;
                }
            }
        }else{
            for(int j=0;j<w+1;j++){
                for(int k=y+1;k<h+1;k++){
                    vec.at(j).at(k) = false;
                }
            }
        }
    }

    int ax1=-1, ay1=-1;
    for(int i=0;i<w+1;i++){
        for(int j=0;j<h+1;j++){
            if(vec.at(i).at(j)){ax1=i;ay1=j;}
        }
    }


    int ax2=-1, ay2=-1;
    for(int i=w;i>=0;i--){
        for(int j=h;j>=0;j--){
            if(vec.at(i).at(j)){ax2=i;ay2=j;}
        }
    }

    cout << (ax2-ax1)*(ay2-ay1) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<vector<int>> solve(int M, int T, int P, int R) {
    vector<vector<int>> ret(T, vector<int>(3));
    vector<int> pena(T);
    vector<vector<int>> table(T, vector<int>(P));

    for (int i = 0; i < T; i++) {
        ret[i][2] = -i;
    }

    for (int i = 0; i < R; i++) {
        int m, t, p, j; cin >> m >> t >> p >> j;
        t--;
        p--;
        if (j == 0) {
            ret[t][0]--;
            ret[t][1] += m;
            pena[t] += table[t][p];
        } else {
            table[t][p] += 20;
        }
    }
    for (int i = 0; i < T; i++) {
        ret[i][1] += pena[i];
    }
    sort(ret.begin(), ret.end());

    return ret;
}

int main(void) {
    int M, T, P, R;
    vector<vector<vector<int>>> outputs;
    while (1) {
        cin >> M >> T >> P >> R;
        if (!M && !T && !P && !R) break;
        outputs.push_back(solve(M, T, P, R));
    }

    for (auto &vv : outputs) {
        for (int i = 0; i < vv.size(); i++) {
            cout << -1*vv[i][2]+1;
            if (i != vv.size()-1) {
                if (vv[i][0] == vv[i+1][0] && vv[i][1] == vv[i+1][1]) {
                    cout << "=";
                } else {
                    cout << ",";
                }
            }
        }
        cout << endl;
    }
}




Measured memory_bytes: 3156
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
if a.count(0) == n:
    print("Yes")
    exit()

if n%3 != 0:
    print("No")
    exit()

c = Counter(a)
if len(c) == 2:
    if 0 not in c.keys():
        print("No")
        exit()
    if c[0] != n//3:
        print("No")
    else:
        print("Yes")
elif len(c) == 3:
    x = 0
    for i,j in c.items():
        if j != n//3:
            print("No")
            exit()
        x ^= i
    if x:
        print("No")
    else:
        print("Yes")

else:
    print("No")


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

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


int main() {
  int k;
  string s;
  cin >> k >> s;

  if (k >= s.size()) {
    cout << s << endl;
    return 0;
  }
  else {
    rep (i, k) {
      cout << s.at(i);
      }
  }
  cout << "..." << endl;
}



Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a = n%1000;
    int b = n/10;
    if(a % 111 == 0 || b % 111 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3568
import math
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
def combination(n, r, mod=10**9+7):
  r = min(r, n-r)
  res = 1
  for i in range(r):
      res = res * (n - i) * modinv(i+1, mod) % mod
  return res
def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)
      ans%=MOD 
    x = (x*x)%MOD
    n = n >> 1 #ビットシフト
  return ans
def COMint():
  fac[0]=1
  fac[1]=1
  finv[0]=1
  finv[1]=1
  inv[1]=1
  for i in range(2,N+1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
def com(n,k):
  if n<k:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
MOD=10**9+7
#繰り返し２乗法を使う場合
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,a,b=[int(x) for x in input().split()]
ans1 = pow(2,n)-1
N = n
a1=combination(n,a)
b1 = combination(n,b)
if ans1-a1%MOD-b1%MOD<0:
  print(((ans1-a1%MOD-b1%MOD)%MOD+MOD)%MOD)
else:
  print(ans1-a1%MOD-b1%MOD)

Measured memory_bytes: 124888
#include <iostream>

using namespace std;

int main()
{
  int N;
  cin >> N;

  for( int nFour = 0; nFour <= N / 4; ++nFour )
  {
    for( int nSeven = 0; nSeven <= N / 7; ++nSeven )
    {
      int sum = 4 * nFour + 7 * nSeven;

      if( sum == N )
      {
        cout << "Yes" << endl;
        return 0;
      }
      else if( sum > N )
      {
        break;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c = sc.nextInt();
		long p=1;
		int x=1;
		for(int i=0;i<9;i++) {
			x *=10;
		}
		for(int i=1;i<=c;i++) {
			p *= i;
			p %= (x+7);
		}
		System.out.print(p);
		sc.close();
	}
}


Measured memory_bytes: 21844
r = 1000000
sqrt = int(r**0.5)
p = [1]*r
p[0] = 0
p[3::2] = [0 for x in range(3,r,2)]
for i in range(2,sqrt):
	if p[i]:
		p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]

while 1:
	n = int(raw_input())
	if n == 0: break
	ans = 0
	for i in range(2,n/2+1):
		if p[i-1] and p[n-i-1]:
			ans += 1
	print ans

Measured memory_bytes: 31784
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = input[0];
        var M = input[1];
        var s = new string[N];
        var W = new int[N];
        var B = new int[N];
        var R = new int[N];
        var min = int.MaxValue;
        for (int i = 0; i < N; i++)
        {
            s[i] = Console.ReadLine();
            W[i] = s[i].Length - s[i].Replace("W", "").Length;
            B[i] = s[i].Length - s[i].Replace("B", "").Length;
            R[i] = s[i].Length - s[i].Replace("R", "").Length;
        }
        for (int i = 1; i < N; i++)
        {
            for (int j = 1; j < N; j++)
            {
                var k = N - i - j;
                if (k < 1)
                {
                    break;
                }
                var count = 0;
                for (int r = 0; r < N; r++)
                {
                    if (r < i)
                    {
                        count += B[r] + R[r];
                    }
                    else if (r < i+j)
                    {
                        count += W[r] + R[r];
                    }
                    else
                    {
                        count += W[r] + B[r];
                    }
                }
                min = Math.Min(min, count);
            }
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 20416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
	ll a,b,k;
	cin>>a>>b>>k;
	ll ta,aa;
	ta=max(0LL,a-k);
	k-=a;
	if(k>0)
		aa=max(0LL,b-k);
	else
		aa=b;
	cout<<ta<<" "<<aa<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)

#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}
void solve()
{ string s;
  in s;
  string p = "";
  for(ll i=0;i<3;i++){
    p+=s[i];
  }
  out p<<en;
}


int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
           //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)
#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
typedef long long ll;
typedef long long int lln;
ll INF=1<<28;
//typedef long long lld;
const double pi=acos(-1.0);
int fx[]={1,-1,0,0}; //direction array
int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
const long double EPS=1e-7;
//#define INF 10000
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

bool cmp(int a, int b)
{
    return a<b;
}

struct compare
{
  bool operator()(const int& l, const int& r)
  {
      return l>r;
  }
};
ll inf=1e18;
ll mod=1e9+7;
int n;
int arr[500];
pLL dp[500][500];
int vis[500][500];
pLL fun(int x,int y)
{
//    cout<<x<<" "<<y<<endl;
    if(x>y)
        return {0,0};
    if(x==y)
        return {0,arr[x]};
    if(vis[x][y]!=0)
        return dp[x][y];
    vis[x][y]=1;
    pLL ans;
    ans.ff=inf;
    ll maxx=inf;
    pLL t1,t2;
    for(int i=x;i<y;i++)
    {
        t1=fun(x,i);
        t2=fun(i+1,y);
        ll val=t1.ff+t2.ff+t1.sn+t2.sn;
        if(val<maxx)
        {
            maxx=val;
            ans.ff=val;
            ans.sn=t1.sn+t2.sn;
        }
    }
    return dp[x][y]=ans;
}
int main()
{
//    READ;
    int k;
    sf(n);
    for(int i=0;i<n;i++)
    {
        sf(arr[i]);
    }
    cout<<fun(0,n-1).ff<<endl;
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {
  ll n, h;
  cin >> n >> h;

  vector<ll> a(n);
  vector<ll> b(n);

  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }

  ll ans = 0;
  vector<pair<ll, bool>> ab(2 * n);

  for (int i = 0; i < n; ++i) {
    ab[i] = make_pair(a[i], false);
  }

  for (int i = 0; i < n; ++i) {
    ab[n + i] = make_pair(b[i], true);
  }


  sort(ab.begin(), ab.end(), [](pair<ll, bool> &l, pair<ll, bool>&r) {
    return l.first > r.first;
  });




  for (int i = 0; i < n*2; ++i) {
    cerr << h <<endl;
    if (ab[i].second == true ) { //投げる
      h -= ab[i].first;
      ans++;
    } else { //投げない
      cerr << " ful  " << ab[i].first <<endl;
      ll num = h/ab[i].first ;
      if (h%ab[i].first != 0)num++;
      ans += num;
      h -=ab[i].first * num;
      break;
    }

    if (h <= 0)break;
  }
  cerr << h <<endl;





  cout << ans;

}




















Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i, n)cin >> v[i];
    int ans = 0;
    rep(i, k+1){
        priority_queue<int, vector<int>, greater<int>> que;
        if(i >= n){
            rep(j, n)que.push(v[j]);
            int a = 0;
            while(a < (k-i) && !que.empty()){
                if(que.top() > 0)break;
                que.pop();
                a++;
            }
            int now = 0;
            while(!que.empty()){now += que.top(); que.pop();}
            ans = max(ans, now);
        }else{  
            rep(j, i+1){
                rep(a, j)que.push(v[a]);
                rep(a, i-j)que.push(v[n-a-1]);
                int a = 0;
                while(a < (k-i) && !que.empty()){
                    if(que.top() > 0)break;
                    que.pop();
                    a++;
                }
                int now = 0;
                while(!que.empty()){now += que.top(); que.pop();}
                
                ans = max(ans, now);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,ans=1; cin>>n; 
    for (int i=2;i*i <=n;i++){
        int s=i*i;
        while (s<=n){
            ans = max(ans,s);
            s *= i;
        }
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3520
#include <iostream>

using namespace std;

int main(void)
{
  int n, a[100];
  
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=n-1; i>0; i--){
    cout << a[i] << " ";
  }
  cout << a[0] << endl;
  return 0;

}
    

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

using namespace std;

constexpr int MX = 100005;
int rnk[MX];
int w_diff[MX];
int root[MX];

int find(int x){
  if (x == root[x]) return x;
  int r = find(root[x]);
  w_diff[x] += w_diff[root[x]];
  return root[x] = r;
}

int weight(int x){
    find(x);
    return w_diff[x];
}

int diff(int x, int y){
    return weight(y) - weight(x);
}

void merge(int x, int y, int w){
    
    w += weight(x);
    w -= weight(y);

    x = find(x);
    y = find(y);
    
    if (x == y) return;
    
    if(rnk[x] < rnk[y]) swap(x, y),  w = -w;
    if(rnk[x] == rnk[y]) ++rnk[x];
    root[y] = x;
    w_diff[y] = w;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n, q;
    cin >> n >> q;
    
    for(int i=0; i<n; i++) {
        rnk[i]=0;
        w_diff[i]=0;
        root[i]=i;
    }
 
    for(int i=0; i<q; i++){
        int c, x, y, z;
        cin >> c;
        if(c == 0){
            cin >> x >> y >> z;
            merge(x, y, z);
        }else if (c == 1){
            cin >> x >> y;
            if (find(x) != find(y)){
                cout << "?" << endl;
            }else{
                cout << diff(x, y) << endl;   
            }
        }
    }
    cout << flush;
    return 0;
}


Measured memory_bytes: 4308
# atcoder 169a の問題
# 値 A × B を整数として出力せよ

# 解答のステップ

# 1. 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())

# 2. 受け取った入力値を使って、適切に処理（計算）すること
answer = a * b

# 3. 計算した結果を出力すること
print(answer)



Measured memory_bytes: 9132
#include <stdio.h>
#include <string.h>
#include <iostream>

int N;
char s[114514];
bool P, Q, R, X, s_P, s_Q;
std::string ans;

int main(void)
{
	scanf("%d%s", &N, s);

	for (int i = 0; i < 4; ++i)
	{
		P = i & 2, Q = i & 1;
		s_P = P, s_Q = Q;
		for (int j = 0; j < N; ++j)
		{
			if (Q == true)
			{
				ans += "S";
			}
			else
			{
				ans += "W";
			}
			X = (s[((j % N + N) % N)] == 'o');
			R = P ^ Q ^ X;
			P = Q;
			Q = R;
		}
		if (s_P == P && s_Q == Q)
		{
			break;
		}
		ans = "\0";
	}

	if (ans[0] != '\0')
	{
		std::cout << ans << std::endl;
	}
	else
	{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[][] seg = new int[n][2];
      for(int i = 0; i < n; i++) {
        seg[i][0] = sc.nextInt();
        seg[i][1] = sc.nextInt();
      }
      Arrays.sort(seg, (s1, s2) -> s1[1] - s2[1]);
      int time = 0;
      for(int i = 0; i < n; i++) {
        int t = seg[i][0];
        int l = seg[i][1];
        if(time + t > l) {
          System.out.println("No");
          return;
        }
        time += t;
      }
      System.out.println("Yes");
  }
}

Measured memory_bytes: 110740
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;
 
int main() {
 
    for (string s; cin >> s&&s!="0";) {
        int a = 0;
        for (int i = 0; i < s.size(); i++) {
            a += s[i] - '0';
        }
        cout << a << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3176
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        String s = sc.next();
        int[] c = new int[26];
        for(int i = 0; i < N; i++){
            int diff = s.charAt(i) - 'a';
            c[diff]++;
        }

        int mod = (int)Math.pow(10, 9)+7;
        long sum = 1;
        for(int i = 0; i < 26; i++){
            if(c[i] != 0)
                sum = (sum*(c[i]+1)%mod);
        }

        System.out.println(sum-1);
    }
}

Measured memory_bytes: 24916
n,m = map(int,input().split())
l = []
r = []
for i in range(m):
        ll,rr = map(int,input().split())
        l.append(ll)
        r.append(rr)
if min(r)-max(l)+1 < 0:
        print(0)
else:
        print(min(r)-max(l)+1)

Measured memory_bytes: 10996
use std::io::*;
use std::cmp;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let v = read_vec::<i64>();
    let (a,b,c) = (v[0],v[1],v[2]);
    let (mut x,mut y) = (v[3],v[4]);
    let mut ans = 0;
    if a + b > 2 * c && x > 0 && y > 0 {
        let m = cmp::min(x,y);
        ans += m * 2 * c;
        x -= m;
        y -= m;
    }
    if a >= 2 * c {
        ans += x * 2 * c;
        x = 0;
        y -= x;
    }
    if b >= 2 * c {
        ans += y * 2 * c;
        y = 0;
        x -= y;
    }
    if x > 0 {
        ans += x * a;
    }
    if y > 0 {
        ans += y * b;
    }
    println!("{}",ans);
}


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> Cd(110);
  int k = 0;
  for (int i = 1; i < min(A, B) + 1; i++) {
    if (A % i == 0 && B % i == 0) {
      Cd.at(k) = i;
      k++;
    }
  }
  cout << Cd.at(k - K) << endl;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let b = (0..n-1).map(|_| iter.next().unwrap().parse().unwrap()).collect::<Vec<i32>>();
    let mut ans = 0;
    ans += b[0] + b[n-2];
    for i in 0..n-2 {
        ans += std::cmp::min(b[i], b[i+1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
import heapq

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    d = {i: [] for i in range(M + 1)}
    for _ in range(N):
        a, b = map(int, input().split())
        if a > M:
            continue
        d[a].append(b)

    ans = 0
    q = []
    heapq.heapify(q)
    for i in range(M, 0, -1):
        a = M - i + 1
        for b in d[a]:
            heapq.heappush(q, -b)
        if q:
            b = heapq.heappop(q)
            ans += -b

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 27100
from heapq import *
n,m = map(int,input().split())
t = [[] for i in range(10**5+1)]
for i in range(n):
    a,b = map(int,input().split())
    t[a].append(b)

ans = 0
h = []
for i in range(1,m+1):
    #print(i,"日目")
    for j in t[i]:
        heappush(h, -j)
        #print("heappush",j)
    if h:
        a = -heappop(h)
        #print("heappop",a)
        ans += a
print(ans)

Measured memory_bytes: 19896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch[100010];
	ll ans[100010];
	for(ll i=0;i<n;i++){
		cin>>ch[i];
		ch[i]--;
		ans[ch[i]]=i;
	}
	for(ll i=0;i<n;i++){
		cout <<ans[i]+1<<" ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 5072
import sys
n=int(input())
A = [int(i) for i in input().split()]
#A =list(map(int,input().split()))
mi = 0
for i in range(n):
    if mi < A[i]:
        mi = A[i]-1
    elif mi == A[i]:
        mi = A[i]
    elif A[i]-mi < 0 :
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 14396
x,y = map(int,input().split())

if x == 0 or y == 0:
    if x == 0 and y >= 0:
       ans = abs(y)
    elif x == 0 and y <0:
        ans = abs(y) + 1
    elif x >= 0 and y == 0:
        ans = abs(x)+1
    elif x < 0 and y == 0:
        ans = abs(x)
elif x*y < 0:
     ans = abs(abs(x) - abs(y)) + 1
elif x > y:
    ans = abs(abs(x) - abs(y)) + 2
else:
    ans = abs(abs(x) - abs(y))

print(ans)


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

#define ll long long
#define mii make_pair<int ,int>
#define mll make_pair<ll, ll>
#define pii pair<int ,int>
#define pll pair<ll, ll>
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define vi vector <int>
#define vvi vector <vector <int> >
#define vl vector <ll>
#define vvl vector <vector <ll> >
#define vb vector <bool>
#define vvb vector <vector <bool> >

int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

    ll n, k;
    cin >> n >> k;

    if (n % k == 0)
        cout << 0;
    else
    {
        cout << min(n % k, k - (n % k));
    }
}


Measured memory_bytes: 256
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    S = input()
    if S == "AC": ac += 1
    elif S == "WA": wa += 1
    elif S == "TLE": tle += 1
    else: re += 1
print("AC","x",ac )
print("WA", "x", wa)
print("TLE", "x", tle)
print("RE", "x", re)


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

int main() {
  int X;
  cin >> X;
  int res;
  if (X >= 400 && X <= 599) res = 8;
  if (X >= 600 && X <= 799) res = 7;
  if (X >= 800 && X <= 999) res = 6;
  if (X >= 1000 && X <= 1199) res = 5;
  if (X >= 1200 && X <= 1399) res = 4;
  if (X >= 1400 && X <= 1599) res = 3;
  if (X >= 1600 && X <= 1799) res = 2;
  if (X >= 1800 && X <= 1999) res = 1;
  
  cout << res << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e18
#define dump(x) cerr<<#x<<"="<<x<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;

int N;
int a,b;
vector<int> vec[100010];
//1 kuro 2 siro
int color[100010];
int memo1[100010];
int memo2[100010];
int reta,retb;
signed main(){
  cin>>N;
  rep(i,N-1){
    cin>>a>>b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }

  queue<int> que;

  que.push(1);
  memo1[1]=1;
  while(que.size()>0){
      int a=que.front();que.pop();
      for(int i=0;i<vec[a].size();i++){
        int n=vec[a][i];
        if(memo1[n]==0){
          que.push(n);
          memo1[n]=memo1[a]+1;
        }
      }
  }

  memo2[N]=1;
  que.push(N);
  while(que.size()>0){
      int a=que.front();que.pop();
      for(int i=0;i<vec[a].size();i++){
        int n=vec[a][i];
        if(memo2[n]==0){
          que.push(n);
          memo2[n]=memo2[a]+1;
        }
      }
  }

  FOR(i,1,N+1){
    if(memo1[i]<=memo2[i]){
      reta++;
    }else{
      retb++;
    }
  }



  if(reta>retb){
    cout<<"Fennec"<<endl;
  }else{
    cout<<"Snuke"<<endl;
  }

}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int *buildFail(const vi &p) {
  int m = p.size();
  int *fail = new int[m+1];
  int j = fail[0] = -1;
  for (int i = 1; i <= m; ++i) {
    while (j >= 0 && p[j] != p[i-1]) j = fail[j];
    fail[i] = ++j;
  }
  return fail;
}
vi match(const vi &t, const vi &p, int *fail) {
  int n = t.size(), m = p.size();
  vi res;
  for (int i = 0, k = 0; i < n; ++i) {
    while (k >= 0 && p[k] != t[i]) k = fail[k];
    if (++k >= m) {
      res.pb(i - m + 1);
      k = fail[k];
    }
  }
  return res;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n; cin >> n;
	vi a(n), b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	
	vi da(2 * n - 2), db(n - 1);
	rep(i, 2 * n - 2) da[i] = a[(i + 1) % n] ^ a[i % n];
	rep(i, n - 1) db[i] = b[(i + 1) % n] ^ b[i % n];
	
	int *f = buildFail(db);
	vi ans = match(da, db, f);
	for(int i : ans) cout << i << " " << (a[i] ^ b[0]) << endl;
	
	return 0;
}

Measured memory_bytes: 9076
while line = gets
  moji = Array.new
  num = Array.new
  line.each_char {|b| moji << b }
  moji.each do |moji1|
    case( moji1.upcase )
    when "I" then
      num << 1
    when "V" then
      num << 5
    when "X" then
      num << 10
    when "L" then
      num << 50
    when "C" then
      num << 100
    when "D" then
      num << 500
    when "M" then
      num << 1000
    else
    end
  end
  
  ret = 0
  
  i = num.length - 1
  while i >= 0 do
    if i == num.length - 1
      ret += num[i]
    elsif num[i] < num[i+1]
      ret -= num[i]
    else
      ret += num[i]
    end
    i = i - 1
  end
  puts ret
end

Measured memory_bytes: 8680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
using ld = long double;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

int main() {
  std::cout << std::fixed << std::setprecision(10);
  ull w, h, x, y;
  cin >> w >> h >> x >> y;

  bool multi = false;

  ld xx = 0;
  ld yy = 0;

  if (x <= w/2) {
    xx = x + ((ld)w/2 - x);
  } else {
    xx = (ld)(w/2) - (x - (ld)w/2);
  }

  const ld halfh = (ld)h / 2;
  if (y <= halfh) {
    yy = (ld)y + (ld)(halfh - (ld)y);
  } else {
    yy = halfh - ((ld)y - halfh);
  }

  if ((ld)x == xx && (ld)y == yy) {
    multi = true;
  }

  const ld area = (ld)(w * h) / 2;

  cout << area << " " << (multi ? 1 : 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
   int A,B,C,D;
   scanf("%d%d%d%d",&A,&B,&C,&D);

   printf("%d\n",max(A*B,C*D));

  return 0;
}

Measured memory_bytes: 128
#pragma GCC target("avx")
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;

vector<int>to[40],quan[40];
int n,m,l,now,num[40];

int main() {
	scanf("%d",&now);
	n=now;
	for(l=1; n; n=n/2,l++) num[l]=n%2;
	l--;
	for(int i=2; i<l; i++) {
		to[i-1].push_back(i);
		quan[i-1].push_back(0);
		to[i-1].push_back(i);
		quan[i-1].push_back((1 << (i-2))); }
	for(int i=l-1; i>=1; i--) {
		if(num[i]) {
			now-=(1 << (i-1));
			to[i].push_back(l);
			quan[i].push_back(now); } }
	now-=(1 << (l-1));
	to[l-1].push_back(l);
	quan[l-1].push_back(now);
	to[l-1].push_back(l);
	quan[l-1].push_back((1 << (l-2))+now);

	for(int i=1; i<=l; i++) m+=to[i].size();
	printf("%d %d\n",l,m);
	for(int i=1; i<=l; i++) {
		for(int j=0; j<to[i].size(); j++) {
			printf("%d %d %d\n",i,to[i][j],quan[i][j]); } } }

Measured memory_bytes: 256