akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
const int MOD = 1e9 + 7;
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 21, maxmask = (1ll << 21);

int n, a[maxn][maxn], dp[maxmask];
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            cin >> a[i][j];
    dp[0] = 1;
    for(int i = 0; i < (1ll << n); i++)
    {
        int pos = __builtin_popcount(i);
        for(int j = 0; j < n; j++)
            if(!(i & 1ll << j) && a[pos][j])
            {
                dp[i | (1ll << j)] += dp[i];
                dp[i | (1ll << j)] %= MOD;
            }
    }
    cout << dp[(1ll << n) - 1] << "\n";
    return 0;
}

Measured memory_bytes: 20032
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <limits>

int main() {

    int64_t N, K;
    std::cin >> N >> K;

    N = N%K;
    int64_t prev = 0;
    while (prev != N) {
        prev = N;
        N = N%K;
    }

    N = std::min(N, std::abs(N-K));

    std::cout << N << std::endl;

    return 0;
}

Measured memory_bytes: 256
program ABC081B;
var
    i,n,x,r,r0: longint;
    arr: array of integer;
begin
    r:=1<<29;
    read(n);
    SetLength(arr,n);
    for i:=0 to n-1 do begin
        read(arr[i]);
    end;
    for i:=0 to n-1 do begin
        r0:=0;
        x:=arr[i];
        while x mod 2 < 1 do begin
            r0:=r0+1;
            x:=x div 2;
        end;
        if r>r0 then begin
            r:=r0;
        end;
    end;
    writeln(r);
end.

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

#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
using ll = long long;


void solve() 
{ 

int n;
cin>>n;
for(int i=1;i<10;i++){
	if(n%i==0){
		if((n/i)<10){
			cout<<"Yes";
			return ;
		}
	}
	
}
cout<<"No";
return ;


}
 

int main(){

		solve();
		cout<<endl;
					
}
		

	

		

 



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0;
#define ll long long

int dp[51][51][51][401];
int cur = 0;

int solve(int a, int b, int c, int x){
    if(a < 0 || b < 0 || c < 0 || x < 0) return 0;
    if(x == 0) return 1;
    int &ret = dp[a][b][c][x];
    if(ret != -1) return ret;
    ret = 0;
    if(cur == 0){
        ret += solve(a-1, b, c, x-10);
        cur = 1;
        ret += solve(a, b-1, c, x-2);
        cur = 2;
        ret += solve(a, b, c-1, x-1);
        cur = 0;
    }
    else if(cur == 1){
        ret += solve(a, b-1, c, x-2);
        cur = 2;
        ret += solve(a, b, c-1, x-1);
        cur = 1;
    }
    else
        ret += solve(a, b, c-1, x-1);
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(dp, -1, sizeof dp);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    cout << solve(a, b, c, x/50) << endl;
    return 0;
}


Measured memory_bytes: 208000
#include<bits/stdc++.h>
using namespace std;
vector<int> mp[26];
int main(){
    string s,t;cin>>s>>t;
    for(int i=0;i<s.length();++i){
      mp[s[i]-'a'].push_back(i+1);
    }
    long long ct = 0;
    long long last = 0;
  
    bool f = true;
    for(int i=0;i<t.length();++i){
      if(mp[t[i]-'a'].size()==0){
        f = false;
        break;
      }else{
        int pos = upper_bound(mp[t[i]-'a'].begin(),mp[t[i]-'a'].end(),last) 
                  - mp[t[i]-'a'].begin();
                  
      	if(pos == mp[t[i]-'a'].size()){
          last = mp[t[i]-'a'][0];
          ct ++;
        }else{
          last = mp[t[i]-'a'][pos];
        }
      }  
    }
    if(f){
      cout<< ct * s.length() + last <<endl;
    }
    else{
      cout<<-1<<endl;
    }
	return 0;
}

Measured memory_bytes: 1216
import 'dart:io';

main(List<String> args) {
  List<int> HWN =
      stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int H = HWN[0];
  int W = HWN[1];
  int N = HWN[2];
  List<int> XY =
      stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int y = XY[0];
  int x = XY[1];

  var S = stdin.readLineSync();
  var T = stdin.readLineSync();

  var l = 1;
  var r = W;
  var u = 1;
  var d = H;

  for (var i = N - 1; i >= 0; i--) {
    if (T[i] == "L" || T[i] == "R") {
      if (T[i] == "L") {
        r += 1;
      } else {
        l -= 1;
      }
      if (r > W) r = W;
      if (l < 1) l = 1;
    } else {
      if (T[i] == "U") {
        d += 1;
      } else {
        u -= 1;
      }
      if (d > H) d = H;
      if (u < 1) u = 1;
    }
    if (S[i] == "L" || S[i] == "R") {
      if (S[i] == "L") {
        l += 1;
      } else {
        r -= 1;
      }
      if (r == 0 || l == W + 1) {
        break;
      }
    } else {
      if (S[i] == "U") {
        u += 1;
      } else {
        d -= 1;
      }
      if (u == H + 1 || d == 0) {
        break;
      }
    }
    //print([l, r, u, d].join(""));
  }

  if (l <= x && x <= r && u <= y && y <= d) {
    print("YES");
  } else {
    print("NO");
  }
}


Measured memory_bytes: 17436
#include<bits/stdc++.h>
using namespace std;
int a[200050],b[200050],n;
int main()
{   
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        for(int i=1;i<=n;i++) scanf("%d",&b[i]);
        reverse(b+1,b+1+n);
        vector<int> p,q;
        int val=0,cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]!=b[i]) continue;
            cnt++;
            p.push_back(i);
            val=b[i];
        }
        for(int i=1;i<=n;i++)
        {
            if(!cnt) break;
            if(a[i]==b[i]) continue;
            if(a[i]!=val&&b[i]!=val)
            {
                cnt--;
                q.push_back(i);
            }
        }
        if(cnt) return cout<<"No\n",0;
        for(int i=0;i<q.size();i++) swap(b[p[i]],b[q[i]]);
        cout<<"Yes\n";
        for(int i=1;i<=n;i++) cout<<b[i]<<' ';
        cout<<'\n';
        return 0;
}

Measured memory_bytes: 5868
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n;
	cin >> n;
	int a[n];
	map<int, int> mp;
	int numOnes = 0;
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		mp[a[i]]++;
		if(a[i] == 1)numOnes++;
	}
	if(numOnes == 1){
		cout << 1 << endl;
		return;
	}else if(numOnes > 1){
		cout << 0 << endl;
		return;
	}
	int ans = 0;
	/*
	for(int i = 0; i < n; ++i){
		bool pr = true;
		if(mp[a[i]] > 1)pr = false;
		
		if(pr and a[i] >= 4 and a[i] % 2 == 0){
			int t1 = a[i] / 2;
			if(mp[2] > 0 or mp[t1] > 0){
				pr = false;
			}
		}
		
		for(int j = 2; pr and j * j <= a[i]; j++){
			if(a[i] % j == 0){
				int t2 = a[i] / j;
				if(mp[j] > 0 or mp[t2] > 0){
					pr = false;
				}
			}
		}
		if(pr)ans++;
	}*/
	for(auto it = mp.begin(); it != mp.end(); ++it){
		bool pr = true;
		if(it->second > 1)pr = false;
		int aa = (it->first);
		for(int j = 2; pr and (j * j <= aa); j++){
			if(aa % j == 0){
				int t1 = aa / j;
				if(mp[j] > 0 or mp[t1] > 0){
					pr = false;
				}
			}
		}
		if(pr)ans++;
	}
	cout << ans << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 43548
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int a[n], b[n], x;
    for(auto &x: a){
        cin >> x;
    }
    for(auto &x: b){
        cin >> x;
    }
    double manh = 0, eucl = 0, p3 = 0, cheb = 0;
    for(int i = 0; i < n; i ++){
        int d = fabs(a[i]-b[i]);
        manh += d;
        eucl += d * d;
        p3   += d * d * d;
        cheb  = (d > cheb)?d:cheb;
    }
    eucl = sqrt(eucl);
    p3 = cbrt(p3);
    printf("%.6f\n%.6f\n%.6f\n%.6f\n", manh, eucl, p3, cheb);
    return 0;
}


Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vl s(n),t(m);
    rep(i,n)cin >> s[i];
    rep(i,m)cin >> t[i];
    vvl dp(n+1,vl(m+1,0));
    vvl sum(n+1,vl(m+1,0));
    rep(i,n){
        rep(j,m){
            if(s[i]==t[j]){
                dp[i+1][j+1]=1+sum[i][j];
            }
            else dp[i+1][j+1]=0;
            dp[i+1][j+1]%=MOD;
            sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1]+MOD;
            sum[i+1][j+1]%=MOD;
        }
    }
    cout << sum[n][m]+1 <<endl;
}

Measured memory_bytes: 62976
///
// File:  2311.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 10 17:01:13 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct pos_t {
  int32_t x;
  int32_t y;
};

bool in_range(int32_t x, int32_t y)
{
  return 0 <= x && x < 8 && 0 <= y && y < 8;
}

void turnover(vector<string> &matrix, vector<pos_t> poss, char my)
{
  for (auto pos : poss) {
    matrix[pos.x][pos.y] = my;
  }
}

vector<pos_t> search(vector<string> &matrix, pos_t start, int32_t dx, int32_t dy, char my, char op)
{
  int32_t k = 1;
  vector<pos_t> poss;
  int32_t x = start.x;
  int32_t y = start.y;
  while (in_range(x + k * dx, y + k * dy) && matrix[x + k * dx][y + k * dy] == op) {
    poss.push_back({x + k * dx, y + k * dy});
    k++;
  }
  if (!poss.empty() && in_range(x + k * dx, y + k * dy) && matrix[x + k * dx][y + k * dy] == my) {
    return poss;
  }

  poss.clear();
  return poss;
}

vector<pos_t> turn(vector<string> &matrix, pos_t start, char my, char op)
{
  vector<pos_t> poss;
  for (int32_t dx = -1; dx <= 1; dx++) {
    for (int32_t dy = -1; dy <= 1; dy++) {
      if (!(dx == 0 && dy == 0)) {
        vector<pos_t> pos = search(matrix, start, dx, dy, my, op);
        poss.insert(poss.end(), pos.begin(), pos.end());
      }
    }
  }
  return poss;
}

int32_t main()
{
  vector<string> matrix(8);
  for (uint32_t i = 0; i < matrix.size(); i++) {
    cin >> matrix[i];
  }

  while (true) {
    bool first = false;
    bool second = false;

    uint32_t maxnum = 1;
    vector<pos_t> maxval;
    for (int32_t i = 0; i < 8; i++) {
      for (int32_t j = 0; j < 8; j++) {
        if (matrix[i][j] == '.') {
          pos_t start{i, j};
          vector<pos_t> poss = turn(matrix, start, 'o', 'x');
          poss.push_back(start);
          if (maxnum < poss.size()) {
            maxnum = poss.size();
            maxval = poss;
            first = true;
          }
        }
      }
    }
    turnover(matrix, maxval, 'o');

    maxnum = 1;
    vector<pos_t> opval;
    for (int32_t i = 7; i >= 0; i--) {
      for (int32_t j = 7; j >= 0; j--) {
        if (matrix[i][j] == '.') {
          pos_t start{i, j};
          vector<pos_t> poss = turn(matrix, start, 'x', 'o');
          poss.push_back(start);
          if (maxnum < poss.size()) {
            maxnum = poss.size();
            opval = poss;
            second = true;
          }
        }
      }
    }
    turnover(matrix, opval, 'x');

    if (first == false && second == false) break;
  }

  for (auto m : matrix) {
    cout << m << endl;
  }

  return 0;
}

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

using namespace std;

int main(){
    int A,B,C,X;

    cin >> A >> B >> C >> X;

    int ans = 0;

    for(int i = 0; i <= A; i++){
        for(int j = 0; j <= B; j++){
            for(int k = 0; k <= C; k++){
                if(500*i + 100*j + 50*k == X){
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    
}


Measured memory_bytes: 256
n=int(input())
ans={'AC' : 0, 'WA' : 0, 'TLE' : 0, 'RE' : 0}
for i in range(n):
  s=input()
  ans[s]+=1
print('AC x  ' + str(ans['AC']))
print('WA x ' + str(ans['WA']))
print('TLE x  ' + str(ans['TLE']))
print('RE x  ' + str(ans['RE']))

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int a=0,b;
  for (int i = 0; i < 3; ++i){
  	cin>>b;
  	a+=b;
  	if(i!=2)a*=10;
  }
  flag3func(a%4==0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e18;
struct edge {int from,to;ll cost;};
using E = vector<edge>;

vector<ll> Bellman_ford(const E &edges, int v, int s) {
  vector<ll> dist(v,INF);
  dist[s] = 0;
  rep(i,v) {
    for (auto e : edges) {
      if (dist[e.from] == INF) continue;
      if (dist[e.to] > dist[e.from] + e.cost) dist[e.to] = dist[e.from] + e.cost;
    }
  }
  return dist;
}

int main(){
  E G;
  int n,m;
  cin >> n >> m;
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;--b;
    G.push_back(edge{a,b,-c});
  }
  auto dist = Bellman_ford(G,n,0);

  //1~nの最短経路上に負閉路があるか
  rep(i,n) {
    rep(j,sz(G)) {
      edge e = G[j];
      if (dist[e.from] == INF) continue;
      if (dist[e.to] > dist[e.from] + e.cost) dist[e.to] = -INF;
    }
  }

  if(dist[n-1] == -INF) puts("inf");
  else cout << -dist[n-1] << endl;
 
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e-a > k or d-a >k or c-a>k or b-a>k or e-b > k or d-b > k or c-b>k or e-c >k or d-c >k or e-d>k:
    print(":(")
else:
    print("Yay!")

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

int N,indeks[100001],number,remov;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    cin>>N;
    for(int i = 1;i <= N;i++){
        cin>>number;
        if(number > 100000) remov++;
        else indeks[number]++;
    }
    for(int i = 1;i <= 100000;i++){
        if (indeks[i] > i) remov += indeks[i] - i;
        else if (indeks[i] < i) remov += indeks[i];
    }
    cout<<remov<<endl;
}


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

bool f(const long kind, const long n, const vector<long>& a){
    map<long,long> c;
    for(long i=0; i<n-1; i++){
        if(a[i]>=a[i+1]){
            while(!c.empty() && c.rbegin()->first >= a[i+1]){
                c.erase(c.rbegin()->first);
            }
            /*
            const auto it = c.upper_bound(a[i+1]);
            c.erase(it, c.end());
            */
            long j = a[i+1]-1;
            c[j]++;
            while(c[j]>=kind){
                c.erase(j);
                if(j<=0){
                    return false;
                }
                c[j-1]++;
                j--;
            }
        }
    }
    return true;
}

bool strict_increasing(const vector<long>& a){
    size_t n = a.size();
    for(size_t i=1; i<n; i++){
        if(a[i-1]>=a[i]){
            return false;
        }
    }
    return true;
}

int main(void){
    long n;
    cin >> n;
    vector<long> a(n);
    for(long i=0; i<n; i++){
        cin >> a[i];
    }
    if(strict_increasing(a)){
        cout << 1 << endl;
        return 0;
    }
    long left=1, right=n;
    for(;;){
        const long mid = (left+right)/2;
        if(right-left<=1){
            if(f(right, n, a)){
                cout << right << endl;
            }else{
                cout << left << endl;
            }
            return 0;
        }
        const bool b = f(mid, n, a);
        //printf("[%ld, %ld] %ld %s\n", left, right, mid, b ? "true" : "false");
        if(b){
            right=mid;
        }else{
            left=mid;
        }
    }
}


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

int main() {
  int n,a,b;
  cin >> n;

  unsigned long long ans, t_a, t_b;
  unsigned long long c_a, c_b, mul;

  cin >> t_a >> t_b;
  for(int i=1;i<n;i++) {
    cin >> a >> b;
    if (a == b) {
      if(t_a < t_b) {
        t_a = t_b;
      }else{
        t_b = t_a;
      }
    } else {
      c_a = (t_a + (a - 1)) / a;
      c_b = (t_b + (b - 1)) / b;
      mul = max(c_a, c_b);
      t_a = mul * a;
      t_b = mul * b;
    }
    // cout << t_a << " " << t_b << endl;
  }

  ans = t_a + t_b;
  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll h,n;
  cin>>h>>n;
  vector<ll> a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  vector<vector<ll>> dp(n+1,vector<ll>(h+1,1e10));
  dp[0][0]=0;
  rep(i,n){
    rep(j,h+1){
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      dp[i+1][min(j+a[i],h)]=min(dp[i+1][min(j+a[i],h)],dp[i+1][j]+b[i]);
    }
  }
  cout<<dp[n][h]<<endl;
  
  
  
}

Measured memory_bytes: 78592
#!usr/bin/env python3
import sys
from collections import defaultdict
from heapq import heappush, heappop
import math
import bisect
import random
def LI(): return list(map(int, input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return list(input())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007

#A

#B

#C
"""
n,a,b,c = LI()
l = IR(n)
f = [True for i in range(3)]
ans = 0
for i in range(n):
    for d in range(3):
        if abs(l[i]-[a,b,c][d]) <= 10 and f[d]:
            ans += abs(l[i]-[a,b,c][d])
            f[d] = False
            l[i] = -float("inf")
k = False
for i in f:
    if i:
        k = True
        break
if not k:
    print(ans)
    quit()
"""
#D
a,b,q = LI()
s = IR(a)
t = IR(b)
for i in range(q):
    x = int(sys.stdin.readline())
    c = bisect.bisect_left(s,x)
    ans = float("inf")
    if c == a:
        k = abs(x-s[-1])
        y = s[-1]
        d = bisect.bisect_left(t,y)
        if d == b:
            k += abs(y-t[-1])
        else:
            if abs(y-t[d-1]) < abs(y-t[d]):
                k += abs(y-t[d-1])
            else:
                k += abs(y-t[d])
        ans = min(k,ans)
    else:
        k = abs(x-s[c-1])
        y = s[c-1]
        d = bisect.bisect_left(t,y)
        if d == b:
            k += abs(y-t[-1])
        else:
            if abs(y-t[d-1]) < abs(y-t[d]):
                k += abs(y-t[d-1])
            else:
                k += abs(y-t[d])
        ans = min(k,ans)
        k = abs(x-s[c])
        y = s[c]
        d = bisect.bisect_left(t,y)
        if d == b:
            k += abs(y-t[-1])
        else:
            if abs(y-t[d-1]) < abs(y-t[d]):
                k += abs(y-t[d-1])
            else:
                k += abs(y-t[d])
        ans = min(k,ans)
    c = bisect.bisect_left(t,x)
    if c == b:
        k = abs(x-t[-1])
        y = t[-1]
        d = bisect.bisect_left(s,y)
        if d == a:
            k += abs(y-s[-1])
        else:
            if abs(y-s[d-1]) < abs(y-s[d]):
                k += abs(y-s[d-1])
            else:
                k += abs(y-s[d])
        ans = min(k,ans)
    else:
        k = abs(x-t[c-1])
        y = t[c-1]
        d = bisect.bisect_left(s,y)
        if d == a:
            k += abs(y-s[-1])
        else:
            if abs(y-s[d-1]) < abs(y-s[d]):
                k += abs(y-s[d-1])
            else:
                k += abs(y-s[d])
        ans = min(k,ans)
        k = abs(x-t[c])
        y = t[c]
        d = bisect.bisect_left(s,y)
        if d == a:
            k += abs(y-s[-1])
        else:
            if abs(y-s[d-1]) < abs(y-s[d]):
                k += abs(y-s[d-1])
            else:
                k += abs(y-s[d])
        ans = min(k,ans)
    print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 12956
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt(),
            M = sc.nextInt(),
            C = sc.nextInt(),
            correct = 0;
        int[] B = new int[M];
        for(int i = 0; i < M; i++){
            B[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            int value = C;
            for(int j = 0; j < M; j++){
                value += sc.nextInt()*B[j];
            }
            if(value > 0){
                correct++;
            }
        }
        System.out.println(correct);
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

int N;
string dfs(const string &s,int L,int R){
	string r;
	int i=L;
	long long n=-1;
	for(;i<R;){
		if('0'<=s[i]&&s[i]<='9'){
			if(n<0)
				n=s[i]-'0';
			else
				n=n*10+s[i]-'0';
			i++;
		}else if(s[i]=='('){
			if(n<0)n=1;
			int cnt=1,j=i+1;
			for(;cnt;){
				if(s[j]=='(')
					cnt++;
				else if(s[j]==')')
					cnt--;
				j++;
			}
			string r0=dfs(s,i+1,j-1);
			for(int _=0;_<n;_++){
				r+=r0;
				if(r.size()>N)return r;
			}
			n=-1;
			i=j;
		}else{
			if(n<0)n=1;
			r+=string(n,s[i]);
			n=-1;
			i++;
		}
	}
	return r;
}

int main(){
	for(;;){
		string s;
		cin>>s>>N;
		if(s=="0")break;
		string r=dfs(s,0,s.size());
		printf("%c\n",r.size()>N?r[N]:'0');
	}
}

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

int main() {
    vector<ll> num(26,0);
    ll H,W;
    cin >> H >>W;
    for(int i=0;i<H;i++){
        string S;
        cin >> S;
        for(int j=0;j<W;j++){
            num[S[j]-'a']++;
        }
    }
    ll remain4 = (H/2)*(W/2);
    ll remain2 = (H*W -remain4*4)/2;
    ll remain1 = H*W -remain4*4 -remain2*2;
    for(int i=0;i<26;i++){
        ll temp = num[i]/4;
        remain4-=temp;
        num[i] -= temp*4;
        temp = num[i]/2;
        remain2-=temp;
        num[i] -= temp*2;
        remain1-= num[i];
    }

    if(remain1==0 && remain4<=0){
        cout << "Yes" << endl;
    }else{
        cout <<"No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>
 main(void){
	int a[15][15];
	int x1,y1,size,max=0,count=0;
	int i,j;
	
	for(i=0;i<15;i++) for(j=0;j<15;j++) a[i][j]=0;
	
	while(~scanf("%d,%d,%d",&x1,&y1,&size)){
		switch(size){
			case 1:
				a[x1+2][y1+2]++; a[x1+1][y1+2]++; a[x1+2][y1+1]++; a[x1+3][y1+2]++; a[x1+2][y1+3]++;
				break;
			case 2:
				a[x1+2][y1+2]++; a[x1+1][y1+2]++; a[x1+2][y1+1]++; a[x1+3][y1+2]++; a[x1+2][y1+3]++;
				a[x1+1][y1+1]++; a[x1+3][y1+1]++; a[x1+1][y1+3]++; a[x1+3][y1+3]++;
				break;
			case 3:
				a[x1+2][y1+2]++; a[x1+1][y1+2]++; a[x1+2][y1+1]++; a[x1+3][y1+2]++; a[x1+2][y1+3]++;
				a[x1+1][y1+1]++; a[x1+3][y1+1]++; a[x1+1][y1+3]++; a[x1+3][y1+3]++;
				a[x1+2][y1]++; a[x1][y1+2]++; a[x1+2][y1+4]++; a[x1+4][y1+2]++;
		}
	}
	for(i=2;i<12;i++){
		for(j=2;j<12;j++){
			if(a[i][j]==0) count++;
			if(max<a[i][j]) max=a[i][j];
		}
	}
	printf("%d\n%d\n",count,max);
return 0;
}

Measured memory_bytes: 600
#include <cstdio>
int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if (a + b > c + d){
        printf("Left\n");
    }else
    if (a + b < c + d){
        printf("Right\n");
    }else{
        printf("Balanced\n");
    }

}

Measured memory_bytes: 128
n = int(input())
d = []
for i in range(n):
    d.append(input().split())
c = 0
for i in d:
    if (c == 3):
        print("Yes")
        break
    if i[0] == i[1]:
        c += 1
    else:
        c = 0
else:
    if (c == 3):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
  cin >> N;
  cout << (N+1)/2 << endl;
}

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

using ll = long long;

int dp[101][76];
int P[101];

void prime_deviation(int n) {
	for (int i = 2; i * i <= n; ++i) {
		if (n % i != 0) continue;
		int num = 0;
		while (n % i == 0) { n /= i; ++num; }
		P[i] += num;
	}
	if (n != 1) P[n] += 1;
}

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

	for (int i = 2; i <= N; ++i)
		prime_deviation(i);

	dp[0][1] = 1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= 75; ++j) {
			for (int k = 1; k <= P[i] + 1 && j * k <= 75; ++k) {
				dp[i + 1][j * k] += dp[i][j];
			}
		}
	}

	cout << dp[N][75] << endl;
	return 0;
}

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

int main(){
	int c[4][3][10] = {0};
	int t;
	cin >> t;
	int z;
	int y;
	int x;
	int a;
	int i;
	for ( i = 0; i<t; i++ ) {
		cin >> z >> y >> x >> a;
		c[z-1][y-1][x-1]+=a;
	}
	for ( z = 0; z<4; z++ ) {
		for ( y = 0; y<3; y++ ) {
			for ( x = 0; x<10; x++ ) {
				cout << " " << c[z][y][x];
			}
			cout << endl;
		}
		if ( z<3 ) {
			cout << "####################" << endl;
		}
	}
    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int a,b;
  vector<pair<int, int> > A(N);
  for(int i=0; i<N; i++){
    cin >> a;
    cin >> b;
    A[i] = make_pair(a, b);
  }
  
  int count=0;
  long long sum=0;
  int tmp;

  sort(A.begin(), A.end());
  for(int i=0; i<N; i++){
    if(A[i].second + count < M){
      count += A[i].second;
      sum += (long long)A[i].first * A[i].second;
    }
    else{
      tmp = M - count;
      sum += (long long)tmp * A[i].first;
      break;
    }
  }
  
  cout << sum << endl;
  
  return 0;
}
    
    

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

const long long MOD = 1000000007;
ll extgcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

//* calculate a^-1 mod m
ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, x, y);
    return(m + x%m) % m;
}
//* calculate x^n mod something in O(log n) -- recursive version
ll mod_pow(ll x, ll n, ll mod){
    if(n == 0) return 1;
    ll res = mod_pow(x*x % mod, n/2, mod);
    if(n & 1) res = res * x % mod;
    return res;
}

//* calculate C(n, 0), C(n, 1), ... C(n, m) mod p in O(m) 
//! m <= n
vll mod_comb_list(ll n, ll m, ll p){
    vll res(m+1, 1);
    for(ll k=1; k <= m; k++){
        res[k] = (res[k-1] * (n - k + 1)) % p;
        res[k] = (res[k] * mod_inverse(k, p)) % p;
    }
    return res;
}

void solve(long long n, long long a, long long b){
    ll m = min(b, n);
    ll x = mod_pow(2, n, MOD);
    vll clist = mod_comb_list(n, b, MOD);
    ll res = (x - clist[a] - clist[b]) % MOD;
    if(res < 0) res += MOD;
    cout<<res-1<<endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(n, a, b);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
using namespace std;
using ll = long long;
vector<ll> v;
vector<ll> w;
vector<vector<ll>> memo;
ll solve(int n, int k)
{
    if(n<0) return 0;
    ll best = -1;  
    if(memo[n][k]!=-1) return memo[n][k];
    if(k-w[n]>=0){
        best = max(best, solve(n-1,k-w[n])+v[n]);
    }
    best = max(best, solve(n-1,k));
    
    memo[n][k]=best;
    return best;
}
 
int main()
{
    ll n, W;
    scanf("%lld %lld", &n, &W);
    v.resize(n + 1);
    w.resize(n + 1);
    memo.resize(n + 1, vector<ll>(W+1, -1));
    for (int i = 0; i < n; i++)
    {
        scanf("%lld %lld", &w[i], &v[i]);
    }
 
    //solve 는 n번째 물건이고 무게가 W일때..
    cout << solve(n, W);
 
    return 0;
}

Measured memory_bytes: 80256
class Card:
    suit = ''
    value = 0

    def __init__(self, val):
        self.suit = val[0]
        self.value = int(val[1])

    def __lt__(self, rhv):
        return self.value < rhv.value

    def __le__(self, rhv):
        return self.value <= rhv.value

    def __eq__(self, rhv):
        return self.suit == rhv.suit and self.value == rhv.value

    def __ne__(self, rhv):
        return not (self == rhv)

    def __str__(self):
        return '%s%d'%(self.suit, self.value)

def merge(arr, length, left, mid, right):
#  n1 = mid - left
#  n2 = right - mid

    L = arr[left : mid]
    R = arr[mid : right]

    L.append(Card([' ', 2000000000]))
    R.append(Card([' ', 2000000000]))

    i, j = 0, 0
    for k in range(left, right):
        if (L[i] <= R[j]):
            arr[k] = L[i]
            i += 1
        else:
            arr[k] = R[j]
            j += 1

def merge_sort(arr, length, left, right):
    if (left + 1 < right):
        mid = (left + right)//2
        merge_sort(arr, length, left, mid)
        merge_sort(arr, length, mid, right)
        merge(arr, n, left, mid, right)

def partition(arr, left, right):
    x = arr[right]
    i = left - 1
    for j in range(left, right):
        if arr[j] <= x:
            i += 1
            arr[i], arr[j] = arr[j], arr[i]
    arr[i + 1], arr[right] = arr[right], arr[i + 1]
    return i + 1

def quick_sort(arr, length, left, right):
    if (left < right):
        q = partition(arr, left, right)
        quick_sort(arr, length, left, q - 1)
        quick_sort(arr, length, q + 1, right)

if __name__ == '__main__':
    n = int(input())

    arr1 = []
    arr2 = []

    for i in range(n):
        temp = input().split(' ')
        arr1.append(Card(temp))
        arr2.append(Card(temp))
    
    stable = True

    merge_sort(arr1, n, 0, n)
    quick_sort(arr2, n, 0, n - 1)

    for i in range(n):
        if (arr1[i].suit != arr2[i].suit):
            stable = False
            break
    if stable:
        print('Stable')
    else:
        print('Not stable')

    for i in arr2:
        print('%s %d'%(i.suit, i.value))
        


Measured memory_bytes: 47696
__asm__ ( "                        \n\
        .comm   b,1,1              \n\
.L0:                               \n\
        .string \"%c\"             \n\
        .globl  main               \n\
main:                              \n\
        pushq   %rbp               \n\
        leaq    b(%rip), %rsi      \n\
        leaq    .L0(%rip), %rdi    \n\
        call    __isoc99_scanf@PLT \n\
        movzbl  b(%rip), %eax      \n\
        cmpl    $65, %eax          \n\
        je      .LA                \n\
        cmpl    $67, %eax          \n\
        je      .LC                \n\
        cmpl    $71, %eax          \n\
        je      .LG                \n\
        movl    $65, %edi          \n\
        jmp     .LEND              \n\
.LA:                               \n\
        movl    $84, %edi          \n\
        jmp     .LEND              \n\
.LC:                               \n\
        movl    $71, %edi          \n\
        jmp     .LEND              \n\
.LG:                               \n\
        movl    $67, %edi          \n\
.LEND:                             \n\
        call    putchar@PLT        \n\
        movl    $0, %eax           \n\
        popq    %rbp               \n\
        ret                        \n\
" );

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
string s;
int main()
{
	cin >>s;
	cout <<(s=="ABC" ? "ARC" : "ABC");
	return 0;
} 

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		
		int n=sc.nextInt();
		String s=sc.next();
		
		 for (int i=0;i<s.length();i++){
	            System.out.print((char)((s.charAt(i)-'A'+ n)%26 + 'A'));
	        }
		sc.close();
	}

}

Measured memory_bytes: 26580
//g++ -std=c++14 test.cpp -o test.out
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
using namespace std;

string S,T;
int A,B;
string U;

int ans = 0;

void solve(){
	if(S==U){
		A--;
		return;
	}
	B--;
}
 
int main(){
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
 
	solve();

	cout << A << " " << B <<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#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>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//

//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	
	int a[3]; cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);

	if (a[0] == 5 && a[1] == 5 && a[2] == 7)YES;
	else NO;

	//
	// your code finished

	return 0;
}

Measured memory_bytes: 256
N, K = (int(i) for i in input().split())
L = []
for i in range(N):
    t,d = (int(i) for i in input().split())
    L.append((t,d))

L = sorted(L, key = lambda x:(x[0], -x[1]))
for i in range(N):
    if i == 0:
        ra = 0
        L[i] = (L[i][0], L[i][1], ra)
    else:
        if L[i][0] == L[i-1][0]:
            ra += 1
        else:
            ra = 0
        L[i] = (L[i][0], L[i][1], ra)

L = sorted(L, key = lambda x:(-x[1], x[0]))

if N != K:
    kouho = L[:K]
    amari = L[K:]
else:
    kouho = L
    
nowval = len(set([sushi[0] for sushi in kouho]))
nowder = sum([sushi[1] for sushi in kouho])
point = nowval ** 2 + nowder

if N == K:
    print(point)
else:
    weaks = []
    for sushi in kouho:
        if sushi[2] > 0:
            weaks.append(sushi)
    weaks.reverse()
    kaburan = []
    for sushi in amari:
        if sushi[2] == 0:
            kaburan.append(sushi)
    
    ma = min(len(weaks), len(kaburan))
    newpoint = point
    if ma:
        for i in range(ma):
            newpoint = newpoint - weaks[i][1] + kaburan[i][1]
            newpoint = newpoint - nowval ** 2 + (nowval + 1) ** 2
            nowval += 1
            point = max(point, newpoint)
        print(point)
    else:
        print(point)


Measured memory_bytes: 32024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Get Many Persimmon Trees
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int N = parseInt(line);
			if (N == 0) break;

			int W, H;
			line = br.readLine();
			W = parseInt(line.substring(0, line.indexOf(' ')));
			H = parseInt(line.substring(line.indexOf(' ') + 1));

			int[][] field = new int[W + 1][H + 1];
			for (int i = 0; i < N; i++) {
				int x, y;
				line = br.readLine();
				x = parseInt(line.substring(0, line.indexOf(' ')));
				y = parseInt(line.substring(line.indexOf(' ') + 1));
				field[x][y] = 1;
			}
			for (int i = 1; i <= W; i++) {
				for (int j = 1; j <= H; j++) {
					field[i][j] = field[i][j] + field[i - 1][j] + field[i][j - 1] - field[i - 1][j - 1];
				}
			}

			int S, T;
			line = br.readLine();
			S = parseInt(line.substring(0, line.indexOf(' ')));
			T = parseInt(line.substring(line.indexOf(' ') + 1));

			//solve
			int max = 0;
			for (int i = S; i <= W; i++) {
				for (int j = T; j <= H; j++) {
					max = Math.max(max, field[i][j] - field[i - S][j] - field[i][j - T] + field[i - S][j - T]);
				}
			}
			System.out.println(max);

		} //end while
	} //end main
}

Measured memory_bytes: 27968
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string ans = "";
  while(N != 0){
    if(N%2 == 0){
      ans = "0" + ans;
    }else{
      ans = "1" + ans;
      N--;
    }
    N/=-2;
  }
  if(ans == ""){
    ans = "0";
  }
  cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3))cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}

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

long long attackTimes(long long H) {
	if(H == 1)
		return 1;
	else
		return 2 * attackTimes(H / 2) + 1;
}

int main() {
	long long H;
	cin >> H;

	cout << attackTimes(H) << endl;
}

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

using namespace std;

const int MAXN = 1e6 + 1;

int main() {
	
	ios_base :: sync_with_stdio(0); cin.tie(NULL);

	int n;
	cin >> n;

	vector<int> v(n);

	map<int,int> freq;

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

	sort(v.begin(), v.end());
	
	vector<int> mark(MAXN + 1, 0);

	int ans = 0;

	for(int i = 0; i < n; ++i) {
		int x = v[i];
		if (mark[x])
			continue;

		for(int j = x; j < MAXN; j += x) {
			mark[j] = true;
		}

		if (freq[x] > 1)
			continue;

		++ans;
	}

	cout << ans << '\n';

	return 0;	
}

Measured memory_bytes: 17128
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
a = list(map(int,input().split()))
color = [0]*8
over_3200 = 0
for i in range(n):
    if a[i] < 3200:
        color[a[i] // 400] = 1
    else: over_3200 += 1
if sum(color) == 0:
    print(1,over_3200)
else:
    print(sum(color),sum(color)+over_3200)

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc,char* argv[]){
  
  int wide;
  int n;
  int amida[31];
  int a,b;
  int tmp,tmp2;

  for(tmp = 0; tmp < 31; ++tmp){
    amida[tmp] = tmp;
  }
  
  scanf("%d",&wide);
  scanf("%d",&n);
  
  for(tmp2 = 0;tmp2 < n;++tmp2){
    scanf("%d,%d",&a,&b);
    tmp = amida[a];
    amida[a] = amida[b];
    amida[b] = tmp;
  }

  for(tmp = 1; tmp <= wide; ++tmp){
    printf("%d\n",amida[tmp]);
  }
  
  return 0;
  
}

Measured memory_bytes: 0
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		Map <String , Integer> hm = new HashMap<String,Integer>();
		

		for(int i = 0 ; i < n ;i++) {
			String s = sc.next();
			if(hm.containsKey(s)){
				hm.put(s, 1+hm.get(s));
			}
			else {
				hm.put(s,1);
			}
		}
		
		System.out.println(hm.size());
	}

}


Measured memory_bytes: 75588
import copy
N, K = map(int, input().split())
A = list(map(int, input().split()))
lights = [0] * N

for _ in range(min(K, 42)):
    lights = [0] * N
    for i, flash in enumerate(A):
        lights[max(0, i-flash)] += 1
        if i+flash < N-1:
            lights[i+flash+1] -= 1
    for i in range(1, N):
        lights[i] += lights[i-1]
    A = copy.deepcopy(lights)

for i in A:
    print(int(i),end=' ')
print()

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

int main(){
  int S, W;
  cin >> S >> W;
  if(W >= S){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	string s, s1, s2;
	cin >> s >> s1 >> s2;
	cout << s[0] << s1[1] << s2[2] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int d[100010];
int out[100010];
int N;

int main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		scanf("%d",&d[i]);
		out[d[i]]=i;
	}
	for(int i=1;i<=N;i++){
		printf("%d ",out[i]);
	}
	
}

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

using namespace std;

void print(string position, int index, vector<int>& H, int size)
{
    if (index > 0 && index <= size)
        cout << position << " key = " << H[index] << ", ";
}

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

    vector<int> H(size+1);
    for (int i = 1; i <= size; ++i)
        cin >> H[i];

    for (int i = 1; i <= size; ++i) {
        int parent = i / 2;
        int left = i * 2;
        int right = i * 2 + 1;

        cout << "node " << i << ": key = " << H[i] << ", ";
        print("parent", parent, H, size);
        print("left", left, H, size);
        print("right", right, H, size);
        cout << '\n';
    }
}



Measured memory_bytes: 3136