akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
ll n,a,b,ans;
vector<ll> tms;
ll ksm(ll beg,ll x)
{
	if(x==0)
	{
		return 1;
	}
	if(x==1)
	{
		return beg;
	}
	ll ret=ksm(beg,x/2);
	if(x%2==1)
	{
		return ((ret*ret)%MOD*beg)%MOD;
	}
	return (ret*ret)%MOD;
}
int main(){
	ll i,j=2,t1=1,t2=1;
	cin>>n>>a>>b;
	ans=ksm(2,n);
	ans=(ans+MOD-1)%MOD;
	for(i=n;i>=n-a+1;i--)
	{
		t1=(t1*i)%MOD;
	}
	for(i=2;i<=a;i++)
	{
		t2=(t2*i)%MOD;
	}
	ans=(ans+MOD-(t1*ksm(t2,MOD-2))%MOD)%MOD;
	//cout<<t1<<" "<<t2<<endl;
	t1=t2=1;
	for(i=n;i>=n-b+1;i--)
	{
		t1=(t1*i)%MOD;
	}
	for(i=2;i<=b;i++)
	{
		t2=(t2*i)%MOD;
	}
	ans=(ans+MOD-(t1*ksm(t2,MOD-2))%MOD)%MOD;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

#define rep(i, N) for (int i = 0; i < N; i++)

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

    vector<vector<vector<vector<lint>>>> num;
    num.assign(N + 1, vector<vector<vector<lint>>>(4, vector<vector<lint>>(4, vector<lint>(4, 0))));
    
    rep(i, 4) rep(j, 4) rep(k, 4) {
        num[3][i][j][k] = 1;
    }
    num[3][0][2][1] = num[3][2][0][1] = num[3][0][1][2] = 0;

    for (int i = 4; i <= N; i++) {
        rep(j, 4) rep(k, 4) rep(l, 4) rep(m, 4) {
            if ((k == 0 and l == 2 and m == 1) or (j == 0 and l == 2 and m == 1)
                or (k == 2 and l == 0 and m == 1) or (k == 0 and l == 1 and m == 2)
                or (j == 0 and k == 2 and m == 1)) {
                num[i][k][l][m] += 0;
            } else {
                num[i][k][l][m] += num[i - 1][j][k][l];
                num[i][k][l][m] %= MOD; 
            }
        }
    }

    lint ans = 0;
    rep(i, 4) rep(j, 4) rep(k, 4) {
        ans += num[N][i][j][k];
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
A,B,C,X,Y=map(int,input().split())

min_xy=min(X,Y)
Max_xy=max(X,Y)
d=A*X+B*Y
e=C*2*Max_xy
if X>=Y:
    print(min(C*2*min_xy+(Max_xy-min_xy)*A,d,e))
else:
    print(min(C*2*min_xy+(Max_xy-min_xy)*B,d,e))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vvl dp(h+10, vl(w+10));  // dp[i][j] : (i,j)への経路の数(未確定のとき-1)
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '.') {
                dp[i+1][j+1] = -1;
            }
        }
    }

    dp[1][1] = 1;
    exrep(i, 1, h) {
        exrep(j, 1, w) {
            if(dp[i][j] == -1) {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
    }

    out(dp[h][w]);
    re0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  string s, t = "";
  cin >> s;

  bool a = false, b = false;
  VI v;
  REP(i, s.size()) {
    if(s[i] == 'x') {
      if(t == "") {
        if(b) v.push_back(-1);
        else v.push_back(1);
      }
      else {
        if(b) v.push_back(-1*stoi(t));
        else v.push_back(stoi(t));
      }
      t = "";
    } else if(s[i] == '^') {
      a = false;
    } else if(s[i] == '+') {
      if(t == "") v.push_back(1);
      else v.push_back(stoi(t));
      a = true;
      b = false;
      t = "";
    } else if(s[i] == '-') {
      if(t == "") v.push_back(1);
      else v.push_back(stoi(t));
      a = true;
      b = true;
      t = "";
    } else if(a) {
      t += s[i];
    } else if(!a) {
      t += s[i];
    }
  }
  if(b) v.push_back(-1*stoi(t));
  else v.push_back(stoi(t));

  VI ans;
  FOR(i, -2000, 2001) {
    int tmp = 0, ret = 0;
    REP(j, v.size()) {
      if(!(j%2)) tmp = v[j];
      else {
        REP(k, v[j]) tmp *= i;
        ret += tmp;
      }
      //cout << tmp << endl;
    }
    //cout << "i:" << i << " ret:" << ret << endl;
    ret += v[v.size()-1];
    if(ret == 0) ans.push_back(i);
  }
  sort(ALL(ans), greater<int>());
  for(int i: ans) {
    cout << "(x";
    if(i>0) cout << "-" << i << ")";
    else cout << "+" << -1*i << ")";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
using namespace std;
using lli = long long;

const int MAXN=100;
int n,W,w[MAXN],va[MAXN];
vector<lli> vv[4],vs[4];

int main() {
	scanf("%d%d",&n,&W);
	for(int i=0;i<n;i++) scanf("%d%d",w+i,va+i);

	lli mx=0;
	for(int i=0;i<n;i++) vv[w[i]-w[0]].push_back(va[i]);
	for(int i=0;i<4;i++) sort(vv[i].begin(),vv[i].end(),greater<int>());
	for(int i=0;i<4;i++) {
		vs[i].push_back(0);
		for(int j=0;j<sz(vv[i]);j++) {
			vs[i].push_back(vs[i].back() + vv[i][j]);
		}
	}
	for(int i=0;i<=sz(vv[0]);i++) for(int j=0;j<=sz(vv[1]);j++)
		for(int a=0;a<=sz(vv[2]);a++) for(int b=0;b<=sz(vv[3]);b++) {
			if(1ll*w[0]*i + 1ll*(w[0]+1)*j + 1ll*(w[0]+2)*a + 1ll*(w[0]+3)*b <= W) {
				mx = max(mx, vs[0][i] + vs[1][j] + vs[2][a] + vs[3][b]);
			}
		}

	printf("%lld\n",mx);

	return 0;
}


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



int main(){
	char a,b;
	scanf(" %c %c",&a,&b);
	if(a > b) printf(">");
	else if(a == b) printf("=");
	else printf("<");
}

Measured memory_bytes: 764
import java.io.*;
import java.util.*;
//import java.util.stream.*;
//import java.math.*;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        Scanner sc = new Scanner(System.in);
        int sx, sy, tx, ty;
        sx = sc.nextInt();
        sy = sc.nextInt();
        tx = sc.nextInt();
        ty = sc.nextInt();
        String s = "";
        int dx = Math.abs(tx - sx);
        int dy = Math.abs(ty - sy);
        for (int i = 1; i <= 4; i++) {
            if (i == 3) {
                bw.write("LU");
            }
            if (i == 4) {
                bw.write("RD");
            }
            for (int j = 0; j < dy; j++) {
                if (i == 1 || i == 3) {
                    bw.write("U");
                } else {
                    bw.write("D");
                }
            }
            for (int j = 0; j < dx; j++) {
                if (i == 1 || i == 3) {
                    bw.write("R");
                } else {
                    bw.write("L");
                }
            }
            if (i == 3) {
                bw.write("RD");
            }
            if (i == 4) {
                bw.write("LU");
            }
        }
        bw.write("\n");
        bw.flush();
    }
}


Measured memory_bytes: 20692
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

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

	string a,b;
	cin>>a>>b;
	bool flag=true;
	for (int i = 0; i < a.size(); ++i)
	{
		if(a[i]!=b[i]){
			flag=false;
			break;
		}
	}
	if(flag){
		if(b.size()==a.size()+1)
			cout<<"Yes";
		else
			cout<<"No";
	}
	else
		cout<<"No";

	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

template<typename T>
T gcd(T a,T b)
{
	if(a==0 || b==0)return 0;
	T r;
	while(1)
	{
		r=a%b;
		if(r==0)break;
		a=b;
		b=r;
	}
	return b;
}

int main()
{
	lint N,K;
	lint A;
	lint GCD;
	lint mx=0;
	
	cin >> N >> K;
	cin >> A;
	mx=max(mx,A);
	GCD=A;
	for(int i=0;i<N-1;i++)
	{
		cin >> A;
		mx=max(mx,A);
		GCD=gcd(GCD,A);
	}
	
	if(K<=mx && K%GCD==0)
		cout << "POSSIBLE";
	else
		cout << "IMPOSSIBLE";
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
LL read(){
	LL nm=0,fh=1; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
LL ans,sum0,sum1,sig;
LL n,m,fs[M],nt[M<<1],to[M<<1],col[M],f[M],sz[M],tmp;
LL fd(LL x){return x==f[x]?x:f[x]=fd(f[x]);}
void link(LL x,LL y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
void merge(LL x,LL y){x=fd(x),y=fd(y);if(x!=y) f[x]=y,sz[y]+=sz[x];}
bool check(LL x,LL now){
	if(col[x]) return col[x]==now; col[x]=now;
	for(LL i=fs[x];i!=-1;i=nt[i])
		if(!check(to[i],3-now)) return false;
	return true;
}
int main(){
	n=read(),m=read(),memset(fs,-1,sizeof(fs));
	for(LL i=1;i<=n;i++) f[i]=i,sz[i]=1;
	for(LL i=1;i<=m;i++){
		LL x=read(),y=read();
		link(x,y),link(y,x),merge(x,y);
	}
	for(LL i=1;i<=n;i++) if(fd(i)==i&&sz[i]==1) sig++;
	for(LL i=1;i<=n;i++){
		if(fd(i)!=i||sz[i]==1) continue;
		if(check(i,1)) sum0++;
		else sum1++;
	}
	ans+=sig*((n<<1)-1)-sig*(sig-1);
	ans+=((sum0*sum0)<<1);
	ans+=sum1*(sum0<<1)+sum1*sum1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12032
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let ab: Vec<(i64, i64)> = (0..n).map(|_| (read(), read())).collect();
    let cd: Vec<(i64, i64)> = (0..m).map(|_| (read(), read())).collect();

    for (a, b) in ab {
        let mut min = (cd[0].0 - a).abs() + (cd[0].1 - b).abs();
        let mut checkpoint = 1;
        for (i, &(c, d)) in cd.iter().enumerate() {
            if min > (c - a).abs() + (d - b).abs() {
                min = (c - a).abs() + (d - b).abs();
                checkpoint = i + 1;
            }
        }
        println!("{}", checkpoint)
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
o=lambda:map(int,raw_input().split())
T,F=True,False
n,k=o()
e=[[] for _ in [0]*n]
for _ in [0]*(n-1):a,b=o();e[a-1]+=[b-1];e[b-1]+=[a-1]
a=10**5
def dfs(x,f):
 if f>=0:l[f]=T
 q=[(x,0)]
 while len(q):
  v,c=q.pop(0)
  if c>k/2:break
  l[v]=T
  for w in e[v]:
   if not l[w]:q+=[(w,c+1)]
 return n-l.count(T)
if k%2:
 for i in range(n):
  for j in e[i]:
   if i<j:l=[F]*n;dfs(i,j);a=min(a,dfs(j,i))
else:
 for i in range(n):l=[F]*n;a=min(a,dfs(i,-1))
print a


Measured memory_bytes: 26268
import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


x = int(input())

min_prime = 2

for i in range(x, 100005):
    if is_prime(i) is True:
        min_prime = i
        break

print(min_prime)

Measured memory_bytes: 3188
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,a,b,ans[4040];
stack<int> sta;
char s[10];
int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int query(int x,int y)
{
    printf("? %d %d\n",x,y);fflush(stdout);
    scanf("%s",s+1);
    return (s[1]=='Y');
}

void answer()
{
    printf("! ");
    rep(i,0,n-1) printf("%d",ans[i]);
    fflush(stdout);
}

int main()
{
    a=read();b=read();n=a+b;
    if (b>=a) {puts("Impossible");return 0;}
    sta.push(0);
    rep(i,1,a+b-1)
    {
        if (sta.empty()) sta.push(i);
        else
        {
            int now=sta.top();
            if (!query(now,i)) sta.pop();else sta.push(i);
        }
    }
    int now=sta.top();
    rep(i,0,n-1)
    {
        if (i==now) {ans[i]=1;continue;}
        ans[i]=query(now,i);
    }
    answer();
    return 0;
}
        

Measured memory_bytes: 724
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string num;
    cin >> num;
    for (int i = 0; i < 3; ++i) {
        if (num[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;

int main() {
    
    int N,Ma,Mb;
    int cost_min = INT_MAX;
    
    
    vector<int> a;
    vector<int> b;
    vector<int> c;
    
    int dp[401][401];
    
    cin >> N;
    cin >> Ma;
    cin >> Mb;
    
    for ( int j = 0; j <= 400; j++ )
    for ( int k = 0; k <= 400; k++ ) {
        dp[j][k] = 0;
    }
    
    
    for ( int i = 0; i < N; i++ ) {
        int x;

        cin >> x;
        a.push_back( x );
        
        cin >> x;
        b.push_back( x );
        
        cin >> x;
        c.push_back( x );
    }
    
    
    for ( int i = 0; i < N; i++ ) {
        
        if ( !dp[a[i]][b[i]] ) {
            dp[a[i]][b[i]] = c[i];
        }
        else if ( dp[a[i]][b[i]] > c[i] ) {
            dp[a[i]][b[i]] = c[i];
        }
        
        for ( int j = 400; j >= 0; j-- ) {
            for ( int k = 400; k >= 0; k-- ) {
                if ( j == a[i] && k == b[i] ) { continue; }
                
                if ( dp[j][k] ) {
                    
                    int cost_pre = dp[j+a[i]][k+b[i]];
                    
                    if ( !cost_pre ) {
                        dp[j+a[i]][k+b[i]] = dp[j][k] + c[i];
                    }
                    else if ( cost_pre > dp[j][k] + c[i] ) {
                        dp[j+a[i]][k+b[i]] = dp[j][k] + c[i];
                    }
                }
            }
        }
    }
    
    for ( int i = 1; Ma*i <= 400 && Mb*i <= 400; i++  ) {
        int cost = dp[Ma*i][Mb*i];
        if ( cost && cost_min > cost ) {
            cost_min = cost;
        }
    }
    
    if ( cost_min != INT_MAX ) {
        cout << cost_min << endl;
    }
    else {
        cout << -1 << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    int main() {
      string n,s;
      cin >> n >> s;
      char a = s.at(0);
      
      cout << "A" << a << "C" << endl;

    }

Measured memory_bytes: 256
'''
N頂点の木があり、i番目の辺は頂点x_iとy_iを結んでいる。
各頂点を白または黒で塗り、どの黒い頂点からどの黒い頂点へも黒い頂点のみをたどって到達できる時、
頂点vが黒であるような頂点の色の組み合わせは何通りか？Mで割ったあまりを求めよ。
graph_i
input:
3 100
1 2
2 3
output:
    3
    4
    3

'''
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


# endregion

# setting
unit = 1  # 単位元


def merge(a, b):
    # モノイド演算
    return a * b % M


def adj_bu(a, i):
    # bottom up DP
    return a + 1


def adj_td(a, i, p):
    # top down DP
    return a + 1


def adj_fin(a, i):
    # 最終結果
    return a
#####


n, M = inpl()
graph = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = inpl()
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
parent = [-1] * n
root = 0  # 0を根とする
queue = collections.deque([root])
sorted_graph = []  # トポロジカルソート

# トポロジカルソート
while queue:
    i = queue.popleft()
    sorted_graph.append(i)
    for a in graph[i]:
        if a != parent[i]:
            parent[a] = i
            graph[a].remove(i)  # graph：隣接リストから子リストにする
            queue.append(a)

# Bottom up DP

BU = [unit] * n  # acc[i]と対応
res = [0] * n
for i in sorted_graph[1:][::-1]:
    res[i] = adj_bu(BU[i], i)
    p = parent[i]
    BU[p] = merge(BU[p], res[i])
res[sorted_graph[0]] = adj_fin(BU[sorted_graph[0]], sorted_graph[0])  # 根だけ別で


# Top down DP

TD = [unit] * n
for i in sorted_graph:
    # 左からDP
    tmp = TD[i]
    for j in graph[i]:
        TD[j] = tmp
        tmp = merge(tmp, res[j])
    # 右からDP
    tmp = unit
    for j in graph[i][::-1]:
        TD[j] = adj_td(merge(TD[j], tmp), j, i)
        tmp = merge(tmp, res[j])
        res[j] = adj_fin(merge(BU[j], TD[j]), j)
print(*res, sep="\n")
'''
各頂点に対して結果を出力するので全方位木を考える。
全方位木では子→親の木DPと親→子の木DPを使う。
acc[i][p]:ノードiにおける親pを除いた全方向からの累積
res[i][p]:acc[i][p]に調整を加えたもの
acc[i]:ノードiにおけるすべての方向からの集約
'''


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

int main() {
    int h,w,n,ans=0;
    cin>>h>>w>>n;
    int a = 0;
    for(int i=0; i<min(h,w); i++) {
        a += max(h,w);
        ans++;
        if(a >= n) break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int last = 0, i, total_time = 0;
  int temp[6];
  for(i = 0; i < 5; i++) {
    scanf("%d", &temp[i]);
    last = ((last == 0) || ((last > temp[i] % 10) && (temp[i] % 10) != 0))? temp[i] % 10 : last;
  }

  for(i = 0; i < 5; i++) {
    total_time = (temp[i] % 10 == 0)? total_time + temp[i] : total_time + temp[i] + (10 - (temp[i] % 10));
  }
  total_time = (last == 0)? total_time : total_time - (10 - last);
  printf("%d\n", total_time);

  return 0;
}


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

int main() {
  string N;
  cin >> N;
  int l = N.size();
  int c = 0;
  for(int i = 0; i < l; i++) {
    c += N.at(i) - '0';
    if(c > 1000) c = c % 9;
  } 
  c = c % 9;
  if(c == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3636
n = int(input())
ws = list(map(int, input().split()))
index = 0
sum_ = ws[index]
# while sum_ < ws[-1]:
#     index += 1
#     sum_ += ws[index]
# print(sum_)
answer = 99999
while True:
    if abs(sum_ - sum(ws[index+1:])) < answer:
        answer = abs(sum_ - sum(ws[index+1:]))
    else:
        break
    index += 1
    sum_ += ws[index]
print(answer)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
const ll mod = 998244353;
int main() {
    ios::sync_with_stdio(0);
    int a,b,c,d,f;
    cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){
            f=1;
            break;
        }
        a-=d;
        if(a<=0){
            f=0;
        break;
        }

    }
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[114514];
int main()
{
	int n,out=0;
	scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);a[i]--;
	}
	rep(i,n){
		if(a[a[i]]==i) out++;
	}
	cout<<out/2<<endl;
}


Measured memory_bytes: 640
// AOJ 2003: Railroad Conflict
// 2017.12.11 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct { double d; int x1, y1, x2, y2; char flg, cross; } T;
T tbl[101];
int xa, ya, xb, yb;
char buf[40], *p;

int getint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = 10*n + (*p++ & 0xf);
		p++; return -n;
	}
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++; return n;
}

int segCross(double *xx, double *yy, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
	long long t1, t2, t3, t4;
	double bo, ua;

	t1 = (long long)(y1-y3)*(x3-x4)-(long long)(x1-x3)*(y3-y4);
	t2 = (long long)(y2-y3)*(x3-x4)-(long long)(x2-x3)*(y3-y4);
	t3 = (long long)(y3-y1)*(x1-x2)-(long long)(x3-x1)*(y1-y2);
	t4 = (long long)(y4-y1)*(x1-x2)-(long long)(x4-x1)*(y1-y2);
	if ((t1 < 0 && t2 > 0 || t1 > 0 && t2 < 0) && (t3 < 0 && t4 > 0 || t3 > 0 && t4 < 0)) {
		bo = (double)((long long)(y4-y3)*(x2-x1)-(long long)(x4-x3)*(y2-y1));
		ua = (double)((long long)(x4-x3)*(y1-y3)-(long long)(y4-y3)*(x1-x3));
		*xx = x1 + ua/bo * (x2-x1);
		*yy = y1 + ua/bo * (y2-y1);
		return 1;
	}
	return 0;
}

int cmp(T *a, T *b)
{
	if (a->cross - b->cross) return b->cross - a->cross;
	if (a->d < b->d) return -1;
	return 1;
}

int main()
{
	int cno, n, i, now, ans;
	T *tp;
	double x, y;

	fgets(p=buf, 10, stdin), cno = getint();
	while (cno--) {
		fgets(p=buf, 40, stdin);
		xa = getint(), ya = getint();
		xb = getint(), yb = getint();
		fgets(p=buf, 10, stdin), n = getint();
		i = n; for (tp = tbl; i--; tp++) {
			fgets(p=buf, 40, stdin);
			tp->x1 = getint(), tp->y1 = getint();
			tp->x2 = getint(), tp->y2 = getint();
			tp->flg = (*p & 1) ^ (*(p+2) & 1);
		}

		i = n; for (tp = tbl; i--; tp++) {
			if (segCross(&x, &y, xa, ya, xb, yb, tp->x1, tp->y1, tp->x2, tp->y2)) {
				tp->d = hypot(x-xa, y-ya), tp->cross = 1;
			} else tp->cross = 0;
		}
		qsort(tbl, n, sizeof(T), cmp);
		ans = 0, now = tbl[0].flg;
		for (tp = tbl; tp->cross && n--; tp++) {
			if (tp->flg != now) ans++, now = !now;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1768
S=list(input())
N=len(S)
abc=list("abcdefghijklmnopqrstuvwxyz")
D={}
for a in abc:
    D[a]=0
idx={}
for i in range(26):
    idx[abc[i]]=i

for s in S:
    D[s]+=1
L=[]
for k,v in D.items():
    if v==0:
        L.append(k)

L=sorted(L)
if len(L)==0:
    lis=[]
    for i in range(25,-1,-1):
        s=S[i]
        lis.append(s)
        if i!=0:
            if idx[s]>idx[S[i-1]]:
                break
    if len(lis)==26:
        print(-1)
        exit()

    lis=sorted(lis)
    for l in lis:
        if idx[S[i-1]]<idx[l]:
            add=l
            break
    ans="".join(S[:i-1])+add
    print(ans)

        
else:
    print("".join(S)+L[0])
#yzxwvutsrqponmlkjihgfedcba

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

using namespace std;
int main()
{
    long long buf,n,ans;
    cin >> n;
    buf = 1;
    std::vector<long long> vec;
    while(buf<=sqrt(n)){
        if(n%buf==0){
            vec.push_back(n/buf + buf -2);
            // cout << n/buf;
            // cout << " ";
            // cout << buf;
            // cout << "  ";
        }
        buf++;
    }
    std::sort(vec.begin(), vec.end());
    cout << *vec.begin();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

vector<ll> vlim;
ll dfs(int depth, int siz, vector<ll> &vcnt, vector<int> &A) {
    if (depth == siz)
        return vcnt[depth];
    if (depth > 0)
        vlim[depth] = min<ll>((vlim[depth - 1] << 1) - A[depth], 1e18);

    return vcnt[depth] = min(dfs(depth + 1, siz, vcnt, A), vlim[depth]) + A[depth];
}

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

    int N;
    cin >> N;
    vector<int> A(N + 1);
    for (int i = 0; i <= N; ++i)
        cin >> A[i];

    if (N == 0 && A[0] != 1) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> vcnt(N + 1);
    vcnt.back() = A.back();
    for (int i = N - 1; i >= 0; --i) {
        vcnt[i] = (vcnt[i + 1] + 1) >> 1;
        vcnt[i] += A[i];
        if (i <= 60 && vcnt[i] > (1LL << i)) {
            cout << -1 << endl;
            return 0;
        }
    }

    vlim.resize(N + 1);
    vlim[0] = 1;
    dfs(0, N, vcnt, A);

    ll ans = 0;
    for (auto i : vcnt)
        ans += i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9796
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[3010][6010];
typedef pair<int, int> P;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    P plate[3010];
    rep(i, N) cin >> plate[i].first >> plate[i].second;
    sort(plate, plate + N);
    rep(i, N) {
        REP(j, 0, 6000) {
            dp[i + 1][j] = dp[i][j];
            if (j - plate[i].first >= 0 && j - plate[i].first < T)
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - plate[i].first] + plate[i].second);
        }
    }
    int ans = 0;
    rep(i, 6001) ans = max(ans, dp[N][i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 70656
h,w=map(int,input().split())
lista=[]
ans=0
count=0
for i in range(h):
    lista.append(list(input()))
for i in range(h):
    for j in range(w):
        count=0
        if lista[i][j]=="#":
            if i!=0:
                if lista[i-1][j]=="#":
                    count=1
            if j!=0:
                if lista[i][j-1]=="#":
                    count=1
            if i!=h-1:
                if lista[i+1][j]=="#":
                    count=1
            if j!=w-1:
                if lista[i][j+1]=="#":
                    count=1
            if count==0:
                ans=1
                break
    if ans==1:
        break
if ans==1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>
#include<sstream>
#include<istream>

using namespace std;


int main()
{

  string w;
  cin >> w;

  int N = w.length();

  if(N%2 == 1){
    cout << "No" << endl;
    return 0;
  }

  vector<char> W(N);

  for(int i=0; i<N; i++){
    W[i] = w[i];
  }

  sort(W.begin(), W.end());

  while(W.size() > 0){
    if(W[W.size()-1] == W[W.size()-2]){
      W.pop_back();
      W.pop_back();
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 110;
const int INF = 0x3f3f3f3f;
int dp[MAXN][MAXN], mz[MAXN][MAXN];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	rep (i, 1, n) {
		rep (j, 1, m) {
			char ch;
			cin >> ch;
			mz[i][j] = ch == '#';
		}
	}
	auto chkMin = [&] (int & a, int b) {
		if (a > b) a = b;
	};
	memset(dp, 0x3f, sizeof(dp));
	dp[1][1] = mz[1][1];
	rep (i, 1, n) rep (j, 1, m) {
		if (dp[i][j] != INF) {
			if (i + 1 <= n) {
				if (mz[i][j] == mz[i + 1][j]) {
					chkMin(dp[i + 1][j], dp[i][j]);
				} else {
					chkMin(dp[i + 1][j], dp[i][j] + mz[i + 1][j]);
				}
			}
			if (j + 1 <= m) {
				if (mz[i][j] == mz[i][j + 1]) {
					chkMin(dp[i][j + 1], dp[i][j]);
				} else {
					chkMin(dp[i][j + 1], dp[i][j] + mz[i][j + 1]);
				}
			}
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 892
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<ll,ll>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int main(){
	ll x;cin >> x;
	for(ll i = 0;i <= 500;i++){
		for(ll j = 0;j < i;j++){
			if(pow(i,5) - pow(j,5) == x){
				cout << i << " " << j << endl;
				return 0;
			}
			if(pow(i,5) + pow(j,5) == x){
				cout << i << " " << -j << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4036
from collections import deque
n, m = map(int, input().split())
s = list(map(int, input().split()))
g = [[] for i in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

q = deque()
chk = [0] * n
res = []

for i in range(n):
    tmp = set()
    if not chk[i]:
        q.append(i)
        while q:
            v = q.pop()
            chk[v] = 1
            tmp.add(v)
            for u in g[v]:
                if chk[u] == 1:
                    continue
                q.append(u)
        res.append(tmp)

ans = 0
for re in res:
    tmp2 = set()
    for r in re:
        tmp2.add(s[r] - 1)
    ans += len(tmp2 & re)
print(ans)


Measured memory_bytes: 98028
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String S = in.readLine();
		int mod = 0;
		for (int i = 0; i < S.length(); ++i) {
			mod += Integer.parseInt(S.substring(i, i + 1));
			mod %= 9;
		}
		if (mod == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 38896
a,b,c,d = map(int,input())

def ope(i,a,b):
    if i == 0:
        return a + b
    elif i == 1:
        return a - b

def convert(i):
    if i == 0:
        return "+"
    elif i == 1:
        return "-"


def search(a,b,c,d):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                if ope(k,ope(j,ope(i,a,b),c),d) == 7:
                    return str(a) + convert(i) + str(b) + convert(j) + str(c) + convert(k) + str(d)

print(search(a,b,c,d)+"=7")
                    


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0){
            break;
        }else{
            for(int i = 0;i<H;i++){
                for(int j=0;j<W;j++){
                    if((i+j) % 2 == 0){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }
                cout << "\n";
            }
            cout << "\n";
        }
       }
    return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define intmx INT_MAX 
#define intmi INT_MIN
const int MOD=1e9+7;
int mod(int x){
    return ((x%MOD + MOD)%MOD);
}
int add(int a,int b){
    return mod(mod(a)+mod(b));
}
int mul(int a,int b){
    return mod(mod(a)*mod(b));
}
void solve(){
   double n,x;
   int t;
   cin>>n>>x>>t;
   int y=ceil(n/x);
   cout<<y*t<<endl;
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3796
s = sorted(input())
t = sorted(input())

if s[0] < t[len(t)-1]:
    print('Yes')
elif s[0] > t[len(t)-1]:
    print('No')
elif len(s) < len(t):
    for i in range(len(s)):
        if s[i] != t[i]:
            print('No')
            break
        elif i == len(s)-1:
            print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

signed main() {
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

class ftT
{
public:
	void clear ()
	{
		INIT ( data, 0 );
	}
	
	void upd ( int p, int x )
	{
		for ( ; p < MAXN; p += p&-p ) data[p] += x;
	}
	
	int sum ( int p )
	{
		int ans = 0;
		for ( ; p; p ^= p&-p ) ans += data[p];
		return ans;
	}
	
private:
	int data[MAXN];
}ft;

int n;
int ia[MAXN][3];
int a[MAXN];
int od[MAXN], ev[MAXN], ko, ke;

void init ();
void input ();
void work ();

int getrev ( int a[], int n );



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	lp ( i, 0, 3 ) lpi ( j, 1, n ) scanf ( "%d", &ia[j][i] );
}

void work ()
{
	// main work
	
	int maxi, mini;
	lpi ( i, 1, n ){
		maxi = *max_element ( ia[i], ia[i]+3 ), mini = *min_element ( ia[i], ia[i]+3 );
		if ( maxi % 3 == 0 ){
			if ( mini == maxi - 2 && ia[i][0] + ia[i][1] + ia[i][2] == maxi * 3 - 3 ){
				if ( ia[i][0] < ia[i][1] && ia[i][1] < ia[i][2] ) a[i] = maxi / 3;
				else if ( ia[i][0] > ia[i][1] && ia[i][1] > ia[i][2] ) a[i] = -maxi / 3;
				else{
					printf ( "No\n" );
					return;
				}
			}else{
				printf ( "No\n" );
				return;
			}
		}else{
			printf ( "No\n" );
			return;
		}
	}
	
//	lpi ( i, 1, n ) cerr << a[i] << " "; cerr << endl;
	
	lpi ( i, 1, n ){
		if ( ( i & 1 ) ^ ( a[i] & 1 ) ){
			printf ( "No\n" );
			return;
		}
	}
	
	lpi ( i, 1, n ) if ( i & 1 ) od[++ko] = a[i]; else ev[++ke] = a[i];
	
	int no = 0, ne = 0, ro, re;
	
	lpi ( i, 1, ko ) if ( od[i] < 0 ) ++no;
	lpi ( i, 1, ke ) if ( ev[i] < 0 ) ++ne;
	
	ro = getrev ( od, ko );
	re = getrev ( ev, ke );
	
	printf ( ( ( no & 1 ) == ( re & 1 ) && ( ne & 1 ) == ( ro & 1 ) ) ? "Yes\n" : "No\n" );
}



int getrev ( int a[], int n )
{
	ft.clear ();
	int ans = 0;
	lpd ( i, n, 0 ){
		ans += ft.sum ( qabs ( a[i] ) );
		ft.upd ( qabs ( a[i] ), 1 );
	}
	return ans;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> vp;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        vp.push_back(make_pair(b, a));
    }
    sort(vp.begin(), vp.end());
    int res = 0;
    int index = -1;
    for (int i = 0; i < m; i++) {
        if (index <= vp[i].second) {
            res++;
            index = vp[i].first;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 4296
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}


int main(){
    ll a,b,x;
    cin >> a >> b >> x;
    ll lb = (a+x-1)/x*x;
    ll ub = b/x*x;
    put((ub-lb)/x+1);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = sum(B)

for i in range(N - 1):
    if A[i + 1] - A[i] == 1:
        total += C[A[i] - 1]

print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <stdlib.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
ll sum[N];
//ll ans[N];

ll gao(int l,int r){  //求区间l,r的和
    return sum[r]-sum[l-1];
}

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

    int n ;
    cin >>n;
    for(int i=1;i<=n;i++)   cin >> a[i];
    for(int i=1;i<=n;i++)   sum[i]=sum[i-1]+a[i]; //求前缀和
    ll l=1,r=3;
    ll ans=1e18+8;
    for(int i=2;i<=n-2;i++){
         while(l+1<i&&abs(gao(1,l)-gao(l+1,i))>=abs(gao(1,l+1)-gao(l+2,i)))//若[1,l+1]和[l+1,i]的距离比[1,l+1]和[l+2,i]的距离小，那么我们就继续加，使得两边尽可能平衡
            l++;
         while(r+1<n&&abs(gao(i+1,r)-gao(r+1,n))>=abs(gao(i+1,r+1)-gao(r+2,n)))
            r++;
         set<ll>st;///利用set的log排序
         st.insert(gao(1,l));
         st.insert(gao(l+1,i));
         st.insert(gao(i+1,r));
         st.insert(gao(r+1,n));
         ans=min(ans,*st.rbegin()-*st.begin());
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
inline void read(int &k)
{
	register int f=1,c=getchar();k=0;
	while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();
	k*=f;
}
bool cmp(int a,int b)
{
	return a<=b;
}
const int maxn=200000+100;
int n,m,a[maxn],b[maxn];
int main()
{
	read(n);
	for (register int i=1;i<=n;i++)
	read(a[i]);
	read(m);
	for (register int i=1;i<=m;i++)
	read(b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+m);
//	for (int i=1;i<=n;i++)cout << a[i]<<" ";cout <<endl;
//	for (int i=1;i<=m;i++)cout << b[i]<<" ";cout <<endl;
	register int now=1;
	for (register int i=1;i<=m;i++)
	{
		if (a[now]==b[i])now++;else{
		while (a[now]!=b[i]&&now<=n)now++;
		now++;}
//		cout << i<<" "<<now<<endl;
		if (now>n+1)break;
	}
	if (now>n+1)printf("NO");else printf("YES");
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
using namespace std;
struct man{int x,y,d;};
int main(){
  string st[9];
  int i,j,k;
  for(i=0;i<9;i++) cin >> st[i];
  bool f=false,mo=false;
  man m;
  m.x=1;m.y=0;m.d=0;
  int c=0;
  cout << "R";
  while(1){
    c++;
    mo=false;
    
    if(m.x==1&&m.y==1&&m.d==2) {
      //cout << "L";
      break;
    }
    if(m.x==0&&m.y==1&&f) {
      //cout << "U";
      break;
    }
    f=true;
    
    //cout << m.x<<":"<<m.y<<":"<<m.d << endl;
    if(m.d==0){
      if(m.y>0){
	if(st[m.y*2-1][m.x]=='1') {
	  cout << "U";
	  m.d=3;
	  continue;
	}
      }
      if(m.y<5){
	if(st[m.y*2][m.x]=='1') {
	  m.x++;
	  cout << "R";
	  continue;
	}
      }
      if(m.y<4){
	if(st[m.y*2+1][m.x]=='1') {
	  m.x++;
	  m.y++;
	  cout << "D";
	  m.d=1;
	  continue;
	}
      }
      m.y++;
      cout << "L";
      m.d=2;
      continue;
    }
    
    if(m.d==1){
      if(m.y<5){
	if(st[m.y*2][m.x-1]=='1') {
	  cout <<"R";
	  m.d=0;
	  continue;
	}
      }
      if(m.x>0&&m.y<4){
	if(st[m.y*2+1][m.x-1]=='1') {
	  m.y++;
	  cout << "D" ;
	  mo=true;
	  continue;
	}
      }
      if(m.x>1&&m.y<5){
	if(st[m.y*2][m.x-2]=='1') {
	  m.x--;
	  m.y++;
	  cout << "L";
	  m.d=2;
	  continue;
	}
      }
      m.x--;
      cout << "U";
      m.d=3;
      continue;
    }
    if(m.d==2){
      if(m.x>0){
	if(st[m.y*2-1][m.x-1]=='1') {
	  cout << "D";
	  m.d=1;
	  continue;
	}
      }
      if(m.x>1&&m.y>0){
	if(st[(m.y-1)*2][m.x-2]=='1') {
	  m.x--;
	  cout << "L" ;
	  mo=true;
	  continue;
	}
      }
      if(m.x>0&&m.y>1){
	if(st[(m.y-1)*2-1][m.x-1]=='1') {
	  m.x--;
	  m.y--;
	  cout << "U";
	  m.d=3;
	  continue;
	}
      }
      m.y--;
      cout << "R";
      m.d=0;
      continue;
    }
    if(m.d==3){

      if(m.y>0){
	if(st[(m.y-1)*2][m.x-1]=='1') {
	  cout << "L";
	  m.d=2;
	  continue;
	}
      }
      if(m.y>1){
	if(st[(m.y-1)*2-1][m.x]=='1') {
	  m.y--;
	  cout << "U" ;
	  mo=true;
	  continue;
	}
      }
      if(m.y>0){
	if(st[(m.y-1)*2][m.x]=='1') {
	  m.x++;
	  m.y--;
	  cout << "R";
	  m.d=0;
	  continue;
	}
      }
      m.x++;
      cout << "D";
      m.d=1;
      continue;
    }
    //if(!mo)m.d=(m.d+2)%4;
  }
  
  cout  << endl;
  return 0;
}

Measured memory_bytes: 1184
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
for i in reversed(range(N)):
    if B[i] >= A[i + 1]:
        B[i] -= A[i + 1]
        ans += A[i + 1]
        A[i + 1] = 0
        if B[i] >= A[i]:
            B[i] -= A[i]
            ans += A[i]
            A[i] = 0
        else:
            A[i] -= B[i]
            ans += B[i]
            B[i] = 0
    else:
        A[i + 1] -= B[i]
        ans += B[i]
        B[i] = 0

print(ans)


Measured memory_bytes: 18624
#include<stdio.h>
int main (void){
    int a,b,c,num=0;
    scanf("%d %d %d",&a,&b,&c);
    for (int i = a; i <= b; i++)
    {
    if (c%i==0)num++;
    }
    printf("%d\n",num);
    
       return 0;   
}


Measured memory_bytes: 2120
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin
#define asn ans

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
//typedef unsigned int uint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,k,st=INT_MAX,l,r,rl,ans=INT_MAX,tmp;

main(){
    cin>>n>>k;
    int x[n];
    rep(i,n)cin>>x[i];
    for(int i=k-1;i<n;i++){
        ans=min(ans,x[i]-x[i-k+1]+min(abs(x[i]),abs(x[i-k+1])));
    }
    dans;
}



Measured memory_bytes: 1024
#include<stdio.h>
int main (void){
  int x, y, a, b;
  scanf ("%d %d", &x, &y);
  if (x < y){
    a = x;
    x = y;
    y = a;
}
  while (y > 0){
    b = x % y;
    x = y;
    y = b;
  }
  printf ("%d\n", x);
  return 0;
}
  

Measured memory_bytes: 592