akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define en '\n'
#define fs first
#define sd second

const ll INF = INT64_MAX;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n = 100;
    ll k, res = 0;
    cin >> k;
    while(n < k){
        n += n/100;
        ++res;
    }
    cout << res;
}

Measured memory_bytes: 3636
n = int(input())
ls_xu = [[_ for _ in input().split()] for _ in range(n)]

ans = 0

for i in range(n):
    if ls_xu[i][1] == 'JPY':
        ans += float(ls_xu[i][0])
    elif ls_xu[i][1] == 'BTC':
        ans += float(ls_xu[i][0]) * 380000

print(ans)

Measured memory_bytes: 3060
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    a, b = input().split()

    print('H') if (a == 'H' and b == 'H') or (a == 'D' and b == 'D') else print('D')

if __name__ == '__main__':
    main()

Measured memory_bytes: 10316
a, b = map(int, input().split())
x = []
if a % 2 == 0:
    m = a
else:
    m = a + 1
    x.append(a)
if b % 2 == 1:
    l = b
else:
    l = b - 1
    x.append(b)
x.append(((l - m + 1) // 2) % 2)
ans = 0
for i in x:
    ans ^= i
print(ans)

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

using namespace std;

int main(){
	long long x,k,d; cin >> x >> k >> d;
	x = abs(x);
	long long times = (x/d);
	if(k < times) {
		cout << abs(x - k*d) << endl;
		return 0;
	}
	
	if(times % 2 == k % 2 ) {
		cout << abs(x - (times)*d) << endl;
	}else cout << abs(x - (times+1)*d) << endl;
	
	return 0;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;

 
 class Main {
  public static void main(String[] args) throws IOException{
      
 
        for( int i= 1; i <= 9 ; i++ ) {
          for ( int j= 1; j <= 9 ; j++){
             System.out.println( i+ "x" + j +"="+i*j) ; 
             }
             }
             
  }
  }
            
        
        
        

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

int main() {

	ll n; cin >> n;
	const ll p = 5;
	vector<ll> c(p);
	ll ans = 4;
	for (ll i = 0; i < p; i++) {
		cin >> c[i];
	}
	ll minValue = c[min_element(c.begin(), c.end()) - c.begin()];
	ans += (n + minValue - 1) / minValue;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    int n,k;
    cin>>n>>k;
    int p[n];
    rep(i,n) cin>>p[i];
    //範囲を選ぶの全パターンはn-k+1通りある
    //0~n-k

    vector<bool> X(n-k+1,true);

    int ans=0;
    set<int> st;
    rep(i,k) st.insert(p[i]);
    for(int i=0;i<n-k;i++){
        auto it1=st.lower_bound(p[i]);
        auto it2=st.lower_bound(p[i+k]);
        if(it1==st.begin()&&it2==st.end()){
            X[i+1]=false;
        }
        st.erase(it1);
        st.insert(p[i+k]);
    }
    //初期盤面が2回以上出てくるときだけそのダブリを省ければいい
    //初期盤面とのダブりをどうやって調べる?
    //imos
    vector<int> imos(n,0);
    for(int j=0;j<n-1;j++){
        if(p[j]>p[j+1]){
            imos[max(0,j-(k-2))]++;
            imos[j+1]--;
        }
    }
    vector<int> sm(n,0);
    sm[0]=imos[0];
    for(int i=1;i<n;i++){
        sm[i]=sm[i-1]+imos[i];
    }
    int cnt=0;
    for(int i=0;i<n-k+1;i++){
        if(sm[i]<=0){
            cnt++;
            X[i]=false;
        }
    }
    rep(i,X.size()){
        if(X[i]) ans++;
    }
    if(cnt==0){
        cout<<ans<<endl;
    }
    else{
        cout<<ans+1<<endl;
    }
    return 0;
}
/*
8 4
2 3 5 4 6 7 8 1
*/


Measured memory_bytes: 12032
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rnk=[0]*(n+1)

    def Find_Root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)
        if x==y:
            return
        elif self.rnk[x]>self.rnk[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y]+=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
ans=[0]*m
ans.append((n*(n-1))//2)
for i in range(m-1,-1,-1):
    a,b=ab[i][0],ab[i][1]
    if uf.isSameGroup(a,b):
        ans[i]=ans[i+1]
    else:
        ans[i]=ans[i+1]-uf.Count(a)*uf.Count(b)
        uf.Unite(a,b)
for i in range(1,m+1):
    print(ans[i])


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

vector<int> enum_div(int n){
    //O(n^1/2)
    vector<int> ret;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ret.push_back(i);
            if(i!=1&&i*i!=n)//<-if i*i==n then same number will be inserted
            {
                ret.push_back(n/i);
            }
        }
    }
    //sort(ret.begin(),ret.end());//if needed
    return ret;
}
int main(){
    int n,ans=0;
    cin>>n;
    for(int i=3;i<=n;i+=2){
        if(enum_div(i).size()==7){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
from math import floor
from sys import exit

def isinteger(n):
    if isinstance(n,int):
        return True
    if isinstance(n,float):
        return n.is_integer()
    return False

n = int(input())
for i in range(floor(1700*n/(7000-n)-1),floor(3*n/4)+2):
    if 14000*i != (3500+i)*n and 4*i != n:
        mini = 3500*n*i/(14000*i-(3500+i)*n)
        maxi = 2*n*i/(4*i-n)
        for j in range(floor(mini)-1,floor(maxi)+2):
            if i!=0 and j!=0 and 4/n != 1/i+1/j:
                w = 1/(4/n-1/i-1/j)
                if abs(w-round(w))<=10**(-8) and 3500>=w>=1 and j >= 1 and i >= 1:
                    exit(print(i,j,round(w)))
            else:
                continue
    else:
        continue

Measured memory_bytes: 9500
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;

class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
        
        if (a >= b) {
        	System.out.println("delicious");
        } else if (a < b && x >= b - a) {
        	System.out.println("safe");
        } else {
        	System.out.println("dangerous");
        }
  
    
    
}
}

Measured memory_bytes: 22604
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[200005];

bool C(int v){
    stack<P> st;
    st.push(P(0,1));
    if(a[0]!=1)st.push(P(a[0]-1,1));
    for(int i=1;i<n;i++){
        if(a[i-1]<a[i])continue;
        if(v==1)return false;
        int pos=a[i]-1;
        while(1){
            while(st.top().first>pos){
                st.pop();
            }
            if(st.top().first!=pos){
                st.push(P(pos,2));
                break;
            }else{
                if(st.top().second==v){
                    if(pos==0)return false;
                    pos--;
                    st.pop();
                }else{
                    st.top().second++;
                    break;
                }
            }
        }
    }
    return true;
}

int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    int l=0,r=200005;
    while(r-l>1){
        int mid=(l+r)/2;
        if(C(mid))r=mid;
        else l=mid;
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
long Gcd(long m, long n)
{
	long temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

int main(){
    long int A, B, C, D;
    long int cnt = 0;
    scanf("%ld %ld %ld %ld", &A, &B, &C, &D);
    int i, j, k;
    long int work=C*D/Gcd(D, C);
    cnt = B-(B/C+B/D-B/work);
    cnt -= A-(A/C+A/D-A/work);
    if(A % C != 0 && A % D != 0)
        cnt += 1;
    printf("%ld", cnt);
}

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

int main() {
  
  int N;
  string A = "Three";
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if ( S == "Y") A ="Four";
  }
  cout << A << endl;
}


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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

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

    ll n;
    cin >> n;
    ll a[n+2] , cnt[n+2]={};
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }

    ll ans = 0;
    for(int i=1; i<=n; i++)
    {
        if (!cnt[i]) continue;
        ans += (cnt[i]*(cnt[i]-1)/2);
    }

    for(int i=1; i<=n; i++)
    {
        ll cur = a[i];
        ans -= (cnt[cur] * (cnt[cur]-1)/2);
        cnt[cur]--;
        ans += (cnt[cur] * (cnt[cur]-1)/2);
        cout << ans << '\n';
        ans -= (cnt[cur] * (cnt[cur]-1)/2);
        cnt[cur]++;
        ans += (cnt[cur] * (cnt[cur]-1)/2);
    }
    return 0;
}


Measured memory_bytes: 5760
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int sum = a;

            for (int i = 0; i < b; i++) {
                sum += a;
                if (sum % b == c) {
                    out.println("YES");
                    return;
                }
            }
            out.println("NO");

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

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

void insert(int);
void inorder(struct Node *);
void preorder(struct Node *u);

struct Node *root,*NIL;

int main(){
  int m,i,k;
  char com[20];

  scanf("%d",&m);

  for(i=0;i<m;i++){
  scanf("%s",com);
 
  if(com[0]=='i'){
    scanf("%d",&k);
    insert(k);
  }
  else if (com[0]=='p'){
  inorder(root);
  printf("\n");
  preorder(root);
  printf("\n");
    }
  }
  return 0;
}


void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(sizeof(struct Node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;

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

void inorder(struct Node *u){
if(u==NIL)  return;

inorder(u->left);
printf(" %d",u->key);
inorder(u->right);

}

void preorder(struct Node *u){
if(u==NIL)  return;

printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}





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

int main(void)
{
    int w, n;
    std::cin >> w >> n;

    std::vector<int> a(n), b(n);
    char temp;

    for(int i = 0; i < n; ++i)
    {
        std::cin >> a[i] >> temp >> b[i];
    }

    std::vector<int> result(n);
    for(int i = 0; i < w; ++i)
    {
        result[i] = i + 1;
    }

    for(int i = 0; i < n; ++i)
    {
        std::swap(result[a[i] - 1], result[b[i] - 1]);
    }

    for(int i = 0; i < w; ++i)
    {
        std::cout << result[i] << std::endl;
    }

    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  100005
ll vis[N],b[N][2],od[N],ch[N];
vi v[N],t[N];
map<pair<ll,ll>,ll> ma; 
void findtree(ll x)
{
	vis[x]=1;
	for(auto i:v[x])
	{
		if(vis[i]==1)
			continue;
		t[i].pb(x);
		t[x].pb(i);
		findtree(i);
	}
}
ll dfs(ll x)
{
	// cout<<x<<endl;
	vis[x]=1;
	ll k=0;
	if(od[x]%2==1)
		k++;
	for(auto i:t[x])
	{
		if(vis[i]==1)
			continue;
		// cout<<"ww   "<<x<<" "<<i<<endl;
		ll y=dfs(i);
		if(y%2==1)
		{
			// cout<<"1        "<<ma[{i,x}]<<" "<<i<<" "<<x<<endl;
			ch[ma[{i,x}]]++;
		}
		k+=y;
	}
	// cout<<x<<" "<<k<<endl; 
	return k;
}
int main()
{
	ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n>>m;
    	clr(od,0);
    	clr(ch,0);
    	for(i=0;i<m;i++)
    	{
    		cin>>k>>l;
    		b[i][0]=k;
    		b[i][1]=l;
    		ma[{k,l}]=i;
    		ma[{l,k}]=i;
    		v[k].pb(l);
    		v[l].pb(k);
    		od[k]++;
    	}
    	if(m%2==1)
    	{
    		cout<<-1;
    		return 0;
    	}
    	clr(vis,0);
    	findtree(1);
    	clr(vis,0);
    	dfs(1);
    	for(i=0;i<m;i++)
    	{	
    		if(ch[i]%2==0)
    			cout<<b[i][0]<<" "<<b[i][1]<<endl;
    		else
    			cout<<b[i][1]<<" "<<b[i][0]<<endl;
    	}
    }
    return 0;
}

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

int main() {
    ll n,m;
    std::cin >> n>>m;
    string s;
    std::cin >> s;
    reverse(s.begin(),s.end());
    vector<bool> dp(n+1,false);
    vector<ll> ans;
    ans.push_back(0);
    for (int i = m; i < n; i++) {
        bool ok = false;
        for (int j = i; j > i-m; j--) {
            if(s[j]=='0'){
                i = j+m-1;
                ans.push_back(j);
                // std::cout << j << std::endl;
                ok = true;
                break;
            }
        }
        if(!ok){
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    ans.push_back(n);
    reverse(ans.begin(),ans.end());
    for (int i = 0; i < ans.size()-1; i++) {
        std::cout << ans[i]-ans[i+1]<<" ";
    }
    std::cout << std::endl;
}

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

using namespace std;
typedef long long LL;
int main(){
    string S;
    string T[4] = {"dream", "dreamer", "erase", "eraser"};
    cin >> S;

    for(LL i = 0; i < S.size();){
        if(S[i] == 'd'){
            if(S.substr(i, 7) == T[1] && S[i + 7] != 'a'){
                i += 7;
            }else if(S.substr(i, 5) == T[0]){
                i += 5;
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else if(S[i] == 'e'){
            if(S.substr(i, 6) == T[3] && S[i + 6] != 'a'){
                i += 6;
            }else if(S.substr(i, 5) == T[2]){
                i += 5;
            }else{
                cout << "NO" << endl;
                return 0;
            }
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 512
N = int(input())
F = list(list(map(int,input().split())) for i in range(N))
P = list(list(map(int,input().split())) for i in range(N))

ans = -float("inf")
for bit in range(1 << 10) :
    expl = []
    for k in range(10) :
        if bit & (1 << k) :
            expl.append(k)
    if len(expl) :
        benefit = 0
        for i in range(N) :
            cnt = 0
            for j in range(len(expl)) :
                if F[i][expl[j]] :
                    cnt += 1
            benefit += P[i][cnt]
        if ans < benefit :
            ans = benefit
print(ans)


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    vector<ll> v[4];

    ll n, limit;
    cin >> n >> limit;
    ll val, w1;
    cin >> w1 >> val;
    v[0].push_back(val);
    rep(i, n - 1)
    {
        ll w;
        cin >> w >> val;
        v[w - w1].push_back(val);
    }
    rep(i, 4) sort(ALL(v[i]), greater<ll>());
    ll maxv = 0;

    rep(i, v[0].size() + 1)
    {
        ll v0 = (!v[0].empty() ? accumulate(v[0].begin(), v[0].begin() + i, 0) : 0);
        rep(j, v[1].size() + 1)
        {
            ll v1 = (!v[1].empty() ? accumulate(v[1].begin(), v[1].begin() + j, 0) : 0);
            rep(k, v[2].size() + 1)
            {
                ll v2 = (!v[2].empty() ? accumulate(v[2].begin(), v[2].begin() + k, 0) : 0);
                rep(l, v[3].size() + 1)
                {
                    ll v3 = (!v[3].empty() ? accumulate(v[3].begin(), v[3].begin() + l, 0) : 0);
                    if (i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3) <= limit)
                        maxv = max(maxv, v0 + v1 + v2 + v3);
                }
            }
        }
    }

    OP(maxv);

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

const long long MOD = 1000000007;

long long exp(long long a, int x) {
    if(x == 0)return 1LL;
    ll tmp = exp(a, x/2);
    if(x % 2 == 1) return tmp * tmp % MOD * a % MOD;
    return tmp * tmp % MOD;
}

void solve() {

    int x, y;
    SI(x); SI(y);
    if(x < y)swap(x, y);

    int tmp = x - y;

    if (y - tmp < 0 || (y - tmp) % 3 != 0) {
        puts("0");
    } else {
        int a = tmp + (y - tmp) / 3;
        int b = (y - tmp) / 3;

        long long xx = 1;
        long long yy = 1;
        long long zz = 1;
        REPP(i, 1, a) {
            xx *= i;
            xx %= MOD;
        }
        REPP(i, 1, b) {
            yy *= i;
            yy %= MOD;
        }

        REPP(i, 1, a+b) {
            zz *= i;
            zz %= MOD;
        }

        zz *= exp(xx, MOD-2);
        zz %= MOD;
        zz *= exp(yy, MOD-2);
        zz %= MOD;
        printf("%lld\n", zz % MOD);
    }
}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int M = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int x,y,a,b,c;
ll p[N],q[N],r[N];


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>x>>y>>a>>b>>c;
    for (int k = 1; k <100005; ++k) {
        p[k]=q[k]=r[k]=20000000000;
    }
    for (int i = 1; i <=a ; ++i) {
        cin>>p[i];
    }
    for (int i = 1; i <=b ; ++i) {
        cin>>q[i];
    }
    for (int i = 1; i <=c ; ++i) {
        cin>>r[i];
    }
    sort(p+1,p+1+a);
    sort(q+1,q+1+b);
    sort(r+1,r+1+c);
    ll ans=0;
    int cnt=0;
    for (int j = a; j >=1 ; --j) {
        ans+=p[j];
        cnt++;
        if(cnt==x)break;
    }
    cnt=0;
    for (int j = b; j >=1 ; --j) {
        ans+=q[j];
        cnt++;
        if(cnt==y)break;
    }
    int l=a-x+1,rs=b-y+1;
    int pos=c;
    while(pos>=1){
        if(l>a&&rs>b)break;
        if(r[pos]<=q[rs]&&r[pos]<=p[l])break;
        if(q[rs]<=p[l]&&r[pos]>q[rs]){
            ans-=q[rs];
            rs++;
            ans+=r[pos];
            pos--;
        }else{
            if(r[pos]>p[l]){
                ans-=p[l];
                l++;
                ans+=r[pos];
                pos--;}
        }
    }
    cout<<ans;
    return 0;

}

Measured memory_bytes: 9216
#include <stdio.h>

int main(void) {
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x-r)<0||(x+r)>W||(y-r)<0||(y+r)>H){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
let analysis (area:string) =
  let len = String.length area in
  let stack = Stack.create () in
  let rec loop acc = function
      i when i = len -> acc
    | i ->
      match area.[i] with
      | '\\' -> Stack.push i stack; loop acc (i+1)
      | '/' -> loop
                 (match Stack.length stack with
                    0 -> acc
                  | _ -> let j = Stack.pop stack in
                    (((j,i),i-j)::acc))
                 (i+1)
      | _ -> loop acc (i+1)
  in loop [] 0

let summarize lst =
  let rec loop acc = function
      []  -> acc
    | [x] -> x::acc
    | ((s1,e1),v1)::((s2,e2),v2)::r when s1 < s2 && e1 > e2 ->
      loop acc (((s1,e1), v1+v2)::r)
    | a::(b::r as rest) -> loop (a::acc) rest
  in loop [] lst

let () =
  let line = read_line () in
  let count = ref 0 in
  let buf = Buffer.create 128 in
  analysis line |> summarize
  |> List.fold_left
    (fun acc (_,v) ->
       incr count;
       Buffer.add_string buf (Printf.sprintf " %d" v);
       acc+v)
    0
  |> (fun sum -> Printf.printf "%d\n%d%s\n" sum !count (Buffer.contents buf))

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

int main(){
  int N, M, A, B;
  cin >> N >> M;
  //N = 展望台の総数     M = 道の総数
  vector <int> H (N);//展望台 i の高さ
  //vector <int> L (N);//展望台 i に接してる道の本数(やっぱ出番なかった)
  vector <int> Good (N);//展望台 i が良い展望台か判定する用の配列
  int nice = 0;//良い展望台の数
  //-----------------------------------
  
  for(int i = 0; i < N; i++){
    
    cin >> H.at(i);//H.at(0) ~ H.at(N - 1)
    
  }
  
  for(int i = 0; i < M; i++){
    //道の両端の展望ABを比較し、
    //低い方のGoodを増やす
    //引き分けは両方増やす
    cin >> A >> B;
    if(H.at(A - 1) > H.at(B - 1)) Good.at(B - 1)++;
    else if(H.at(A - 1) < H.at(B - 1)) Good.at(A - 1)++;
    else {
      Good.at(A - 1)++;
      Good.at(B - 1)++;
    }
    
  }
  
  //この時点でGood.at(i)が0なら 展望台iは良い展望台
  
  for(int i = 0; i < N; i++){
    if(Good.at(i) == 0)nice++;
  }
  cout << nice << endl;
}

Measured memory_bytes: 4052
#include <iostream>
#include <float.h>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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




int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n)
		cin >> v[i];
	int odd = 0;
	int even = 0;
	rep(i, n) {
		if (v[i] % 2 == 0)
			even++;
		else
			odd++;
	}
	int maximum = 1;
	rep(i, n) {
		maximum *= 3;
	}
	if (n == 1) {
		cout << maximum - even * 2 << endl;
	}
	else {
		int hiku = 1;
		rep(i, even)
			hiku *= 2;
		cout << maximum - hiku << endl;
	}


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;

signed main(){
    int N,M;
    cin >> N >> M;
    int AC=0,WA=0;
    bool ac[1111111];
    int tmp[111111];
    for(int i=0;i<N+1;i++){
        ac[i] = false;
        tmp[i] = 0;
    }
    
    string S;
    int p;
    for(int i=0;i<M;i++){
        cin >> p >> S;
        if(S=="AC" && ac[p]==false){
            ac[p] = true;
            AC++;
        }else if(S=="WA" && ac[p]==false){
            tmp[p]++;
        }
    }
    
    for(int i=1;i<=N;i++){
        if(ac[i] == true){
            WA += tmp[i];
        }
    }
    
    cout << AC << " " << WA << endl;
    return 0;
}


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

using ll = long long int;
const int mod = 1e9+7;
const int INF = 1e9+5;

//int solve(string a, string b, int i, int j){
	
	//if(i >= (int)a.size() || j > (int)b.size()){
		//return 0;
	//}
	//int res = 0, res1 = 0, res2 = 0;
	//if(a[i]==b[j]){
		//res = 1 + solve(a, b, i+1, j+1);
	//}
	//res2 = solve(a, b, i, j+1);
	//res1 = solve(a, b, i+1, j);
	//return max(res, max(res2, res1));
//}

//backward dp

int solve(string a, string b){
	int m = a.size();
	int n = b.size();
	vector<vector<int>>dp(m+1, vector<int>(n+1));
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++){
			if(a[i] == b[j]){
				dp[i][j] = 1+max(dp[i-1][j] , dp[i][j-1]);
			}else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	return dp[m][n];
}

int solve2(string a, string b){
	
	int m = a.length();
	int n = b.length();
	
	vector<vector<int>>dp(m+1, vector<int>(n+1));
	
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			if(a[i] == b[j]){
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
			}
			dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
			dp[i][j+1] = max(dp[i][j+1], dp[i][j]);
		}
	}
	//return dp[m][n];
	int ans = 0;
	for(int i = 0; i <= m; i++){
		for(int j = 0; j <= n; j++){
			///ans = max(ans, dp[i][j]);
			cout<<dp[i][j]<<' ';
		}
		cout<<endl;
	}
	return ans;
}

template<typename T> T maxi(T a, T b){
	return max(a, b);
}

//template<typename T> void maxi(T& a, T b){
	//a = max(a, b);
//}

bool first_row_or_col(pair<int, int>p){
	return p.first==0 || p.second==0;
}

string solve3(string a, string b){
	
	int m = a.size();
	int n = b.size();
	vector<vector<pair<int, pair<int, int>>>>dp(m+1, vector<pair<int, pair<int, int>>>(n+1, {-INF, {0, 0}}));
	dp[0][0] = {0, {0, 0}};
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			if(a[i] == b[j]){
				dp[i+1][j+1] = maxi(dp[i+1][j+1], make_pair(dp[i][j].first+1, make_pair(i, j)));
				//maxi(dp[i+1][j+1], make_pair(dp[i][j].first+1, make_pair(i, j)));
			}
			dp[i+1][j] = maxi(dp[i+1][j], make_pair(dp[i][j].first , make_pair(i, j)));
			//maxi(dp[i+1][j], make_pair(dp[i][j].first , make_pair(i, j)));
			dp[i][j+1] = maxi(dp[i][j+1], make_pair(dp[i][j].first, make_pair(i, j)));
			//maxi(dp[i][j+1], make_pair(dp[i][j].first, make_pair(i, j)));
		}
	}
	
	pair<int, pair<int, int>>ans = {0, {0, 0}};
	for(int i = 0; i <= m; i++){
		for(int j = 0; j <= n; j++){
			ans = maxi(ans, make_pair(dp[i][j].first, make_pair(i, j))); //something is missing
			//maxi(ans, make_pair(dp[i][j].first, make_pair(i, j))); //something is missing
		}
	}
	
	//gather the string 
	string s = "";
	pair<int, int>curr = ans.second;
	while(!first_row_or_col(curr)){
		int i = curr.first;
		int j = curr.second;
		pair<int, int>prev = dp[i][j].second;
		if(prev == make_pair(i-1, j-1)){
			assert(a[i-1] == b[j-1]);
			s += a[i-1];
		}
		curr = prev;
	}
	//puts(s);
	reverse(s.begin(), s.end());
	//cout<<s<<endl;
	return s;
}


int main(){
	string a, b;
	cin>>a>>b;
	//cout<<solve(a, b, 0, 0);
	//cout<<solve(a, b);
	//cout<<solve2(a, b);
	cout<<solve3(a, b)<<endl;
	
	return 0;
}


Measured memory_bytes: 105984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1'){
            s[i]='9';
        }
        else if(s[i]=='9'){
            s[i]='1';
        }
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long int mod = 1e9+7;

long long int modpow(long long int x,long long int n){
    long long int res=1;
    for(; n>0; n>>=1) {
        if (n&1) res=res*x%mod;
        x=x*x%mod;
    }
    return res;
}


long long int num[100005];
int main(){
    long long int N,K;
    cin >> N >> K;
    long long int i,j;
    long long int ans=0;
    for(i=K;i>0;i--){
        num[i]=modpow(ceil(K/i),N);
        for(j=2;j<=ceil(K/i);j++){
            num[i] += (mod - num[i*j]);
            num[i] %= mod;
        }
        ans += num[i]*i;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4328
#include <stdio.h>

int main(void)
{
    int i, j;

    int row, column;
    scanf("%d %d", &row, &column);

    int in_spread[row][column];
    int in_num;
    int all_sum = 0;
    for (i = 0; i < row; i++) {
        for (j = 0; j < column; j++) {
            scanf("%d", &in_num);
            in_spread[i][j] = in_num;
            all_sum += in_num;
        }
    }

    int row_sum[row];
    for (i = 0; i < row; i++) {
        row_sum[i] = 0;
        for (j = 0; j < column; j++) {
            row_sum[i] += in_spread[i][j];
        }
    }

    int column_sum[column];
    for (j = 0; j < column; j++) {
        column_sum[j] = 0;
        for (i = 0; i < row; i++) {
            column_sum[j] += in_spread[i][j];
        }
    }

    int out_spread[row + 1][column + 1];
    for (i = 0; i < row; i++) {
        for (j = 0; j < column; j++) {
            out_spread[i][j] = in_spread[i][j];
        }
    }
    for (i = 0; i < row; i++) {
        out_spread[i][column] = row_sum[i];
    }
    for (j = 0; j < column; j++) {
        out_spread[row][j] = column_sum[j];
    }
    out_spread[row][column] = all_sum;

    for (i = 0; i < row + 1; i++) {
        for (j = 0; j < column + 1; j++) {
            if (j != 0) {
                printf(" ");
            }
            printf("%d", out_spread[i][j]);
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 684
//  Copyright © 2019 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long i64;

int main()
{
    optimiza_io
    int a, b, c;
    cin >> a >> b >> c;
    cout << a *b / 2 << endl;
    return 0;
}



Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n,r;cin>>n>>r;
  if(10<=n){
    cout<<r<<ENDL;
  }else{
    cout<<r+100*(10-n)<<ENDL;
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int judge(int n){
    int s = n / 10;
    if(n%10 != 0)
        s++;
    return s;
}
int main(){
    int a[5], sum = INT_MAX;
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    do{
        int sum1 = 0;
        for(int i = 0; i < 4; i++){
            sum1 += judge(a[i])*10;
            }
    sum1 += a[4];
    sum = min(sum,sum1);
    }while(next_permutation(a,a+5));
            cout << sum << endl;
    return 0;
}


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main(){
    ll k;
    cin >> k;
    int cnt=0;
    ll p = 7;
    while(true){
        p = p%k;
        cnt++;
        if(p==0){
            cout << cnt << endl;
            return 0; 
        }
        p = (p*10+7)%k;
        if(cnt>=1000000){
            cout << -1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3628
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;


public class my
{
	
	private static StringBuilder sb = new StringBuilder();
	
	public static void Main()
	{
		var n = my.GetInt();
		
		for(int i = 0; i < n; i++) {
			var A = my.GetIntArray();
			
			Array.Sort(A);
			
			sb.AppendLine( (A[0]*A[0] + A[1]* A[1]== A[2]*A[2])? "YES" : "NO");
		}
		
		my.Flush();
	}
	
	private static int CountChar(string s, char c)
	{
		return s.Length - s.Replace(c.ToString(), "").Length;
	}
	
	private static void Flush()
	{
		Console.Write(sb);
		sb.Length = 0;
	}
	
	private static void AppendLine(int v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(long v)
	{
		sb.AppendLine(v.ToString());
	}
	
	private static void AppendLine(string[] v)
	{
		sb.AppendLine(string.Join(" ", v));
	}

	private static void Swap(ref string a, ref string b) 
	{
		string tmp = a;
		a = b;
		b = tmp;
	}
	
	private static void Swap(ref int a, ref int b) 
	{
		int tmp = a;
		a = b;
		b = tmp;
	}
	
	private static int[] GetIntArray()
	{
		return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
	}
	
	private static void WriteArray(int[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static void WriteArray(long[] a)
	{
		Console.WriteLine(string.Join(" ", Array.ConvertAll( a, x=>x.ToString() ) ) );
	}
	
	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
	
	private static long GetLong()
	{
		return long.Parse(Console.ReadLine());
	}
}

Measured memory_bytes: 9124
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(br.readLine().trim());
		long[] arr = new long[n];
		StringTokenizer st = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++){
			arr[i] = Integer.parseInt(st.nextToken());
		}
		long[] res = new long[n];
		res[0] = 2*arr[0];
		for(int i = 1; i < n; i++){
			res[i] = 2*arr[i-1] - res[i-1];
		}
		long d = 2*arr[n-1] - res[0] - res[n-1];
		for(int i = 0; i < n; i++){
			if(i%2 == 0) res[i] += d/2;
			else res[i] -= d/2;
		}
		StringBuilder sb = new StringBuilder();
		for(long k: res) sb.append(k+" ");
		bw.write(sb.toString().trim()+"\n");
		bw.flush(); bw.close();
	}

}


Measured memory_bytes: 50116
my$n=get;$_=+<<get.words;
say $n*2-1;
((.max>-.min??.first: *==.max,:k!!.first: *==.min,:k)+1,++$).put xx$n;
put(.max>-.min??(++$,2+$++)!!($n-$++,$n-++$))xx $n-1;

Measured memory_bytes: 67200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, d, a;
  cin >> n >> k;
  set<int> s;
  for(int i = 0; i < k; i++){
    cin >> d;
    for(int i = 0; i < d; i++){
      cin >> a;
      s.insert(a);
    }
  }
  cout << n-s.size() << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
LL bs(LL A, LL B) {
    // [1, 2, ..., A-1] x [B+1, B+2, ...]
    // find max n st [1, 2, ... n] x [B+1, B+2, ..., B+n] is affordable
    // given n, the max is (B+n+1)^2 / 4
    LL lo = 1, hi = A;
    if (B+1 >= A*B)  return 0;
    while (lo < hi - 1) {  // [lo, hi)
        LL mid = (lo + hi) / 2;
        // cout << "mid " << mid << endl;
        LL t = B+mid+1;
        LL ma = max(1 * (B+mid+1-1), mid * (B+mid+1-mid));
        if (t/2 <= mid)  ma = max(ma, t/2 * (B+mid+1-t/2));
        if (ma >= A*B) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    return lo;
}

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int Q; cin >> Q;
    while (Q--) {
        LL A, B; cin >> A >> B;
        LL l = bs(A, B);
        LL r = bs(B, A);
        // cout << l << ' ' << r << endl;
        cout << l + r + min(A-1-l, B-1-r) << endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void){
	int stack[10];
	int sp = -1;
	int n = 0;
	for(int i=0;i<10;++i){
		stack[i] = 0;
	}
	while(scanf("%d", &n) != EOF){
		if(n == 0){
			printf("%d\n", stack[sp]);
			sp--;
		}else{
			stack[++sp] = n;
		}
	}
	return 0;
}

Measured memory_bytes: 0
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  ll L,R;
  cin >> L >> R;
  ll ans;
  ll right,left;
  ans = 2018*2018;
  if(R-L+1 >= 2019){
    ans = 0;
  }else{
    for(ll i = L; i <= R; i++){
      for(ll j = i+1; j <= R; j++){
        right = i%2019;
        left = j%2019;
        right = (right*left)%2019;
        ans = min(ans,right);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

int filde[90][90],dx[4]={-1,0,0,1},dy[4]={0,-1,1,0};
bool visit[90][90];
int m,n;

int count(int i,int j);

int main(){
	int ans;
	while(1){
		cin >> m >> n;
		if(m==0&&n==0){
			return 0;
		}
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				cin >> filde[i][j];
			}
		}
		ans=-1;
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				ans =max(ans, count(i,j));
			}
		}
		cout << ans << endl;
		
	}
}

int  count(int i,int j){
	visit[i][j]=true;
	int ans =0;
	for(int k=0;k<4;k++){
		if(filde[dx[k]+i][dy[k]+j]==1&&0<=dx[k]+i&&dx[k]+i<=m&&0<=dy[k]+j&&dy[k]+j<=n&&visit[dx[k]+i][dy[k]+j]==false){
			ans=max(ans,count(dx[k]+i,dy[k]+j)+1);
		}
	}
	visit[i][j]=false;
	return ans;
}

Measured memory_bytes: 1196
import numpy as np
from collections import defaultdict

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

counter = defaultdict(int)
ans = 0

for j in range(N+1):
    if j - K >= 0:
        counter[B[j-K]] -= 1
    ans += counter[B[j]]
    counter[B[j]] += 1

print(ans)


Measured memory_bytes: 39628
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,gyo0=0,gyo1=0,re0=0,re1=0,h,w,count;
    string s;
    cin>>s;
    if(s=="a" || s=="i" || s=="u" || s=="e" || s=="o"){
        cout<<"vowel"<<'\n';
    }
    else{
        cout<<"consonant"<<'\n';
    }
    return(0);
}

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

int main(){
        int second[5]={0}, ans[3];
        cin >>second[1]>>second[2]>>second[3]>>second[4];
        ans[2]=second[1]+second[2]+second[3]+second[4];
        ans[1]=ans[2]/60;
        ans[2]%=60;
        cout <<ans[1]<<"\n"<<ans[2]<<endl;
    return 0;
}

Measured memory_bytes: 1168
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

int main(){
  ll a,b,t; cin >> a >> b >> t;
  cout << b*(t/a) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define value( x ) cout<< "value of "<< #x << " is "<< x<<endl;
using namespace std;
int max(int x, int y) {if(x>y) return x; else return y;}
int min(int x, int y) {if(x<y) return x; else return y;}
int main()
{
   int a, b, c, d;
   cin>>a>>b>>c>>d;
   int solution=0;
   if(!(b<c||a>d)) {
   		int temp1 = max(a, c);
   		int temp2= min(b, d);
   		solution=(temp2-temp1);
   }
cout<<solution;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int n,x,y;
	cin>>n>>x>>y;	
	vector<int>v(n,0);
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{	
		    int num=min(j-i,abs(i-x)+abs(j-y)+1);
		     v[num]++;
		}
	}
	for(int i=1;i<=n-1;i++)
	cout<<v[i]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

int vis[123456], par[123456], sz[123456], ans[123456];

vector <vector <int> > vec;

void dfs(int n){
     sz[n] = 1;
     vis[n] = 1;
     for(auto x: vec[n]){
         if(!vis[x]){
            par[x] = n;
            dfs(x);
            sz[n] += sz[x];
         }
     }
}

void dfs1(int n, int e){
     for(auto x:vec[n]){
         if(x != e){
            dfs1(x, n);
            if(!(sz[x]%2)){
                 ans[n]  += (ans[x]+1);
            }
            else ans[n] += ans[x];
         }
     }
}

int main(){

   ll a, b, c, k;
   cin >> a >> b >> c >> k;
   if(k%2){
      cout << (b-a);
   }
   else cout << (a-b);
   
   
}

Measured memory_bytes: 256