akhauriyash/Code-Regression huggingface dataset:
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;*/

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define PI (acos(-1.0))
#define inf INT_MAX/2
#define infll (1LL<<62)
#define abs(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define fbo(k) find_by_order(k) ///returns iterator to the kth largest element counting from 0
#define ook(val) order_of_key(val) ///returns the number of items in a set that are strictly smaller than val

///typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
//typedef pair<ll,ll> pll;
typedef vector<int> vi;
//typedef vector<ll> vl;
typedef set<int> si;
typedef multiset<int> msi;
typedef map<int,int> mii;
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_int_set;

///cout << fixed << setprecision(12) << ans << endl;

const int maxn=2e5+5;
const int MOD=1e9+7;

long long cnt[30];
int n,ara[maxn];
int bb[30][maxn];

int lowerBound (int i,int tt)
{
    int lo=0, hi=n-1;
    while (lo<=hi) {
        int mid=(lo+hi)/2;
        if (tt>bb[i][mid]) lo=mid+1; ///for non-decreasing use >=
        else hi=mid-1;
    }
    return lo;
}

int upperBound (int i,int tt)
{
    int lo=0, hi=n-1;
    while (lo<=hi) {
        int mid=(lo+hi)/2;
        if (tt>=bb[i][mid]) lo=mid+1; ///for non-decreasing use >=
        else hi=mid-1;
    }
    return lo;
}

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

    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",&ara[i]);
    for (int j=0;j<n;j++) {
        int b;
        scanf ("%d",&b);
        int mask=2;
        for (int i=1;i<=29;i++) {
            bb[i][j]=(b&(mask-1));
            mask<<=1;
        }
    }
    for (int i=1;i<=29;i++) sort(bb[i],bb[i]+n);
    for (int j=0;j<n;j++) {
        int mask=2;
        for (int i=1;i<=29;i++) {
            int x=ara[j]%mask;
            int ll=(1<<(i-1));
            int hh=(1<<i)-1;
            int lo=max(ll-x,0);
            int hi=max(hh-x,0);
            int temp=upperBound(i,hi)-lowerBound(i,lo);
            assert(temp>=0);
            assert(lo<=hi);
            cnt[i]+=temp;

            ll+=(1<<i);
            hh+=(1<<i);
            lo=max(ll-x,0);
            hi=max(hh-x,0);
            temp=upperBound(i,hi)-lowerBound(i,lo);
            assert(temp>=0);
            assert(lo<=hi);
            cnt[i]+=temp;
            mask<<=1;
        }
    }
    int ans=0;
    for (int i=1;i<=29;i++) {
        if (cnt[i]%2==1) ans+=(1<<(i-1));
        //cout<<"------"<<i<<' '<<cnt[i]<<endl;
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 23680
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int SIZEN = 200010;
char a[SIZEN] = {0};
int N;
int main(){
    scanf("%d",&N);
    scanf("%s",a+1);
    int sumr = 0,ans = 0;
    for(int i = 1;i <= N;i++){
        if(a[i] == 'R')sumr++;
    }
    for(int i = 1;i <= sumr;i++){
        if(a[i] == 'W')ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct Point {
  Point(int _index, int _x,int _y){
    index = _index;
    x = _x;
    y = _y;
  }
  int index;
  int x;
  int y;
};

bool xcmp(const Point &a, const Point &b)
{
    return a.x < b.x;
}

bool ycmp(const Point &a, const Point &b)
{
    return a.y < b.y;
}

struct Edge{
  Edge(int _a, int _b, int _cost){
    a = _a;
    b = _b;
    cost = _cost;
  }

  int a;
  int b;
  int cost;
};

bool costcmp(const Edge &a, const Edge &b)
{
    return a.cost < b.cost;
}

int kruskal(vector<Edge>& edges, int n){
  UnionFind uf(n);
  int cost =0;
  int rest = n;
  for(auto it: edges){
    if(uf.findSet(it.a,it.b)){continue;}
    cost += it.cost;
    uf.unionSet(it.a,it.b);
    rest--;
    
    //cout << "a:" << it.a << ",b:" << it.b << ",cost:" << it.cost << endl;

    if(rest-1==0){break;}
  }
  return cost;
}

int main(void){
  int N;
  cin >> N;
  vector<Point> points;
  for(int i=0;i<N;i++){
    int x,y;
    cin >> x >> y;
    points.push_back(Point(i,x,y));
  }

  vector<Edge> edges;

  sort(points.begin(), points.end(), xcmp);
  for(int i=1;i<N;i++){
    auto prev = points[i-1];
    auto curr = points[i];
    edges.push_back(Edge(prev.index,curr.index,curr.x-prev.x));
  }
  sort(points.begin(), points.end(), ycmp);
  for(int i=1;i<N;i++){
    auto prev = points[i-1];
    auto curr = points[i];
    edges.push_back(Edge(prev.index,curr.index,curr.y-prev.y));
  }

  sort(edges.begin(), edges.end(), costcmp);

  int cost = kruskal(edges,N);
  
  cout << cost << endl;
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a=0,b=0;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if('A'<=s[i]&&s[i]<='Z')a++;
  }
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C')b++;
  }
  if(s[0]=='A'&&a==2&&b==1){
    cout<<"AC"<<endl;
  }
  else cout<<"WA"<<endl;
  return(0);
}


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

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

    //010101....
    //101010....
    //の２パターンと異なった回数をそれぞれ求めて最小が答え。
    int a = 0, b = 0;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == s[i] % 2) a++;
        else b++;
    }

    cout << min(a, b) << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  const int MAX = 30000;

  vint is_p(MAX+1, inf);
  is_p[0] = is_p[1] = 0;
  for(int i = 2; i*i <= MAX; ++i) {
    if(is_p[i] != inf) continue;
    is_p[i] = i;
    for(int j = i+i; j <= MAX; j += i) chmin(is_p[j], i);
  }

  int n;
  cin >> n;

  if(n == 3) {
    cout << 2 << " " << 5 << " " << 63 << endl;
    return 0;
  }

  vint s;
  int num = 2;
  while(n > 1) {
    if(is_p[num] > 5 || is_p[MAX-num] > 5) {
      ++num;
      continue;
    }
    s.push_back(num);
    s.push_back(MAX-num);
    n -= 2;
    ++num;
  }
  if(n == 1) s.push_back(30000);
  sort(all(s));

  rep(i, s.size()) cout << s[i] << " \n"[i==(int)s.size()-1];

  int GCD = MAX;
  rep(i, n) {
    GCD = __gcd(GCD, s[i]);
  }
  //cout << GCD << endl;
  bool flag = true;
  int S = accumulate(all(s), 0);
  rep(i, n) {
    if(__gcd(s[i], S-s[i]) == 1) {
      //cout<<s[i]<<" "<<S-s[i]<<endl;
      flag = false;
    }
  }
  //cout << flag << endl;


  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(){

  int x, y, t, n;

  scanf("%d%d",&x,&y);

  //xに大きい素数を代入
  if(x<y){
      t=x;
    x=y;
    y=t;
  }

  /*nにxをyで割ったあまりを代入*/
  n=x%y;
  /*ユークリッドの互除法*/
  while(n!=0){
    x=y;
    y=n;
    n=x%y;
  }

  printf("%d\n",y);

  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

using namespace std;

int main(void)
{
    int line[10];
    double lina[10];
    double linb[10];

    while (scanf("%d,", &line[0]) != EOF) {
        int dist = line[0];
        for (int i = 1; i < 10; i++) {
            scanf("%d,", &line[i]);
            dist += line[i];
        }
        int n, m;
        scanf("%d,%d", &n, &m);
        double d = (double)dist * (double) n / (n + m);
        dist = 0;
        for (int i = 0; i < 10; i++) {
            dist += line[i];
            if (dist >= d) {
                cout << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define swap(a,b) ((*a!=*b)&&(*a+=*b,*b=*a-*b,*a-=*b))
const int IMIN=(1<<31);
static inline long IN(void)
{
  long x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
static inline void Sort(unsigned *from,unsigned *to,unsigned bit)
{
  if(!bit||to<from+1)return;
  unsigned *left=from,*right=to-1;
  for(;;)
  {
    while(left<right&&!(*left&bit))left++;
    while(left<right&&(*right&bit))right--;
    if(left>=right)break;
    swap(left,right);
  }
  if(!(bit&*left)&&left<to)left++;
  bit>>=1;
  Sort(from,left,bit);
  Sort(left,to,bit);
}
static inline void Radix(int *array,const int len)
{
  unsigned *x=(unsigned*)array;
  rep(i,len)x[i]^=IMIN;
  Sort(x,x+len,IMIN);
  rep(i,len)x[i]^=IMIN;
}
int main(void)
{
  int N=IN(),x,p=0,m=0,z=0,minus=0,A[200000],B[200000];
  long K=IN(),count=0,l=-2e18,r=-l,mid;
  while(N--){x=IN();if(x>0)A[p++]=x;else if(x<0)B[m++]=-x;else z++;}
  if(K>1l*m*p&&K<1l*m*p+1l*z*(N-1)/2)return puts("0"),0;
  Radix(A,p),Radix(B,m);
  if(K<=1l*m*p)r=1l;else l=-1l;
  while(l<=r)
  {
    mid=(l+r)/2;count=0;
    if(mid>=0)
    {
      int plus=p-1,minus=m-1;count+=1l*z*(p+m)+1l*z*(z-1)/2+1l*p*m;
      rep(i,plus){while(1l*A[i]*A[plus]>mid){plus--;}if(i>=plus){break;}count+=1l*plus-i;}
      rep(i,minus){while(1l*B[i]*B[minus]>mid){minus--;}if(i>=minus){break;}count+=1l*minus-i;}
    }
    else{mid*=-1l;minus=1;int low=0;rep(i,m){while(1l*A[low]*B[m-1-i]<mid&&low<p){low++;}count+=1l*p-low;}}
    if(count>=K){if(minus)r=-mid-1l;else r=mid-1l;}else{if(minus)l=-mid+1l;else l=mid+1l;}
  }
  return OUT(l),0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
    int n; cin >> n;
    vector<int> as(n+1, 0); 
    rng(x, 1, 101) {
        rng(y, 1, 101) {
            rng(z, 1, 101) {
                int ans = x*x + y*y + z*z + x*y + y*z + z*x;
                if (ans <= n) as[ans]++;
            }
        }
    } 
    rep(i, n) {
        cout << as[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3668
from collections import deque
n=int(input())
*p,=map(int, input().split())

for i in range(n*n):p[i]-=1
seats=[min(i//n,i%n,n-(i//n)-1,n-(i%n)-1) for i in range(n*n)] 

exist=[1]*(n*n)
dxy=(n,-n,1,-1)

ans=0
q=deque()
for pi in p:
    ans+=seats[pi]
    exist[pi]=0
    q.append(pi)
    while q:
        i=q.popleft()
        for dx in dxy:
            idx=i+dx
            if 0<=idx<n*n :
                if seats[i]+exist[i]<seats[idx]:
                    seats[idx]=seats[i]+exist[i]
                    q.append(idx)
print(ans)

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

int main(){
    int player, dpoint, question;
    cin >> player >> dpoint >> question;

    int stats[player];
    for(int i=0; i<player; i++)
        stats[i] = 0;

    int winner;
    for(int i=0; i<question; i++){
        cin >> winner;
        stats[winner-1]++;
    }

    for(int i=0; i<player; i++){
        if(question-stats[i] < dpoint) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int X, Y, Z;
	int A, B, C;
	cin >> X >> Y >> Z;

	A = X, B = Y, C = Z;
	A = Y, B = X, C = Z;
	A = Z, B = X, C = Y;

	printf("%d %d %d\n", A, B, C);
	return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

int n;
char s[100010];

int main() {
  scanf("%d\n", &n);
  rep(i, n) {
    scanf("%c", &s[i]);
  }
  
  char now = '1';
  int counter = 0;
  rep(i, n) {
    if(s[i] != now) {
      counter++;
      now = s[i];
    }
  }
  
  cout << counter;
}

Measured memory_bytes: 384
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

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

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())

ans = 0
for i in range(1, n+1):
    for j in range(i, n+1, i):
        ans += j

print(ans)


Measured memory_bytes: 74428
from itertools import permutations 

n = int(input())
p = tuple(int(i) for i in input().split())
q = tuple(int(i) for i in input().split())
a = 0
b = 0
cnt = 0
st = 0
for i in permutations(range(1,n+1)):
    cnt += 1
    if i == p:
        a = cnt
        st += 1
    if i == q:
        b = cnt
        st += 1
    if st == 2:
        break
    
print(abs(a-b))

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

int main(){
  int N,cnt=1,cnt2=-1;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++)
    cin >> a[i];
  int b = a[0];
  for(int i=0;i<N;i++){
    if(b==2){
      cnt2=cnt;
      break;
    }
    b = a[b-1];
    cnt++;
  }
  cout << cnt2 << endl;
}


Measured memory_bytes: 640
using System;
using System.Linq;

public class ABC152_C
{
    public static void Main()
    {
        int count = int.Parse(Console.ReadLine());
        int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        int result = 1, min = ints[0];
        for (int i = 1; i < count; i++)
        {
            if (min > ints[i])
            {
                min = ints[i];
                result++;
            }
            if (min == 1) break;
        }
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 35676
n, k = map(int,input().split())
a = list(map(int,input().split()))

s = [-1] * n
c = [1]
t = 0
now = 0
while s[now] == -1:
    s[now] = t
    now = a[now] - 1
    c.append(now+1)
    t += 1

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

Measured memory_bytes: 32876
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

char m[12][12];
void island(int x,int y){
   m[x][y]='0';
   if(x!=0)if(m[x-1][y]=='1') island(x-1,y);
   if(x!=11)if(m[x+1][y]=='1') island(x+1,y);
   if(y!=0)if(m[x][y-1]=='1') island(x,y-1);
   if(y!=11)if(m[x][y+1]=='1') island(x,y+1);
}
int main(){
   while(cin >> m[0][0]){
      int ans=0;
      rep(j,12)rep(i,12){
         if(i==0&&j==0) continue;
         cin>>m[i][j];
      }
      rep(j,12)rep(i,12){
         if(m[i][j]=='1'){
            island(i,j); ans++;
         }
      }
      cout << ans << endl;
   }
}

Measured memory_bytes: 1144
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main() {
	int n;
	while(cin >> n && n) {
		ll a[10000+10] = {};
		rep(i,n) {
			cin >> a[i];
		}
		sort(a,a+n);

		ll ret = 0;
		rep2(j,1,n) {
			a[j] += a[j-1];
		}
		rep(j,n-1) {
			ret += a[j];
		}
		cout << ret << endl;
	}
	return 0;
}

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

int N;
int T[20][20];

int dp[(1<<16)];

int solve(int st){
  if( dp[st] != -1 ) return dp[st];
  if( st == (1<<N)-1 ) return dp[st] = 0;
  int ret = (1<<29);
  for(int i=0;i<N;i++){
    if( st & (1<<i) ) continue;
    for(int j=1;j<=N;j++){
      if( st & (1<<(j-1)) ) {
	ret = min( ret, solve( st | (1<<i) ) + T[i][j] );
      }
    }
    ret = min( ret, solve( st | (1<<i) ) + T[i][0] );
  }
  return dp[st] = ret;
}

int main(){
  while( cin >> N && N ){
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++)
      for(int j=0;j<=N;j++) cin >> T[i][j];
    cout << solve(0) << endl;    
  }
}

Measured memory_bytes: 1424
# coding: utf-8

n, max_weight = list(map(int, input().split(" ")))

dp = [0 for _ in range(max_weight + 1)]

items = [0 for _ in range(10**7)]
weights = []
for _ in range(n):
    v, w = list(map(int, input().split(" ")))
    if w not in weights:
        weights.append(w)
    items[w] = max(items[w], v)


for i in range(1, max_weight+1):
    for w in weights:
        if i >= w:
            dp[i] = max(dp[i-w] + items[w], dp[i])

print(dp[max_weight])



Measured memory_bytes: 85504
#include<bits/stdc++.h>
#include <string>
using namespace std;
int main(){
  int a,b; cin>>a>>b;
  string A = to_string(a);
  string B = to_string(b);
  string ansA, ansB;
  
  for (int i=0; i<b; i++){ //aをb回
    ansA += A;
  }
  for (int i=0; i<a; i++){ //bをa回
    ansB += B;
  }
  
  if (ansA < ansB) cout << ansA << endl;
  else cout << ansB << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> num;
int main(){
  num.push_back(1ll);
  for(ll i=2;i<33;i++){
    ll x=i*i;
    while(x<=1000){
      num.push_back(x);
      x*=i;
    }
  }
  sort(num.begin(),num.end());
  num.erase(unique(num.begin(),num.end()),num.end());
  num.push_back(114514ll);
  ll n;
  cin>>n;
  for(int i=0;i<num.size();i++){
    if(num[i]>n){
      cout<<num[i-1]<<endl;
      return 0;
    }
  }
  return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<int> idx;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        idx.push_back(i);
    }

    sort(idx.begin(), idx.end(), [&](int i1, int i2){
        return b[i1] < b[i2];
        //return a[i1] < a[i2];
    });
    ll sum = 0;
    bool ans = true;
    for (int i : idx) {
        sum += a[i];
        if (sum > b[i]) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {

	ll n;
	cin >> n;
	VLL dp(100005, 0);
	dp[0] = 3;
	VLL b(100005, 0);
	b[0]++;

	VI a(n);
	cin >> a[0];
	if (a[0] != 0) {
		cout << 0 << endl;
		return 0;
	}
	FOR(i, 1, n) {
		cin >> a[i];
		if (a[i] == 0) {
			dp[i] += dp[i - 1];
		}
		else {
			if (b[a[i] - 1] <= b[a[i]]) {
				cout << 0 << endl;
				return 0;
			}
			dp[i] += (ll)(dp[i - 1] * (ll)(b[a[i] - 1] - b[a[i]])) % mod;
		}
		b[a[i]]++;
		if (dp[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}
	if (b[0] > 1)dp[n - 1] *= 2;
	dp[n - 1] %= mod;
	if (b[0] > 3) {
		cout << 0 << endl;
		return 0;
	}
	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 2176
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      m: usize,
      lrds: [(usize, usize, i64); m],
    }
    let mut edges = vec![vec![]; n];

    for &(l, r, d) in lrds.iter() {
        edges[l-1].push((r-1, d));
        edges[r-1].push((l-1, -d));
    }

    const INF: i64 = 1 << 32;
    let mut xs = vec![INF; n];

    fn dfs(i: usize, edges: &Vec<Vec<(usize, i64)>>, xs: &mut Vec<i64>) -> bool {
        for &(ni, d) in edges[i].iter() {
            let nx = xs[i] + d;
            if xs[ni] == INF {
                xs[ni] = nx;

                if !dfs(ni, edges, xs) {
                    return false;
                }
            }

            if nx != xs[ni] {
                return false;
            } else {
                continue;
            }
        }
        true
    }

    for i in 0..n {
        if xs[i] == INF {
            xs[i] = 0;
            if !dfs(i, &edges, &mut xs) {
                println!("{}", "No");
                return;
            }
        }
    }
    println!("{}", "Yes");
}


Measured memory_bytes: 28540
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;


int main()
{
int N,M;
cin>>N;
cin>>M;
int K[N];
int A[N][M];
int min=30;
int num=0;
for(int j=0;j<N;j++){
  cin>>K[j];
  if(min>K[j]){
    min=K[j];
    num=j;
  }
  for(int i=0;i<K[j];i++){
cin>>A[j][i];
  }
}
int count=0;
int sum=0;
for(int k=0;k<min;k++){
  count=0;
  for(int j=0;j<N;j++){
    for(int i=0;i<K[j];i++){
if(A[num][k]==A[j][i])count=count+1;
    }
  }
  if(count==N)sum=sum+1;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
typedef pair<long long, int> data_t;

int main() {
  vector<data_t> a(114514);
  long long n,m,res=0;
  cin >> n >> m;
  for(int i=0;i<n;i++){
    cin >> a[i].first >> a[i].second;
  }
  int j = 0;
  sort(a.begin(),a.end());
  while(m>0){
    if(a[j].second<=m){
      res+=a[j].first*a[j].second;
      m=m-a[j].second;
      j++;
    }else{
      res+=a[j].first*m;
      m=0;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
  int a,b;
  int ans;

  cin>>a>>b;
  cout<<(a*3+b)/2<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
// bitset<8>set1(p);
// __builtin_popcountll(x);
// bitset<100> b("1010");
long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
  ll int binomial(ll int n, ll int k) 
{ 
    ll int C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll int i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (int j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 
  vector<int> pr;
  bool prime[10000000];
void Sieve(ll int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            pr.push_back(p);
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}
 


//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}
void reverse(string& str) 
{ 
    int n = str.length(); 
  
    // Swap character starting from two 
    // corners 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
} 
int fun(string s,char c)
{
    int n=s.length();
    if(n==1)
    {
        if(s[0]!=c)
        {
         return 1;
        }
        else {
        return 0;
        }
    }
    else {
    int l=0,k=0;
   int r=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=c)
        {
           l++;
        }
    }
    for(int i=n/2;i<n;i++)
    {
        if(s[i]!=c)
        {
            k++;
        }
    }
   // cout<<l<<" "<<k<<endl;
   string p=s.substr(0,n/2);
        string o=s.substr(n/2,n/2);
        r+=min(k+fun(p,char(c+1)),l+fun(o,char(c+1)));
        return r;
    }
}



  
int main() {
       ll int n;
       cin>>n;
       cout<<3*n*n<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t,n,i,j,k,x,y,h,w,m,ans;
    cin>>h>>w>>m;
    unordered_map<long long,long long> keyx,keyy;
    map<pair<long long,long long>,long long> po;
    vector<long long> X,Y;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        keyx[x]++;
        keyy[y]++;
        po[{x,y}]++;
    }
    m=0;
    for(auto x:keyx)
        m=max(m,x.second);
    for(auto x:keyx)
        if(x.second==m)
            X.push_back(x.first);
    ans=m;
    m=0;
    for(auto x:keyy)
        m=max(m,x.second);
    for(auto x:keyy)
        if(x.second==m)
            Y.push_back(x.first);
    ans+=m;k=0;
    for(i=0;i<X.size();i++)
        for(j=0;j<Y.size();j++)
            if(po[{X[i],Y[j]}]==0)
            {
                k=1;
                break;
            }
    if(!k)
        ans--;
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 72292
<?php

fscanf(STDIN, '%d', $D);

if ($D === 25) {
    echo 'Christmas';
} elseif ($D === 24) {
    echo 'Christmas Eve';
} elseif ($D === 23) {
    echo 'Christmas Eve Eve';
} elseif ($D === 22) {
    echo 'Christmas Eve Eve Eve';
}

echo PHP_EOL;


Measured memory_bytes: 16044
from bisect import bisect_left
D = int(input())
Cs = list(map(int, input().split()))
Sss = []
for _ in range(D):
    Ss = list(map(int, input().split()))
    Sss.append(Ss)

Ts = []
for _ in range(D):
    Ts.append(int(input()))

lasts = [[0] for _ in range(26)]
score = 0
for i, t in enumerate(Ts):
    d = i + 1
    t -= 1
    score += Sss[i][t]
    lasts[t].append(d)
    for j in range(26):
        score -= (d - lasts[j][-1]) * Cs[j]

for i in range(26):
    lasts[i].append(D+1)

M = int(input())
for _ in range(M):
    d, afterIdx = map(int, input().split())
    i = d - 1
    beforeIdx = Ts[i] - 1
    afterIdx -= 1

    before = lasts[beforeIdx]
    # dが何番目にあるか
    k = bisect_left(before, d)
    w = before[k+1] - d
    h = d - before[k-1]
    score -= Sss[i][beforeIdx]
    score -= w * h * Cs[beforeIdx]
    lasts[beforeIdx] = before[:k] + before[k+1:]

    after = lasts[afterIdx]
    # dが何番目にあるか
    k = bisect_left(after, d)
    w = after[k] - d
    h = d - after[k-1]
    score += Sss[i][afterIdx]
    score += w * h * Cs[afterIdx]
    lasts[afterIdx] = after[:k] + [d] + after[k:]

    Ts[i] = afterIdx + 1
    print(score)


Measured memory_bytes: 73008
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
  int N,K,ans=0;
  cin>>N>>K;
  rep(i,N){int X; cin>>X;
           if(K<=X) ans++;
          }
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
using namespace std;
int func(int N) {
	int ans = 0;
	for (int i = 1; i <= sqrt(N); i++) {
		if (N % i == 0) ans += 2;
	}
	return ans;
}
int main() {
	int N; cin >> N;
	int A = 0;
	if (N < 105) {
		cout << 0 << endl;
		return 0;
	}
	else {
		for (int i = 105; i <= N; i++) {
			if (i % 2 != 0 && func(i) == 8) {
				A++;
			}
		}
	}
	cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0; i<N; i++) cin>>a[i];

    vector<int> count(100000);
    for(int i=0; i<N; i++) count[a[i]]++;

    int max=0;
    for(int i=1; i<99999; i++) {
        int tmp=count[i-1]+count[i]+count[i+1];
        if(max<tmp) max=tmp;
    }
    cout<<max<<endl;

    /*
    int max=0;
    for(int i=-1; i<100000; i++) {
        int count=0;
        for(int j=0; j<N; j++) {
            if(abs(a[j]-i)<=1) count++;
        }
        if(max<count) max=count; 
    }
    cout<<max<<endl;
    */
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n, k := readI(), readI()
	h := make([]int, n+1)
	for i := 1; i <= n; i++ {
		h[i] = readI()
	}

	dp := make([]int, n+1)
	for i := 2; i <= n; i++ {
		m := make([]int, 0, k)
		for j := 1; j <= k; j++ {
			if i-j < 1 {
				break
			}
			m = append(m, dp[i-j]+abs(h[i]-h[i-j]))
		}
		dp[i] = min(m...)
	}
	fmt.Println(dp[n])
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a ...int) int {
	m := a[0]
	for i := 1; i < len(a); i++ {
		if m > a[i] {
			m = a[i]
		}
	}
	return m
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	if(k*2>=(b-a+1))
		for (a; a < b + 1; ++a)
		{
			cout << a << endl;
		}
	else {
		int A, B;
		A = a;
		B = b;
		for (A; A< (a + k); ++A)
		{
			cout << A << endl;
		}
		int t = B - k + 1;
		for (t; t<b+1; ++t)
		{
			cout << t<< endl;
		}
	}
	fflush (stdin);
	getchar();
	fflush(stdin);
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

struct Node{int l,p,r,b;}T[100];
int D[100],H[100],n,DE[100];

void jiedian(int p,int u){
    if(p == -1)return ;
D[p] = u;
jiedian(T[p].l,u+1);
jiedian(T[p].r,u+1);
}
int pops(int u){
if(H[u] == 0)return 0;
int h1 = pops( T[u].r ) + 1;
int h2 = pops( T[u].l ) + 1;
return H[u] = ( h1 > h2 ? h1 : h2 );
}
int main(){
int m1,m2,m3,qq;
scanf("%d",&n);
for( int i = 0 ; i < n ; i++){
    T[i].p = -1 ; T[i].l = -1 ; T[i].r = -1 ; T[i].b = -1 ; H[i] = -1;D[i]=-1;
}
for( int i = 0 ; i < n ; i++ ){
    scanf("%d%d%d",&m1,&m2,&m3);
    T[m1].l = m2 ; T[m1].r = m3;
    if(m2 != -1){T[m2].p = m1 ; T[m2].b = m3 ; DE[m1]++;}
    if(m3 != -1){T[m3].p = m1 ; T[m3].b = m2 ; DE[m1]++;}
    if(m2 == -1 && m3 == -1)H[m1] = 0;
}
for( int i = 0 ;i < n ; i++ ){
    if(T[i].p==-1)qq=i;/**?里?里?里sb**/
}
jiedian(qq,0);
pops(qq);

for(int i = 0 ;i < n ; i++){
    printf("node %d: parent = %d",i,T[i].p);
    printf(", sibling = %d, degree = %d,",T[i].b,DE[i]);
    printf(" depth = %d, height = %d, ",D[i],H[i]);
    if(T[i].p == -1)printf("root\n");
    else if(DE[i] != 0)printf("internal node\n");
    else printf("leaf\n");
}
return 0;
}

Measured memory_bytes: 2748
#include <iostream>
using namespace std;
int main() 
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == 1) 
	{
        cout << "YES\n";
        return 0;
    }
    for(int i = 1; i <= 105; i++)
    {
        if(a * i % b == c)
        {
            cout << "YES\n";
            return 0;
        }
    }
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using Int=long long;

int count(int i, int j,int H,int W,const std::vector<std::string> &S) {

	int res = 0;
	for (int k = std::max(0, i - 1); k <= std::min(H - 1, i + 1); k++) {
		for (int l = std::max(0, j - 1); l <= std::min(W - 1, j + 1); l++) {
			if (S[k][l] == '#')res++;
		}
	}
	return res;
}


int main() {

	int H, W;
	std::cin >> H >> W;

	std::vector <std::string> S(H);
	for (int i = 0; i < H; i++) std::cin >> S[i];

	std::vector<std::string> ans(H,std::string(W,'0'));//二次元vector<string>の初期化（初期化しないと、後々for文でアクセスできない）

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') ans[i][j] += count(i, j,H,W, S);
			else ans[i][j] = '#';
		}
	}

	for(int i=0;i<H;i++)std::cout << ans[i] << std::endl;


}




Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPE(i,a,n) for(int i=a;i<=n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T,class U> void cinn(T& n,U a) {REP(i,0,n) cin >> a[i];}


int atcoder(){
    //入力
    string s;
    cin >> s;
    string ans = "";
    
    REP(i,0,s.size()){
        if(s[i]=='0') ans += '0';
        if(s[i]=='1') ans += '1';
        if(s[i]=='B' && ans!="") ans.pop_back();;
    }
    
    cout << ans;
    
    return 0;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int  A,B,C;
    cin>>A>>B>>C;
    if (C<=A+B)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int i = scanner.nextInt();
		
		scanner.close();
		
		int result = i % 1000;
		int t = i / 1000;
		
		if (result == 0) {
			System.out.println(0);
		} else {
			System.out.println(((t + 1) * 1000) - i);
		}
	
	}

}


Measured memory_bytes: 27064
def solve
  return :UNRESTORABLE if S.size<T.size
  q=[]
  0.upto(S.size-T.size) do |i|
    ok = true
    T.size.times do |j|
      ok = false if S[i+j]!=?? &&  S[i+j]!=T[j]
    end
    next unless ok
    q << S.gsub(??, ?a)
    q[-1][i...i+T.size]=T
  end
  q.empty? ? :UNRESTORABLE : q.min
end

S=gets.chop
T=gets.chop
puts solve


Measured memory_bytes: 1788
#abc087b

a=int(raw_input())
b=int(raw_input())
c=int(raw_input())
x=int(raw_input())

cnt=0
for i in xrange(a+1):
 for j in xrange(b+1):
  for k in xrange(c+1):
   if i*500+j*100+k*50==x:
    cnt+=1
print cnt


Measured memory_bytes: 2568
import bisect
import math
from collections import deque

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def main():
    H,W  =isRaw()
    ss = [sRaw() for _ in range(H)]
    memo = [[INF for _ in range(W)] for _ in range(H)]
    qu = deque()
    isF = 1 if ss[0][0] == "#" else 0
    ans = INF
    memo[0][0] = isF
    for y in range(H):
        for x in range(W):
            s = ss[y][x]
            if x!=0:
                prevM = memo[y][x-1]
                prevS = ss[y][x-1]
                if s=="#" and prevS!="#":
                    memo[y][x] = min(memo[y][x],prevM+1)
                else:
                    memo[y][x] = min(memo[y][x], prevM)
            if y!=0:
                prevM = memo[y-1][x]
                prevS = ss[y-1][x]
                if s == "#" and prevS != "#":
                    memo[y][x] = min(memo[y][x], prevM+1)
                else:
                    memo[y][x] = min(memo[y][x], prevM)
    return memo[H-1][W-1]

    
if __name__ == "__main__":
    print(main())


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

const ll MOD = 1000000007;
int n, m;
ll answer(unordered_map<int, bool> &a) {
    vector<ll> ans(n + 1, 0);
    ans[0] = 1;
    if(!a[1]) ans[1] = 1;
    for (int i = 2; i <= n; i++) {
        if (!a[i]) {
            ans[i] = (ans[i - 1] + ans[i - 2])%MOD;
        }
    }
    return ans[n]%MOD;
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    unordered_map<int, bool> a(m);
    
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        a[b] = true;
    }

    cout << answer(a);

    return 0;
}

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

string ans;
int main()
{

    int N;
    cin >> N;
    string s, t;
    cin >> s;
    cin >> t;

    for (int i = 0; i < N; ++i)
    {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <numeric>
#include <queue>

using namespace std;

typedef pair<int, int> P;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i = 0; i < M; ++i){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    
    vector<P> ab(M);
    for(int i = 0; i < M; ++i){
        ab[i] = P(b[i], a[i]);
    }
    sort(ab.begin(), ab.end());
    
    int now = -1;
    int ans = 0;
    for(int i = 0; i < ab.size(); ++i){
        if(ab[i].second <= now)     continue;
        
        now = ab[i].first - 1;
        ans++;
    }
    
    cout << ans << endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n;cin >> n;
  vint a(n);vin(a);
  
  int cnt=0;
  rep(i,n){
    if(a[i]%2==1)cnt++;
  }

  if(cnt%2==0)cout << "YES" << endl;
  else cout << "NO" << endl;


}


Measured memory_bytes: 1148
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::HashMap;

#[allow(unused)]
fn gcd(x: i64, y: i64) -> i64 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

#[allow(unused)]
fn lcm(x: i64, y: i64) -> i64 {
    x * y / gcd(x, y)
}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        a: usize,
        p: usize,
    }

    let peace = 3 * a + p;
    println!("{}", peace / 2);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
    using namespace std;
	#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
	#define pb push_back
	#define mp make_pair
	#define all(v) v.begin(),v.end()
	typedef long long ll;
	#define lim 20000000000007LL

	int main()
	{
		fast
		int t=1;
		// cin>>t;
		while(t--)
		{
			ll n;
			cin>>n;
			ll sum=(1000)*(n/500);
			n=n%500;
			sum+=(5)*(n/5);
			cout<<sum;

		}
	}

			

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second


template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin>>n>>q;
    VV to(n);
    int a,b;

    rep(i,n-1){
        cin>>a>>b;
        a--,b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    Vec c(n,0);

    while(q--){
        ll p,x;
        cin>>p>>x;
        p--;
        c[p] += x;
    }
    auto dfs = [&](auto dfs, ll v, ll p)->void{
        Each(x, to[v]){
            if(x!=p){
                c[x] += c[v];
                dfs(dfs,x,v);
            }
        }
    };
    dfs(dfs,0,-1);
    rep(i,n){
        cout<<c[i]<<" ";
    }
    return  0;
}


Measured memory_bytes: 22528