akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())

int c[10001][1261]={};
int main(void){
  int N,M;
  while(cin>>N>>M,N&&M){
    REP(i,10001)REP(j,1261)c[i][j]=0;
    int r;
    cin>>r;
    while(r--){
      int t,n,m,s;
      cin>>t>>n>>m>>s;
      if(s){
        c[m][t]++;
      }else{
        c[m][t]--;
      }
    }
    REP(m,M+1)REP(time,1260)c[m][time+1]+=c[m][time];
    
    int q; cin>>q;
    while(q--){
      int ans = 0;
      int t1,t2,m;
      cin>>t1>>t2>>m;
      for(int time = t1; time < t2; time++){
        if(c[m][time]) ans ++;
      }
      cout<<ans<<endl;
    }
  }

  return 0;
}

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

int N;
int c[4];

double dp[310][310][310];

double solve(int c1, int c2, int c3) {
    if(c1 == 0 && c2 == 0 && c3 == 0) return 0;
    if(dp[c1][c2][c3] > 0) return dp[c1][c2][c3];

    double res = N;
    if(c1 >= 1) res += solve(c1 - 1, c2, c3) * c1;
    if(c2 >= 1) res += solve(c1 + 1, c2 - 1, c3) * c2;
    if(c3 >= 1) res += solve(c1, c2 + 1, c3 - 1) * c3;
    res /= c1 + c2 + c3;
    return dp[c1][c2][c3] = res;
}

int main() {
    cin >> N;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        c[a]++;
    }

    cout << fixed << setprecision(10) << solve(c[1], c[2], c[3]) << endl;

    return 0;
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    vector<string> w = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    for (int i = 0; i < w.size(); i++) {
        if (s == w[i]) {
            cout << 7 - i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

    #define MAXN 1000005
    int spf[MAXN];
    void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)

                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }


    vector<int> gf(int x)
    {
        vector<int> ret;
        while (x != 1)
        {
            ret.push_back(spf[x]);
            x = x / spf[x];
        }
        return ret;
    }
    int BIT[100050]; //fenwick
    void upd(int x) { ++x;  while(x<=MAXN)  {  BIT[x]++;  x+=(x&-x);  } }
    int cal(int x) {  ++x;  int res=0;  while(x>0)  {  res+=BIT[x];  x-=(x&-x);  } return res; }
    ll Com[1051][1051];
    void pre()
    {

        ll i,j,n=1051;
        rep(i,0,n) Com[i][0]=Com[i][i]=1;
        rep(i,2,n)
        {
            rep(j,1,i)
            {
                Com[i][j]=Com[i-1][j]+Com[i-1][j-1];
                Com[i][j]%=hell;
            }
        }

    }
    ll mod=hell;
    ll pr( ll x , ll y)
    {
        ll ans=1;
        if(y==0) return ans;
        while(y>1)
        {
            if(y&1) ans*=x;
            x*=x;
            y/=2;
            x%=mod;
            ans%=mod;
        }
        ans*=x;
        ans%=mod;
        return ans;
    }
    ll inv(ll n)
    {
        return pr(n,mod-2);
    }
    ll stoi(string s)
    {
        int n=s.size();
        ll k=0; int i;
        rep(i,0,n)
        {
            k+=s[i]-'0';
            k*=10;
        }
        return k/10;
    }
    string to_string(ll n)
    {  if(!n) return "0";
        string s=""; int a,b;
        while(n>0)
        {
            b=n%10;
            s+=(b+'0');
            n/=10;
        }
        reverse(all(s));
        return s;
    }


    void solve()
    {
    ll i,j=0,r=200,p,q,k=0,d,y=0,n,h=100000000000000,flag=0,m=0,a=hell,b=hell,id,h1,h2,a1,b1,a2,w,x,u,f,l,c=0,e,ans=0;
     cin>>n;
     vector < ll > v(n+1);
     rep(i,1,n)
     {
         cin>>d;
         v[d]++;
     }
     rep(i,1,n+1) cout<<v[i]<<endl;

    }
    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
       // cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int cnt = 0;
void merge(vector<int> &A,int left,int mid,int right){
    int n1 = mid-left;
    int n2 = right - mid;
    vector<int> L(n1+1);
    vector<int> R(n2+1);
    iota(L.begin(),L.end(),0);
    iota(R.begin(),R.end(),0);
    for(int i=0;i<=n1-1;i++){
        L[i] = A[left+i];
    }
    for(int i=0;i<=n2-1;i++){
        R[i] = A[mid+i];
    }
    L[n1] = INF;
    R[n2] = INF;
    int i=0;
    int j=0;
    for(int k=left;k<=right-1;k++){
        if(L[i]<=R[j]){
            cnt++;
            A[k]=L[i];
            i = i+1;
        }else{
            cnt++;
            A[k] = R[j];
            j = j+1;
        }
    }
}
void mergeSort(vector<int> &A,int left,int right){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(A,left,mid);
        mergeSort(A,mid,right);
        merge(A,left,mid,right);
    }
}
int main(){
    int n;cin >> n;
    vector<int> a(n);
    for(auto &i:a) cin >> i;
    mergeSort(a,0,n);
    for(int i=0;i<n;i++){
        cout << a[i];
        cout << ((i==n-1)?"\n":" ");
    }
    cout << cnt << endl;
}


Measured memory_bytes: 6856
class BIT
  attr_accessor(:size, :node)
  
  def initialize(size)
    @size = size
    @node = Array.new(size + 1, 0)
  end
  
  def add(i, x)
    while i <= @size
      @node[i] += x
      i += (i & -i)
    end
  end
  
  def sum(i)
    s = 0
    while i > 0
      s += @node[i]
      i -= (i & -i)
    end
    return s
  end
end

MOD = 10 ** 9 + 7

n, k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

bit = BIT.new(a.max)
left = []
0.step(n - 1) do |i|
  bit.add(a[i], 1)
  left << i + 1 - bit.sum(a[i])
end

res = 0
sa = a.sort
0.step(n - 1) do |i|
  res += (k * left[i]) % MOD
  res += (sa.bsearch_index {|x| x >= a[i] } || n) * (k * (k - 1) / 2) % MOD
  res %= MOD
end

puts res

Measured memory_bytes: 14224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = Long.parseLong((sc.next()));
		long w = Long.parseLong((sc.next()));
		long cell = h * w;

		if (h == 1 || w == 1) {
			System.out.println(1);
		} else if (cell % 2 == 1) {
			System.out.println(cell / 2 + 1);
		} else {
			System.out.println(cell / 2);
		}

	}
}


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

using namespace std;

vector<long long> func(vector<long long> &vv){
  long long temp;
  temp = vv[0];
  bool flag = false;
  int fl=0;
  for(long long j=1; j<vv.size(); j++){
    if (temp != vv[j]){
      vv.erase(vv.begin() + j - 1);
      vv.erase(vv.begin() + j - 1);
      fl = 1;
      break;
    }
    temp = vv[j];
  }
  if (fl == 0){
    return vv;
  }
  return func(vv);
}
     
int main() {
  std::string s;
  cin >> s;
  long long size = s.length();
        
  char cary[size]; 
  s.copy(cary, size);
  
  vector<long long> v(size);
  for (long long i=0;i<size;i++){
    v[i] = cary[i];
  }
  
  vector<long long> v2;
  v2 = func(v);
  
  cout << size - v2.size() <<endl;
      
  return 0;
}

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

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

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

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

  string ans = "No";
  string S;
  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) {
    ans = "Yes";
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
def search(arr, target):
    l, r = 0, len(arr) - 1
    while l <= r:
        mid = (l + r) // 2
        if arr[mid] == target:
            return True
        elif arr[mid] > target:
            r = mid - 1
        else:
            l = mid + 1
    return False


if __name__ == '__main__':
    n = int(input())
    arr_1 = list(map(int, input().split()))
    q = int(input())
    arr_2 = list(map(int, input().split()))
    ans = 0
    for element in arr_2:
        if search(arr_1, element):
            ans += 1
    print(ans)



Measured memory_bytes: 16712
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main(void){
  string s;cin>>s;
  if(atoi(s.substr(5,6).c_str())<=4)
    cout<<"Heisei"<<endl;
  else
    cout<<"TBD"<<endl;
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    if (S.at(S.length() - 1) == 's') {
        S += "es";
    }
    else {
        S += "s";
    }

    cout << S << endl;
    return 0;
}


Measured memory_bytes: 3632
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

const MAX = 50;

map0 = [];
for (i = 0; i <= MAX; i++) map0.push(0);
map1 = [].concat(map0);
map2 = [].concat(map1);
map3 = [].concat(map2);

for (i = 0; i <= 9; i++) map0[i] = 1;

function expand_map(map, smaller) {
	for (var i = 0; i < MAX; i++) {
		for (var j = Math.max(0, i - 9); j <= i; j++) {
			map[i] += smaller[j];
		}
	}
}

expand_map(map1, map0);
expand_map(map2, map1);
expand_map(map3, map2);

require('fs').readFileSync(config.input, 'ascii')
	.trim()
	.split(config.newline)
	.forEach(function (line) { console.log(map3[parseInt(line)]); })
	;

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

int main() {
	int N, D, X, A;
	cin >> N >> D >> X;
	for (int i = 0;i < N;++ i) {
		cin >> A;
		X += (D + A - 1) / A;
	}
	cout << X;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

各参加者について、1, A+1, ..., nA+1日目(nA+1≦D)にチョコレートを食べている
ここでnA+1≦Dよりn≦(D-1)/Aが成り立つので、答えは(D-1)/A+1となる
*/

Measured memory_bytes: 256
'use strict'
 
function main(s) {
  let first = s.split('\n')[0].split('').sort().join("");
  let second = s.split('\n')[1].split('').sort().reverse().join("");
  if(first <second){
  	console.log("Yes");
  } else {
  	console.log("No");
  }
  
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
from itertools import starmap
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
k=0
for _ in range(n):
    a=list(map(int,input().split()))
    w=sum(starmap(lambda i,j:i*j,zip(a,b)))+c
    if w>0:
        k+=1
print(k)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    double t=1,a=0,b=0,h,w,n,min=100000000000,k,ans=0;
    int aa,bb;
    string s,s2;
    cin >> a >> b;
    h = a;
    while(h<b){
        t++;
        h += a-1;
    }
    if(b==1) t = 0;
    cout << t <<endl;
    return 0;
}


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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int32_t a, int32_t b){return a * b / GCD(a, b);}
int64_t LCM(int64_t a, int64_t b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



//#define int int64_t
signed main()
{
	string s; cin >> s;
	//dp[i][k]->iを13で割った余りがKのパターン数
	vector<int> dp(13, 0);

	dp[0] = 1;

	int carry = 1;
	for(int i = s.size()-1; i >= 0; --i){
		vector<int> nextdp(13, 0);
		if(s[i] == '?'){
			for(int k = 0; k < 10; ++k){
				for(int j = 0; j < 13; ++j){
					nextdp[(k*carry+j)%13] += dp[j];
					nextdp[(k*carry+j)%13] %= MOD;
				}
			}
		}
		else{
			int k = s[i] - '0';
			for(int j = 0, i_len = (int)13; j < i_len; ++j){
				nextdp[(k*carry+j)%13] += dp[j];
				nextdp[(k*carry+j)%13] %= MOD;
			}
		}
		carry *= 10;
		carry %= 13;
		for(int i = 0; i < 13; ++i){
			dp[i] = nextdp[i];
		}
	}
	cout << dp[5];
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, 0, N)
    {
        cin >> L.at(i);
    }
    sort(all(L));
    int sum = 0;
    rep(i, 0, N)
    {
        if (i != N - 1)
        {
            sum += L.at(i);
        }
        else if (sum > L.at(i))
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
import sys
# sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# arr = [[int(el) for el in input().split()] for i in range(n)]

n = int(input())

s = set()

for _ in range(n):

    st = input()

    s.add(st)

print (len(s))



Measured memory_bytes: 28720
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};


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

    ll n;
    cin>>n;

    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    array<ll,2> dp[n+1][2]={};
    dp[0][0] = {1000,0};
    ll ans = 0;
    for(int i=0;i<n;i++){
        // pass
        for(int j=0;j<2;j++)dp[i+1][j] = dp[i][j];

        for(int j=0;j<2;j++){
            // buy
            if(chmax(dp[i+1][0][1],dp[i][j][1]+(ll)(dp[i][j][0]/a[i]))){
                dp[i+1][0][0] = dp[i][j][0] % a[i];
            }
            if(dp[i+1][0][1] == dp[i][j][1]+(ll)(dp[i][j][0]/a[i])){
                chmax(dp[i+1][0][0], dp[i][j][0]%a[i]);
            }
            // sell
            if(chmax(dp[i+1][1][0],dp[i][j][0]+a[i]*dp[i][j][1])){
                dp[i+1][1][1] = 0;
            }
        }
        chmax(ans,dp[i+1][0][0]);
        chmax(ans,dp[i+1][1][0]);
    }
    cout << ans << endl;
    
}

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

using namespace std;
    
int main(){

    int n,k;
    string s;

    cin >> n >> k;
    cin >> s;
    
    int ans = 0;

    vector<int> v;
    vector<int> sumv;
    int prev = 1;
    int count = 0;

    if(n > 3){

        for(int i = 0; i < n; i++){
            if(prev != s[i] - 48){
                v.push_back(count);
                prev = (prev + 1) % 2;
                count = 1;
            }else{
                count++;
            }
        }

        v.push_back(count);
        if(s[n - 1] - 48 == 0) v.push_back(0);

        for(int i = 0; i < v.size(); i++) cerr << v[i] << " ";
        cerr << endl;

        //k = 1 ... 3, k = 2 ... 5
        if(k * 2 + 1 > v.size()){
            ans = n;
        }else{
            sumv.push_back(0);
            for(int i = 0; i < v.size(); i++){
                sumv.push_back(sumv[i] + v[i]);
            }

            for(int i = 0; i < sumv.size(); i++) cerr << sumv[i] << " ";
            cerr << endl;

            int tmp = 0;
            for(int i = 0; i + k * 2 + 1 < sumv.size(); i = i + 2){
                cerr << sumv[i + k * 2 + 1] - sumv[i] << " ";
                tmp = max(tmp,sumv[i + k * 2 + 1] - sumv[i]);
            }
            cerr << endl;

            ans = tmp;
        }


    }else{
        ans = n;
    }

    cout << ans << endl;

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int A, B;

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

    std::cin >> A >> B;

    int cost = A + B / 2;
    std::cout << cost << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(long long i=0; i<N; i++){    ;
int main() {
long long N;
cin>>N;
long long answer=1;
bool a=true;
vector<long long>A(N);
rep(i,N)
cin>>A.at(i);
  if(A.at(i)==0){
    a=false;
    cout<<0<<endl;
}
}
  if(a==true){
rep(i,N)
ll hantei=1000000000000000000/answer;
answer*=A.at(i);
if(answer>1000000000000000000||hantei<A.at(i)){
    cout<<-1<<endl;
        a=false;
    break;
}
}
}
if(a==true){
    cout<<answer<<endl;
}
}


Measured memory_bytes: 4052
#include <stdio.h>

int n, a[50];

int solve (int i, int b) {
  int res;

  if (b == 0) {
    return 1;
  }
  if (i >= n) {
    return 0;
  }

  res = solve(i+1, b) || solve(i+1, b - a[i]);

  return res;
}

int main () {

   int q, i, m;

   scanf ("%d\n", &n);
   for (i = 0; i < n; i++) {
     scanf ("%d\n", &a[i]);
   }

   scanf ("%d\n", &q);
   for (i = 0; i < q; i++) {
     scanf ("%d\n", &m);
     if ( solve(0, m) ) {
       printf("yes\n");
     }
     else {
       printf ("no\n");
     }
   }

   return 0;
}

Measured memory_bytes: 584
import java.util.*;
 
class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    if (N%1000 == 0){
      System.out.println(0);
    }else if (N<=1000&&0<N){
      System.out.println(1000-N);
    }else if(1000<N&&N<10000){
      System.out.println(1000-N%1000);
    }
  }
}


Measured memory_bytes: 35832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
vector<pair<ll,ll> > p;
int main(){
  int k;
  cin >> k;
  string s[32] = {"1", "1", "1", "2", "1", "2", "1", "5", "2", "2", "1", "5", "1", "2", "1", "14", "1", "5", "1", "5", "2", "2", "1", "15", "2", "2", "5", "4", "1", "4", "1", "51"};
  cout << s[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){
  
  int n;
  cin >> n;
  
  int rate[n];
  REP(i,n){
    cin >> rate[i];
  }

  sort(rate,rate+n);
  
  int color[8] = {},free = 0;
  REP(i,n){
    if(rate[i] >= 3200) free++;
    else color[rate[i]/400]++;
  }
  
  int ans = 0;
  REP(i,8){
    if(color[i] > 0) ans++;
  }
  
  if(ans == 0 && free != 0) {ans = 1; free--;}
  
  cout << ans << " " << ans + free << endl;


 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long
using namespace std;

int main() {
      int N;
      cin >> N;
      ll A[N];

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

      int count = 1;        // given N>=1, there will at least be 1 subarray
      int order = 0;        // 0 - reset (partition);     1 - ascending;       2 - descending

      for(int i=1; i<N; i++) {
            if((order == 1 && A[i]<A[i-1]) || (order == 2 && A[i]>A[i-1])) {  // set partition
                  order = 0;
                  count++;
            }     
            else if(A[i] > A[i-1]) order = 1;
            else if(A[i] < A[i-1]) order = 2;
      }
      
      cout << count << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    VI x(n), y(n);
    VI sort_x, sort_y;
    REP(i, n){
        cin >> x[i] >> y[i];
        sort_x.push_back(x[i]);
        sort_y.push_back(y[i]);
    }
    sort(ALL(sort_x));
    sort(ALL(sort_y));

    ll ans = 1LL * (sort_x.back() - sort_x.front()) * (sort_y.back() - sort_y.front());
    REP(xf, n)REP(yf, n)FORR(xe, n - 1, xf + 1)FORR(ye, n - 1, yf + 1){
        int k_count = 0;
        REP(i, n){
            if(sort_x[xf] <= x[i] and x[i] <= sort_x[xe] and sort_y[yf] <= y[i] and y[i] <= sort_y[ye])
                k_count++;
        }
        if(k_count >= k)
            ans = min(ans, 1LL * (sort_x[xe] - sort_x[xf]) * (sort_y[ye] - sort_y[yf]));
    }

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


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

#define all(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

//constexpr int mod = 998244353;
constexpr int MOD = 1000000007;

class mint {
  private: 
    long long x;

  public:
    constexpr mint(const long long x = 0) noexcept : x((x % MOD + MOD) % MOD) {}
    constexpr long long value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= MOD) x -= MOD;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += MOD - right.x) >= MOD) x -= MOD;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % MOD;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }

    constexpr mint inv() const {
      return pow(MOD-2);
    }

    constexpr mint pow(long long n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

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

  int n, k;
  cin >> n >> k;

  vector<int> plus, minus;
  mint val(1);

  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;

    val *= a;

    if (a < 0) minus.emplace_back(abs(a));
    else plus.emplace_back(a);
  }

  if (k == n) {
    cout << val.value() << '\n';
    return (0);
  }

  sort(all(minus), greater<int>());
  sort(all(plus), greater<int>());

  vector<int> choose(k);
  bool flag = true;
  int p = 0, m = 0;

  while (p+m < k) {
    if (p >= plus.size()) {
      choose[p+m] = minus[m];
      ++m;
      flag ^= 1;
      continue;
    }

    if (m >= minus.size()) {
      choose[p+m] = plus[p];
      ++p;
      continue;
    }

    if (plus[p] > minus[m]) {
      choose[p+m] = plus[p];
      ++p;
    } else {
      choose[p+m] = minus[m];
      ++m;
      flag ^= 1;
    }
  }

  mint ans(1);
  for (int i = 0; i < k; ++i) ans *= choose[i];

  if (flag) {
    cout << ans.value() << '\n';
    return (0);
  }

  if (plus.empty() && (k & 1)) {
    ans = 1;
    for (int i = 0; i < k; ++i) ans *= -minus[n-i-1];
    cout << ans.value() << '\n';

    return (0);
  }

  if (p == 0 || m == minus.size()) ans = (ans / minus[m-1]) * plus[p];
  else if (m == 0 || p == plus.size()) ans = (ans / plus[p-1]) * minus[m];
  else {
    if (plus[p] * plus[p-1] > minus[m] * minus[m-1]) ans = ans / minus[m-1] * plus[p];
    else ans = ans / plus[p-1] * minus[m];
  }

  cout << ans.value() << '\n';

  return (0);
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N;
vec A(101010), B(101010);

signed main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

  int ans = 0;
  for (int i = N - 1; 0 <= i; i--) {
    A[i] += ans;
    int tmp = (B[i] - A[i] % B[i]) % B[i];
    ans += tmp;
  }

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


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

int n, k, d[55], esta[55];

bool valido(int val){
	while(val>0){
		if(esta[(val%10)]==1){
			return false;
		}
		val/=10;
	}
	return true;
}

int main(){
	while(scanf("%d %d", &n, &k)!=EOF){
		memset(esta, 0, sizeof(esta));
		for(int i=0; i<k; i++){
			scanf("%d", &d[i]);
			esta[d[i]]=1;
		}
		int val;
		for(val=n; val<=100000; val++){
			if(valido(val)){
				break;
			}
		}
		printf("%d\n", val);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int N, K;
	cin >> N >> K;
	if (N % K == 0)
		cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;
}

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

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

    static class CAtCoDeer {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long x = in.nextInt();
            long y = in.nextInt();
            for (int i = 0; i < n - 1; i++) {
                long t = in.nextInt();
                long a = in.nextInt();
                long k = Math.max(MathUtil.ceil(x, t), MathUtil.ceil(y, a));
                x = t * k;
                y = a * k;
            }
            out.println(x + y);
        }

    }

    static class MathUtil {
        public static long ceil(long l1, long l2) {
            return (l1 - 1 + l2) / l2;
        }

    }
}



Measured memory_bytes: 39728
# %% AGC 025 A


def sumOfDigits(n):
    res = 0
    while n > 0:
        res += n % 10
        n //= 10
    return res


n = int(input())
mn = n
for i in range(1, n):
    b = n - i
    mn = min(sumOfDigits(i) + sumOfDigits(b), mn)

print(mn)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int R;
    cin >> R;
    if (R < 1200)
    cout << "ABC" << endl;
    else if (R < 2800)
    cout << "ARC" << endl;
    else 
    cout << "AGC" << endl;
}

Measured memory_bytes: 256
x = int(input())

expo = [0]*(x+1)
expo[1] = 1

for i in range(2,x+1):
    v = i*i
    while v <= x:
        expo[v] = 1
        v *= i
        
for i in range(x,-1,-1):
    if expo[i]:
        print(i)
        exit()

Measured memory_bytes: 9188
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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

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

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};


int main(){
    double a,b,x;
    cin >> a >> b >> x;
    if(x > a*a*b / 2){
        double tan = 2*(a*a*b - x) / (a*a*a);
        double res = atan(tan);
        res = res * (180 / M_PI);
        printf("%.12lf\n",res);
    }
    else{
        double tan = (a * b * b) / (2 * x);
        double res = atan(tan);
        res = res * (180 / M_PI);
        printf("%.12lf\n",res);
    }
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
vi ans;
int32_t main()
{
  BOOST;
  int k;
  cin>>k;
  int n=50;
  for (int i=0;i<n;i++)ans.pb(i+k/n);
  int ile=k%n;
  for (int i=0;i<=ile-1;i++){
  	for (int j=0;j<n;j++){
  		if (i==j)ans[j]+=n;
  		else ans[j]--;
  	}
  }
  cout<<sz(ans)<<"\n";
  for (auto it:ans)cout<<it<<" ";
  return 0;
}


Measured memory_bytes: 3664
N = int(input())
A = list(map(int, input().split()))
ans, dic = 0, {i:0 for i in range(1, 10**5 + 1)}
for a in A:
    ans += a
    dic[a] += 1
Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * dic[B]
    dic[C] += dic[B]
    dic[B] = 0
    print(ans)

Measured memory_bytes: 24460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
using namespace std;
#define ll long long

int main() {
	int N; cin >> N;
	vector<pair<ll, ll>> v(N);
	map<pair<ll, ll>, int> mp;
	for(int i=0; i<N; ++i){
	    cin >> v[i].first >> v[i].second;
	}
	sort(v.begin(), v.end());
	for(int i=0; i<N; ++i){
	    for(int j=i+1; j<N; ++j){
	        ++mp[make_pair(v[j].first-v[i].first, v[j].second-v[i].second)];
	    }
	}
	int mx=0;
	for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
	    mx=max(mx, itr->second);
	}
	cout << N-mx << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n;
    cin >> n;
    vector<ll> s(n-1), c(n-1), f(n-1);
    rep1(i, n-1) cin >> c[i] >> s[i] >> f[i];
    ll sta;
    rep1(i, n-1){
        sta = i;
        ll t = 0;
        while (sta<n-1) {
            if (t>=s[sta]){
                if (t%f[sta]!=0) t += f[sta] - t%f[sta] + c[sta];
                else t += c[sta];
            }
            else t = s[sta]+c[sta];
            sta++;
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    //printf("%.12f", ans);
}

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

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    int curr_num = -1, target = 1;
    for (int i = 0; i < N; i++) {
        if (a[i] == target) {
            curr_num = target;
            target++;
        }
    }

    if (curr_num == -1) {
        std::cout << -1 << std::endl;
    }
    else {
        std::cout << N - curr_num << std::endl;
    }
    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
import re
import math
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 

 
#main
n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
sum_=0
for a in range(n-k):
    sum_+=H[a]
print(sum_)

Measured memory_bytes: 114896
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x.size());
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	
	int n=in();
	int g=in(),x;
	for(int i=1;i<n;i++){x=in();g=__gcd(x,g);}
	cout<<g;
}

Measured memory_bytes: 3728
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

int gcd(int a, int b) {
  if (b==0) return a;
  return gcd(b,a%b);
}

signed main() {
	int a,b,c,d;
	std::cin >> a >> b >> c >> d;
	int x = abs(a-c);
	int y = abs(b-d);
	int n = gcd(x,y);
	int e = x/n;
	int f = y/n;
	int ans = (e+f-1)*n;
	print(ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, C, D, E, M, N, K, Q, W, H, T, X, Y;

int main()
{
    string s;
    cin >> s;
    cout << s[0] << (s.size()-2) << s[s.size()-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<typename T>void chmax(T &a,T b){a=max(a,b);}
template<typename T>void chmin(T &a,T b){a=min(a,b);}
using namespace std;

void solve(){
	int n;
	vector<string> s(3);
	cin>>n;
	rep(i,3)cin>>s[i];
	sort(begin(s),end(s));
	int cnt=0;
	rep(i,n){
		if(s[0][i]!=s[1][i]&&s[1][i]!=s[2][i]&&s[2][i]!=s[0][i]){
			cnt+=2;
		}
		else if(s[0][i]==s[1][i]&&s[0][i]!=s[2][i])++cnt;
		else if(s[1][i]==s[2][i]&&s[0][i]!=s[2][i])++cnt;
		else if(s[0][i]==s[2][i]&&s[0][i]!=s[1][i])++cnt;
	}
	cout<<cnt<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
int n, m;
cin >> n >> m;
int ans1 = 0, ans2 = 0;
for (int i = 0; i < n; i++){
    ans1 += i;
}
for (int i = 0; i < m; i++){
    ans2 += i;
}
cout << ans1 + ans2 << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  int n,d;
  cin >> n >> d;
  cout << (n+2*d)/(2*d+1) << endl;
}

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

int c[9];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);	
	for (int i = 1; i <= 3; i++) {
		int a, b; cin >> a >> b;
		c[a]++; c[b]++;
	}
	for (int i = 1; i <= 4; i++)
		if (c[i] == 3) {
			cout << "NO" << '\n';
			return 0;
		}
	cout << "YES" << '\n';
	return 0;
}

Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2==0:
               print('#',end="")
            else:
               print('.',end="")
        print()
    print()


Measured memory_bytes: 7004
#include<bits/stdc++.h>
     
    using namespace std;
     
    #define all(x) x.begin(), x.end()
    typedef vector<int> vi;
    typedef pair<int,int> ii;
    typedef long long ll;
     
    const ll inf = 3e18 + 5;
     
    const int MAXN = 1 << 19;
    int N = 400000;
    int seg[2 * MAXN], A[MAXN];
    typedef vector<vi> vvi;
    
    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
    
        char c;
        cin >> c;
        if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
            cout << "vowel";
        else
            cout << "consonant";
    }

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

using namespace std;

const int MAXV = 1E5;
const int MAXN = 100;
const int MAXW = 1E9;
pair<int, int> item[MAXN + 1];
int dp[MAXV + 1][MAXN + 1];

int main()
{
    int n, w;
    cin >> n >> w;
    for (int i = 1; i <= n; i++)
        cin >> item[i].first >> item[i].second;
    for (int i = 1; i <= MAXV; i++)
        dp[i][0] = MAXW + 1;
    int ans = 0;
    for (int value = 1; value <= MAXV; value++)
    {
        for (int i = 1; i <= n; i++)
        {
            int leftover = max(0, value - item[i].second);
            dp[value][i] = dp[value][i - 1];
            if (dp[leftover][i - 1] < MAXW + 1)
                dp[value][i] = min(dp[value][i], item[i].first + dp[leftover][i - 1]);
        }
        if (dp[value][n] <= w)
            ans = value;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 39808
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int A, B;
	bool flag = true;
	string S;

	cin >> A >> B >> S;

	for (int i = 0; i < A + B + 1; i++)
	{
		if (i == A)
		{
			if (S[i] != '-')
			{
				flag = false;
				break;
			}
		}
		else if ('0' <= S[i] && S[i] <= '9')
		{
		}
		else
		{
			flag = false;
			break;
		}
	}

	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    int sx,sy,gx,gy; cin >> sx >> sy >> gx >> gy;
    vector<string> S(H); cin >> S;

    vector<vector<int>> dp(H,vector<int>(W,INF));
    deque<pair<int,int>> deq;
    dp[--sx][--sy]=0; deq.emplace_back(sx,sy);
    auto ok=[&](int x,int y){return !(x<0||H<=x||y<0||W<=y||S[x][y]=='#');};
    while(!deq.empty()){
        auto p=deq.front(); deq.pop_front();
        int x=p.first,y=p.second;
        for (int i=0;i<4;++i){
            int nx=x+dx[i],ny=y+dy[i];
            if (!ok(nx,ny)) continue;
            if (chmin(dp[nx][ny],dp[x][y])) deq.emplace_front(nx,ny);
        }
        for (int i=-2;i<=2;++i){
            for (int j=-2;j<=2;++j){
                int nx=x+i,ny=y+j;
                if (!ok(nx,ny)) continue;
                if (chmin(dp[nx][ny],dp[x][y]+1)) deq.emplace_back(nx,ny);
            }
        }
    }

    int ans=dp[--gx][--gy];
    cout << (ans==INF?-1:ans) << '\n';
}

Measured memory_bytes: 8796
#include<iostream>
using namespace std;
#include<string>
#include<utility>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#include<stdio.h>

int main(){
    int N;
    cin >> N;
    double X=108;
    double Y=N*100;
    double K=Y/X;
    int L=(int) K;
    int Z=(int) N;
    int S=(int) X;
    int D=(int) Y;
    int start=0;
    bool exist=false;
    int num=0;
    for(int i=0;i<=N;++i){
        if(floor(i*1.08)==N){
            exist=true;
            num=i;
            break;
        }
    }
    if(exist){
        cout << num;
    }
    else{
        cout << ":(";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
using Graph=vector<vector<pair<int,int>>>;
vector<int> color;
void dfs(const Graph &G,int v,int cur=0){
  color[v]=cur;
  for(auto next:G[v]){
    if(color[next.first]!=-1) continue;
    if(next.second==0) dfs(G,next.first,cur);
    if(next.second==1) dfs(G,next.first,1-cur);
  }
  
}
int main(){
  int N;
  cin >> N;
  color.resize(N+1);
  for(int i=1;i<N+1;i++) color[i]=-1;
  Graph G(N+1);
  for(int i=1;i<N;i++){
    int x,y,z;
    cin >> x >> y >> z;
    z%=2;
    G[x].push_back(make_pair(y,z));G[y].push_back(make_pair(x,z));
  }
  dfs(G,1);
  for(int i=1;i<N+1;i++)
    cout << color[i] << endl;
  
}

Measured memory_bytes: 8192