akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define per(i,x,y) for (int i=(x);i>=(y);i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 1000000001
#define INF 1000000000000000001ll
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define y1 y1_
#define mset(x,y) memset((x),(y),sizeof(x))
#define mcpy(x,y) memcpy((x),(y),sizeof(y))
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
template<typename T> void cmin(T &x,T y){x=y<x?y:x;}
template<typename T> void cmax(T &x,T y){x=y>x?y:x;}
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10);putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (;p;p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll getinv(ll x){return ksm(x,mod-2);}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (;p;p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 5005
int n,k,All,rk[N],tp[N],sa[N],tong[N],h[N];char s[N];
void sort_(){
	rep (i,0,All) tong[i]=0;
	rep (i,1,n) tong[rk[tp[i]]]++;
	rep (i,1,All) tong[i]+=tong[i-1];
	per (i,n,1) sa[tong[rk[tp[i]]]--]=tp[i];
}
void get_sa(){
	rep (i,1,n) rk[i]=s[i],tp[i]=i;
	All =127; sort_(); int w=1; All=1;
	while (All<n){
		int t=0;
		rep (i,n-w+1,n) tp[++t]=i;
		rep (i,1,n) if (sa[i]>w) tp[++t]=sa[i]-w;
		sort_(); rep (i,1,n) tp[i]=rk[i];
		rk[sa[1]]=All=1;
		rep (i,2,n) rk[sa[i]]=(tp[sa[i]]==tp[sa[i-1]] && tp[sa[i]+w]==tp[sa[i-1]+w])?All:++All;
		w<<=1;
	}
	int k=0;
	rep (i,1,n){
		if (k) k--; int j=sa[rk[i]-1];
		for (; i+k<=n && j+k<=n && s[i+k]==s[j+k]; k++);
		h[rk[i]]=k;
	}
}
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	scanf("%s",s+1);n=strlen(s+1);k=read();get_sa();
	rep (i,1,n){
		if (n-sa[i]+1-h[i]>=k){
			rep (j,sa[i],sa[i]+h[i]+k-1) putchar(s[j]);
			exit(0);
		}
		k-=n-sa[i]+1-h[i];
	}
	return 0;
}
// sample data:
/*

*/

// rest:
/*

*/

Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;
int main()
{
    string S;
    cin >> S;
    long long sum = 0;
    int n = S.size();
    for (int i = 0; i < (1 << (n - 1)); ++i)
    {
        long long psum = 0;
        for (int j = 0; j < n; ++j)
        {
            psum *= 10;
            psum += S[j] - '0'; //数値変換
            if ((i & (1 << j)) == 0)
            {
                sum += psum;
                psum = 0;
            }
        }
        sum += psum;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ans=[[0,0,0] for i in range(n+1)]
for i in range(n):
    ans[i+1][0]+=max(ans[i][1]+l[i][0],ans[i][2]+l[i][0])
    ans[i+1][1]+=max(ans[i][2]+l[i][1],ans[i][0]+l[i][1])
    ans[i+1][2]+=max(ans[i][0]+l[i][2],ans[i][1]+l[i][2])
print(max(ans[-1]))

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,k;
    cin>>n>>k;

    ll ans=0;
    ll tmp=1;
    do{
        tmp *= k;
        ans++;
    }while(tmp<=n);

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

Measured memory_bytes: 256
import java.util.*;

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

    int num = 0;
    for(int i=1; i<n; i++){
      Set<Character> set_1 = new HashSet<>();
      for(int j=0; j<i; j++)
        {
          set_1.add(s.charAt(j));
        }

      Set<Character> set_2 = new HashSet<>();
      for(int j=i; j<n; j++)
        {
          set_2.add(s.charAt(j));
        }

        int count = 0;

        for(char c = 'a' ; c<='z';c++){
          if(set_1.contains(c)&&set_2.contains(c)){
            count++;
          }
        }

        num = Math.max(num,count);

    }

    System.out.println(num);
  }
}

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

const int maxn = int(1e5)+5;

int vis[maxn], col[maxn];
vector<pair<int, int>> graph[maxn];

void dfs(int node, int d)
{
	if(vis[node]) return;
	col[node] = d%2;
	vis[node] = 1;
	for(auto it: graph[node]) dfs(it.first, (d+it.second)%2);
}

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

	dfs(0, 0);
	for(int i = 0;i < n;i++) printf("%d\n", col[i]);
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    t.pop_back();
    puts(s==t?"Yes":"No");
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <random>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <cstring>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <bitset>

#pragma comment(linker, "/STACK:36777216")
using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

typedef long double ptype;

long long mod = /*27449*//*998244353*/ 1e9 + 7 /*1e9 + 9*/;
int inf = 1e9;
double eps = 1e-7;
long double pi = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ifstream in("input.txt");
ofstream out("output.txt");

void solve()
{
	string s;
	cin >> s;
	cout << s;
	if (s.back() == 's') cout << "es";
	else cout << "s";
}

int main()
{
	cout << setprecision(20) << fixed;
	cin.tie();
	cout.tie();
	clock_t t1 = clock();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
		//test();
	}
	//cout << (clock() - t1) * 1.0 / CLOCKS_PER_SEC;
	gg;
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

    int N;
    int M;
    int count;

    cin >> N >> M;

    vector<int> c(M);

    for(int i = 0; i < N; i++){
        int K;
        cin >> K;
        for(int j = 0; j < K; j++){
            int A;
            cin >> A;
            c[A - 1]++;
        }
    }

    for(int i = 0; i < M; i++){
        if(c[i] == N){
            count++;
        }
    }

    cout << count;
}

Measured memory_bytes: 384
import java.util.*;

class Main{

    Main(){
        Scanner SC = new Scanner(System.in);
        int N = Integer.parseInt(SC.next());
        String S = SC.next();
        String T = SC.next();

        for(int i=0;i<N;i++){
            System.out.print(S.charAt(i));
            System.out.print(T.charAt(i));
        }

        System.out.println("");
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
unsigned long long n,m,o;
int main(){
	cin>>n>>m;
	o=n;
	if(n*2<m){
		n+=(m-2*o)/4;
		m-=(m-2*o)/4*2;
	}
	cout<<min(n,m/2)<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)
x=0
for i in range(0,N+1):
    x+=abs(A[i+1]-A[i])
for i in range(1,N+1):
    print(x-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1]))

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


int main(){
	int A, B, C;
	cin >> A >> B >> C;
	if((A < C && C < B) || (B < C && C < A)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		Long X = Long.parseLong(scanner.next());
		Double num = 100.0;
		int year= 0;
		do {
			year++;
			num = Math.floor(num * 1.01);
		} while (num < X);
		System.out.println(year);
	}

}


Measured memory_bytes: 35856
#include<iostream>
using namespace std;
int main() {
    string S;
    cin >> S;

    string ans = "Good";

    for (int i = 0; i < S.length()-1; i++) {
        if (S.at(i) == S.at(i+1)) {
            ans = "Bad";
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n, a, d[101] = {};
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a;
    d[a]++;
  }
  int sum = 0;
  for(int i = 100; i >= 0; i--){
    if(d[i]) sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  map<int, vector<int>> mp;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    mp[a].push_back(b);
  }

  int ans = 0;
  rep2(i, 1, m+1){
    if(mp.count(i) == 1){
      for(auto j : mp[i]){
        q.push(j);
      }
    }

    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 14108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(u == s) a--;
  if(u == t) b--;
  cout << a << " " << b << endl;
return 0;
}

Measured memory_bytes: 3584
#include<iostream>

using namespace std;

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

    for (int i = 0; i < s.size(); i++) {
        s[i] = (s[i] + n - 0x41) % 26 + 0x41;
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int n,a,b,c,d;
string s;
bool ok[4][200004];
int main(){
	cin>>n>>a>>b>>c>>d>>s;
	a--,b--,c--,d--;
	for (int i=0;i<s.size();i++){
		if (i==a) ok[0][i]=1;
		if (i==b) ok[1][i]=1;
		if (s[i]!='#' && ((i>0 && ok[0][i-1])||(i>1 && ok[0][i-2]))) ok[0][i]=1;
		if (s[i]!='#' && ((i>0 && ok[1][i-1])||(i>1 && ok[1][i-2]))) ok[1][i]=1;
	}
	if (c<d){
		if (ok[0][c] && ok[1][d]) cout<<"Yes";
		else cout<<"No";
	}
	else{
		for (int i=s.size()-1;i>=0;i--){
			if (i==c) ok[2][i]=1;
			if (i==d) ok[3][i]=1;
			if (s[i]!='#' && ((i<s.size()-1 && ok[2][i+1])||(i<s.size()-2 && ok[2][i+2]))) ok[2][i]=1;
			if (s[i]!='#' && ((i<s.size()-1 && ok[3][i+1])||(i<s.size()-2 && ok[3][i+2]))) ok[3][i]=1;
		}
		bool oka=0;
		for (int i=1;i<s.size()-1;i++)
			if (ok[1][i] && ok[3][i] && ok[0][i-1] && ok[0][i+1] && ok[2][i-1] && ok[2][i+1]) oka=1;
		if (oka==1) cout<<"Yes";
		else cout<<"No";
	}
}

Measured memory_bytes: 1156
n = int(input())
l = list(map(int,input().split()))
e = []
ans = 'APPROVED'

for i in l:
    if i % 2 == 0: e.append(i)

for i in e:
    if not i % 3 == 0 and not i % 5 == 0:
        ans = 'DENIED'
        break

print(ans)

Measured memory_bytes: 3060
def main():
    n,m = map(int,input().split())
    graph = {}
    for i in range(n):
        graph[i+1]=[]
    for i in range(m):
        a,b = map(int,input().split())
        graph[a]+=[b]
        graph[b]+=[a]
    dist = [-1 for i in range(n)]
    ans = [0 for i in range(n)]
    dist[0]=0
    que = [1]
    while len(que)>0:
        q = que.pop(0)
        for v in graph[q]:
            if dist[v-1]!=-1:
                continue
            dist[v-1] = dist[q-1]+1
            ans[v-1] = q
            que.append(v)
    print('Yes')
    for i in range(n-1):
        print(ans[i+1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 42440
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    num = int(input())
    data = list(map(int, input().split()))

    data.sort()
    dp = [0 for i in range(max(data) * 2 + 1)]

    count = Counter(data)

    for i in range(1, max(data) * 2 + 1):
        dp[i] = dp[i - 1] + count[i]

    count = sorted(count.items(), key=lambda x: x[0])
    ans = 0

    # print(data)
    # print(count)
    # print(dp)

    for i in range(len(count)):
        if count[i][1] >= 3:
            ans += (count[i][1] * (count[i][1] - 1) * (count[i][1] - 2)) // 6
        if count[i][1] >= 2:
            nokori = count[i][0] * 2 - 1
            ans += (count[i][1] * (count[i][1] - 1)) // 2 * (dp[nokori] - dp[count[i][0]])

        for j in range(i + 1, len(count)):
            if count[j][1] >= 2:
                ans += count[i][1] * (count[j][1] * (count[j][1] - 1)) // 2
            max_data = count[i][0] + count[j][0] - 1
            kari = count[i][1] * count[j][1] * (dp[max_data] - dp[count[j][0]])
            ans += kari

    print(ans)








if __name__ == '__main__':
    main()


Measured memory_bytes: 41580
#include<cstdio>
using namespace std;
int n,m,cnt=-1;
char a[10][10];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%s",a[i]+1);int na=1,nb=1;
	for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) if(a[i][j]=='#') ++cnt;
	while(na!=n||nb!=m) {
		if(a[na][nb+1]=='#') {++nb;--cnt;}
		else if(a[na+1][nb]=='#') {++na;--cnt;}
		else {printf("Impossible\n");return 0;}
	}
	if(!cnt) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

int main(){
  ll n,a,cnt=0,ans=1;
  P c[200010];
  bool f;
  cin>>n;
  fr(i,n){cin>>a;c[i]=mp(a,0);}
  fr(i,n){cin>>a;c[n+i]=mp(a,1);}
  sort(c,c+2*n);
  fr(i,2*n){
    if(cnt==0){f=c[i].sd;cnt++;}
    else if(c[i].sd^f){
      ans=mlt(ans,cnt);
      cnt--;
    }
    else cnt++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

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


using namespace std;



int main() {

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a + 3);
	cout << a[0] + a[1] << endl;
	return 0;

}




Measured memory_bytes: 256
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = min(a) + min(b)
for i in range(M):
    x, y, c = map(int, input().split())
    x-= 1
    y -= 1
    cost = a[x] + b[y] - c
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 18736
peper=[[0 for i in range(14)]for j in range(14)]
while True:
    try:
        x,y,s=map(int,input().split(","))
        x +=2
        y +=2
        if s==3:
            peper[y][x] +=1
            peper[y][x-1] +=1
            peper[y][x-2] +=1
            peper[y][x+1] +=1
            peper[y][x+2] +=1
            peper[y-1][x] +=1
            peper[y-2][x] +=1
            peper[y+1][x] +=1
            peper[y+2][x] +=1
            peper[y-1][x-1] +=1
            peper[y-1][x+1] +=1
            peper[y+1][x-1] +=1
            peper[y+1][x+1] +=1
        elif s==2:
            peper[y][x] +=1
            peper[y][x+1] +=1
            peper[y][x-1] +=1
            peper[y+1][x] +=1
            peper[y+1][x+1] +=1
            peper[y+1][x-1] +=1
            peper[y-1][x] +=1
            peper[y-1][x+1] +=1
            peper[y-1][x-1] +=1
        elif s==1:
            peper[y][x] +=1
            peper[y+1][x] +=1
            peper[y-1][x] +=1
            peper[y][x+1] +=1
            peper[y][x-1] +=1
    except:
        co=0
        ma=0
        for i in range(2,12):
            for j in range(2,12):
                if peper[i][j]==0:
                    co +=1
                else:
                    ma=max(ma,peper[i][j])
        print(co)
        print(ma)
        break



Measured memory_bytes: 5628
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
        if a[i] < b[i]:
                ans += a[i]
                b[i] -= a[i]
                if b[i] > a[i+1]:
                        ans+=a[i+1]
                        a[i+1]=0
                else:
                        a[i+1]-=b[i]
                        ans+=b[i]
        else:
                ans += b[i]
print(ans)


Measured memory_bytes: 18476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll mod=ll(1e9+7);



int main()
{
	IOS;
	ll a,b;
	cin>>a>>b;
	int cnt=0;
	while(a<=b){
		a*=2;
		cnt++;
	}
	cout<<cnt;

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  vector<ll> p(n+2);
  rep(i,n){
    cin>>p[i+1];
  }

  ll sum=abs(p[n]);
  repo(i,n+1){
    sum+=abs(p[i]-p[i-1]);
  }

  repo(i,n+1){
    cout << sum+abs(p[i-1]-p[i+1])-abs(p[i-1]-p[i])-abs(p[i]-p[i+1]) << endl;
  }

}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int count(int x){
	int counter = 0;
	for(int i = 0; i < 20; i++) {
		if((x >> i) & 1){
			counter++;
		}
	}
	return counter;
}




int main(){
	int n,m,x,y;
	cin >> n;
	vector<vector<P>> a(n);
	vector<int> A(n);
	for(int i = 0; i < n; i++) {
		cin >> m;
		A[i] = m;
		for(int j = 0; j < m; j++) {
			cin >> x >> y;
			a[i].pb(mp(x,y));
		}
	}
	
	int ans = 0;
	for(int bit = 0; bit < 1 << n; bit++) {
		int flag = 0;

		for(int i = 0; i < n; i++) {
			if (!(bit & 1 << i)){
				continue;
			}
			for(int j = 0; j < A[i]; j++) {
				x = a[i][j].fs - 1;
				y = a[i][j].sc;
				if ((bit >> x & 1) && !y){
					flag = 1;
					break;
				}
				else if (!(bit >> x & 1) && y){
					flag = 1;
					break;
				}
			}
		}
		if(flag == 0){
			ans = max(ans,count(bit));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
using namespace std;
struct Info {int l,r;}c[100010];
int m,n,a[100010],b[100010],nc;
map<int,int> f;
bool comp(Info &a,Info &b){if (a.l!=b.l)return a.l<b.l;return a.r>b.r;}
int lo(int x){return x&(-x);}
int que(int x){int sum=0;for (;x;x-=lo(x))sum=(f[x]+sum)%mo;return sum;}
void add(int x,int p){for (;x<=mo;x+=(lo(x)))f[x]=(f[x]+p)%mo;}
int main(){
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	for (int j=1;j<=m;j++) scanf("%d",&a[j]);
	for (int i=0,j=1;j<=n;j++){
		while (i<m&&b[j]>a[i+1])i++;
		if (i!=0&&i!=m){c[++nc].l=b[j]-a[i];c[nc].r=a[i+1]-b[j];}
	}
	sort(c+1,c+nc+1,comp);
	add(1,1);
	for (int i=1;i<=nc;i++){if (i==1||c[i].l!=c[i-1].l||c[i].r!=c[i-1].r)add(c[i].r+1,que(c[i].r));}
	cout<<que(mo)<<endl;
	return 0;
}

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

#define MAX_N 1000
#define MAX_M 1000


int main(){
	int k, n;
    cin >> k >> n;
    vector<int> a(n);
    int MAX = 0;
    rep(i, n) {
        cin >> a[i];
    }
    for(int i = 1; i < n; i++){
        int tmp = a[i] - a[i-1];
        MAX = max(MAX, tmp);
    }
    int tmp2 = k + a[0] - a[n-1];
    MAX = max(MAX, tmp2);

    int ans = k - MAX;
    cout << ans << endl;

}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const ll cfmod = 998244353;
const ll LINF = 0x3f3f3f3f3f3f3f;
const int MAXN = 2e5+5;

int a, b, c, n, m, k, q;
string s, t, u;


int32_t main() {
	cin >> n >> k >> q;
	vector<int> v(n+1);
	for(int i = 0; i < q; i++) {
		int x;
		cin >> x;
		v[x]++;
	}
	for(int i = 1; i <= n; i++) {
		if( (k + v[i]) - q <= 0)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
}


Measured memory_bytes: 1408
//https://atcoder.jp/contests/abc133/tasks/abc133_a
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, a , b, mini;
    cin >> n >> a >> b;
    mini = min(a,b);
    mini *= n;
    if(mini <= b)
    {
        cout << mini << endl;
    }
    else
        cout << b << endl ;
}


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

ll a, b;
ll ans;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> a >> b;
    for (int i = 0; i < 45; i++) {
        ll start;
        if (a % (1ll << i) == 0) start = a;
        else {
            start = a + ((1ll << i) - (a % (1ll << i)));
        }
        ll cnt = 0;
        // 5, 7, cur pow is 2^2 aka 4
        // if (start % (1ll << i) == 0) {
            // cnt = start - a - max(0ll, start - 1 - b);
            // start += (1ll << i);
        // }
        if ((start / (1ll << i)) % 2 == 0) {
            cnt += min(start - 1, b) - a + 1;
            start += (1ll << i);
        }

        if (start > b) {
            // cout << i << ' ' << cnt << ' ' << start << '\n';
            if (cnt % 2) ans += (1ll << i);
            continue;
        }



        // cout << i << ' ' << cnt << ' ' << start << '\n';
        ll mul = (b - start + 1) / (1ll << i);
        cnt += ceil((long double)mul / 2) * (1ll << i);
        start += (1ll << i) * mul;
        if (mul % 2 == 1) start++;
        if (mul % 2 == 0 && start <= b) cnt += b - start + 1;
        // cout << i << ' ' << mul << ' ' << cnt << ' ' << start << '\n';
        if (cnt % 2) ans += (1ll << i);
    }
    cout << ans;
}



Measured memory_bytes: 256
#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);
      int a, b;
      cin >> a >> b;
      if(b % a == 0){
          cout << a+b << endl;
      }
      else{
          cout << b-a << endl;
      }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define int long long int
#define vec vector<int>
#define mp map<int,int>
#define inf 1e18
using namespace std;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tt=1;
  //cin>>tt;
  while(tt--)
  {
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=1000000;i++)
    {
      for(int j=1;j<=1000000;j++)
      {
        if(n-i*j>0)
            ans++;
        else
            break;
      }
    }
    cout<<ans<<"\n";
  }
}


Measured memory_bytes: 3640
x = int(input())
lis = []
for i in range(1,100):
    for j in range(2,10):
        lis.append(i**j)
lis.sort()
#print(lis)
for i in range(1001):
    if lis[i+1] == x:
        print(lis[i+1])
        break
    elif lis[i+1] > x:
        print(lis[i])
        break

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define F(n) for(int i=0;i<n;++i)

int main(){
    int S;
    cin >> S;
    int h=0,m=0,s=0;
    while(3600<=S){
        S-=3600;
        ++h;
    }
    while(60<=S){
        S-=60;
        ++m;
    }
    s=S;
    cout << h << ':' << m << ':' << s << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    string s = to_string(i);
    if (s.size() % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int w, n, l[31];

int main(){
	int a, b, t;
	scanf("%d", &w);
	scanf("%d", &n);
	for (int i = 1; i <= w; i++) {
		l[i] = i;
	}
	for (int I = 0; I < n; I++) {
		scanf("%d,%d", &a, &b);
		t = l[a];
		l[a] = l[b];
		l[b] = t;
	}
	for (int i = 1; i <= w; i++) {
		printf("%d\n", l[i]);
	}

	return 0;
}

Measured memory_bytes: 2672
import collection.mutable.ArrayBuffer
import scala.reflect.ClassTag
import scala.language.implicitConversions

trait Graph { 
    case class Edge[T:Numeric](from : Int, to : Int, cost : T)

    class Edges[T:Numeric](val data : ArrayBuffer[Edge[T]]) {
        def size = data.size
    }
    object Edges {
        def apply[T:Numeric](xs : Edge[T]*) = new Edges(ArrayBuffer(xs:_*))
        implicit def toUnderLying[T](x:Edges[T]) = x.data
    }

    class WeightedGraph[T:Numeric](val size : Int, val data : Array[Edges[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(Edges()))
    }
    object WeightedGraph {
        // def apply[T:Numeric](size : Int) = new WeightedGraph[T](size)
        implicit def toUnderLying[T](x:WeightedGraph[T]) = x.data
    }

    class UnWeightedGraph[T:Numeric](val size : Int, val data: Array[ArrayBuffer[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(ArrayBuffer[T]()))
    }
    object UnWeightedGraph {
        // def apply[T:Numeric](size : Int) = new UnWeightedGraph[T](size)
        implicit def toUnderLying[T](x:UnWeightedGraph[T]) = x.data
    }
   
    class Matrix[T:Numeric:ClassTag](val row : Int, val col : Int, val data : Array[Array[T]]) {
        def this(row : Int, col : Int) = this(row, col, Array.fill(row, col)(implicitly[Numeric[T]].zero))
        def this(size : Int) = this(size, size)
    }
    object Matrix {
        implicit def toUnderLying[T](x:Matrix[T]) = x.data
    }
}

object BellmanFord extends Graph {
    import Edges._

    // return ArrayBuffer() when find a negative cycle
    def bellmanFord[T:ClassTag](edges : Edges[T], V : Int, s : Int, INF : T)(implicit num : Numeric[T]) : Array[T] = {
        import num._
        val dist = Array.fill[T](V)(INF)
        dist(s) = zero
        for (i <- 1 to V) {
            for (Edge(from, to, cost)  <- edges) {
                if(dist(from) != INF 
                    && dist(from) + cost < dist(to)) {
                        dist(to) = dist(from) + cost
                        if (i == V && to == V-1) return Array.empty
                    }
            }
        }
        dist
    }
}

import BellmanFord._

object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val N, M = sc.nextInt
        val edges = Edges[Long]()
        for (_ <- 1 to M) {
            val s, t = sc.nextInt
            val c = sc.nextLong
            edges += Edge(s-1, t-1, -c)
        }
        // println(edges.toList)
        val res = bellmanFord[Long](edges, N, 0, Long.MaxValue)
        // println(res.toList)
        if (res.isEmpty) println("inf")
        else {
            println(-res(N-1))
        }
    }
}

Measured memory_bytes: 106140
a = Array.new(4, 0)

10.times do
  a[3] = gets.chomp.to_i
  3.times do |i|
    if a[2-i] < a[3-i]
      a[2-i], a[3-i] = a[3-i], a[2-i]
    else
      break
    end
  end
end

print a[0], "\n", a[1], "\n", a[2], "\n"

Measured memory_bytes: 6096
#include <iostream>
using namespace std;
 
int solve(int N){
    int ans = 0;
    for(int i = 0; i <= 9; ++i){
        for(int j = 0; j <= 9; ++j){
            for(int k = 0; k <= 9; ++k){
                for(int l = 0; l <= 9; ++l){
                    int tmp = i + j + k + l;
                    if(tmp == N) ans++;
                }
            }
        }
    }
    return ans;
}
 
int main(){
    int N;
    while(cin >> N){
        int ans = solve(N);
        cout << ans << endl;
    }
}


Measured memory_bytes: 3096
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include <iomanip>
#include<algorithm>
#include<vector>
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i,n,m;
  cin >> n >> m;
  int l[m],r[m];
  rep(i,m){
    cin >> l[i] >> r[i];
  }

  int l_max = 1;
  int r_min = 100000;
  rep(i,m){
    if(l_max < l[i]) l_max = l[i];
    if(r_min > r[i]) r_min = r[i];
  }
  int res = r_min - l_max + 1;

  cout << max(res, 0) << "\n";

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n;
char t3[3][3] = {
	{'a', 'a', 'd'},
	{'b', '.', 'd'},
	{'b', 'c', 'c'}
};
char t3ver2[3][3] = {
	{'e', '.', '.'},
	{'e', '.', '.'},
	{'.', 'f', 'f'}
};
char t4[4][4] = {
	{'a', 'a', 'd', 'c'},
	{'b', 'b', 'd', 'c'},
	{'d', 'c', 'a', 'a'},
	{'d', 'c', 'b', 'b'},
};
char t5[5][5] = {
	{'a', 'h', 'h', 'g', 'g'},
	{'a', 'i', '.', '.', 'f'},
	{'b', 'i', '.', '.', 'f'},
	{'b', '.', 'j', 'j', 'e'},
	{'c', 'c', 'd', 'd', 'e'},
};
int main() {
	cin >> n;
	if (n >= 12) {
		vector<vector<char>> ans(1010, vector<char>(1010, '.'));
		ll now = 0;
		while (now < n) {
			if ((n - now) % 4 != 0) {
				REP(i, 5) {
					REP(j, 5) {
						ans[now + i][now + j] = t5[i][j];
					}
				}
				now += 5;
			}
			else {
				REP(i, 4) {
					REP(j, 4) {
						ans[now + i][now + j] = t4[i][j];
					}
				}
				now += 4;
			}
		}
		REP(i, n) {
			REP(j, n)cout << ans[i][j];
			cout << endl;
		}
	}
	else if (n % 3 == 0) {
		REP(i, n) {
			REP(j, n) {
				cout << t3[i % 3][j % 3];
			}
			cout << endl;
		}
	}
	else if (n % 4 == 0) {
		REP(i, n) {
			REP(j, n) {
				cout << t4[i % 4][j % 4];
			}
			cout << endl;
		}
	}
	else if (n % 5 == 0) {
		REP(i, n) {
			REP(j, n) {
				cout << t5[i % 5][j % 5];
			}
			cout << endl;
		}
	}
	else if (n == 11) {
		vector<vector<char>> ans(11, vector<char>(11, '.'));
		REP(i, 5) REP(j, 5) ans[i][j] = t5[i][j];
		REP(i, 3) REP(j, 3) ans[5 + i][5 + j] = t3[i][j];
		REP(i, 3) REP(j, 3) ans[8 + i][8 + j] = t3[i][j];
		REP(i, 3) REP(j, 3) ans[8 + i][5 + j] = t3ver2[i][j];
		REP(i, 3) REP(j, 3) ans[5 + i][8 + j] = t3ver2[i][j];
		REP(i, n) {
			REP(j, n)cout << ans[i][j];
			cout << endl;
		}
	}
	else if (n == 7) {
		char ans[7][7] = {
			{'d', 'a', 'd', 'd', '.', '.', '.'},
			{'d', 'a', '.', 'c', '.', '.', '.'},
			{'e', 'b', 'b', 'c', '.', '.', '.'},
			{'e', '.', '.', '.', 'a', 'd', 'd'},
			{'d', '.', '.', '.', 'a', '.', 'c'},
			{'d', '.', '.', '.', 'b', 'b', 'c'},
			{'.', 'd', 'd', 'e', 'e', 'd', 'd'},
		};
		REP(i, n) {
			REP(j, n)cout << ans[i][j];
			cout << endl;
		}
	}
	else cout << -1 << endl;
}





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

using namespace std;

int main(void) {
	string s;
	cin >> s;
	int count = s.length();
	int x = 0;
	for (int i = 0; i < count; i += 2) {
		if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') {
			x = 1;
		}
		else {
			x = 0;
			break;
		}
	}
	if (x == 1) {
		for (int i = 1; i < count; i += 2) {
			if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') {
				x = 1;
			}
			else {
				x = 0;
				break;
			}
		}
	}
	if (x == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;
ll dp[3001][3001],n;
pair <ll,ll> a[3001];
ll func(ll i, ll t)
{
    if(i == n or t <= 0)
        return 0;
    if(dp[i][t] != -1)
        return dp[i][t];
    return dp[i][t] = max(a[i].ss+func(i+1, t-a[i].ff), func(i+1, t));
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t, i,j;
    cin>>n>>t;
    for(i=0;i<n;i++)
        cin>>a[i].ff>>a[i].ss;
    sort(a,a+n);
    for(i=0;i<=n;i++)
        for(j=0;j<=t;j++)
            dp[i][j] = -1;
    cout<<func(0,t);
    return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 1010

ll a, b, x;

signed main()
{
    cin >> a >> b >> x;
    int ans = 0;

    a += (a % x == 0) ? 0 : x - (a % x);
    b -= b % x;

    if(b < a) {
        printf("0\n");
        return 0;
    }

    ans = (b - a) / x + 1;

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int N = 100010;

int main(void){
    int wanum[N] = {};
    int acflag[N] = {};
    int n, m;
    int qnum;
    string isAC;
    
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        cin >> qnum >> isAC;
        if(isAC == "AC"){
            acflag[qnum] = 1;
        }else{
            if(!acflag[qnum]){
                wanum[qnum]++;
            }
        }
    }
    
    int acnum = 0;
    int pnum = 0;
    for(int i = 1; i <= n; i++){
        if(acflag[i]){
            acnum++;
            pnum += wanum[i];
        }
    }
    
    cout << acnum << " " << pnum;
    
    return 0;
}

Measured memory_bytes: 1024
// 2011/10/22 Tazoe

#include <iostream>
using namespace std;

int DFS(int M[12][12], int N, int Y, int X, int Y2, int X2)
{
//	cout << M[Y][X] << ' ' << N << endl;

	if(M[Y][X]==1)
		N--;

	if(N==0)
		if(Y==Y2||X==X2)
			return 1;
		else
			return 0;

	M[Y][X] = 0;

	int cnt = 0;

	int y = Y;
	int x = X;
	y--;
	while(M[y][x]==0)
		y--;
	if(M[y][x]==1)
		cnt += DFS(M, N, y, x, Y2, X2);

	y = Y;
	x = X;
	y++;
	while(M[y][x]==0)
		y++;
	if(M[y][x]==1)
		cnt += DFS(M, N, y, x, Y2, X2);

	y = Y;
	x = X;
	x--;
	while(M[y][x]==0)
		x--;
	if(M[y][x]==1)
		cnt += DFS(M, N, y, x, Y2, X2);

	y = Y;
	x = X;
	x++;
	while(M[y][x]==0)
		x++;
	if(M[y][x]==1)
		cnt += DFS(M, N, y, x, Y2, X2);

	M[Y][X] = 1;
	return cnt;
}

int main()
{
	while(true){
		int m, n;
		cin >> m >> n;
		if(m==0&&n==0)
			break;

		int M[12][12];
		for(int y=0; y<n+2; y++)
			for(int x=0; x<m+2; x++)
				M[y][x] = 3;

		int N = 0;
		int Y, X;
		for(int y=1; y<=n; y++){
			for(int x=1; x<=m; x++){
				cin >> M[y][x];
				if(M[y][x]==1){
					N++;
				}
				else if(M[y][x]==2){
					Y = y;
					X = x;
				}
			}
		}

		int cnt;
		cnt = DFS(M, N, Y, X, Y, X);

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;


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

    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import itertools
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int, input().rstrip().split()))

ans = 0
for i in itertools.count(0, 2):
    if i > N - 1:
        break
    if A[i] % 2 == 1:
        ans += 1
print(ans)


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

using namespace std;

typedef struct{
  int k;
  char m[50];
}res;

res r[1000];
int adj[1000][1000] = {{0}};
int n;
void show(int num,int f){
  f++;
  for(int i=0;i<f;++i)
    putchar('.');
  printf("%s\n",r[num].m);

  for(int i = num ;i<n;++i)
    if(adj[i][num]){
      show(i,f);
    }
}

int main(){
  cin >> n;
  for(int i=0;i<n;++i)
    for(int j=0;j<n;++j)
      adj[i][j]=0;
  for(int i=0;i<n;++i){
    cin >> r[i].k >> r[i].m;
    adj[i][r[i].k-1] = 1;
  }

  show(0,-1);

}

Measured memory_bytes: 5116
#include <cstdlib>
#include <climits>
#include <iostream>
#include <sstream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> a;
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        a.push_back(t);
    }

    if (N % 2 == 0) {
        // 偶数
        for (int64_t i = N - 1; i > 0; i -= 2) {
            std::cout << a[i] << " ";
        }
        for (int64_t i = 0; i < N; i += 2) {
            std::cout << a[i] << " ";
        }
    }
    else {
        // 奇数
        for (int64_t i = N - 1; i >= 0; i -= 2) {
            std::cout << a[i] << " ";
        }
        for (int64_t i =1; i < N; i += 2) {
            std::cout << a[i] << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());
//int randt(int l, int r){ return (rando() % (r - l + 1) + l); }

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5;
int mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
ll infll = 1e18 + 7;

string s;
string t;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> s;
    Fora(v, s){
        if (v == 'B'){
            if (!t.empty()) t.pob();
        }
        else t += v;
    }
    cout << t;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

const int N=309;

int n,m;
int a[N][N],top[N];
int val[N];

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);

	int ans=0;
	for(int i=1;i<=n;i++)
		top[i]=1,++val[a[i][1]];
	for(int i=1;i<=m;i++)
		ans=max(ans,val[i]);

	for(int i=1;i<m;i++)
	{
		int mp=1;
		for(int j=2;j<=m;j++)
			if(val[j]>val[mp])
				mp=j;
		//printf("%d\n",mp);
		val[mp]=-1;
		
		for(int j=1;j<=n;j++)
		{
			int rec=top[j];
			while(val[a[j][top[j]]]==-1)
				++top[j];
			if(top[j]!=rec)
				++val[a[j][top[j]]];
		}

		int curans=0;
		for(int j=1;j<=m;j++)
			curans=max(curans,val[j]);
		//printf("%d\n",curans);
		ans=min(ans,curans);
	}

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


Measured memory_bytes: 640