akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

n = int(input())
fs = [input().split() for i in range(n)]
check = "mcxi"

for f2 in fs:
    v = [0, 0, 0, 0]
    for f in f2:
        for i in range(len(f)):
            for c in range(4):
                if check[c] == f[i]:
                    if i==0:
                        tmp = 1
                    else:
                        tmp = 1 if f[i-1] in check else int(f[i-1])
                    v[c] += tmp
                    break
    for i in range(3, 0, -1):
        if v[i] > 9:
            v[i] -= 10
            v[i-1] += 1
    for i in range(4):
        if v[i] > 0:
            print(check[i] if v[i] == 1 else str(v[i])+check[i], end="")
    print()



Measured memory_bytes: 6820
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
int main(){
    int x;
    scanf("%d",&x);
    if(x>=30)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3656
w = input()

w = sorted(w, key = lambda x: x)
word_count = {}
for i in w:
    if i in word_count:
        word_count[i] += 1
    else:
        word_count[i] = 1

for i in word_count.values():
    if i % 2 != 0:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 38384
w[100000],c,n,k,g,i,l,m,r=1e9;
f(p)
{
    c=1;g=0;
    for(i=0;i<n;)
    {
        if(g+w[i]<=p)
        {
            g+=w[i++];
        }
        else
        {
            if(g>0)c++;
            else return k+1; 
            g=0;
        }
    }
    return c;
}
 
main()
{
    scanf("%d%d",&n,&k);
    for(;i<n;scanf("%d",w+i++));
    while(l<r)
    {
        m=(l+r)/2;
        if(f(m)>k)l=m+1;
        else r=m;
    }
    for(m--;;m++)
    {
        if(f(m)<=k)break;
    }
    printf("%d\n",m);
    return 0;
}
 

Measured memory_bytes: 2164
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i = 0; i , (n); ++i)
using ll = long long;
using namespace std;
int sum(int n) {
    if (n == 0) {
        return 0;
    }

    int s = sum(n - 1);
    return s + n;
}
int main() {
    int N, K, sum=0;
    cin >> N >> K;
    vector<int>p(N);
        for (int i = 0;i < N;i++) {
            cin >> p.at(i);
        }
        sort(p.begin(), p.end());
        for (int i = 0;i < K;i++) {
            sum+=p.at(i);
        }
        cout << sum;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <chrono>
#include <random>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int N;
VL A;

int main(void) {
    cin >> N;
    A.resize(1 << N);
    for_each(ALL(A), [](auto &e){scanf("%lld", &e);});
    while ((int)A.size() > 1) {
        VL a;
        REP(i, A.size()) {
            LL buf = llabs(A[i] - A[i + 1]);
            if (buf == 0) buf = A[i];
            a.EB(buf);
            i++;
        }
        A = a;
    }
    cout << A[0] << endl;
}


Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    int a[n],sum=0;
    for(int i=1;i<=n;i++){
            cin>>a[i];
            if(a[i]%2==0){for(int j=1;j<=m;j=j+a[i])
                {
                    sum++;
                }
            }
            else if(a[i]!=0){for(int j=1;j<=m;j=j+a[i])
                {
                    sum++;
                }}
            else sum=sum+1;
    }cout<<sum+x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(m);
    for (int i = 0; i < m; i++) {
        int s, c;
        cin >> s >> c;
        v[i] = {s - 1, c};
    }

    for (int i = 0; i < 100000; i++) {
        string now = to_string(i);
        if (now.size() != n)continue;

        bool ok = true;
        for (auto x:v) {
            if (now[x[0]] - '0' != x[1])ok = false;
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

N = map(int, raw_input().strip().split())
L = map(int, raw_input().strip().split())
pos = 0
for i in range(N[0]):
    if(L[0] > N[1]):
        print(0)
        sys.exit()
    if (pos + L[i]) > N[1]:
        print(i+1)
        sys.exit()
    else:
        pos +=L[i]
    
print(N[0]+1)

Measured memory_bytes: 2568
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int h,w,n;
int main(){
	cin>>h>>w>>n;
	if(h<w)
	swap(h,w);
	n+=h;
	n--;
	cout<<n/h;
	re 0;
}


Measured memory_bytes: 256
/////////////////////////////////////////
///       Please Give Me AC!!!!!      ///
/////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main(){
    ll N; cin>> N;
    ll A, B; cin>> A >> B;
    if(abs(A-B) % 2 == 0){
        cout<< abs(A - B) / 2;
    }else{
        cout<< min(A + (B - A - 1) / 2, N - B + 1 + (B - A - 1) / 2) << endl;
    }
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef unsigned long long ll;

int N, M;
int graph[51][51]={0};
int homon[51]={0};
int cnt = 0;
void dfs(int n){
  for(int i = 1; i <= N; i++){
    if(graph[n][i] && !homon[i]){
      homon[i]=1;
      dfs(i);
    }
  }
}

void func(){
  
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= N; j++){
      if(graph[i][j] == 1){
        int flag = 0;
        graph[i][j]=0;
        graph[j][i]=0;
        homon[1]=1;
        dfs(1);
        for(int l = 1; l <= N; l++){
          if(homon[l] == 0)
            flag=1;
        }
        if(flag)
          ++cnt;
        for(int l = 1; l <= N; l++)
          homon[l] = 0;
        graph[i][j]=1;
        graph[j][i]=1;
      }  
    }
  }
}

int main(){
  cin >> N >> M;
  for(int i=0; i < M; i++){
    int a,b;
    cin >> a >> b;
    graph[a][b]=1;
    graph[b][a]=1;
  }

  func();
  cout << cnt/2 << endl;


  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

#define MAX_N 100001

int main(void){

    int N,i,A[MAX_N],mem[MAX_N];
    long int ans = 1;

    scanf("%d",&N);
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
        mem[i] = 0;
    }

    for(i = 0;i < N;i++){
        mem[A[i]]++;
    }

    if(N % 2 == 1){
        //for(i = 0;i < N;i += 2) printf("mem[%d]:%d\n",i,mem[i]);
    
        for(i = 0;i < N;i += 2){
            if((i != 0 && mem[i] != 2)){
                printf("0\n");
                return 0;
            }
        }
    }else{
        //printf("mem[0]:%d\n",mem[0]);
        //for(i = 1;i < N;i += 2) printf("mem[%d]:%d\n",i,mem[i]);

        for(i = 1;i < N;i += 2){
            if((i != 0 && mem[i] != 2) || mem[0] == 2){
                printf("0\n");
                return 0;
            }
        }
    }

    for(i = 1;i <= N/2;i++){
        ans *= 2;
        ans %= 1000000000+7;
    }

    printf("%ld\n",ans);
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  int res=0;
  int num=1;
  for(int i=1; i<=n; i++){
    int res1=0;
    int j=i;
    while (j%2 ==0){
      j/=2;
      ++res1;
    }
    if (res1>res){
      res=res1;
      num=i;
    }
  }
  cout<<num<<endl;

  return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
    s <- getLine
    print (min (f True s) (f True (map rev s)))

inputs :: Read a => IO [a]
inputs = map read . words <$> getLine

f :: Bool -> String -> Int
f _ [] = 0
f True ('1':cs) = f False cs
f False ('0':cs) = f True cs
f b (_:cs) = 1 + f (not b) cs

rev :: Char -> Char
rev '1' = '0'
rev '0' = '1'


Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i = 1; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int A, B, K, ans=0;
  in(K);
  in(A);
  in(B);
  
  for (int i = A; i<=B; i++) {
    if (i%K==0) ans++;
  }
  if (ans>0) cout << "OK" << endl;
  else cout << "NG" << endl;
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
//#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
//const int mod=1e9+7;
const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;

// int n,m,x,y,res=0,sz[2*up],par[2*up],ans[2*up];

// int get(int x)
// {
//     return x*(x-1)/2;
// }

// int find(int x)
// {
//     if(par[x]==x)
//         return x;
//     else
//         return par[x]=find(par[x]);
// }

// void merge(int u,int v)
// {
//     x=find(u);
//     y=find(v);
//     if(sz[x]<sz[y])
//         swap(x,y);
//     res-=get(sz[x]);
//     res-=get(sz[y]);
//     sz[x]+=sz[y];
//     res+=get(sz[x]);
//     par[v]=u;
// }

// void solve()
// {
//     cin>>n>>m;
//     vector<pii>q(m+1);
//     vector<pair<int,pii>>e(n);
//     repn(i,1,n)
//     {
//         sz[i]=1;
//         par[i]=i;
//     }
//     repn(i,1,n-1)
//     {
//         cin>>e[i].ss.ff>>e[i].ss.ss>>e[i].ff;
//     }
//     repn(i,1,m)
//     {
//         cin>>q[i].ff;
//         q[i].ss=i;
//     }
//     sort(all(e));
//     sort(all(q));
//     int pos=1;
//     repn(i,1,m)
//     {
//         while(pos<n && e[pos].ff<=q[i].ff)
//         {
//             x=e[pos].ss.ff;
//             y=e[pos].ss.ss;
//             merge(x,y);
//             ++pos;
//         }
//         ans[q[i].ss]=res;
//     }
//     repn(i,1,m)
//     {
//         cout<<ans[i]<<" ";
//     }
//     cout<<endl;
// }



void solve()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int f=h1*60+m1;
    int g=h2*60+m2;
    int ans=(g-f);
    if(ans<0)
    {
        ans+=24*60;
    }
    cout<<ans-k<<endl;
}

int32_t main()
{
    int t;
    // memset(prime, true, sizeof(prime)); 
    // sieve();
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;

int main() {
	priority_queue<int> pq;
	int k, t;
	cin >> k >> t;
	int a[t];
	for (int i = 0; i < t; i++) {
		cin >> a[i];
		pq.push(a[i]);
	}
	int ans = 0;
	while (!pq.empty()) {
		int top = pq.top(); pq.pop();
		if (pq.empty()) {
			ans += top;
		} else {
			int top2 = pq.top(); pq.pop();
			if (top-1 > 0) pq.push(top-1);
			if (top2-1 > 0) pq.push(top2-1);
		}
	}
	if (ans == 0) {
		cout << ans << endl;
	} else {
		cout << ans-1 << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int D = sc.nextInt();

        int[][] X = new int[N][D];

        for(int i = 0; i < N; i++){
            for(int j = 0; j < D; j++){
                X[i][j] = sc.nextInt();
            }
        }

        int count = 0;

        for(int i = 0; i < N-1; i++){
            for(int j = i+1; j < N; j++){
                int dis2 = 0;
                for(int k = 0; k < D; k++) {
                    dis2 += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
                }
                if (Math.sqrt(dis2) == (int)Math.sqrt(dis2))
                    count++;
            }
        }
        sc.close();
        System.out.println(count);
    }

}

Measured memory_bytes: 21712
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
import collections
from heapq import *
#RRR...WWW...にしたい
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))
suctable=[]
scoretable=[[0 for _ in range(N)] for _ in range(N)]
cyclesum=[]
for i in range(N):
    suctable.append(P[i]-1)
for i in range(N):
    #scoretable[i][0]=C[i]
    suc=suctable[i]
    l=[0]*N
    flag=0
    l[suc]=1
    for j in range(N-1):
        scoretable[i][j+1]=scoretable[i][j]+C[suc]
        suc=suctable[suc]
        if (l[suc]==0)and(flag==0):
            l[suc]=1
        else:
            flag=1
    #print(l)
    num=0
    num2=0
    for j in range(N):
        if l[j]==1:
            num=num+C[j]
            num2=num2+1
    cyclesum.append([num,num2])
#print(scoretable,cyclesum)
ma=-float("inf")
K2=K
for i in range(N):
    #print("i=",i)
    K=K2
    if cyclesum[i][0]<=0:
        ma=max(ma,max(scoretable[i][1:(min(N,K+1))]))
    else:
        n=0
        if K<cyclesum[i][1]:
            n=max(scoretable[i][1:(min(N,K+1))])
        else:
            K=K-cyclesum[i][1]
            n=cyclesum[i][0] * (K // cyclesum[i][1])
            res=K%cyclesum[i][1]
            res=res+cyclesum[i][1]
            #print(res,K,n)
            suc=suctable[i]
            for _ in range(res):
                n=n+C[suc]
                ma=max(ma,n)
                suc=suctable[suc]
                #print(n)
            #n = cyclesum[i][0] * (K // cyclesum[i][1])+max(scoretable[i][:(K%cyclesum[i][1])+1])
        ma=max(ma,n)
print(ma)





Measured memory_bytes: 287448
n = int(input())
i = 1
while (n-26**i) > 0:
    n -= 26**i
    i += 1

ans = [0]*(i)

n -= 1
for j in range(1,i+1):
    t = n%26
    n -= t
    n = n//26
    ans[j-1] = t

a = ""
for i in range(i-1,-1,-1):
    a += chr(97+ans[i])
print(a)


Measured memory_bytes: 8900
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    RVS = [input().rstrip().split(' ')+[i+1] for i in range(N)]
    RVS = [(x[0],int(x[1]),x[2]) for x in RVS]
    RVS.sort(key=itemgetter(1), reverse=True)
    RVS.sort(key=itemgetter(0))
    for x in RVS:
        print(x[2])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int main(){
  int w, d;
  while(cin >> w >> d, w){
    int sum[21] = {}, ret = 0;
    for(int i = 0; i < w; i++){
      int h;
      cin >> h;
      sum[h]++;
      ret += h;
    }
    for(int i = 0; i < d; i++){
      int h;
      cin >> h;
      if(sum[h] > 0){
        sum[h]--;
      } else {
        ret += h;
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;


int main() {
	string s; cin >> s;
	string ans = "keyence";
	if (s == ans) {
		cout << "YES" << endl;
		return 0;
	}
	int n = s.size();
	for (int i = 0; i < n; i++) {
		for (int j = 0; i + j < n; j++) {
			string t = s.substr(0, i) + s.substr(i + j + 1, n - i - j);
			//cout << t << endl;
			if (ans == t) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
void chmin(int &a,int b){if(a>b) a=b;}

vector<int> a;


int main()
{
    int a1,a2,a3;
    cin>>a1>>a2>>a3;
    a.push_back(a1);
    a.push_back(a2);
    a.push_back(a3);
    
        if(a[1]<a[0])
        {
            int temp=a[0];
            a[0]=a[1];
            a[1]=temp;
        }
        if(a[2]<a[1])
        {
            int temp=a[1];
            a[1]=a[2];
            a[2]=temp;
        }
        if(a[1]<a[0])
        {
            int temp=a[0];
            a[0]=a[1];
            a[1]=temp;
        }
        
        
        
    
    cout<<a[2]-a[0]<<endl;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

//height 違う
public class Main{
    static int count =0;
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        str = br.readLine();
        
        String[] tmp = str.split("\\s");
        int[] num = new int[3];
        num[0] = Integer.parseInt(tmp[0]);
        num[1] = Integer.parseInt(tmp[1]);
        num[2] = Integer.parseInt(tmp[2]);
        run(num[0],num[1],num[2]);

    }
    public static void run(int a,int b,int c){
        if(a < b){
            if(c < a){
                System.out.println(c + " " + a + " " + b);
            }else if(c > b){
                System.out.println(a + " " + b + " " + c);
            }else{
                System.out.println(a + " " + c + " " + b);
            }
        }else{
            //a>b
            if(c < b){
                System.out.println(c + " " + b + " " + a);
            }else if(c > a){
                System.out.println(b + " " + a + " " + c);
            }else{
                System.out.println(b + " " + c + " " + a);
            }
        }
    }
}



Measured memory_bytes: 24588
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>

using namespace std;

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

    for(int i=0;i<n;i++){
        int count =0;
        for(int j=1;j<=n+i;j++){
            if((n+i)%j==0){
                count++;

            }
            if(count>2){
                break;
            }
        }
        if(count==2){
            cout <<n+i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

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

int main()
{
	int start = -1, end = -1;
	string s;
	cin >> s;
	rep(i, s.length())
	{
		if (start == -1 && s[i] == 'A') start = i;
		if (s[i] == 'Z')                end   = i;
	}
	cout << end - start + 1;
	return 0;
}

Measured memory_bytes: 3728
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import accumulate
def main():
    n, m, k = map(int,input().split())
    A = [0] + list(map(int,input().split()))
    B = [0] + list(map(int,input().split()))
    A = list(accumulate(A))
    B = list(accumulate(B))
    ans = 0
    j = m
    for i in range(n + 1):
        if A[i] > k:
            break
        while A[i] + B[j] > k:
            j -= 1
        ans = max(ans, i + j)
    print(ans)


if __name__=='__main__':
    main()

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    if (a % 2 != 0)
      cnt++;
  }
  cout << (cnt % 2 == 0 ? "YES" : "NO") << endl;

  return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int t = 1;
	int cnt = 0;
	while (t < k) {
		t *= 2;
		cnt++;
	}
	double s = 0;
	for (int i = 1; i <= n; i++) {
		if (i * t < k) t *= 2;
		double x = 1.0 / t;
		s += x;
		if (t > 1) t /= 2;
	}
	double ans = s / n;
	printf("%.20f\n", ans);
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	int A, B, C;
	
	scanf("%d %d %d", &A, &B, &C);
	if (1 <= A && B <= 500 && 1 <= C && C <= 1000) {
	}
	else exit(1);

	if (C <= A + B) printf("Yes");
	else if(A + B <= C) printf("No");

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
 
int main(){
  ll i, j;
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);
  for(i = 0; i < n; i++)
    cin >> x[i];
  ll mint = MOD;
  for(i = 0; i <= n - k; i++){
    if(x[i + k - 1] <= 0)
      chmin(mint, -x[i]);
    else if(x[i] >= 0)
      chmin(mint, x[i + k - 1]);
    else
      chmin(mint, x[i + k - 1] - x[i] + min(-x[i], x[i + k - 1]));
  }
  cout << mint << endl;
 
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = [0] * N
for i, h in enumerate(input().split()):
  H[i] = int(h)
  
max_n = 0
n = 0

for i in range(N-1):
  if H[i] < H[i+1]:
    if max_n < n:
      max_n = n
    n = 0
  else:
    n += 1
if max_n < n:
  max_n = n
print(max_n)

Measured memory_bytes: 15020
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return x

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
N,D = int_map()
XY = int_mtx(N)

ans = 0
for i in range(0,N):
    if XY[i][0]**2+XY[i][1]**2 <= D**2:
        ans += 1

print(ans)


Measured memory_bytes: 63400
import java.io.*;
import java.util.*;


public class Main{
    static long [][] memo;
    static long [] pow = new long[33];
    static ArrayList <Integer> [] graph;
    static Integer [] d;
    static int [] dist;
    static boolean[][] visited;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        int mod = 2019;
        //int t = sc.nextInt();
        int t = 1;
        while(t -- > 0)
        {
            String s = sc.next();
            char c[] = s.toCharArray();
            long dp[] = new long[2019];
            int n = c.length;
            long res = 0l;
            dp[c[0] - '0'] = 1;
            for(int i = 1; i < n; i++)
            {
                long [] tmp = new long[2019];
                int k = c[i] - '0';
                for(int j = 0; j < 2019; j++)
                    if(dp[j] != 0)
                        tmp[(j * 10 + k) % 2019] += dp[j];
                dp = tmp;
                res += dp[0];
                tmp[k]++;
            }
            out.println(res);
        }
        out.close();
    }
    public static void bfs(int source, int i, int g)
    {
        if(visited[i][g]) return;
        visited[i][g] = true;
        if(g == 0) graph[source].add(i);

        if(dist[i] <= g) bfs(source, i - 1, g - dist[i]);
        if(dist[i + 1] <= g) bfs(source, i + 1, g - dist[i + 1]);
    }
    public static long solve(long n){
        for(int i = 1; i < 33; i ++)
            if(n % pow[i] == 0)
                return n / pow[i];
        return -1;
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}


Measured memory_bytes: 53944
from itertools import product

def generator(ls, length):
    for i in product(*(ls for i in range(length))):
        yield "".join(i)

def solve(ls, n):
    for i in generator(ls, len(n)):
        if n <= i:
            return i
    if ls[0] == "0":
        return ls[1] + "".join(ls[0] for i in range(len(n)))
    return "".join(ls[0] for i in range(len(n) + 1))


if __name__ == "__main__":
    n, k = input().split()
    ls = {chr(i) for i in range(ord("0"), ord("0") + 10)}
    ls.difference_update(set(input()))
    ls = sorted(ls)
    print(solve(ls, n))


Measured memory_bytes: 3188
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int a, b;
    cin >> a >> b;
    if(a <= 5){
        cout << 0;
        exit(0);
    }
    else if(a <= 12){
        cout << b / 2;
        exit(0);
    }
    else{
        cout << b;
        exit(0);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#define MAXN 200005
#define PLI pair<long long,int>
#define fi first
#define se second
#define mp make_pair
#define ha 99994711
#define ba 823
//#define ivorysi
using namespace std;
typedef long long int64;
int N;
char s[305][305],b[305][305];
int64 hc[305],hr[305],e;
inline int C(int x) {
    return x > N ? x - N : x;
}
bool check(int y) {
    int T = C(N + y);
    for(int i = 1 ; i <= N ; ++i) 
        hr[i] = (hr[i] * ba + (b[i][T] - 'a' + 1)) % ha;
    for(int i = 1 ; i <= N ; ++i) {
        if(hr[i] != hc[C(i + y)]) {
            T = C(N + y + 1);
            for(int j = 1 ; j <= N ; ++j) 
                hr[j] = (hr[j] - e * (b[j][T] - 'a' + 1) % ha + ha) % ha;
            return false;
        }
    }
    T = C(N + y + 1);
    for(int i = 1 ; i <= N ; ++i) 
        hr[i] = (hr[i] - e * (b[i][T] - 'a' + 1) % ha + ha) % ha;
    return true;
}
void Solve() {
    scanf("%d",&N);
    if(N == 1) {
        puts("1");return;
    }
    e = 1;
    for(int i = 1 ; i < N ; ++i) e = e * ba % ha;
    for(int i = 1 ; i <= N ; ++i) {
        scanf("%s",s[i] + 1);
    }
    int cnt = 0;
    for(int A = 0 ; A < N ; ++A) {
        memset(hc,0,sizeof(hc));
        memset(hr,0,sizeof(hr));
        for(int i = 1 ; i <= N ; ++i) {
            for(int j = 1 ; j <= N ; ++j) {
                b[i][j] = s[C(i + A)][j];
                hc[j] = (hc[j] * ba + (b[i][j] - 'a' + 1)) % ha;
                if(j != N) {
                    hr[i] = (hr[i] * ba + (b[i][j] - 'a' + 1)) % ha;
                }
            }
        }
        for(int B = 0 ; B < N ; ++B) {
            if(check(B)) ++cnt;
        }
    }
    printf("%d\n",cnt);
}
int main() {
    Solve();
    return 0;
}

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

using namespace std;

typedef long long ll;

struct Point
{
    ll x,y;
    Point(){ x = y = 0.0; }
    Point(ll _x, ll _y) : x(_x), y(_y){}

    Point operator+ (Point p)
    {
        return Point(p.x + x, p.y + y);
    }

    Point operator- (Point p)
    {
        return Point(x - p.x, y - p.y);
    }

    ll operator* (Point p)
    {
        return p.x * x + p.y * y;
    }

    Point operator* (ll t)
    {
        return Point(x*t, y*t);
    }

    ll operator~ ()
    {
        return x * x + y * y;
    }

    ll operator% (Point p)
    {
        return x * p.y - y * p.x;
    }

};

int main()
{
    Point p0,p1,p2,p3;
    Point vec, vec1;
    int q;
    cin >> q;
    while(q--)
    {
        cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        vec = (p1 - p0);
        vec1 = (p3 - p2);
        if(vec * vec1 == 0) puts("1"); // Cuando el producto punto es 0 son perpendiculares.
        else if( vec.x * vec1.y == vec1.x * vec.y ) puts("2"); // Cuando esta de la forma n(x,y) paralelo.
        else puts("0");
    }
    return 0;
}

Measured memory_bytes: 3084
sets = dict()

def gcd(a, b):
    tmp = 0
    while b != 0:
        if b < a:
            tmp = a
            a = b
            b = tmp
        b = b % a
    return a

def gcd2(a, b):
    if a > b:
        key = (b, a)
    else:
        key = (a, b)
    
    try:
        # print("cached")
        return sets[key]
    except:
        # print("stored")
        ans = gcd(a, b)
        sets[key] = ans
        return ans

n = int(input())

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

        for k in range(1, n+1):
            ans += gcd2(pre, k)

print(ans)


Measured memory_bytes: 10824
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

const int MAX_N = 200005;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi c(n);
    rep(i, n) cin >> c[i];
    vector<mint> dp(n+1, 0), cnt(MAX_N, 0);
    dp[0] = 1;
    rep(i, n) {
        if (i != 0 && c[i-1] == c[i]) {
            dp[i+1] += dp[i];
        } else {
            dp[i+1] += dp[i] + cnt[c[i]];
            cnt[c[i]] += dp[i];
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4224
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    int n; cin >> n;
    VI a(n);
    REP(i, n) cin >> a[i];
    int q; cin >> q;
    REP(i, q){
        int b, e, k, cnt = 0;
        cin >> b >> e >> k;
        FOR(j, b, e)
            if(a[j] == k) ++cnt;
        cout << cnt << "\n";
    }
    return 0;
}



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

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

  if (n > 500)
    if (n % 500 > a)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  else
  {
    if (n > a)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}

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

using namespace std;

int a, b;

int main(){
    int n;
    cin >> n;
    bool ok = false;
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i <= 9 && n / i >= 1) {
            ok = true;
            break;
        }
    }
    
    if (ok) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main(){
  int N,m,ans,i;
  ans=0;
  i=0;
  while(1){
    ans =0;
    cin >> N;
    for(int a=1;a<N;a++){
      m=0;
      for(i=a;i<N;i++){
	m+=i;
	if(m==N){
	  ans++;
	}
      }
    }
    if(N==0){
      break;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3056
#include<iostream>
#include<cmath>

int n;
int a[31];

int main()
{
	a[0] = 1;
	a[1] = 1;
	a[2] = 2;

	for( int i = 3; i <= 30; ++i )
		a[i] = a[i-1] + a[i-2] + a[i-3];

	while( std::cin >> n, n )
		std::cout << ceil( a[n] / 10.0 / 365.0 ) << std::endl;

	return 0;
}

Measured memory_bytes: 1232
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pab*2*x)
if y-x>= 0:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*x)
    li.append(pab*2*y)
li.sort()
print(li[0])

Measured memory_bytes: 38384
# C - Prison
# https://atcoder.jp/contests/abc127/tasks/abc127_c

n, m = map(int, input().split())
gates = [list(map(int, input().split())) for _ in range(m)]
# gates = []
# for i in range(m):
#     gates.append(list(map(int, input().split())))


scope = [1, n]

for element in gates:
    """
    ここで範囲の左右を取得する
    Lは0番目の最大値
    Rは1番目の最小値を検索する
    """

    if element[0] > scope[0]:
        scope[0] = element[0]

    if element[1] < scope[1]:
        scope[1] = element[1]

"""
範囲の最大値がnを超えていた場合について
最小値~nまでの範囲で処理を行う

超えていない場合について
普通にR-Lを行う
"""


def return_num():
    if scope[1] > n:
        return n - scope[0] + 1

    else:
        return scope[1] - scope[0] + 1


num = return_num()

if num < 0:
    print(0)
else:
    print(num)

# print(scope)


Measured memory_bytes: 27336
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll h, w, n;
ll a[200005];

int main()
{
    scanf("%lld%lld%lld", &h, &w, &n);
    for(ll i = 1; i <= h; i++)
    {
        a[i] = w + 1;
    }
    for(ll i = 0; i < n; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        a[t1] = min(a[t1], t2);
    }
    ll now = 1;
    for(ll i = 2; i <= h; i++)
    {
        if(a[i] <= now)
        {
            printf("%lld\n", i - 1);
            return 0;
        }
        else
        {
            if(a[i] != now + 1) now++;
        }
    }
    printf("%lld\n", h);
    return 0;
}


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

int n; 

int main()
{
	cin>>n;
	int ge=n%10,shi=(n%100)/10,bai=n/100;
	if (bai*11>=n%100)  cout<<bai<<bai<<bai<<endl;
	else cout<<bai+1<<bai+1<<bai+1<<endl;
	return 0;
}

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

int main() {
	int a, b;
  cin >> a >> b;
  
  vector<string> vec(a + 2);
 
  for(int i = 0; i < a + 2; i++){
    
    if(i == 0 || i == a + 1){
      for(int j = 0; j < b + 2; j++){
        vec.at(i) += "#";
      }
    }
    
    else{
      string xi;
      cin >> xi;
      vec.at(i) = "#" + xi + "#";
    }
     cout << vec.at(i) << endl;
  }
 
}

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

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

	int A, B;
	cin >> A >> B;

	if(K == 1)
	{
		cout << "OK" << endl;
	}
	else if (A % K == 0)
	{
		cout << "OK" << endl;
	}
	else if ((A / K) == (B / K))
	{
		cout << "NG" << endl;
	}
	else
	{
		cout << "OK" << endl;
	}



	return 0;
}



Measured memory_bytes: 3624
#include <iostream>
using namespace  std;
int main(){
	int sh, sm, ss, eh, em, es;
	int h, m, s;
	for (int i = 0; i < 3; i++){
		cin >> sh >> sm >> ss >> eh >> em >> es;
		if (es < ss){
			em = em - 1;
			es = es + 60;
		}
		s = es - ss;
		if (em < sm){
			eh = eh - 1;
			em = em + 60;
		}
		m = em - sm;
		h = eh - sh;
		cout << h << " " << m << " " << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAX_N 100005

using namespace std;

int n;
int t[MAX_N];
int x[MAX_N];
int y[MAX_N];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d%d",&t[i],&x[i],&y[i]);
	for(int i=1;i<=n;i++)
	{
		int d=abs(x[i-1]-x[i])+abs(y[i-1]-y[i]);
		if(!(d<=t[i]-t[i-1] && !((d&1)^((t[i]-t[i-1])&1))))
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}


Measured memory_bytes: 1408
#abc110b

N,M,X,Y=map(int,raw_input().split())
x=map(int,raw_input().split())
y=map(int,raw_input().split())
xmax=max(x)
ymin=min(y)
if xmax<Y and ymin>X and xmax<ymin:
 print 'No War'
else:
 print 'War'


Measured memory_bytes: 2568
#include <stdio.h>

int main(void){

  int a,b,c,i;
  int count=0;
  scanf("%d %d %d",&a, &b,&c);
  
  if(c*a<=b){
  	printf("%d",c);
  }
  else{
  	for(i=b;i>=0;i=i-a){
    	count++;
    }
    printf("%d",count-1);
  }
  return 0;
}
  


Measured memory_bytes: 1696
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define PRINT
#define LCERR
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:

private:

};

int solve() {
    Solution solution;
    // handle IO here
    int N, D;
    cin >> N >> D;
    int range_size = 2 * D + 1;
    int ins_required = N / range_size + (N % range_size > 0 ? 1 : 0);
    cout << ins_required << endl;
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string S, LR = "L";
    cin >> S;
    ll L = 1, R = 0;
    for(int i=1;i<2*n;i++){
        if(S[i] == S[i-1]){
            if(LR[i-1] == 'R') LR.push_back('L'), L++;
            else LR.push_back('R'), R++;
        }
        else{
            if(LR[i-1] == 'R') LR.push_back('R'), R++;
            else LR.push_back('L'), L++;
        }
    }
    
    ll ans = 1;
    //cout << LR << endl;
    if(L != R || S[0] == 'W'){
        cout << 0 << endl;
        return 0;
    }
    else{
        L = 0;
        REP(i,2*n){
            if(LR[i] == 'L') L++;
            else{
                ans *= L;
                ans %= MOD;
                L--;
            }
        }
        REP(i,n){
            ans *= (i+1);
            ans %= MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 916
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n

let rec loop s mx =
  if String.length s = n then print_endline s
  else for i = (int_of_char 'a') to mx do
    loop (s ^ (Char.escaped @@ char_of_int i)) (if i = mx then mx + 1 else mx)
  done

let () = loop "" (int_of_char 'a')

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

using namespace std;

int h, w;
string s[50];

int dx[] = { 0, -1, 0, 1 };
int dy[] = { -1, 0, 1, 0 };

bool check(int p, int q);

int main()
{
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#' && !check(i, j)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;

	return 0;
}

bool check(int p, int q)
{
	int x, y;
	for (int i = 0; i < 4; i++) {
		x = p + dx[i];
		y = q + dy[i];

		if (x >= 0 && x < h && y >= 0 && y < w && s[x][y] == '#') {
			return true;
		}
	}

	return false;
}

Measured memory_bytes: 256
class WarshallFloyd:
    def __init__(self,V,inf):
        self.V=V
        self.inf=inf
        self.G=[[inf]*V for _ in range(V)]
        for i in range(V):
            self.G[i][i]=0

    def add(self,u,v,cost):
        self.G[u][v]=min(self.G[u][v],cost)

    def shortest_path(self):
        for k in range(self.V):
            for i in range(self.V):
                for j in range(self.V):
                    self.G[i][j]=min(self.G[i][j],self.G[i][k]+self.G[k][j])
        return self.G

    def exist_negative_loop(self):
        for i in range(self.V):
            if self.G[i][i]<0:
                return True
        return False

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    inf=10**9
    h,w=map(int,readline().split())
    c=[list(map(int,readline().split())) for _ in range(10)]
    a=[list(map(int,readline().split())) for _ in range(h)]
    wf=WarshallFloyd(10,inf)
    for i in range(10):
        for j in range(10):
            if i==j: pass
            else: wf.add(i,j,c[i][j])

    tmp=wf.shortest_path()
    to_one=[tmp[i][1] for i in range(10)]

    ans=0
    for i in range(h):
        for j in range(w):
            if a[i][j]==-1: pass
            else:
                ans+=to_one[a[i][j]]

    print(ans)

if __name__=="__main__":
    main()

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

void prians(bool answer) {
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int x, dummy, h = 0;

int main() {
  cin >> x;
  dummy = x;
  while(dummy > 0) {
    h += dummy % 10;
    dummy /= 10;
  }
  prians(x % h == 0);
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>

using namespace std;

int main() {
  char c[3];
  int cur = 0, ans = 0;

  scanf("%s", c);
  for (int i=0; i<3; i++) {
    if (c[i] == 'R') {
      cur++;
      if (cur > ans) {
        ans = cur;
      }
    }
    else {
      cur = 0;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1732