akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

#define ll long long

#ifndef ONLINE_JUDGE
#define debug(format, ...) fprintf(stderr, \
    "%s:%d: " format "\n", __func__, __LINE__,##__VA_ARGS__)
#else
#define debug(format, ...)
#define NDEBUG
#endif

vector<int> graph[200005];
int depth[200005];
int parent[200005];
int leafdis[200005];

int diameter = 0;

void dfs(int node, int prt)
{
    depth[node] = depth[prt] + 1;
    parent[node] = prt;
    leafdis[node] = 1;
    vector<int> leafdis_val;
    for (int i = 0; i < graph[node].size(); i++) {
        int nxt = graph[node][i];
        if (nxt == prt) continue;
        dfs(nxt, node);
        leafdis_val.push_back(leafdis[nxt]);
        leafdis[node] = max(leafdis[node], leafdis[nxt] + 1);
    }
    if (leafdis_val.size() < 2) {
        diameter = max(diameter, leafdis[node]);
    } else {
        sort(leafdis_val.begin(), leafdis_val.end());
        reverse(leafdis_val.begin(), leafdis_val.end());
        diameter = max(diameter, leafdis_val[0] + leafdis_val[1] + 1);
    }
}


void inputtree(int siz, int root = 1)
{
    for (int i = 1; i < siz; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    dfs(root, 0);
}

int n;

int main()
{
    scanf("%d", &n);
    inputtree(n);
    //printf("%d\n", diameter);
    if (diameter % 3 == 2) {
        printf("Second");
    } else {
        printf("First");
    }
    return 0;
}


Measured memory_bytes: 43356
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

int bin[100010][45], k[45], N;
long se(int key, bool small){
    if(key<0) return 0;
    long sum=0, mul=1;
    for(int i=0; i<key; ++i) mul *= 2;
    for(int j=0; j<N; ++j) sum += bin[j][key];
    if(small) return max(sum, N-sum)*mul+se(key-1, true);
    else{
        if(k[key]==0) return sum*mul+se(key-1, false);
        else{
            if(sum*2<N){
                return max(sum*mul+se(key-1, true), (N-sum)*mul+se(key-1, false));
            }
            else return sum*mul+se(key-1, true);
        }
    }
}
int main() {
	long K, A;
	cin >> N >> K;
	for(int i=0; K>0; ++i){
	    k[i]=K%2;
	    K /= 2;
	}
	for(int i=0; i<N; ++i){
	    cin >> A;
	    for(int j=0; A>0; ++j){
	        bin[i][j]=A%2;
	        A /= 2;
	    }
	}
	cout << se(44, false) << endl;
	return 0;
}


Measured memory_bytes: 17792
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


s = ns()
n = len(s)

TEN = 10
THIRTEEN = 13
MOD = 10**9 + 7
dp = [[0]*THIRTEEN for _ in range(n+1)]
dp[0][0] = 1

for i, si in enumerate(s):
    if si == "?":
        for k in range(TEN):
            for j in range(THIRTEEN):
                dp[i + 1][(10*j + k) % THIRTEEN] += dp[i][j]
                dp[i + 1][(10*j + k) % THIRTEEN] %= MOD

    else:
        k = int(si)
        for j in range(THIRTEEN):
            dp[i + 1][(10*j + k) % THIRTEEN] += dp[i][j]
            dp[i + 1][(10*j + k) % THIRTEEN] %= MOD

print(dp[n][5])


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

int main() {
  int N;
  cin >> N;
  vector<int> b(N),ans(N,0);
  for (int i=0; i<N; i++) {
    cin >> b[i];
    if (b[i] > i+1) {
      cout << -1 << endl;
      return 0;
    }
  }
  
  
  int num,loc;
  for (int i=N-1; i>=0; i--) {
    num = i - (b[i] - 1) + 1;
    loc = N;
    while (loc >= 0) {
      if (num == 0) {
        ans[loc] = b[i];
        break;
      }
      if(ans[loc-1] == 0) {
        num--;
      }
      loc--;
    }
  }
  for (int i=0; i<N; i++) {
    cout << ans[i] << endl;
  }
  
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int[] array;
    static int n;
    static int m;
    static int x;
    static int[] c;
    static int[][] a;
    static int INF = 1000000000;
    static int ans = INF;
    
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        x = sc.nextInt();
        
        // array: 長さnのbit列
        array = new int[n];
        
        // 全探索する時のデータを取得
        c = new int[n];
        a = new int[n][m];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        
        // arrayのパターンを全探索
        // ex.[1, 1, 1], [1, 1, 2], ... , [m, m, m]
        dfs(0, 0);
        
        // ans: costの最小値
        if (ans == INF) ans = -1;
        System.out.println(ans);
    }
    
    public static void dfs(int index, int now) {
        // 終了条件
        if (index == n) {
            // 作ったarrayで全探索
            int cost = 0;
            int[] b = new int[m];
            for (int i = 0; i < n; i++) {
                if (array[i] == 1) {
                    cost += c[i];
                    for (int j = 0; j < m; j++) {
                        b[j] += a[i][j];
                    }
                }
            }
            
            for (int i = 0; i < m; i++) {
                if (b[i] < x) {
                    return;
                }
            }
            ans = Math.min(ans, cost);
            return;
        }
        
        // 次項の取る値: 0 or 1
        for (int i = 0; i < 2; i++) {
            array[index] = i;
            dfs(index + 1, i);
        }
    }
}

Measured memory_bytes: 37736
k,n = map(int,input().split())
a = list(map(int,input().split()))
dis = []
dis.append(a[0] - a[n - 1] + k)
for i in range(n - 1):
    dis.append(a[i +1] - a[i] )

dis.sort
print(sum(dis) - max(dis))



Measured memory_bytes: 32196
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
int n,a[15000];
int color[8];
int main() {
//freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,a[1000],cnt = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] >= 3200) cnt++;
        else color[a[i]/400]++;
    }
    int ans = 0;
    for(int i = 0; i < 8; i++){
        if(color[i] != 0)ans++;
    }
    int minn, maxn;
    if(ans > 0) minn = ans;
    else minn = 1;
    maxn = ans+cnt;
    //if(maxn > 8) maxn = 8;
    cout << minn << " " << maxn << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int i, N, cnt = 0;
    long int a[100001];
    
    scanf("%d", &N);
    
    for(i = 0; i < N; i++){
        scanf("%d", &a[i]);
        if(a[i] % 2 != 0) cnt++;
    }
    
    if(cnt % 2 == 0) printf("YES");
    else printf("NO");
    
    return 0;
}


Measured memory_bytes: 896
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
 
int main(){
  LL N;
  cin >> N;
  LL A[N];
  REP(i,N) cin >> A[i];
  LL num_odd=0,num_even=0;
  for(int i=0;i<N;++i){
    if(A[i]%2==0){
      ++num_even;
    }
    else{
      ++num_odd;
    }
  }
  bool possible=false;
  if(num_odd%2==0){
    possible=true;
  }
  if(possible){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
  }

Measured memory_bytes: 1024
N=int(input())
W=list(map(int,input().split()))
sum_W=sum(W)
half_W=sum_W/2
a=sum_W
b=0
for i in range(N):
  a-=W[i]
  b+=W[i]
  if a<=half_W:
    print(min(abs(a-b),abs(a-b+2*W[i])))
    break

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i <= (int)(n); i++)

int main()
{
  int n,m;
  cin >> n >> m;
  
  int a[m];
  cin >> a[0];
  for(int i = 1; i < m; i++)
  {
    cin >> a[i];
    if(a[i] == a[i-1]+1)
    {
      cout << 0 << endl;
      return 0;
    }
  }
  
  int f[n+1];
  ll mod = 1000000007;
  f[0] = 1; f[1] = 1;
  for(int i = 2; i <= n; i++)
  {
    f[i] = f[i-1] + f[i-2];
    f[i] %= mod;
  }
  
  ll ans = 1;
  ll now = 0;
  ll up = 0;
  for(int i = 0; i < m; i++)
  {
    up = a[i] - now;
    ans = (ans % mod) * (f[up-1] % mod);
    ans %= mod;
    now = a[i]+1;
  }
  up = n - now;
  ans *= f[up];
  
  ans %= mod;
  cout << ans << endl;

}
  


Measured memory_bytes: 4228
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
	
	ll N;
	ll W;
	cin>>N>>W;
	ll weights[N];
	ll values[N];
	
	for(ll i=0;i<N;i++){
	    cin>>weights[i];
	    cin>>values[i];
	}
     ll dp[N+1][W+1];
	for(ll i=0;i<=N;i++){
	    for(ll j=0;j<=W;j++){
	        if(i==0||j==0)
	        dp[i][j]=0;
	        else if(weights[i-1]<=j)
	        dp[i][j]=max(values[i-1]+dp[i-1][j-weights[i-1]],dp[i-1][j]);
	        else
	        dp[i][j]=dp[i-1][j];
	    }
	}
	
	cout<<dp[N][W];
	return 0;
}

Measured memory_bytes: 79104
def 解():
    iN = int(input())
    aA = [int(_) for _ in input().split()]

    iM = sum(aA) / iN

    d = {}
    for i,a in enumerate(aA):
        d[i] = [a, abs(a - iM)]
    print(sorted(d.items(),key=lambda x:x[1][1])[0][0])
解()


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

using namespace std;

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

    int n;
    while (cin >> n, n)
    {
        int suspected[n + 1] = {0};
        std::vector<int> owner[n + 1];
        for (int i = 1; i <= n; i++)
        {
            int m;
            cin >> m;
            for (int j = 0; j < m; j++)
            {
                int p;
                cin >> p;
                owner[p].push_back(i);
            }
        }
        int k;
        cin >> k;
        for (int i = 0; i < k; i++)
        {
            int idx;
            cin >> idx;
            int len = owner[idx].size();
            for (int i = 0; i < len; i++)
                suspected[owner[idx][i]]++;
        }
        int res = -1;
        bool humei = false;
        for (int i = 1; i <= n; i++)
        {
            if (suspected[i] == k)
            {
                if (res < 0)
                    res = i;
                else
                    humei = true;
            }
        }
        if (humei || res < 0)
            cout << -1 << endl;
        else
            cout << res << endl;
    }
}


Measured memory_bytes: 3216
from collections import deque

h,w = map(int,input().split())
ch,cw = map(int,input().split())
dh,dw = map(int,input().split())
S = ["#" *(w+2) ] + ["#" + input()+ "#" for _ in range(h)] + ["#" *(w+2) ]
v = [[10 ** 6]*(w+2) for _ in range(h+2)]
v[ch][cw] = 0
Q = deque([(ch,cw)])
while Q :
    y,x = Q.pop()
    for i,j in [(0,1),(1,0),(-1,0),(0,-1)] :
        if S[y+i][x+j] == "." and v[y+i][x+j] > v[y][x]:
            v[y+i][x+j] = v[y][x]
            Q.append((y+i,x+j))
    for i in range(-2,3) :
        for j in range(-2,3) :
            if i == j == 0 :
                continue
            elif 1 <= y+i <= h and 1 <= x+j <= w and S[y+i][x+j] == "." and v[y+i][x+j] > v[y][x] + 1 :
                v[y+i][x+j] = v[y][x] + 1
                Q.appendleft((y+i,x+j))
ans = v[dh][dw]
if ans == 10 ** 6 :
    print(-1)
else :
    print(ans)

Measured memory_bytes: 92208
n = int(input())
s = []
for i in range(n):
    s.append(input())

n_ac = 0
n_wa = 0
n_tle = 0
n_re = 0

for st in s:
    if st == 'AC':
        n_ac += 1
    if st == 'WA':
        n_wa += 1
    if st == 'TLE':
        n_tle += 1
    if st == 'RE':
        n_re += 1

print(f'AC x {n_ac}')
print(f'WA x {n_wa}')
print(f'TLE x {n_tle}')
print(f'RE x {n_re}')


Measured memory_bytes: 16316
card = [[1] * 13 for i in range(4)]
simbol = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(n):
    mark,num = input().split()
    num = int(num)
    if mark == 'S':
        card[0][num-1] = 0
    elif mark == 'H':
        card[1][num-1] = 0
    elif mark == 'C':
        card[2][num-1] = 0
    else:
        card[3][num-1] = 0

for j in range(4):
    for k in range(13):
        if card[j][k] == 1:
            print(simbol[j],k+1)


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

int main(){
	int th,ta,aa,ah;
	bool tt=true;
	cin>>th>>ta>>ah>>aa;
	while(th>0&&ah>0){
		if(tt){
			ah-=ta;
			tt=false;
		}else{
			th-=aa;
			tt=true;
		}
	}
	if(tt){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
using namespace std;
const int N=4000005;
const int MOD=998244353;
int n,m;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
void init(int n=4000000)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	return;
}
long long C(int n,int m)
{
	if(m<0||n<0) return 0;
	if(m>n) return 0;
	else return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
	init();
	scanf("%d%d",&n,&m);
	long long ans=0;
	int num=(m+1)%2==1?m+1:m+2;
	for(int i=0;i<=n&&i<=m;i++)
	{
		if(i%2!=m%2) continue;
		int t=(3*m-i)/2;
		if(t<0) continue; 
		long long res=0;
		res=(res+C(t+n-1,n-1)*C(n,i)%MOD)%MOD;
		if(t-m>=0) res=(res-C(t-m+n-1,n-1)*C(n-1,i-1)%MOD*n%MOD+MOD)%MOD;
		if(t-(m+1)>=0) res=(res-C(t-(m+1)+n-1,n-1)*C(n-1,i)%MOD*n%MOD+MOD)%MOD;
		ans=(ans+res)%MOD;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 66324
#include <stdio.h>

int main(void)
{
	int x, y, n;
	while(1)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)
		{
			break;
		}
		if (x > y)
		{
			n = x, x = y, y = n;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}

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

int main() {

  while(1) {
    int n, r;
    cin>>n>>r;
    if(n==0) break;
    int p, c;
    int a[n];
    for(int i = 1; i <= n; i++) {
      a[i-1] = n - i + 1;
    }
    for(int i = 0; i < r; i++) {
      cin>>p>>c;
      rotate(a, a+p-1, a+p+c-1);
	}
    cout<<a[0]<<endl;
  }

  return 0;
}
  



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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << max(a-2*b,0) << endl;   
}

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

using namespace std;

const int N = 1e5 + 5;
const int inf = 0x3f3f3f3f;

vector <int> g[N];
int n, k, dist[N];
priority_queue <pair <int, int>, vector <pair <int, int> >, greater <pair <int, int> > > pq;

void input(){
    scanf("%d", &n);
    for (int i = 1; i <= n - 1; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }

    scanf("%d", &k);
    memset(dist, 0x3f, sizeof(dist));
    for (int i = 1; i <= k; i++) {
        int u, x;
        scanf("%d %d", &u, &x);
        dist[u] = x;
        pq.push(make_pair(dist[u], u));
    }
}

void dijkstra(){
    while (!pq.empty()) {
        int d = pq.top().first;
        int u = pq.top().second;
        pq.pop();

        for (int v: g[u]) {
            if (dist[v] == inf) {
                dist[v] = dist[u] + 1;
                pq.push(make_pair(dist[v], v));
            }
            else if (abs(dist[v] - dist[u]) != 1) {
                printf("No");
                return;
            }
        }
    }

    puts("Yes");
    for (int i = 1; i <= n; i++) printf("%d\n", dist[i]);
}

void solve(){
    dijkstra();
}

signed main(){
    input();
    solve();
    return 0;
}

Measured memory_bytes: 7924
import sys
input = sys.stdin.readline
p=int(input())
A=[int(i) for i in input().split()]
B=[0]*p

P=[[0]*p for _ in range(p)]
for i in range(1,p): 
  for j in range(1,p):
    if j==1:
      P[i][j]=i
    else:
      P[i][j]=(P[i][j-1]*i)%p

for i in range(p):
  a=A[i]
  B[0]-=a
  for j in range(1,p):
    B[j]-=a*P[i][j]
    if j==p-1:
      B[j]+=a
B=B[::-1]
for i in range(p):
  B[i]%=p
print(*B)

Measured memory_bytes: 115420
//https://atcoder.jp/contests/abc076/tasks/abc076_c
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
using namespace std;
bool f=0;
string s,t;
int i,j;
int main()
{
	cin>>s;
	cin>>t;
	//此题需要倒序check，因为可能会有多个位置满足与T的匹配
	//在最后一个位置匹配T，前面的位置用a填上，才能做到字典序最小 
	for (i=s.length()-1;i>=t.length()-1;i--)
	{
		bool subf=1;
		for (j=0;j<t.length();j++)
		{
			if (s[i-j]!='?' && s[i-j]!=t[t.length()-1-j])
			{
				subf=0;
				break;
			}
		}
		if (subf)
		{
			for (j=0;j<t.length();j++) s[i-j]=t[t.length()-1-j];
			for (j=0;j<s.length();j++)
			{
				if (s[j]=='?') printf("a");
				else cout<<s[j];
			}
			printf("\n");
			return 0;
		}
	}
	printf("UNRESTORABLE\n");
	return 0;
}

Measured memory_bytes: 256
l = list(map(int, input().split()))
N = int(l[0])
K = int(l[1])
R1 = N // K
R2 = (N - (K // 2))// K + 1
if K % 2 == 1:
  print(R1**3)
else:
  print(R1**3 + R2**3)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {

    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnt_1 = 0, cnt_2 = 0;
    rep(i, 0, n) {
        if (s[i] == 'a') {
            if (cnt_1 < a+b) {
                cnt_1++;
                cout << "Yes" << endl;
            }
            else
                cout << "No" << endl;
        }
        if (s[i] == 'b') {
            if (cnt_1<a+b && cnt_2<b) {
                cnt_1++;
                cnt_2++;
                cout << "Yes" << endl;
            }
            else
                cout << "No" << endl;
        }
        if (s[i] == 'c')
            cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
using ll= long long;

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

Measured memory_bytes: 256
s = input()
n = len(s)

if s == s[::-1] and s[:(n - 1) // 2] == s[:(n - 1) // 2][::-1] and s[(n + 3) // 2 - 1:] == s[(n + 3) // 2 - 1:][::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61292
#include <bits/stdc++.h>
using namespace std;
# define M_PI 3.14159265358979323846
using ll = long long int;
const int MOD = 1e9 + 7;
int main()
{
    string s;
    cin>>s;
    if(s[1]=='B')
    {
        cout<<"ARC";
    }
    else
    {
        cout<<"ABC";
    }
    
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int W,H,N;
	cin>>W>>H>>N;
	
	vector<vector<int>> grid(H,vector<int>(W,0));
	
	for(int i=0;i<N;i++){
		int x,y,a;
		cin>>x>>y>>a;
		
		if(a==1){
			for(int i=0;i<H;i++){
				for(int j=0;j<x;j++){
					grid[i][j]=1;
				}
			}
		}
		if(a==2){
			for(int i=0;i<H;i++){
				for(int j=x;j<W;j++){
					grid[i][j]=1;
				}
			}
		}
		if(a==3){
			for(int i=0;i<y;i++){
				for(int j=0;j<W;j++){
					grid[i][j]=1;
				}
			}
		}
		if(a==4){
			for(int i=y;i<H;i++){
				for(int j=0;j<W;j++){
					grid[i][j]=1;
				}
			}
		}
	}
	
	int ans = H*W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			ans -= grid[i][j];
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N,M;cin>>N>>M;
  int ans=(N==1?M:1);
  for(int i=2;i<=M/2;i++){
    if(M%i==0 and (long long)i*N<=M and ans<i) ans=i;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
signed main() {
	char s;
	cin >> s;
	if (s == 'A')cout << 'T' << endl;
	else if (s == 'T')cout << 'A' << endl;
	else if (s == 'C')cout << 'G' << endl;
	else cout << 'C' << endl;
}

Measured memory_bytes: 256
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define int ll
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=2000010;
int w,h,n;
struct node{
	int x,y;
	bool operator<(const node &b)const{return x<b.x || (x==b.x && y<b.y);}
}p[N];
typedef pair<int,int> pii;
#define mp make_pair
pii a[N],b[N];//stack
int mx[N],tag[N],ans;
void pushup(int o){mx[o]=max(mx[o<<1],mx[o<<1|1]);}
void pushdown(int o){
	if(!tag[o])return;
	tag[o<<1]+=tag[o];tag[o<<1|1]+=tag[o];
	mx[o<<1]+=tag[o];mx[o<<1|1]+=tag[o];
	tag[o]=0;
}
void modify(int o,int l,int r,int posl,int posr,int v){
	if(posl<=l && r<=posr){tag[o]+=v;mx[o]+=v;return;}
	pushdown(o);int mid=(l+r)>>1;
	if(posl<=mid)modify(o<<1,l,mid,posl,posr,v);
	if(mid<posr)modify(o<<1|1,mid+1,r,posl,posr,v);
	pushup(o);
}
void work(){
	memset(mx,0,sizeof(mx));memset(tag,0,sizeof(tag));
	sort(p+1,p+n+1);int l=0,r=0;
	for(int i=1;i<n;i++){
		if(p[i].y<=h/2){
			//单调栈维护
			int lst=i-1;
			while(l && p[i].y>a[l].second){
				modify(1,1,n,a[l].first,lst,a[l].second-p[i].y);
				lst=a[l--].first-1;
			}
			if(lst!=i-1)
				a[++l]=mp(lst+1,p[i].y);
		}
		else{
			//单调栈维护
			int lst=i-1;
			while(l && p[i].y<b[r].second){
				modify(1,1,n,b[r].first,lst,p[i].y-b[r].second);
				lst=b[r--].first-1;
			}
			if(lst!=i-1)b[++r]=mp(lst+1,p[i].y);
		}
		modify(1,1,n,i,i,h-p[i].x);//为了便于计算答案.
		a[++l]=mp(i,0);b[++r]=mp(i,h);//为了减去上面或者下面.
		ans=max(ans,mx[1]+p[i+1].x);//计算答案.
	}
}
signed main(){
	w=gi();h=gi();n=gi();
	for(int i=1;i<=n;i++)p[i].x=gi(),p[i].y=gi();
	p[++n]=(node){0,0};p[++n]=(node){w,h};
	work();
	for(int i=1;i<=n;i++)swap(p[i].x,p[i].y);swap(h,w);
	work();
	printf("%lld\n",ans*2);
	return 0;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int N,ans = 0;
string s[300];

void solve(){
	
	rep(d,N){
		bool k = 1;
		rep(i,N)rep(j,N){ if(s[j][i + d] != s[i][j + d]) k = 0; if(!k) break; }
		if(k) ans += N;
	}
	cout<<ans<<endl;
	
	return;
}

void input(){
	
	cin>>N;
	rep(i,N){
		cin>>s[i];
		s[i] += s[i];
	}
	
	return;
}

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





Measured memory_bytes: 512
from collections import deque
h, w = map(int, input().split())
L = [list(input()) for i in range(h)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def bfs(x, y):
    V = [[-1] * w for i in range(h)]
    que = deque([])
    que.append([x, y])
    V[x][y] = 0
    while que:
        p=que.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < h and 0 <= ny < w and L[nx][ny] == '.' and V[nx][ny] == -1:
                V[nx][ny] = V[p[0]][p[1]] + 1
                que.append([nx, ny])
    r=0
    for i in range(h):
        for j in range(w):
            r = max(r, V[i][j])
    return r

R = 0
for x in range(h):
    for y in range(w):
        if L[x][y] != '#':
            l = bfs(x, y)
            R=max(R,l)
print(R)

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

bool solve(int mx, int n, int order[])
{
	queue<int> search;
	queue<int> back[252];

	bool start[252];
	for (int i = 0; i <= n + 1; i++) start[i] = false;
	start[0] = true;
	search.push(0);
	while (!search.empty()){
		int now = search.front();
		search.pop();
		for (int i = 1; i <= mx; i++){
			int next;
			if (now + i <= 0) continue;
			else if (now + i > n + 1) next = n + 1;
			else if (now + i + order[now + i] <= 0) continue;
			else if (now + i + order[now + i] > n + 1) next = n + 1;
			else next = now + i + order[now + i];
			back[next].push(now);
			if (start[next]) continue;
			start[next] = true;
			search.push(next);			
		}
	}
	if (!start[n + 1]) return false;
	
	int goal[252];
	for (int i = 0; i <= n + 1; i++) goal[i] = false;
	goal[n + 1] = true;	
	search.push(n + 1);
	while (!search.empty()){
		int now = search.front();
		search.pop();
		while (!back[now].empty()){
			int from = back[now].front();
			back[now].pop();
			if (goal[from]) continue;
			goal[from] = true;
			search.push(from);
		}
	}
	for (int i = 0; i <= n + 1; i++){
		if (start[i] && !goal[i]) return false;
	}
	return true;
}

int main()
{
	while (true){
		int mx;
		cin >> mx;
		if (!mx) break;
		int n, order[252];
		cin >> n;
		order[0] = order[n + 1] = 0;
		for (int i = 1; i <= n; i++){
			cin >> order[i];
		}
		if (solve(mx, n, order)) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 1356
def v():
 from collections import deque
 H,W,N=map(int,input().split())
 e='X'*(W+2)
 M=e+''.join('X'+input()+'X'for _ in[0]*H)+e
 m=(1,-1,W+2,-W-2)
 def f(s,g):
  p,t=s,0
  q=deque()
  b=[1]*len(M);b[s]=0
  while 1:
   for d in m:
    n=p+d
    if'X'!=M[n]and b[n]:
     if M[n]==g:return(n,t+1)
     b[n]=0;q.append([n,t+1])
   p,t=q.popleft()
 s=M.find('S')
 a=0
 for i in range(1,N+1):
  s,t=f(s,str(i))
  a+=t
 print(a)
v()


Measured memory_bytes: 14944
def digit(i)
  (i % 2 == 0 ? +1 : -1) * (1 << i)
end

def stoi(s)
  n = 0
  
  s.split('').each_with_index do |c, i|
    j = s.size - i - 1
    n += c.to_i * digit(j)
  end
  
  return n
end

def solve(n)
  s = ''
  
  i = 0
  while i < 32 do
    k = n % (1 << (i + 1))
    
    if i % 2 == 0 then
      if k == digit(i) then
        n -= digit(i)
        s = '1' + s
      else
        s = '0' + s
      end
    else
      if k == -digit(i) then
        n -= digit(i)
        s = '1' + s
      else
        s = '0' + s
      end
    end
    
    i += 1
  end
  
  return s.gsub(/^0*/, '')
end

def main(argv)
  n = gets.chomp.to_i

  if n == 0 then
    puts '0'
  else
    puts solve(n)
  end
end

if self.to_s === 'main' then
  main(ARGV)
end

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

int main(){
  long N, K;
  cin >> N>> K;
  long abs_diff;
  long val_tmp = N;
  long val_surp = N % K;
  long val_surp_next = abs(val_surp - K);
  if(val_surp_next < val_surp){
    cout << val_surp_next << endl;
  }else{
    cout << val_surp << endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())

if N%2==1:
    for i in range(1,M+1):
        print(i,N+1-i)
else:
    for i in range(1,M+1):
        if i<=N//4:
            print(i,N+1-i)
        else:
            print(i,N-i)

Measured memory_bytes: 9308
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, K, X, Y;
  cin >> N >> K >> X >> Y;
  ll ans = min(N, K) * X + Y * max(0ll, (N - K));
  ANS;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end())
#define DOUBLECHANGE(count) cout << setprecision(count)
#define REV(vec) reverse(vec.begin(),vec.end())
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      string s;
      cin >> s;
      if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
          cout << "Bad" << endl;
      }
      else{
          cout << "Good" << endl;
      }
}


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

int judge(int a,int b,int c)
{
    if((a+b)>c&&(a+c)>b&&(b+c)>a)
        return 1;
    else
        return 0;
}

int main()
{
    int n;
    cin>>n;
    int a[n],i,j,k,sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
   /* for(i=0;i<n;i++)
    {
        cout<<a[i]<<endl;
    }*/
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            for(k=j+1;k<n;k++)
            {
                if(judge(a[i],a[j],a[k])==1)
                {
                    sum++;
                }
                if(judge(a[i],a[j],a[k])==0)
                    break;
            }
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A; cin >> A;
	cout << A + A * A + A * A*A << endl;
	return 0;
}



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

signed main(){
	int n;cin>>n;
	vector<vector<int>> a(n,vector<int>(n));
	vector<vector<int>> b(n,vector<int>(n));
	vector<vector<bool>> c(n,vector<bool>(n,true));


rep(i,n)rep(j,n){cin>>a[i][j];b[i][j]=a[i][j];}

rep(i,n)rep(j,n)rep(k,n)a[i][j]=min(a[i][j],a[i][k]+a[k][j]);

rep(i,n)rep(j,n){if(a[i][j]!=b[i][j])cout<<-1<<endl,exit(0);}

rep(i,n)rep(j,n)rep(k,n){
if(i==k||k==j)continue;
if(a[i][j]==a[i][k]+a[k][j])c[i][j]=false;
}
int ret=0;
rep(i,n)rep(j,n){if(c[i][j] && i<j)ret+=a[i][j];}
cout<<ret<<endl;
//rep(i,n){rep(j,n){cout<<a[i][j]<<" ";}cout<<endl;}
//  cout<<ret<<endl;
// rep(i,n){rep(j,n){cout<<c[i][j]<<" ";}cout<<endl;}
 
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	string s;
	cin >> s;
	if(s[0] ==s[1] && s[1] == s[2])
	{
		cout << "No";
		return;
	}
	cout << "Yes";
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void run(void){
  int n;
  scanf("%d",&n);
  int k=1;
  while(k*(k+1)/2<n) k++;
  while(n>0){
    if(k<=n){
      printf("%d\n",k);
      n-=k;
    }
    k--;
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
long long int e[200005];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> e[i];
	}
	sort(e, e + n);
	for (int i = 0; i < n; i++) {
		if (e[i] == e[i + 1]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 1792
N, Y = map(int, input().split())
exist_comb = False
res10000 = -1
res5000 = -1
res1000 = -1

for i in range(N+1):
  for j in range(N-i+1):
    k = N-i-j
    Sum = 10000*i + 5000*j + 1000*k
    if Sum == Y:
      res10000 = i
      res5000 = j
      res1000 = k

print("{} {} {}".format(res10000, res5000, res1000))

Measured memory_bytes: 9160
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    h = list(map(int, input().split()))
    ans = 1
    for i in range(1, n):
        if h[i] >= max(h[:i]):
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
#include <stdio.h>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s;
    cin >> s;
    set<int> st;
    int x = s;
    while (st.count(x) == 0)
    {
        st.insert(x);
        if (x % 2 == 0)
        {
            x /= 2;
        }
        else
        {
            x = x * 3 + 1;
        }
    }
    cout << (st.size() + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);

	public static void main(String[] args){
		int[] count = new int[100];
		int max = 0;
		while(scan.hasNext()){
			int a = scan.nextInt();
			count[a-1]++;
			if(count[a-1] > max){
				max = count[a-1];
			}
		}

		for(int i = 0; i < 100; i++){
			if(count[i] == max){
				System.out.printf("%d\n", i+1);
			}
		}
	}
}

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

int main() {
	int H,N;
	cin >> H >> N;
	vector<int> A(N),B(N);
	vector<vector<int>> dp(N+1, vector<int>(H+1,INF));
	rep(i,N)
		cin >> A.at(i) >> B.at(i);
	
	dp.at(0).at(0) = 0;
	rep(i,N)
		rep(j,H+1) {
			dp.at(i+1).at(j) = min(dp.at(i+1).at(j), dp.at(i).at(j));
			dp.at(i+1).at(min(j+A.at(i),H)) = min(dp.at(i+1).at(min(j+A.at(i),H)), dp.at(i+1).at(j)+B.at(i));
		}
	cout << dp.at(N).at(H) << endl;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector< vector<int> > towns(M, vector<int>(2));
    
    for (int i = 0; i < M; i++){
        cin >> towns.at(i).at(0) >> towns.at(i).at(1);
    }
    

    vector<int> tc(N+1);
    for (int i = 0; i < M; i++){
        for (int j = 1; j <= N; j++){
            if (j == towns.at(i).at(0)){
                tc.at(j)++;
            }
            if (j == towns.at(i).at(1)){
                tc.at(j)++;
            }
        }
    }

    for (int j = 1; j <= N; j++){
        cout << tc.at(j) << endl;
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,w;
  cin>>w>>a>>b;
  if(b>(a+w))
  cout<<max(0, b-(a+w));
  else if(b<=(a+w) and (b+w)>=a)
    cout<<0;
  else cout<<max(0, a-(b+w));
    
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
cnt = 1
fl = 0
for i in range(1,n):
    if fl==1 and a[i]<a[i-1]:
        cnt+=1
        fl=0
    elif fl==-1 and a[i]>a[i-1]:
        cnt+=1
        fl=0
    elif fl==0 and a[i]<a[i-1]:
        fl = -1
    elif fl==0 and a[i]>a[i-1]:
        fl = 1
print(cnt)

Measured memory_bytes: 14252
while True:
    
    n=int(input())
    if n==0:
        break
    
    list=[]
    for x in range(n):
        x=int(input())
        list.append(x)
        a=sum(list)
        b=min(list)
        c=max(list)
    print((a-b-c)//(n-2))


Measured memory_bytes: 5592
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <list>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
using namespace std;

#define mp make_pair
#define pb push_back

typedef long long int64;
typedef unsigned long long uint64;

template<typename T>
void printVector(string &txt, vector<T> &a){
    cout << txt;
    for (int i = 0; i < a.size(); ++i)
        cout << a[i] << ' ';
    cout << endl;
}


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie();

    int n;
    cin >> n;
    vector<int64> a, b;
    a.resize(n + 1);
    for (int i = 0; i < n + 1; ++i)
        cin >> a[i];
    b.resize(n);
    for (int i = 0; i < n; ++i)
        cin >> b[i];

    int64 res = 0;
    for (int i = 0; i < n; ++i){
        if (a[i] >= b[i]){
            a[i] -= b[i];
            res += b[i];
        }
        else{
            b[i] -= a[i];
            res += a[i];
            a[i] = 0;
            if (a[i + 1] >= b[i]){
                a[i + 1] -= b[i];
                res += b[i];
            }
            else{
                b[i] -= a[i + 1];
                res += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>

struct rect{ 
  int h;
  int w;
};

int rect_cmp(struct rect x, struct rect y)
{
  if(x.h * x.h + x.w * x.w < y.h * y.h + y.w * y.w){
    return -1;
  } else if(x.h * x.h + x.w * x.w == y.h * y.h + y.w * y.w){
    if(x.h < y.h) return -1;
    else if(x.h == y.h) return 0;
    else return 1;
  } else return 1;
}


int main(void)
{
  int H,W;
  struct rect x;
  struct rect y;

  for(;;){ 
    struct rect std;
    scanf("%d %d", &std.h, &std.w);
    if(!(std.h|std.w)) break;

    struct rect ans;
    ans.h=150;
    ans.w=150;

    struct rect cmp;
    for(cmp.h = 1; cmp.h < 150; cmp.h++){
      for(cmp.w = cmp.h+1; cmp.w < 150; cmp.w++){
	if(rect_cmp(std, cmp) < 0 && rect_cmp(cmp, ans) < 0){
	  ans = cmp;
	}
      }
    }
    printf("%d %d\n", ans.h, ans.w);
  }

  return 0;
}


Measured memory_bytes: 600
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n;
  cin>>n;
  vector<ll> v;
  ll mn = 10000000000000LL;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  rep(i,-200,200){
    ll c = 0;
    rep(j,0,v.sz){
      c += (v[j]-i)*(v[j]-i);
    }
    mn = min(mn,c);
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=110;
int i,j,k,n,m,t1,t2;
int A[N];
int main() {
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++) {
		scanf("%d",&A[i]);
		if (A[i]&1) {
			if (t1) {
				if (t2) return puts("Impossible"),0;
				else t2=i;
			}
			else t1=i;
		}
	}
	if (!t1) t1=1;
	if (!t2) t2=m;
	if (t1>1) swap(A[1],A[t1]);
	if (t2<m) swap(A[m],A[t2]);
	for (i=1;i<=m;i++) printf("%d ",A[i]);
	puts("");
	if (m==1) {
		A[2]=A[1];
		A[1]=0;
		m=2;
	}
	A[1]++;
	A[m]--;
	while (!A[m]) m--;
	printf("%d\n",m);
	for (i=1;i<=m;i++) printf("%d ",A[i]);
	puts("");
}

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

using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];
    ll xsum = 0;
    rep(i, n - 1) {
        ll dx = ((1L + i) * (n - i - 1)) % MOD;
        xsum += dx * (x[i + 1] - x[i]);
        xsum %= MOD;
    }
    ll ysum = 0;
    rep(i, m - 1) {
        ll dy = ((1L + i) * (m - i - 1)) % MOD;
        ysum += dy * (y[i + 1] - y[i]);
        ysum %= MOD;
    }
    cout << (xsum * ysum) % MOD << endl;
}

Measured memory_bytes: 1024
<?php 
  fscanf(STDIN, "%d %d", $A, $B);
	if($A === $B){
      echo "Draw";
    }else if($A == 1 && $B <= 13){
      echo "Alice";
    }else if($B == 1 && $A <= 13){
      echo "Bob";
    } 
	else if($A > $B){
      echo "Alice";
    }else {
      echo "Bob";
    } 
  
  ?>


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int cnt[2001];
int X, Y;

int dp[20][10];
int d[11];

int K;

    
int backtrack(int res, int k, int ii){
    if (k <= 0)return 0;
    rep(i, 10){
        if (abs(i - ii) <= 1){
            if (res + dp[k][i] >= K){
                //fprintf(stderr, "k = %d, ii = %d, res = %d\n", k, i, res);
                cout << i;
                backtrack(res, k - 1, i);
                return 0;
            }
            res += dp[k][i];
        }
    }
    return 0;
}
int main() {
    cin >> K;
    
    rep(i, 10)dp[1][i] = 1;
    
    //if (K <= 9){
    //    cout << K;
    //    return 0;
    //}
    d[0] = 0;
    //d[1] = 9;
    int k;
    for (k = 0; k < 11; k++){
        d[k + 1] = d[k];
        rep(i, 10){
            if (i > 0)
                dp[k + 1][i] += dp[k][i - 1];
            dp[k + 1][i] += dp[k][i];
            if (i < 9)
                dp[k + 1][i] += dp[k][i + 1];
            if (i != 0){
                d[k + 1] += dp[k + 1][i];
            }
        }
        //fprintf(stderr, "k = %d, %d\n", k + 1, d[k + 1]);
        if (d[k + 1] >= K){
            break;
        }
        
    }

        
    int res = d[k];
    //cout << "res = " << res << " " << k << endl;
    for (; k >= 0; k--){
        rep(i, 10){
            if (i != 0){
                //fprintf(stderr, "i = %d, dp = %d, res = %d\n", 
                //    i, dp[k + 1][i], res);
            
                if (res + dp[k + 1][i] >= K){
                    cout << i;
                    //fprintf(stderr, "res = %d, i = %d\n", res, i);
                    //backtrack(res, k - 1, i);
                    backtrack(res, k, i);
                    return 0;
                }
                res += dp[k + 1][i];
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 256