akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int x[110000];
long long p[110000];
long long val[110000];
int main(){
	int a;scanf("%d",&a);
	long long b;scanf("%lld",&b);
	for(int i=0;i<a;i++){
		scanf("%lld%d",p+i+1,x+i);
	}
	p[a+1]=b;
	long long ret=0;
	for(int f=0;f<2;f++){
		set<pair<long long,int> >S;
		long long cur=0;
		S.insert(make_pair(0LL,a));
		for(int i=a-1;i>=0;i--){
			cur+=x[i];
			cur-=p[i+2]-p[i+1];
			val[i]=cur;
			S.insert(make_pair(cur,i));
		}
		cur=0;
		for(int i=0;i<a;i++){
			ret=max(ret,(S.rbegin()->first)+cur);
			cur+=x[i];
			cur-=(p[i+1]-p[i])*2;
			S.erase(make_pair(val[i],i));
		}
		reverse(p,p+a+2);
		reverse(x,x+a);
		for(int i=0;i<a+2;i++)p[i]=b-p[i];
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;



int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> Q(m);
	rep (i, m) cin >> Q[i].se >> Q[i].fi;

	sort(rng(Q));

	int ans = 1;
	int pos = -1;
	rep (i, m) {
		if (pos == -1) {
			pos = Q[i].fi;
			continue;
		}
		if (Q[i].se >= pos) {
			pos = Q[i].fi;
			ans++;
		}
	}

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

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll X[100005];
ll Y[100005];

int main()
{
    ll N, L, T;
    cin >> N >> L >> T;
    REP(i, N)
    {
        cin >> X[i].first >> X[i].second;
        if (X[i].second == 1)
            Y[i] = (X[i].first + T) % L;
        else
            Y[i] = (L + X[i].first - (T % L)) % L;
    }

    ll n = 0;
    bool same = false;
    FOR(i, N, 1)
    {
        if (X[i].second == X[0].second)
            continue;
        //! X[0]と何回ぶつかるか？
        ll l = X[i].first - X[0].first;
        if (X[0].second == 2)
            l = L - l;
        if (2LL * T - l < 0)
            continue;
        n += 1 + (2LL * T - l) / L;
        if ((2LL * T - l) % L == 0)
            same = true;
    }
    n %= N;
    //! Y[0]にいるindex
    int k = X[0].second == 1 ? n : (N - n) % N;
    ll x = Y[0];

    sort(Y, Y + N);
    int j = 0;
    REP(i, N)
    {
        if (x == Y[i])
        {
            j = i;
            break;
        }
    }
    int t = N + j - k;
    if (same && X[0].second == 1)
        t++;

    REP(i, N)
    {
        cout << Y[(i + t) % N] << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int case_cnt;
int ball[12];
bool visited[12];
int maxx;
int main()
{
  cin>>case_cnt;
  while(case_cnt--)
  {
	
	  for(int i=1;i<=10;i++) 
	  {
		  cin>>ball[i];
		  visited[i]=false;
	  }
	  maxx=ball[1];
	  visited[1]=true;
	  //找到一段递增序列
	  for(int i=2;i<=10;i++) 
	  {
		 if(ball[i]>maxx)
		 {
			 visited[i]=true;
			 maxx=ball[i];
		 }
	  }
	  //剩下的数中有无不递增的。先找到剩下数中的第一个
	  maxx=-1;
	  int i;
	  for(i=2;i<=10;i++) 
	  {
		 if(visited[i]) continue;
		 if(ball[i]<maxx) break;
		 maxx=ball[i];
	  }
	  if(i==11) cout<<"YES"<<endl;
	  else cout<<"NO"<<endl;
  }
   return 0;
}


Measured memory_bytes: 3052
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc133_a.cpp
 * time   : Sat May  2 01:14:31 2020
 * quest  : A - T or T
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(b, n * a) << "\n";
  return 0;
}


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

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int H1,M1,H2,M2,K;
	cin>>H1>>M1>>H2>>M2>>K;
	cout<<H2*60+M2-H1*60-M1-K<<"\n";
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#define MAX 100001

int i, n, a, b, c, ptr;
int h[MAX], dp[MAX];

int abs(int x)
{
	return (x > 0) ? x : -x;
}

int min(int a, int b)
{
	return (a < b) ? a : b;
}

int main(void)
{
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		scanf("%d", &h[i]);

	dp[1] = 0;  dp[2] = abs(h[2] - h[1]);
	for (i = 3; i <= n; i++)
	{
		a = dp[i - 1] + abs(h[i] - h[i - 1]);
		b = dp[i - 2] + abs(h[i] - h[i - 2]);
		dp[i] = min(a, b);
	}

	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long Q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> p, std::vector<long long> x){
  map<ll, vector<ll>> m;
  vector<ll> v(N+1, 0);
  for(ll i=0; i<N; i++){
    m[a[i]].push_back(b[i]);
    m[b[i]].push_back(a[i]);
  }
  for(ll i=0; i<Q; i++) {
    v[p[i]]+=x[i];
  }
  queue<ll> q;
  q.push(1);
  vector<ll> visited(N+1, 0);

  while(!q.empty()) {
    ll c = q.front();
    q.pop();
    visited[c] = 1;
    for(auto next : m[c]) {
      if(visited[next]) continue;
      q.push(next);
      v[next] += v[c];
    }
  }
  for(ll i=1; i<=N; i++) {
    if(i==N) {
      std::cout << v[i] << std::endl;
    } else {
      std::cout << v[i] << " ";
    }
  }
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long Q;
  scanf("%lld",&Q);
  std::vector<long long> a(N-1);
  std::vector<long long> b(N-1);
  for(int i = 0 ; i < N-1 ; i++){
    scanf("%lld",&a[i]);
    scanf("%lld",&b[i]);
  }
  std::vector<long long> p(Q);
  std::vector<long long> x(Q);
  for(int i = 0 ; i < Q ; i++){
    scanf("%lld",&p[i]);
    scanf("%lld",&x[i]);
  }
  solve(N, Q, std::move(a), std::move(b), std::move(p), std::move(x));
  return 0;
}



Measured memory_bytes: 36720
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
#define MOD		(1000000000 + 7)	// 10^9 + 7
#define T(n)	((n) % (MOD))		// mod 10^9 + 7
    uint32 N;
    string s1, s2;
    cin >> N;
    cin >> s1;
    cin >> s2;

    if(N==1){
        cout << 3 << endl;
        return;
    }
    const uint8 TYPE_HH = 0;
    const uint8 TYPE_VV = 1;
    const uint8 TYPE_V = 2;
    vector<uint8> typeList;
    for(uint32 i=0; i<N-1; i++){
        // TYPE_HH
        if(s1[i] == s1[i+1]){
            typeList.push_back(TYPE_HH);
            i++;
        }
        // TYPE_V
        if(s1[i]==s2[i]){
            typeList.push_back(TYPE_V);
        }
    }
    if(s1[N-1]==s2[N-1]){
        typeList.push_back(TYPE_V);
    }

    uint32 ans;
    uint8 prevType;
    // first type
    if(typeList[0] == TYPE_V){
        ans = 3;
        prevType = TYPE_V;
    }else{ // TYPE_HH
        ans = 6;
        prevType = TYPE_HH;
    }
    //
    for(uint32 i=1; i<typeList.size(); i++){
        uint8 type = typeList[i];
        if(prevType == TYPE_V){
            if(type == TYPE_V){
                ans = T(ans * 2);
            }else{ // TYPE_HH
                ans = T(ans * 2);
            }
        }else{ // TYPE_HH
            if(type == TYPE_V){
                ans = T(ans * 1);
            }else{ // TYPE_HH
                ans = T(ans * 3);
            }
        }
        prevType = type;
    }

    cout << ans << endl;

    return;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	const int price[5]={10000,6000,4000,3000,2000};
	int i;
	for(i=0;i<4;i++) {
		int t,n;
		scanf("%d%d",&t,&n);
		printf("%d\n",price[t]*n);
	}
	return 0;
}

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

int main(){
    int a, b, c;cin>>a>>b>>c;
    vector<int> nums{a, b, c};
    sort(nums.begin(), nums.end());
    int small = nums[0];
    int mid = nums[1];
    int big = nums[2];

    int first = big - mid;
    if ((big - (small + first)) % 2 == 0){
        cout << first + (big - (small + first)) / 2 << endl;
    } else {
        cout << first + ((big - (small + first)) / 2) + 2 << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

string S;
int dp[100010][5];

int DP(int a,int b){
	if(dp[a][b]!=-1)return dp[a][b];
	int res=0;
	if(a==S.size()){
		res=((b==3)? 1LL:0LL);
	}
	else{
		res=DP(a+1,b)*((S[a]=='?')?3LL:1LL);
		if(b<3 &&(S[a]=='?'||S[a]=="ABC"[b])){
			res+=DP(a+1,b+1);
		}
	}
	res%=MOD;
	return dp[a][b]=res;
}

signed main(){
	cin>>S;
	REP(i,100010)REP(j,5){
		dp[i][j]=-1;
	}
	int ans=DP(0,0);
	cout<<ans<<endl;
	return 0;
}


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


Measured memory_bytes: 2124
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    int n,s;
    while(cin >> n >> s,n+s){
        int temp = s;
        vi v(n,0); int count = 0; bool check = true;
        while(true){
            if(s != 0){s-=1;v[count]++; if(v[count] == temp){cout << count << endl; break;}
            }else if(s == 0){
                s+=v[count]; v[count] = 0;
            }
            if(count == n-1)
                count =0;
            else
                count++;
            
        }
    }
}

Measured memory_bytes: 3076
a, b, c, d, e, f = map(int, input().split())

limit_water = f * 100 / (100 + e)
limit_suger = f * e / (100 + e)


waters = []
sugars = []

for i in range(31):
    for j in range(31):
        water = 100 * a * i + 100 * b * j
        if water != 0 and water <= 3000:
            waters.append(water)

for i in range(1500):
    for j in range(1500):
        sugar = c * i + d * j
        sugars.append(sugar)

ans = []
max_density = 0.0

sugars = list(set(sugars))
sugars.sort()
waters = list(set(waters))
waters.sort()

for water in waters:
    for sugar in sugars:
        if sugar + water <= f and sugar <= (water * e / 100):
            density = sugar / (sugar + water)
            if density >= max_density:
                ans = [water + sugar, sugar]
                max_density = density

print(*ans)



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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	for (int i=0; i<s.size()-1; i++)
		if(s.substr(i,2)=="AC") { cout << "Yes" << endl; return 0; }
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// ********* Assalamualaikum****** IN the name of my Almighty****:):)***

#include<bits/stdc++.h>

using namespace std;

#define suni ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define endl "\n"

#define f(i,a,b) for(int i=a;i< b;i++)

#define ff(i,a,b) for(int i= a;i>=b;i--)

#define T int t; cin >>t; while(t--)

#define vi  vector<int>

#define vll vector<long long>

#define vs vector<string>

#define vp vector<pair

#define pii pair<int,int>

#define pb push_back

#define mk make_pair

#define b(a) a.begin(),a.end()

#define rb(a) a.rbegin(),a.rend()

#define I  int

#define ll long long

#define st string

#define C char

#define mn int main()

#define fa(u,v) for(auto u:v)

mn

{

    suni;

    I n;

    cin>>n;

    I a=(n+(n*n)+(n*n*n));

    cout<<a<<endl;

}

//*******Happy Coding*******???******

Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// Circle in rectangle
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	ary := strings.Split(strings.TrimSpace(sc.Text()), " ")
	W, _ := strconv.Atoi(ary[0])
	H, _ := strconv.Atoi(ary[1])
	x, _ := strconv.Atoi(ary[2])
	y, _ := strconv.Atoi(ary[3])
	r, _ := strconv.Atoi(ary[4])
	if r <= x && r <= y && x+r <= W && y+r <= H {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}



Measured memory_bytes: 1100
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

const ll c=1000000000LL;
const ll MAX=1e18;

int main(){
    ll S; cin>>S;
    if(S==MAX){
        cout<<0<<" "<<0<<" "<<c<<" "<<0<<" "<<0<<" "<<c<<endl;
        return 0;
    }
    ll p=S/c, r=S%c;
    cout<<0<<" "<<0<<" "<<c<<" "<<1<<" "<<c-r<<" "<<p+1LL<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  char o[100],e[100];
  int i;
  
  fgets(o,sizeof(o),stdin);
  fgets(e,sizeof(e),stdin);
  
  for(i=0;o[i]!='\0';i++){
    printf("%c",o[i]);
    if(e[i]!='\0')
      printf("%c",e[i]);
  }  
return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int a = 0;
    if (s[0] == '1')
        a++;
    if (s[1] == '1')
        a++;
    if (s[2] == '1')
        a++;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
	int n,a,b,i,j,foreign,passed;
	char s[100002];
	foreign=0;
	passed=0;
	
	scanf("%d%d%d",&n,&a,&b);
	scanf("%s%*c",s);
	
	for(i=0;i<n;i++){
		if(passed<a+b){
			if(s[i]=='a'){
				puts("Yes");
				passed++;
			}else if(s[i]=='b' && foreign<b){
				puts("Yes");
				foreign++;
				passed++;
			}else{
				puts("No");
			}
		}else{
			puts("No");
		}
	}
	
	return 0;
}

Measured memory_bytes: 640
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 1e18;


int32_t main(){
   
   speed_cubing
   
   ld a,b;
   cin>>a>>b;

   ld temp = a*b;

   temp = floor(temp);

   cout<<(int)temp;
 
   return 0;
}

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

int main() {
  string S;
  cin >> S;

  string ans = "AC";

  if (S.front() != 'A') ans = "WA";

  if (count(S.begin() + 2, S.end() - 1, 'C') != 1) ans = "WA";

  int cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if(isupper(S.at(i))) cnt++;
  }
  if (cnt != 2) ans = "WA";

  cout << ans << "\n";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final int N = Integer.parseInt(sc.next());
        StringBuilder P = new StringBuilder();
        for (int i=0; i<N; i++) {
            P.append(sc.next());
        }
        StringBuilder Q = new StringBuilder();
        for (int i=0; i<N; i++) {
            Q.append(sc.next());
        }
        sc.close();

        Inner inner = new Inner();
        inner.init(N);
        inner.perm(1);

        System.out.println(Math.abs(inner.get(P.toString()) - inner.get(Q.toString())));

    }
    static class Inner {
        private int[] p;
        private int N;
        private List<String> list;
        void init(int N) {
            this.N = N;
            p = new int[N+1];
            for (int i=1; i<=N; i++) {
                p[i] = i;
            }
            list = new ArrayList<>();
        }
        void perm(int i) {
            int j, k, t;
    
            if (i<N) {
                for (j=i; j<=N; j++) {
                    t=p[j];
                    for (k=j; k>i; k--) {
                        p[k] = p[k-1];
                    }
                    p[i]=t;
                    perm(i+1);
                    for (k=i; k<j; k++) {
                        p[k] = p[k+1];
                    }
                    p[j]=t;
                } 
            } else {
                StringBuilder sb = new StringBuilder();
                for (j=1; j<=N; j++) {
                    sb.append(p[j]);
                }
                list.add(sb.toString());
            }
        }
        int get(String s) {
            return list.indexOf(s);
        }
    }
}

Measured memory_bytes: 30404
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x;std::cin >> x;
  for(ll i=-200;i<=200;i++){
    for(ll j=-200;j<=200;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        std::cout << i << " " << j << '\n';
        exit(0);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3180
#include<stdio.h>

int main(){
	char a;

    if(scanf("%c",&a) == -1){
    	return 0;
    }
    
    if(a >=65 && a <= 90 ){
    	printf("A\n");
	}else if(a >=97 && a <= 122 ){
    	printf("a\n");
	}else{
		return 0;
	}
    
    return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> Like(M, 0);
    REP(i, 0, N) {
        int K;
        cin >> K;
        REP(k, 0, K) {
            int a;
            cin >> a;
            Like[a - 1]++;
        }
    }
    int ans = 0;
    REP(i, 0, M) {
        ans += (Like[i] == N);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	double cc = M_PI * c / 180;
	double s = a * b * sin(cc) * 0.5;
	double l = sqrt(a *a + b * b - 2 * a * b * cos(cc)) + a + b;
	double h = b * sin(cc);
	printf("%.10f\n", s);
	printf("%.10f\n", l);
	printf("%.10f\n", h);
	
	return 0;
}


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

int Fn_total(int number){
    int total=0;
    while(number){
        total+=number%10;
        number/=10;
    }
    return total;
}

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int number=0 ,left=0, right=0;
    while(cin>>number>>left>>right){
        int answer=0;
        for(int cnt=1;cnt<=number;cnt++){
            if(Fn_total(cnt) >= left && Fn_total(cnt) <= right){
                answer+=cnt;
            }
        }
        cout<<answer<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
def segfunc_min(x,y):return min(x,y)
def segfunc_max(x,y):return max(x,y)
ide_ele_min=10**18
ide_ele_max=0
class segtree():
  def __init__(self,init_val,segfunc,ide_ele):
    n=len(init_val)
    self.segfunc=segfunc
    self.ide_ele=ide_ele
    self.num=1<<(n-1).bit_length()
    self.tree=[ide_ele]*2*self.num
    for i in range(n):
      self.tree[self.num+i]=init_val[i]
    for i in range(self.num-1,0,-1):
      self.tree[i]=self.segfunc(self.tree[2*i], self.tree[2*i+1])
  def update(self,k,x):
    k+=self.num
    self.tree[k]=x
    while k>1:
      self.tree[k>>1]=self.segfunc(self.tree[k],self.tree[k^1])
      k>>=1
  def query(self,l,r):
    res=self.ide_ele
    l+=self.num
    r+=self.num
    while l<r:
      if l&1:
        res=self.segfunc(res,self.tree[l])
        l+=1
      if r&1:
        res=self.segfunc(res,self.tree[r-1])
      l>>=1
      r>>=1
    return res
n,k=map(int,input().split())
*p,=map(int,input().split())
q=[1]*n
ans=n-k+1
cnt=1
c=0
for i in range(n-1):
  if p[i+1]>p[i]:cnt+=1
  else:cnt=1
  c+=cnt>=k
  if cnt>k:q[i-k+1]=0
if c>1:ans-=c-1
stn=segtree(p,segfunc_min,ide_ele_min)
stx=segtree(p,segfunc_max,ide_ele_max)
for i in range(n-k):
  if stn.query(i,i+k)==p[i] and stx.query(i+1,i+k+1)==p[i+k] and q[i]:ans-=1
print(ans)

Measured memory_bytes: 108080
#include<algorithm>
#include<cstdio>
using namespace std;
const int mod=1e9+7;
int n,m,N,sl,fh,ans,a[20],fac[1<<16],ifc[1<<16],num[1<<16],dp[1<<16];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
int _pow(int k,int i)
{
	int t=1;
	for(;i;i>>=1,k=1ll*k*k%mod)
		if(i&1)
			t=1ll*t*k%mod;
	return t;
}
int C(int x,int y) {return 1ll*fac[x]*ifc[y]%mod*ifc[x-y]%mod;}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	n=rd();m=rd();N=1<<n;fac[0]=1;
	for(int i=m;i;--i) a[i]=rd();
	for(int i=1;i<N;++i) fac[i]=1ll*i*fac[i-1]%mod,num[i]=num[i>>1]+(i&1);
	ifc[N-1]=_pow(fac[N-1],mod-2);
	for(int i=N-1;i;--i) ifc[i-1]=1ll*i*ifc[i]%mod;
	if(!m) {printf("%lld\n",1ll*N*fac[N-1]%mod); return 0;}
	dp[0]=1;
	for(int i=1;i<=m;++i)
		for(int j=N-1;~j;--j)
			if(dp[j])
				for(int k=1;k<=n;++k)
					if(!((j>>k-1)&1)&&N-a[i]-j>=(1<<k-1)-1)
						dp[j|(1<<k-1)]=(dp[j|(1<<k-1)]+1ll*dp[j]*C(N-a[i]-j,(1<<k-1)-1)%mod*fac[1<<k-1])%mod;
	for(int i=0;i<N;++i) dp[i]=1ll*dp[i]*fac[N-i-1]%mod;
	for(int i=0;i<N;++i)
		if(num[i]&1) upd(ans,mod-dp[i]);
		else upd(ans,dp[i]);
	printf("%lld\n",1ll*N*ans%mod);
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        String t;
        int cnt = 0;
        while(true){
            t = sc.next();
            if(t.equals("END_OF_TEXT")) break;
            if(t.equalsIgnoreCase(w)) cnt++;
        }
        System.out.println(cnt);
    }
}

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

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

  ll L; cin >> L;
  ll R; cin >> R;
  ll d; cin >> d;
  ll ans = 0;
  for (ll i = L; i <= R; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cout << #x << " : " << (x) << " --------------" << endl;
using namespace std;

int main(void){
    int e;
    while (cin >> e, e) {
        int m = 1000000;
        for (int z = 100; z >= 0; --z) {
            int val = z * z * z;
            if (val > e) continue;
            for (int y = sqrt(e-val); y >= 0; --y) {
                int val2 = val + y * y;
                if (val2 > e) continue;
                m = min(m, (e - val2) + y + z);
            }
        }
        cout << m << endl;
    }
    return EXIT_SUCCESS;
}

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

int main(){

    unsigned long long  N;
    unsigned long long  M;
    unsigned long long cnt = 0;

    cin >> N >> M;

    vector <unsigned long long> A(M+1);

    for(unsigned long long i = 1; i <= M; i++){
      cin >>A.at(i);
      cnt += A.at(i);
    }


    if(cnt > N) cout << "-1" << endl;
    else {
      cout << N - cnt << endl;
    }
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  int n; cin >> n;
  vi a(n);

  rep(i, n) cin >> a[i];
  sort(all(a));

  int target = (a[n-1] + 1) / 2;
  int mn = inf, x;

  rep(i, n-1) {
    int diff = abs(target - a[i]);
    if (chmin(mn, diff)) x = a[i];
  }

  cout << a[n-1] << " " << x << endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    
    
    
    int main() {
   
     while(true){
     int m,f,r;
     cin >> m >> f >> r;
     if(m == -1 && f == -1 && r == -1){
     	return 0;
     }
     
     if(m== -1 || f == -1)	cout << 'F' << '\n';
     else if(m+f >= 80)	cout << 'A' << '\n';
     else if(m+f >= 65)	cout << 'B' << '\n';
     else if(m+f >= 50 ||( m+f >= 30 && r>=50))	cout << 'C' << '\n';
     else if(m+f >= 30)	cout << 'D' << '\n';
     else cout << 'F' << '\n';
     }
     
     return 0;
    }


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>

constexpr size_t NMAX = 700;
int V[NMAX + 1];
int E[NMAX + 1][NMAX + 1];
int G[NMAX + 1][2];
bool DP[NMAX+1][NMAX+1];
size_t N, M;

void setgroup(size_t v, int group) {
    //std::cout << "set " << v << ' ' << group << std::endl;
    V[v] = group;
    for (size_t i = v + 1; i <= N; i++) {
        if (E[v][i]) {
            continue;
        }
        if (V[i] == -1) {
            setgroup(i, group ^ 1);
        } else if (V[i] == (group ^ 1)){
            continue;
        } else if (V[i] == group) {
            //std::cout << v << ' ' << i << ' ' << V[i] << std::endl;
            std::cout << "-1" << std::endl;
            exit(0);
        } else {
            size_t x = V[i];
            // unify group with V[i]
            //std::cout << "unify " << x << ' ' << group << std::endl;
            for (size_t j = 1; j <= N; j++) {
                if (V[j] == x) {
                    V[j] = group ^ 1;
                } else if (V[j] == (x ^ 1)) {
                    V[j] = group;
                }

            }
            
        }

    }
}

int main()
{

    for (size_t i = 0; i < NMAX + 1; i++) {
        for (size_t j = 0; j < NMAX; j++) {
            E[i][j] = 0;
        }
    }

    for (size_t i = 0; i < NMAX + 1; i ++) {
        V[i] = -1;
    }


    std::cin >> N >> M;
    for (size_t i = 0; i < M; i++) {
        int a, b;
        std::cin >> a >> b;
        E[a][b] = E[b][a] = 1;
    }

    int group = 0;

    for (size_t i = 1; i <= N; i++) {
        if (V[i] != -1) {
            continue;
        }

        V[i] = group;
        setgroup(i, group);
        group += 2;
    }

    size_t maxsum = 0;
    DP[0][0] = true;
    for (size_t i = 1; i <= N; i++) {
        DP[0][i] = false;
    }
    size_t dp = 1;
    for (size_t g = 0; g < group; g += 2) {
        std::pair<size_t, size_t> pair = {0, 0};
        for (size_t i = 1; i <= N; i++) {
            if (V[i] == g) {
                pair.first += 1;
            }
            if (V[i] == g + 1) {
                pair.second += 1;
            }
        }
        if (pair.first + pair.second == 0) { 
            continue;
        }

        for (size_t i = 0; i <= N - std::max(pair.first, pair.second); i++) {
            DP[dp][i + pair.first] |= DP[dp-1][i];
            DP[dp][i + pair.second] |= DP[dp-1][i];
        }
        dp++;
    }

    size_t min = N * (N - 1) / 2;
    for (size_t i = 0; i <= N; i++) {
        if (DP[dp-1][i]) {
            min = std::min(min, i * (i - 1) / 2 + (N - i) * (N - i - 1) / 2);
        }
    }
    std::cout << min << std::endl;

    return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long p[110000];
long long L[110000];
long long R[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%lld",p+i);
	L[0]=R[0]=2;
	for(int i=0;i<a;i++){
		long long f=L[i]-L[i]%p[a-1-i];
		if(L[i]%p[a-1-i])f+=p[a-1-i];
		long long g=R[i]-R[i]%p[a-1-i];
		g+=p[a-1-i]-1;
		L[i+1]=f;
		R[i+1]=g;
		if(L[i+1]>R[i+1]){
			printf("-1\n");return 0;
		}
	}
	printf("%lld %lld\n",L[a],R[a]);
}

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

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

using namespace std;

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

    int n, l, sum = 0, ans, cur = 2e9;
    cin >> n >> l;
    int arr[n];

    for (int i = 0; i < n; i++)
        arr[i] = l + i, sum += arr[i];

    for (int x : arr)
        if (abs(sum - (sum - x)) < cur)
            ans = sum - x, cur = abs(sum - (sum - x));

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int x, y, z;
	cin >> x >> y >> z;

	cout << z<<" "<<x<<" "<<y << "\n";

}


Measured memory_bytes: 256
import random

#0:上面 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]  #[0, 1, 2, 3, 4, 5]
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])

    def roll_2(self, top, front):  # 上面と前面の整数から右側の面の整数を求めるメソッド
        directions = ["N", "E", "W", "S"]
        while True:
            i = random.randint(0, 3)
            self.roll(directions[i])
            if top == self.number[0] and front == self.number[1]:
                break
        return self.number[2]

    def get_Top(self):
        return self.number[0]

num = list(map(int, input().split()))
dice = Dice()
dice.setNumber(num[0], num[1], num[2], num[3], num[4], num[5])
q = int(input())  # 質問の数
for i in range(q):
    top, front = map(int, input().split())
    print(dice.roll_2(top, front))



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

using namespace std;

long long ans;
int n, R, C, D, xcnt, ycnt, x[100005], y[100005],
    markx[100005], marky[100005];
bool mark[200005];
vector<int> edge[200005];

void dfs(int x)
{
    ++D;
    if (mark[x]) return;
    mark[x] = true;
    if (x <= xcnt) ++R;
    else ++C;
    for (int i = 0, _i = edge[x].size(); i < _i; ++i)
        dfs(edge[x][i]);
    return;
}

int main(void)
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &x[i], &y[i]);
        if (markx[x[i]] == 0) markx[x[i]] = ++xcnt;
        if (marky[y[i]] == 0) marky[y[i]] = ++ycnt;
    }
    for (int i = 1; i <= n; ++i) {
        edge[markx[x[i]]].push_back(marky[y[i]] + xcnt);
        edge[marky[y[i]] + xcnt].push_back(markx[x[i]]);
    }
    for (int i = 1; i <= xcnt + ycnt; ++i) {
        if (mark[i]) continue;
        R = 0, C = 0, D = 0;
        dfs(i);
        if (R < 2 || C < 2) continue;
        ans += (long long)R * C - D / 2;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 12928
#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 mod 1000000007
using ll=long long;
const int INF=1000000000;
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 true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int n;cin>>n;
    cout<<1000*((n+999)/1000)-n<<endl;
    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef long long ll;
const int N = 1e5+5, mod = 1e9+7;
ll n, dp[N][14], p[N];
string s;
ll sol(int i, int rem)
{
	if(i == n) return (rem == 5? 1 : 0);
	ll &ret = dp[i][rem];
	if(ret != -1) return ret;
	ret = 0;
	if(s[i] != '?') return ret = sol(i+1, (rem+(s[i]-'0')*p[n-i])%13);
	for(int j=0; j<=9; j++) ret += sol(i+1, (rem+j*p[n-i])%13), ret %= mod;
	return ret;
}
int main() 
{
	memset(dp, -1, sizeof dp);
	cin >> s;
	n = s.size();
	p[1] = 1;
	for(int i=2; i<N; i++) p[i] = p[i-1]*10, p[i] %= 13;
	cout << sol(0, 0) << endl;
}

Measured memory_bytes: 19968
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

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

	int N;
	long[] a;
	long[] result;

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		a = new long[N];
		String[] tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			a[i] = Long.parseLong(tokens[i]);
		}
		result = new long[N];
	}

	void calc() {
		{
			// まず最初の要素を求める
			long val = a[0];
			for (int diff = 1; diff < N / 2; ++diff) {
				int left = (0 - diff + N) % N;
				int right = (0 + diff) % N;
				val ^= a[left];
				val ^= a[right];
			}
			int target = (0 + (N / 2)) % N;
			result[target] = val;
		}
		{
			// まず最初の要素を求める
			long val = a[1];
			for (int diff = 1; diff < N / 2; ++diff) {
				int left = (1 - diff + N) % N;
				int right = (1 + diff) % N;
				val ^= a[left];
				val ^= a[right];
			}
			int target = (1 + (N / 2)) % N;
			result[target] = val;
		}

		// result[N/2]が求まったので，そこを足がかりに求める
		for (int i = N / 2 + 1; i < N / 2 + N; ++i) {
			int index = i % N;
			int left = (index - 1 + N) % N; // これは
			int right = (index + 1) % N;
			long val = a[left] ^ a[right];
			val ^= result[left];
			result[right] = val;
		}
	}

	void showResult() {
		System.out.print(result[0]);
		for (int i = 1; i < N; ++i) {
			System.out.print(" " + result[i]);
		}
		System.out.println("");
	}
}

Measured memory_bytes: 70436
#include <iostream>
using namespace std;
int main()
{
  int A, B, C, K, sum = 0;
  cin >> A >> B >> C >> K;
  for(int i = 0; i < A; i++){
    if(!K) break;
    sum += 1;
    K--;
  }
  for(int i = 0; i < B; i++){
    if(!K) break;
    K--;
  }
  for(int i = 0; i < C; i++){
    if(!K) break;
    sum -= 1;
    K--;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3648
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::Ordering;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    input! {
        n: i32,
        k: i32,
        x: [i32; n],
    }
    let mut ans = 0;
    for val in x {
        let val1 = (k - val).abs();
        let val2 = val - 0;
        ans += if val1 < val2 { val1 } else { val2 };
    }
    println!("{}", ans * 2);
} 


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    ll ok = INF, ng = 0, mid;
    while (ok - ng > 1) {
        mid = (ok + ng) / 2;
        vector<ll> v(n);
        rep(i, n) v[i] = max(0ll, h[i] - b * mid);
        ll cnt = 0;
        rep(i, n) cnt += (v[i] + (a - b) - 1) / (a - b);
        (cnt <= mid ? ok : ng) = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 1792
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
                sc.close();
		int d = a / b;
		int r = a % b;
		double f = (double)a / (double)b;
		System.out.printf("%d %d %f", d, r, f);
	}
}

Measured memory_bytes: 17320
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read();
    if(n<=5)puts("0");
    else if(n<=12)pr2(m/2);
    else pr2(m);
   	return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

    vector<vector<ll>> table(9,vector<ll>(9,0));

    ll cv;
    ll a,b;
    rep(i,n+1){
        cv = i;
        a = cv%10;
        if(a==0)continue;
        while(cv!=0){
            if(cv/10==0){
                b = cv;
            }
            cv /= 10;
        }

        table.at(a-1).at(b-1)++;
    }

    ll co=0;
    rep(i,9){
        rep(j,9){
            if(i==j){
                co += table.at(i).at(j)*table.at(i).at(j);
            }else if(i<j){
                co += table.at(i).at(j)*table.at(j).at(i)*2;
            }
        }
    }

    cout<<co<<endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var arr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).OrderBy(x => x).ToArray();
            Console.WriteLine(arr.Max() - arr.Min());
        }
    }
}


Measured memory_bytes: 13524