akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Tree {
  int key;
  struct Tree *parent, *left, *right;
};

struct Tree *root, *nill;

void insert(int key) {
  struct Tree *x, *y, *z;
  y = nill;
  x = root;

  z = malloc(sizeof(struct Tree));
  z->key = key;
  z->left = nill;
  z->right = nill;

  while (x != nill) {
    y = x;
    if (key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if (y == nill) {
    root = z;
  }
  else if (z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

int find(int key) {
  struct Tree *x;
  x = root;

  while (x != nill) {
    if (x->key == key)
      return 1;
    else if (x->key > key)
      x = x->left;
    else
      x = x->right;
  }
  return 0;
}

void inorder(struct Tree *t) {
  if (t->left != nill)
    inorder(t->left);
  printf(" %d", t->key);
  if (t->right != nill)
    inorder(t->right);
}

void preorder(struct Tree *t) {
  printf(" %d", t->key);
  if (t->left != nill)
    preorder(t->left);
  if (t->right != nill)
    preorder(t->right);
}

int main(void) {
  int n, key;
  char s[10];

  nill = (struct Tree *)malloc(sizeof(struct Tree));

  root = nill;
  
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    if (strcmp(s, "insert") == 0) {
      scanf("%d", &key);
      insert(key);
    }
    else if (strcmp(s, "print") == 0) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else {
      scanf("%d", &key);
      if (find(key) == 1)
	printf("yes\n");
      else
	printf("no\n");
    }
  }


  return 0;
}



Measured memory_bytes: 20472
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;

    long long sum = 0;

    int s, t;
    for (int i = 1; i <= n; i++)
    {
        s = i % 3;
        t = i % 5;
        if (s == 0 || t == 0)
        {
            continue;
        }
        sum += i;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y;
    cin >> x >> y;
    cout << (a[x] == a[y] ? "Yes" : "No") << endl;

    return 0;
}

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

int main(){
    int i,j;
    int n;
    cin >> n;
    for(i=0;i<n;i++){
        int ar[3];
        for(j=0;j<3;j++) cin >> ar[j];
        int sum = 0;
        for(j=0;j<3;j++) sum += ar[j] * ar[j];
        for(j=0;j<3;j++) if(sum==ar[j]*ar[j]*2) break;
        if(j==3) cout << "NO" << endl;
        else cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long n,m;
	cin>>n>>m;
	cout<<min(n%m,abs((n%m)-m));

	   return 0;
	}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> a(n*3);
    rep(i,n*3)cin>>a.at(i);
    sort(all(a),greater<int>());
    int ans=0;
    rep(i,n){
        ans+=a.at(i*2+1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
    int X,Y;
    cin >> X >> Y;
    if(Y%2==1 || !(Y>=2*X && Y<=4*X)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
long long int judge(long long int k)
{
    if(k < 2){
		return 0;
	}
	if(k == 2){
		return 1;
	}
	if(k % 2 == 0){
		return 0;
	}
	long double s = sqrt(k);
    for(long long int i = 3;i <= s + 1;i += 2)
    {
        if(k % i == 0)
        {
            return 0;
        }
    }
    return 1;
}
long long int p(long long int c, long long int d){
	long long int r = 1;
	for(long long int i = 0;i < d;i++){
		r *= c;
	}
	return r;
}
int main(){
	long long int n, co = 0;
	cin >> n;
	for(long long int i = 2;i <= 1000000;i++){
		if(judge(i)){
			for(long long int j = 1;;j++){
				if(n % p(i, j) == 0){
					n /= p(i, j);
					co++;
				}else{
					break;
				}
			}
		}
	}
	if(n > 1000000){
		cout << (co) + 1 << endl;
		return 0;
	}
	cout << co << endl;
}

Measured memory_bytes: 3652
a=input()
b=input()

if len(a)>len(b):
    print('GREATER')
elif len(a)<len(b):
    print('LESS')
else:
    for i in range(len(a)):
        if a[i]>b[i]:
            print('GREATER')
            exit()
        elif a[i]<b[i]:
            print('LESS')
            exit()
    print('EQUAL')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <string>

int main() {
	int N; std::cin >> N;
    int ans = 0;
	std::string S; std::cin >> S;
    for (int i = 0; i < 1000; i++) {
        int a[3] = { i / 100, (i / 10) % 10, i % 10 };
        int cnt = 0;
        for (int j = 0; j < N; j++) {
            if (cnt <= 2 && a[cnt] == (int)(S[j] - '0')) cnt++;
        }
        if (cnt == 3) ans += 1;
    }
    std::cout << ans << std::endl;
        return 0;
}

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

#define int long long
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()

#define fast ios::sync_with_stdio(0); cin.tie(0)

int32_t main(){

    fast;
    int n; cin >> n;
    int ar[n];

    int maxx_freq = -1 , element = -1;
    map<int,int> mp;

    for(int i=0;i<n;i++){
      cin >> ar[i];
      mp[ar[i]]++;
      if(mp[ar[i]]>maxx_freq){
        maxx_freq = mp[ar[i]];
        element = ar[i];
      }
    } 
    
    if(maxx_freq==1){
      for(auto p : mp) element = max(element,p.f);
    }
    // cout << "maxx " << element << '\n';

    vector<int> divisor;

    for(int i=1;i*i<=element;i++){
      if(element%i==0){
        divisor.pb(i);
        if(i!=element/i) divisor.pb(element/i);
      }
    }

    int ans = -1;

    for(int i=0;i<divisor.size();i++){
      int gcd = 0;
      bool flag = false;
      for(int j=0;j<n;j++){
        if(ar[j]%divisor[i]!=0&&!flag){
          gcd = __gcd(divisor[i],gcd);
          flag = true;
        }
        else {
          gcd = __gcd(ar[j],gcd);
        }
      }
      ans = max(ans,gcd);
    }

    cout << ans << '\n';


    return 0;
} 

Measured memory_bytes: 1024
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,T = inpl()
ans = INF
for i in range(N):
    c,t = inpl()
    if t <= T:
        ans = min(c,ans)

if ans == INF:
    print('TLE')
else:
    print(ans)


Measured memory_bytes: 4208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define tests int t1234;cin>>t1234;for(int i1234=1;i1234<=t1234;i1234++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mods (1000000007)
#define arrLB(arr,n,x) (int)(lower_bound(arr,arr+n,x)-arr)
#define arrUB(arr,n,x) (int)(upper_bound(arr,arr+n,x)-arr)
#define vecLB(arr,x) (int)(lower_bound(arr.begin(),arr.end(),x)-arr.begin())
#define vecUB(arr,x) (int)(upper_bound(arr.begin(),arr.end(),x)-arr.begin())
const int N=200001;

int main() {
    fastio;
    string s;cin>>s;
    rep(i,s.size()){
        if(s[i]=='?')cout<<'D';
        else cout<<s[i];
    }

}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

struct data {
    int a, b, sum;
};

bool comp(const data &a, const data &b) {
    if (a.sum > b.sum) {
        return true;
    } else {
        return false;
    }
    return 0;
}

int main() {
    int N;
    cin >> N;
    vector<data> A(N);
    rep(i, N) {
        cin >> A[i].a >> A[i].b;
        A[i].sum = A[i].a + A[i].b;
    }
    sort(all(A), comp);

    lint ans = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            ans += A[i].a;
        } else {
            ans -= A[i].b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(in.hasNext()) {
			int T=in.nextInt();
			if(T>=30) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
	}
}


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

using namespace std;

int a[123];
string s;

int main()
{
    getline(cin,s);
    for (int i = 97; i <= 122; i++) a[i] = 0;
    for (int i = 0; i < s.length(); i++)
    {
        a[s[i]]++;
    }
    for (int i = 97; i <= 122; i++)
    {
        if (a[i] % 2 != 0)
        {
            cout << "No"<< endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Ribhav
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABiscuitGenerator solver = new ABiscuitGenerator();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABiscuitGenerator {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int a = s.nextInt(), b = s.nextInt(), t = s.nextInt();
            out.println(t / a * b);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

int main(){

    int k,a,b;
    bool ans=false;
    cin>>k>>a>>b;

    for(int i=a;i<=b;i++){
        if(i%k==0) ans=true;
    }
    cout<<(ans?"OK":"NG")<<endl;

    return 0;
}

Measured memory_bytes: 3596
a, b, c = map(int, input().split())


if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
    print(0)
    exit(0)
if a == b == c and a % 2 == 0:
    print(-1)
    exit(0)

counter = 0
while True:
    counter += 1
    w_a = a / 2
    w_b = b / 2
    w_c = c / 2

    a = w_b + w_c
    b = w_a + w_c
    c = w_b + w_a

    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        print(counter)
        exit(0)


Measured memory_bytes: 3064
import collections

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
 
N = int(input())

l = collections.Counter(prime_decomposition(N))

ans = 0
for p,c in l.items():
    i = 1
    while c >= i :
        c -=i
        i += 1
        ans +=1

print(ans)  

Measured memory_bytes: 9532
# -*- coding: utf-8 -*-

def check_ans(Ai, B, C):
    ans = 0
    for Aij, Bj in zip(Ai, B):
        ans += Aij * Bj
    ans += C
    if ans > 0:
        return True
    else:
        return False
        
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

cnt = 0
for Ai in A:
    if check_ans(Ai, B, C):
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
//下に解法を書きました．
#include<bits/stdc++.h>
#include<iostream>

using namespace std;

const int MAX = 680000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

#define comuse Comuse()

int combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


void Solve();

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

/*
前提条件として，入力で与えられる座標に必ず移動できるとする．
移動する回数は(X+Y)/3で得ることができるので，移動する回数をnとすると直線y=-x+3n上の格子点のみをみればよいことがわかる．
いま駒はすべて(i,j)から(i+2,j+1)に遷移したと仮定して考える．
すると，端の座標は(2n,n)と(n,2n)であることがわかる．

ここでパスカルの三角形を考えると，入力で与えられる座標はパスカルの三角形の左からいくつ目なのかは2n-xまたはy-nで得ることができる．
あとはそれに対する二項係数(n)C(2n-x)を計算すればよい．

コーナーケースは(X+Y)が3の倍数ではない場合と，パスカルの三角形の端から端を定義域としたときに(X,Y)がy=-x+3n上にない場合である．
*/

void Solve(){
  int x,y;
    scanf("%d%d",&x,&y);

  int n=(x+y)/3;
  
  if(2*n<x||2*n<y||(x+y)%3!=0){
    cout<<0<<endl;
    return;
  }
  
  comuse;
  
  printf("%d\n",combi(n,2*n-x));
}

Measured memory_bytes: 16256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

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

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    vector<int> xs(H * W + 1);
    vector<int> ys(H * W + 1);
    vector<int> cs(H * W, -1);

    rep(i, H){
        rep(j, W){
            int a;
            cin >> a;
            ys[a] = i;
            xs[a] = j;
        }
    }

    for(int i = 1; i + D <= H * W; i ++){
        cs[i + D] = cs[i] + abs(xs[i] - xs[i + D]) + abs(ys[i] - ys[i + D]);
    }

    int Q;
    cin >> Q;
    vector<int> rs(Q);
    vector<int> ls(Q);
    rep(i, Q){
        cin >> ls[i] >> rs[i];
    }
    rep(i, Q){
        int r = rs[i];
        int l = ls[i];
        cout << cs[r] - cs[l] << endl;
    }

    return 0;
}


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

int main(){
    int n,d;cin>>n>>d;
    int ans=0;
    double x,y;
    for(int i=0;i<n;++i){
        cin>>x>>y;
        if(sqrt(x*x+y*y)<=d)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define min_index(a) (int)distance(begin(a), min_element(ALL(a)))
#define max_index(a) (int)distance(begin(a), max_element(ALL(a)))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

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

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0, cnt = 0;

  cin >> n;
  cout << n * 2 - 1 << endl;
  vi a(n);
  REP(i, n) {
    cin >> a[i];
  }
  int min_a = min_of(a);
  int max_a = max_of(a);
  int min_i = min_index(a);
  int max_i = max_index(a);
  int xi = 0;
  if(min_a > 0 || (max_a > 0 && abs(min_a) < abs(max_a))) {
    xi = max_i;
    REP(i, n) {
      if (i != xi)cout << xi + 1 << " " << i + 1 << endl;
    }
    cout << xi + 1 << " " << xi + 1 << endl;
    REP(i, n - 1) {
      cout << i + 1 << " " << i + 2 << endl;
    }
  } else {
    xi = min_i;
    REP(i, n) {
      if (i != xi)cout << xi + 1 << " " << i + 1 << endl;
    }
    cout << xi + 1 << " " << xi + 1 << endl;
    RREP(i, n - 1) {
      cout << i + 2 << " " << i + 1 << endl;
    }
  }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


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

typedef double type_n;
typedef complex<type_n> point;

int main()
{
    point a, b, c, z, h, w;
    int i, q;
    type_n a1, a2, b1, b2, z1, z2;
    scanf("%lf %lf %lf %lf", &a1, &a2, &b1, &b2);
    a.real(a1), a.imag(a2), b.real(b1), b.imag(b2);
    c = b - a;

    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%lf %lf", &z1, &z2);
        z.real(z1), z.imag(z2);
        h = a + c * (((z - a) / c).real());
        w = h + h - z;
        printf("%.12f %.12f\n", w.real(), w.imag());
    }
    return 0;
}

Measured memory_bytes: 1256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,k;
	cin >> a >> b >> k;
	map<int,bool> mp;
	for(int i = a;i <= a+k-1 && i <= b;++i){
		cout << i << '\n';
		mp[i] = true;
	}
	for(int i = b-k+1;i <= b && i >= a;++i){
		if(!mp[i]) cout << i << '\n';
	}
	return 0;
}


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

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;
bool func(ll arr[],ll n)
{
    ll xr=0;
    for(ll i=0;i<n;i++)
        xr = xr^arr[i];
    return xr==0;
}

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

    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];

    //sort(arr,arr+n);

    if(func(arr,n))
        cout<<"Yes";
    else
        cout<<"No";
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main(){
    int n,m,a,b;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--;
        b--;
        mp[a]++;
        mp[b]++;
    }
    for(int i=0;i<n;i++) cout<<mp[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

int main() {
  int n;
  string s;

  cin >> n >> s;

  int ans = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i-1]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{

    string S ;
    cin >> S;
    if (S.at(0)== S.at(1))
        cout << "Bad" ;
    else if (S.at(2)== S.at(3))
        cout << "Bad" ;
     else if (S.at(1)== S.at(2))
        cout << "Bad" ;
    else
        cout << "Good" ;




    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    long int i,j,k,l=0;

    while(cin>>i>>j)
    {
    k=i+j;
    //cout<<k;
    while(k!=0)
    {
        k=k/10;
        l+=1;
    }
    cout<<l<<endl;
    l=0;
    }
    return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 21 22:49:30 2019

@author: Yamazaki Kenichi
"""

N = int(input())
S = [input() for i in range(N)]

for i in range(N):
    S[i] = ''.join(sorted(S[i]))
S.sort()
ans = 0
counta = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        counta += 1
    else:
        ans += counta*(counta+1)//2
        counta = 0
ans += counta*(counta+1)//2
print(ans)

Measured memory_bytes: 10660
import sys


def main():
    a, b, c, x, y = map(int, input().split())

    min_price = None

    for i in range(max(x, y) + 1):
        nc = i * 2
        na = x - i
        if na < 0:
            na = 0
        nb = y - i
        if nb < 0:
            nb = 0

        price = na * a + nb * b + nc * c
        if min_price is None or price < min_price:
            min_price = price

    print(min_price)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define S second
#define F first
#define all(a) a.begin() , a.end()
#define pb push_back 
#define DBG cout<<"debug\n";

typedef long long ll;

const int N = 2 * 1e5 + 10;
const ll inf = 9e18 + 9; 

ll res;
ll a[N];
ll mod = 1e9 + 7;

void solve(){
    ll n , k;
    cin>>n>>k;
    vector<ll> v;

    for(int i = 0 ; i < n ; i++) {
        ll x;
        cin>>x;
        v.pb(x);
    }

    ll ans = 0;


    for(int i = 0; i < n ;i++) {
        for(int j = i+1; j < n; j++ ) {
            if(v[i] > v[j]) {
                ans += k;
                ans %= mod;
            }
        }
    }

    for(int i = 0 ; i < n ; i++) {
        ll cnt = 0;
        for(int j = 0; j < n; j++) {
            if(v[i] > v[j]) {
                cnt++;
            }
        }

    ans += ((k * (k - 1)) / 2 ) % mod * cnt;

    ans = ans % mod;
    }



    cout<<ans<<endl;
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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


using namespace std;


using ll = long long;


void dump_array(vector<ll>& A)
{
    auto N = A.size();
    for (auto i = 0; i < N - 1; i++) {
        cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
}


int main()
{
    ll N;
    vector<ll> A;
    cin >> N;
    for (auto i = 0; i < N; i++) {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
    }

    ll cnt = 0;
    for (ll i = 0; i < N - 1; i++) {
        for (ll j = 0; j < N - i - 1; j++) {
            if (A[j] > A[j + 1]) {
                ll tmp = A[j];
                A[j] = A[j + 1];
                A[j + 1] = tmp;
                cnt++;
            }
        }
    }

    dump_array(A);
    cout << cnt << endl;
}



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

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

    string a[n];
    rep(i, n){
        cin >> a[i];
    }

    string b[n];
    rep(i, n){
        if(i % 2 == 0){
            b[i/2] = a[n - 1 - i];
        }else{
            b[n - 1 - i / 2] = a[n - 1 - i];
        }
    }

    rep(i, n){
        cout << b[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 17536
/**
 *    author:  tourist
 *    created: 13.10.2018 15:17:07       
**/
#include <bits/stdc++.h>

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  a[0] = 0;
  for (int i = 1; i < n; i++) {
    a[i] = a[i - 1];
    add(a[i], inv(i + 1));
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    add(ans, mul(x, a[i]));
    add(ans, mul(x, a[n - 1 - i]));
    add(ans, mul(x, 1));
  }
  for (int i = 0; i < n; i++) {
    ans = mul(ans, i + 1);
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

using ll = long long;
typedef vector<vector<ll> > Matrix; //隣接行列

const ll INF = 1e15;

Matrix dist;

//trueなら負の閉路を検出
bool warshall_floyd(int n) { //nは頂点数
    for (int k = 0; k < n; k++) { //経由点
        for (int i = 0; i < n; i++) { //始点
            for (int j = 0; j < n; j++) { //終点
                if (dist[i][k] != INF && dist[k][j] != INF) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }

    //負の閉路を検出
    for (int i = 0; i < n; i++) {
        if (dist[i][i] < 0) return true;
    }
    return false;
}

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

    dist.resize(n, vector<ll>(n, INF));
    for (int i = 0; i < m; i++) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = dist[b][a] = c;
    }

    warshall_floyd(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j) continue;
            if (dist[i][j] > L) dist[i][j] = INF;
            else dist[i][j] = 1;
        }
    }

    warshall_floyd(n);
    
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (dist[s][t] >= INF ? -1 : dist[s][t] - 1) << "\n";
    }
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  int c = a*b;
  if (c % 2 == 0) {
    cout << "Even" << endl;
  }else cout << "Odd" << endl;
  
}

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

long long a;
int lb, rb;

int main () {
    while (scanf("%lld %d.%d", &a, &lb, &rb) == 3) {
        long long res = 0;
        res += a * lb * 100;
        res += a * (rb / 10) * 10;
        res += a * (rb % 10);
        res /= 100;
        printf("%lld\n", res);
    }
}



Measured memory_bytes: 3824
# A
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def db(x): 
    global debug
    if debug: print(x)
debug = True
N,A,B = getIntList()
mx = min(A,B)
mn = max(A+B-N,0)
print(mx,mn)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 10;
int k;
bool visited[N];

int main() {
    cin >> k;
    deque <ii> que;
    que.push_back({1, 1});
    while (1) {
        auto[n, c] = que.front();
        que.pop_front();
        if (visited[n]) continue;
        visited[n] = true;
        if (!n) {
            cout << c << endl;
            exit(0);
        }
        int n1 = n * 10 % k;
        int n2 = (n + 1) % k;
        que.push_front({n1, c});
        que.push_back({n2, c + 1});
    }

    return 0;
}


Measured memory_bytes: 4428
unittest
{
	assert( [ "2", "2", "3" ].parse.expand.solve == 6 );
	assert( [ "5", "2", "5", "10", "1000000000000000000", "1000000000000000000" ].parse.expand.solve == 1000000000000000000 );
}



import std.algorithm;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	auto ts = new long[ n ];
	foreach( ref t; ts )
	{
		input.popFront;
		t = input.front.strip.to!( long );
	}
	return tuple( ts );
}

auto solve( long[] ts )
{
	auto us = ts.sort!( ( a, b ) => b < a ).uniq;
	auto r = us.front;
	us.popFront;
	
	// 最小公倍数を計算
	foreach( u; us )
	{
		r = r / gcd( r, u ) * u;		// オーバーフローしないように割り算を先にやる
	}
	
	return r;
}


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

int main()
{
	std::vector<int> height(10);

	for(size_t i=0; i<height.size(); ++i)
	{
		std::cin >> height[i];
	}

	std::sort(height.begin(),height.end());

	for(size_t i=0; i<3; ++i)
	{
		std::cout << height[height.size()-1-i] << '\n';
	}
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a){
  return 0<=a&&a<=5000;
}
int main(){
  while(cin>>n&&n){
    int x[5000],y[5001],an=0;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i],p[x[i]][y[i]]=1;
    for(int i=0;i<n;i++)
      for(int j=i;j<n;j++){
	int dx=x[i]-x[j],dy=y[i]-y[j];
	int x1=x[i]-dy,y1=y[i]+dx,x2=x[j]-dy,y2=y[j]+dx;
	int x3=x[i]-dy,y3=y[i]+dx,x4=x[j]+dy,y4=y[j]-dx;
	if(c(x1)&&c(y1)&&p[x1][y1]&&c(x2)&&c(y2)&&p[x2][y2])
	  an=max(an,dx*dx+dy*dy);
	if(c(x3)&&c(y3)&&p[x3][y3]&&c(x4)&&c(y4)&&p[x4][y4])
	  an=max(an,dx*dx+dy*dy);
      }
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 25004
S = input()
a = int(S[:2])
b = int(S[2:])
ret = ""
if 1 <= a and a <= 12 and 1 <= b and b <= 12:
    ret = "AMBIGUOUS"
elif 1 <= a and a <= 12:
    ret = "MMYY"
elif 1 <= b and b <= 12:
    ret = "YYMM"
else:
    ret = "NA"
print(ret)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
template<typename ll_t,ll_t mod>
class basic_modint{
public:
    ll_t x_;
    basic_modint(ll_t x=0):x_((x%mod+mod)%mod){}
    basic_modint& operator+=(const basic_modint a)       { if((x_+=     a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator-=(const basic_modint a)       { if((x_+= mod-a.x_)>=mod)x_-=mod; return *this; }
    basic_modint& operator*=(const basic_modint a)       { (x_*=a.x_)%=mod; return *this; }
    basic_modint  operator+ (const basic_modint a) const { basic_modint res(*this); return res+=a; }
    basic_modint  operator- (const basic_modint a) const { basic_modint res(*this); return res-=a; }
    basic_modint  operator* (const basic_modint a) const { basic_modint res(*this); return res*=a; }
    basic_modint  pow(ll_t t) const { if(t==0)return 1; basic_modint a = pow(t>>1); a*=a; if(t%2==1)a*=(*this); return a; }
    basic_modint  inv() const { return pow(mod-2); }
    basic_modint& operator/=(const basic_modint a)       { return (*this) *= a.inv(); }
    basic_modint  operator/ (const basic_modint a) const { basic_modint res(*this); return res/=a; }
    friend istream& operator>>(istream& ist, basic_modint& a) { ist>>a.x_; return ist; }
    friend ostream& operator<<(ostream& ost, basic_modint& a) { ost<<a.x_; return ost; }
    bool operator==(const basic_modint a){return x_==a.x_; }
    bool operator!=(const basic_modint a){return x_!=a.x_; }
};
using mint = basic_modint<ll,ll(1e9+7)>;
//dp[i][j]=i人未満のグループでj人を分ける場合の数
constexpr int max_N=1010;
mint factorial[max_N],finv[max_N],inv[max_N],dp[max_N][max_N];
mint ncr(int i,int j){
    if(i<j)return 0;
    return factorial[i]*finv[j]*finv[i-j];
}
int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    factorial[0]=1;
    rep(i,1,max_N)factorial[i]=factorial[i-1]*i;
    loop(i,max_N)finv[i]=factorial[i].inv();
    rep(i,1,max_N)inv[i]=mint(i).inv();
    loop(i,max_N)dp[i][0]=1;
    rep(i,a,b+1)loop(j,n+1){
        if(dp[i][j]==0)continue;
        if(j!=0)dp[i+1][j]+=dp[i][j];
        mint p=1;
        for(int k=1;k<=d&&j+i*k<=n;++k){
            p*=ncr(n-j-i*(k-1),i)*inv[k];
            if(k>=c)dp[i+1][j+i*k]+=dp[i][j]*p;
        }
    }
    cout << dp[b+1][n] << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#define ll long long
using namespace std;
const ll md = 1000000007;
string mp[1000]={};int h,w;
ll dp[2][1001]={};
int main()
{
	cin>>h>>w;
	for (int i=0;i<h;i++)
	{
		cin>>mp[i];
	}
	dp[1][1] = 1;mp[0][0]='#';
	for (int i=1;i<=h;i++)
	{
		for (int j=1;j<=w;j++)
		{
			if (i!=1||j!=1) {dp[i%2][j]=0;}
			if (mp[i-1][j-1]!='#') 
			{
				dp[i%2][j] = dp[i%2][j-1]+dp[(i-1)%2][j];
				dp[i%2][j] %= md;
			}
		}
	}
	cout<<dp[h%2][w]<<"\n";
	return 0;
}

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

using Int = long long;

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

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

	std::vector<std::vector<Int>> a(N, std::vector<Int>(3));
	for (Int i = 0; i < N; i++)for (Int j = 0; j < 3; j++)std::cin>>a[i][j];

	std::vector<std::vector<Int>> dp(N + 5, std::vector<Int>(3,0));

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < 3; j++) {
			for (Int k = 0; k < 3; k++) {
				if (k == j)continue;
				chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
			}

		}
	}
	Int ans = 0;
	for (Int i = 0; i < 3; i++)chmax(ans, dp[N][i]);

	std::cout << ans << std::endl;


}

Measured memory_bytes: 11136
from heapq import*
R=range;I=lambda:map(int,input().split());n=int(input());g=[[]for _ in R(n+1)];z=[-1]*n;d=[1e9]*n+[0];q=[-1]*(n+1);r='';Q=[];heappush(Q,(0,-2,n))
for _ in R(n-1):a,b=I();a-=1;b-=1;g[a]+=[(1,a,b)];g[b]+=[(1,b,a)]
for _ in R(*I()):a,b=I();a-=1;g[n]+=[(b,n,a)];z[a]=b
while Q:
	e=heappop(Q)
	if q[e[2]]!=-1:continue
	q[e[2]]=e[1]
	for f in g[e[2]]:
		if d[f[2]]>e[0]+f[0]:d[f[2]]=e[0]+f[0];heappush(Q,(e[0]+f[0],f[1],f[2]))
for _ in g:
	if any(n!=e[1]and abs(d[e[1]]-d[e[2]])!=1 for e in _):r="No"
if any(~z[i]and z[i]!=d[i]for i in R(n)):r="No"
print(r or"Yes\n"+"\n".join(map(str,d[:n])))

Measured memory_bytes: 70856
#include <bits/stdc++.h>
using namespace std;
int dp[1002][1002];
const int mod = 1e9+7;
int rec(vector<string>&grid, int i, int j, int h, int w){
	int ans = 0;
	if (i == h-1 and j == w-1){
		return 1;
	}
	else if (i == h or j == w){
		return 0;
	}
	else if (grid[i][j] == '.'){
		if(dp[i][j] != -1){
			return dp[i][j];
		}
		ans += (rec(grid, i+1, j, h, w)+rec(grid, i, j+1, h, w))%mod;
		// cout << "y";
	}
	return dp[i][j] = ans;
}

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>grid;
	memset(dp, -1, sizeof(dp));
	for(int i = 0; i < h; i++){
		string s;
		cin >> s;
		grid.push_back(s);
	}
	cout << rec(grid, 0, 0, h, w) << "\n";
	return 0;
}

Measured memory_bytes: 8692
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long dp[2004];
long long ways(int s)
{
    if(s==0)
    {
        return 1;
    }
    if(s<0)
        return 0;
    if(dp[s]!=-1)
        return dp[s];
    long long ans=0;
    for(int i=3;i<=s;i++)
    {
        ans=(ans+ways(s-i))%mod;
    }
    return dp[s]=ans;
}
int main()
{
    int s;
    cin>>s;
    memset(dp,-1,sizeof(dp));
    long long ans=ways(s)%mod;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,e,tmp[10],tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dat[10];
ll zyuu;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,5)cin>>tmp[i];
    ll mi=tmp[0];
    rrep(i,1,5){
        mi=min(mi,tmp[i]);
        tmp[i]=mi;
    }
    rep(i,4){
        if(tmp[i]!=tmp[i+1]){
            cnt++;
            ans+=max(cnt+(max(n-tmp[i],0LL)%tmp[i]==0?max(n-tmp[i],0LL)/tmp[i]:max(n-tmp[i],0LL)/tmp[i]+1)-zyuu,0LL);
            //zyuu=cnt+(max(n-tmp[i],0LL)%tmp[i]==0?max(n-tmp[i],0LL)/tmp[i]:max(n-tmp[i],0LL)/tmp[i]+1);
            ll sa=cnt+(max(n-tmp[i],0LL)%tmp[i]==0?max(n-tmp[i],0LL)/tmp[i]:max(n-tmp[i],0LL)/tmp[i]+1)-cnt;
            zyuu=sa;
            //ans-=zyuu;
            cnt=0;
        }
        else cnt++;
    }
    cnt++;
    ans+=max(cnt+(max(0LL,n-tmp[4])%tmp[4]==0?max(0LL,n-tmp[4])/tmp[4]:max(0LL,n-tmp[4])/tmp[4]+1)-zyuu,0LL);
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#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 edge(i, u) for (int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define mod 1000000007
#define ll long long
#define N 205
#define pb push_back
int n, m, x, y, a, b, c;
int main ()
{
    scanf("%d %d %d", &n, &x, &y);
    fo (i, 1, n) 
    {
        scanf("%d", &m);
        if (m <= x)
            ++a;
        else
        if (m <= y)
            ++b;
        else
            ++c;
    }
    printf("%d", std::min(std::min(a, b), c));
}

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

int main() {
 int N;
 int D;
 cin >> N >> D;
 if(N%(2*D+1)==0){
 cout << N / (2*D+1) << endl;
 } else{
     cout << N / (2*D+1) + 1 << endl;
 }
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int n, r;
	int array[51];
	int tmp[51];
	while (1) {
		scanf("%d %d", &n, &r);
		if (n == 0 && r == 0) break;

		for (int i = 1; i <= n; i++) {
			array[i] = i;
		}
		for (int i = 0; i < r; i++) {
			int p, c;
			scanf("%d %d", &p, &c);
			for (int j = 0; j < c; j++) {
				tmp[j] = array[n - (p - 1) - j];
			}
			for (int j = 0; j < (p - 1); j++) {
				array[n - (p - 1) - c + 1 + j] = array[n - (p - 1) + 1 + j];
			}
			for (int j = 0; j < c; j++) {
				array[n - c + 1 + j] = tmp[c - 1 - j];
			}
		}
		printf("%d\n", array[n]);
	}
}

Measured memory_bytes: 1028
// Comment
// easy

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

int N, Nr[MAX_N];
int main() {
	cin >> N;
	for(int i=0; i<N; i++) {
		scanf("%d", &Nr[i]);
		Nr[i] -= (i+1);
	}
	sort(Nr, Nr+N);
	ll ans = 0;
	for(int i=0; i<N; i++) {
		ans += abs(Nr[i] - Nr[N/2]);
	}
	cout << ans << endl;
	return 0;
}


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

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n, m;
int a[N], b[N];

int main() {
  scanf("%d%d", &n, &m);
  for(int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  for(int j = 0; j < m; j++) {
    scanf("%d", b + j);
  }
  vector<long long> v, u;
  for(int i = 0; i < m - 1; i++) {
    v.push_back(b[i + 1] - b[i]);
  }
  for(int i = 0; i < n - 1; i++) {
    u.push_back(a[i + 1] - a[i]);
  }
  long long ans = 0, cnt = 0, cry = 0;
  for(int i = 0; i < m - 1; i++) {
    cry = (cry + (long long)(i + 1) * (m - 1 - i) % MOD * v[i] % MOD) % MOD;
  }
  for(int i = 0; i < n - 1; i++) {
    ans = (ans + ((long long)(i + 1) * (n - 1 - i) % MOD) * cry % MOD * u[i] % MOD) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
      int x, y; cin >> x >> y;
      for (int i=0; i<=x; i++){
          if (2*i+4*(x-i)==y){
              cout << "Yes" << endl;
              return 0;
          }
      } 
      cout << "No" << endl;
}

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

typedef long long ll;

int n;
ll tot, a[20];
ll ans;

int main()
{
	scanf("%d", &n);
	
	ans = 1, --n;
	while(n--) {
		//printf("%d ", ans);
		
		tot = 0;
		while(ans) {
			a[++tot] = ans % 10;
			ans /= 10;
		}
		
		a[tot + 1] = a[tot] + 1;
		for(int i = 1; i <= tot; ++i) {
			if(a[i + 1] >= a[i] && (i == tot || a[i] < 9)) {
				++a[i];
				for(int j = i - 1; j >= 1; --j)
					a[j] = max(a[j + 1] - 1, 0ll);
				break;
			}
		}
		
		if(a[tot] > 9) {
			a[++tot] = 1;
			for(int i = 1; i < tot; ++i)
				a[i] = 0;
		}
		
		for(int i = tot; i >= 1; --i)
			ans = ans * 10 + a[i];
	}
	printf("%lld", ans);
}

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main(){
	int n;
	int m;
	cin >> n >> m;
	vector<int> x(n);
	int res = 0;
	vector<int> moded(m,0);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		moded[x[i] % m]++;
	}

	sort(ALL(x));
	for (int i = 0; i < m; i++) {
		if (i != (m - i) % m) {
			int sa = min(moded[(m - i) % m], moded[i]);
			res += sa;
			moded[i] -= sa;
			moded[(m - i) % m] -= sa;
		}
		else {

			int sa = moded[i] / 2;
			res += sa;
			moded[i] -= sa * 2;
		}

	}
	for (int i = 1; i < n; i++) {
		if (x[i] == x[i - 1]&& moded[x[i]%m]>=2) {
			res++;
			moded[x[i] % m] -= 2;
			i++;
		}
	}

	cout << res << endl;
	return 0;



}



Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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


	int n;
	cin >> n;
	if (n==1) {
		cout << 1 << endl;
		cout << "0" << endl;
	}
	else if (n==2) {
		cout << 2 << endl;
		cout << "0" << endl;
		cout << "11" << endl;
	}
	else {
		cout << n - 1 << endl;
		for (int i = 2; i <= n;i++) {
			cout << '0';
			rep(j, i - 2)cout << '1';
			cout << '0';
			cout << endl;
		}
	}




	return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define SC(a) scanf("%c", &a);
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int K, A, B;

int main() {
	S3(K, A, B);
	int a = B - A;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) {
			printf("OK");
			return 0;
		} 
	}
	printf("NG");
}



Measured memory_bytes: 3748
#include<stdio.h>
int main(){
  int n,m,i,j,k,l,min,d;
  int ic[150],is[2][150][10];
  int c[80][150][11];
  while(scanf("%d %d",&n,&m),n||m){
    int c[80][150][11]={0};
    for(i=0;i<80;i++){
      for(j=1;j<150;j++){
	for(k=0;k<11;k++)c[i][j][k]=2100000000;
      }
    }
    for(i=0;i<11;i++)c[1][1][i]=0;
    for(i=0;i<n;i++){
      scanf("%d",&ic[i]);
      for(j=0;j<ic[i];j++){
	scanf("%d %d",&is[0][i][j],&is[1][i][j]);
      }
    }
    for(i=0;i<=m;i++){
      for(j=0;j+1<n;j++){
	for(k=0;k<ic[j];k++){
	  for(l=0;l<ic[j+1];l++){
	    d=(is[1][j][k]+is[1][j+1][l])*abs(is[0][j][k]-is[0][j+1][l]);
	    //printf("d%d from %d %d to %d %d\n",
	    //	   d,is[0][j][k],is[1][j][k],is[0][j+1][l],is[1][j+1][l]);
	    if(c[i][j+1][l]>c[i][j][k]+d)c[i][j+1][l]=c[i][j][k]+d;
	  }
	  if(j+2==n)continue;
	  for(l=0;l<ic[j+2];l++){
	    d=(is[1][j][k]+is[1][j+2][l])*abs(is[0][j][k]-is[0][j+2][l]);
	    //printf("d%d from %d %d to %d %d\n",
	    //	   d,is[0][j][k],is[1][j][k],is[0][j+2][l],is[1][j+2][l]);
	    if(c[i+1][j+2][l]>c[i][j][k]+d)c[i+1][j+2][l]=c[i][j][k]+d;
	  }
	}
      }
    }
    /*for(i=0;i<=m;i++){
      for(j=0;j<n;j++){
	for(k=0;k<ic[j];k++)printf("%d ",c[i][j][k]);printf("\n");
      }printf("\n");
      }//*/
    min=2100000210;
    for(i=0;i<=m;i++){
      for(j=0;j<ic[n-1];j++){
	if(min>c[i][n-1][j])min=c[i][n-1][j];
      }
      if(m==i)continue;
      for(j=0;j<ic[n-2];j++){
	if(min>c[i][n-2][j])min=c[i][n-2][j];
      }
    }
    printf("%d\n",min);
  }
  return 0;
}


	    
	      

Measured memory_bytes: 1136