akhauriyash/Code-Regression huggingface dataset:
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(long long int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  long long int n;
  cin>>n;
  vector<long long int> v(5);
  rep(i,5) cin>>v[i];
  sort(v.begin(),v.end());
  cout<<(n+v[0]-1)/v[0]+4<<endl;
}

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

class unionfind {
private:
	int size_;
	std::vector<int> parent;
	std::vector<int> rank;
public:
	unionfind() : size_(0), parent(std::vector<int>()), rank(std::vector<int>()) {};
	unionfind(int size__) : size_(size__), parent(std::vector<int>(size_)), rank(std::vector<int>(size_, 0)) {
		std::iota(parent.begin(), parent.end(), 0);
	}
	int size() { return size_; }
	int root(int x) {
		if (parent[x] == x) return x;
		return parent[x] = root(parent[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) parent[x] = y;
		else if (rank[x] > rank[y]) parent[y] = x;
		else parent[y] = x, rank[x]++;
	}
};

#include <cstdio>
int N, Q, tp, x, y;
int main() {
	scanf("%d%d", &N, &Q);
	unionfind uf(N);
	while (Q--) {
		scanf("%d%d%d", &tp, &x, &y);
		if (tp == 0) uf.unite(x, y);
		else printf("%d\n", uf.same(x, y));
	}
	return 0;
}

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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)
#define MP(a, b) make_pair(a, b)


int main()
{
	rep(i, 3) {
		string s;
		cin >> s;
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int a,b; cin>>a>>b;
	if(a<=9 && b<=9) return cout<<a*b<<endl, 0;
	else return cout<<-1<<endl, 0;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=(a>b)?(a):(b);
#define chmin(a, b) (a)=(a<b)?(a):(b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PL;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  string s;
  cin >> s;
  
  if(s[2]==s[3]&&s[4]==s[5]) pt("Yes");
  else pt("No");
  
  
  
}




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

ll a,b,c;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	a=rd();b=rd();c=rd();
	if (c<=b+1) { printf("%lld\n",b+c);return 0; }
	printf("%lld\n",b+min(c,a+b+1));
	return 0;
}

Measured memory_bytes: 764
import itertools
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
b = [0,1]
ans = -float('inf')
for e in itertools.product(b,repeat=10):
    e = list(e)
    if e == [0]*10:
        continue
    res = 0
    for i in range(N):
        cnt = 0
        for j in range(10):
            if e[j] == 1 and F[i][j] == 1:
                cnt += 1
        res += P[i][cnt]
    if res > ans:
        ans = res
print(ans)

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

int main()
{
 int n;
 while(cin>>n)
 {
  if(n>2)
  {
   int m=0, count=1;
    for(int i=0; i<n-2; i++)
     {
        m+=count;
        count++;
      }
     cout<<n*2+m<<endl;
    }
   else
   {
    cout<<n*2<<endl;
   }
   }
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Stack<Integer> st = new Stack<>();

        while (sc.hasNext()) {
            String s = sc.next();
            if ('0' <= s.charAt(0) && s.charAt(0) <= '9') {
                st.push(Integer.parseInt(s));
            } else {
                int b = st.pop(), a = st.pop();
                if ("+".equals(s)) {
                    st.push(a + b);
                } else if ("-".equals(s)) {
                    st.push(a - b);
                } else if ("*".equals(s)) {
                    st.push(a * b);
                }
            }
        }
        System.out.println(st.pop());
    }

}


Measured memory_bytes: 26412
#include <stdio.h>
#include <ctype.h>

int main(){
    char ch;
    while(1){
        scanf("%c", &ch);
        if(ch=='\n'){
            printf("\n");
            break;
        }else if(islower(ch)){
            printf("%c", toupper(ch));
        }else if(isupper(ch)){
            printf("%c", tolower(ch));
        }else{
            printf("%c", ch);
        }
    }

    return 0;
}


Measured memory_bytes: 2076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x=Q[head];
    head=(head+1)%LEN;
    return x;
}

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

int main() {
    int elaps=0,c;
    int i,q;
    P u;
    scanf("%d %d",&n,&q);
    for(i=1;i<=n;i++){
        scanf("%s",Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head=1;tail=n+1;
    while(head!=tail){
        u=dequeue();
        c=min(q,u.t);
        u.t-=c;
        elaps+=c;
        if(u.t>0){
            enqueue(u);
        }
        else{
            printf("%s %d\n",u.name,elaps);
        }
    }
	return 0;
}



Measured memory_bytes: 12860
S = input()
K = int(input())

ans = 1
count = 0

if len(S) == 1:
    ans = S[0]
else:
    for i in S:
        if i == "1":
            count += 1
        if not i == "1":
            if K > count:
                ans = i
                break
            else:
                ans = 1
print(ans)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Collections;
import java.util.ArrayList;

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

    static class ID {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            HashMap<Long, Integer> map = new HashMap<>();
            int[] pre = new int[n + 1];
            HashMap<Integer, Long> imap = new HashMap<>();


            for (int i = 0; i < m; i++) {
                int p = Integer.parseInt(in.next());
                long year = Long.parseLong(in.next());
                map.put(year, p);
                imap.put(i, year);
            }

            ArrayList<Long> ys = new ArrayList<>(map.keySet());
            Collections.sort(ys);

            HashMap<Long, String> result = new HashMap<>();
            for (Long year : ys) {
                int p = map.get(year);
                int num = pre[p] + 1;
                pre[p] = num;

                result.put(year, String.format("%06d%06d", p, num));
            }

            ArrayList<Integer> keys = new ArrayList<>(imap.keySet());
            Collections.sort(keys);

            for (Integer i : keys) {
                Long y = imap.get(i);
                out.println(result.get(y));
            }
        }

    }
}



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

ll p=3;

ll happy(ll n,ll h[][3])
{
    ll t[n][3];
    
    for(int j=0;j<3;j++)
    {
        t[0][j]=h[0][j];
    }
    
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            t[i][j]=h[i][j]+ max(t[i-1][(j+1)%p], t[i-1][(j+2)%p] );
        }
    }
    
    ll largest=max( t[n-1][0], max( t[n-1][1], t[n-1][2] ) );
    
    return largest;
}

int main() {
	
	ll n;
	cin >>n;
	ll h[n][3];
	
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<3;j++)
	    cin >>h[i][j];
	}
	
	std::cout << happy(n,h) << std::endl;
	
	return 0;
}

Measured memory_bytes: 8252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define len(arr) (int)(sizeof(arr)/sizeof((arr)[0]))
#define Sort(arr) sort(arr,arr+len(arr))
#define For(i,s,n) for(int i=s;i<n;i++)	
#define Rep(i,n) for(int i=0;i<n;i++)
#define Per(i,n) for(int i=n;i>=0;i--)
#define All(x) (x).begin(),(x).end()
#define in(arr,n) Rep(i,n) cin >> arr[i];
#define in2(arr1,arr2,n) Rep(i,n) cin >> arr1[i] >> arr2[i];
#define in3(arr1,arr2,arr3,n) Rep(i,n) cin >> arr1[i] >> arr2[i] >> arr3[i];
#define LL_MAX 9223372036854775807
#define LL_MIN -9223372036854775808
#define MOD 1000000007
#define MOD9 1000000009

//{ ライブラリ

// 標準出力の高速化
#define endl "\n"

// 出力
template<typename Type>
void print(Type a[],int n){
	Rep(i,n) cout << a[i] << endl;
}
template<typename Type1,typename Type2>
void print(Type1 a[],Type2 b[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << endl;
}
template<typename Type1,typename Type2,typename Type3>
void print(Type1 a[],Type2 b[],Type3 c[],int n){
	Rep(i,n) cout << a[i] << " " << b[i] << " " << c[i] << endl;
}

// 配列の最大値
template<typename Type>
Type max(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=max(ret,a[i]);
	return ret;
}

// 配列の最小値
template<typename Type>
Type min(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=min(ret,a[i]);
	return ret;
}

// 最大公約数
template<typename Type>
Type gcd(Type a,Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type gcd(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=gcd(ret,a[i]);
	return ret;
}

// 最小公倍数
template<typename Type>
Type lcm(Type a,Type b){return (a/gcd(a,b))*b;}
template<typename Type>
Type lcm(Type a[],int n){
	Type ret=a[0];
	For(i,1,n) ret=lcm(ret,a[i]);
	return ret;
}

// aを元にしてペアでソート
template<typename Type1,typename Type2>
void PairSort(Type1 a[],Type2 b[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,left,i-1);
	if(j+1<right) PairSort(a,b,j+1,right);
}
template<typename Type1,typename Type2,typename Type3>
void PairSort(Type1 a[],Type2 b[],Type3 c[],int left,int right){
	int i=left,j=right;
	Type1 p=a[(left+right)/2];
	while(true){
		while(a[i]<p) i++;
		while(p<a[j]) j--;
		if(i>=j) break;
		swap(a[i],a[j]);
		swap(b[i],b[j]);
		swap(c[i],c[j]);
		i++;j--;
	}
	if(left<i-1) PairSort(a,b,c,left,i-1);
	if(j+1<right) PairSort(a,b,c,j+1,right);
}

// 配列を逆順にする
template<typename Type>
void Reverse(Type a[],int n){Rep(i,n/2) swap(a[i],a[n-i-1]);}

// 文字列を逆順にする
// reverse(All(str));

//}

int main(){
	int A,B;
	cin >> A >> B;
	if((A+B)%2==1){
		cout << "IMPOSSIBLE";
		return 0;
	}
	cout << (A+B)/2;
}

Measured memory_bytes: 256
'use strict';

function main(input) {
  const arr = input.trim().split(' ');
  const hpT = Number(arr[0]);
  const attackT = Number(arr[1]);
  const hpA = Number(arr[2]);
  const attackA = Number(arr[3]);
  const T = Math.ceil(hpA / attackT);
  const A = Math.ceil(hpT / attackA);

  if (T <= A) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29620
#include <bits/stdc++.h>
using namespace std;
 int main(){
   long long n,k;
   cin >> n >> k;
   vector<long long> v(n);
   for(int i=0;i<n;i++){
     cin >> v[i];
   }
   sort(v.begin(),v.end());
   long long t=v.size()-k;
   long long ans=0;
   for(int i=0;i<t;i++){
     ans+=v[i];
   }
   cout << ans << endl;
 }


Measured memory_bytes: 1792
s = input()
ans = float('inf')
for x in s:
    cnt = 0
    temp = s
    while len(set(temp))!=1:
        t = ''
        for i in range(len(temp)-1):
            if temp[i+1]==x:
                t += temp[i+1]
            else:
                t += temp[i]
        temp = t
        cnt += 1
    ans = min(ans,cnt)
print(ans)

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


int main(){
  
  

  int n;
  cin>>n;
  
  vector<int> data(n+1);
  
  data.at(0)=0;
  
  for (int i=1;i<=n;i++){
    int count=data.at(i-1)+1;
    
    for (int j=6;j<=i;j*=6){
      int tmp=data.at(i-j)+1;
      count=min(tmp,count);
    }
    
    for (int j=9;j<=i;j*=9){
      int tmp=data.at(i-j)+1;
      count=min(tmp,count);
    }
    
    data.at(i)=count;
  }
  
  cout<<data.at(n)<<endl;
  
    
    

  
  

  
  
}

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

int main() {
	int D, C[26];
	cin >> D;
	for (int i = 0; i < 26; i++) cin >> C[i];
	vector<int> L(26, -1);
	vector<vector<int> > S(D, vector<int>(26));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) cin >> S[i][j];
	}
	for (int i = 0; i < D; i++) {
		long long MAX = -1000000000000000, ID = -1;
		for (int j = 0; j < 26; j++) {
			if (MAX < S[i][j] + C[j] * 10 * (i - L[j])) MAX = S[i][j] + 10 * C[j] * (i - L[j]), ID = j;
		}
		L[ID] = i;
		cout << ID + 1 << endl;
	}
}

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

int main(){
	int n;
	cin>>n;
	vector<int>v(n);
	int k;
	cin>>k;
	int m;
	int d;
	for (int i = 0; i<k; i++){
		cin>>m;
		for (int j = 0; j<m; j++){
			cin>>d;
			v[d-1]++;
		}
	}
	int ans = 0;
	for (int i = 0; i<n; i++){
		if (v[i] == 0){
			ans++;
		}
	}
	cout<<ans;	
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
#define LL long long

const LL MOD = 1e9 + 7;
LL n;

LL get(LL x, LL y)
{
    LL ret = 0;
    while(x >= y) {
        ret += x / y;
        x /= y;
    }
    return ret;
}


bool prime(int x)
{
    if(x < 2) return false;
    if(x == 2) return true;
    if(x % 2 == 0) return false;
    for(int i=3;i*i<=x;i+=2) if(x % i == 0) return false;
    return true;
}

int main()
{

    while(cin >> n){
        LL ans = 1;
        for(int i=2;i<=n;i++){
            if(!prime(i)) continue;
            LL dv = get(n, i);
//            cout << i << ' ' << dv << '\n';
            ans = (ans * (dv + 1LL)) % MOD;
        }
        cout << ans << '\n';
    }
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

void solve(long long K, long long N, std::vector<long long> A) {}

int main()
{
    long long K;
    scanf("%lld", &K);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    ll tot = 0;
    ll max_dis = 0;
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
        if (i == 0)
        {
            continue;
        }
        else
        {
            tot += A[i] - A[i - 1];
            max_dis = max(max_dis, A[i] - A[i - 1]);
        }
    }
    tot += K - A[N - 1] + A[0];
    max_dis = max(max_dis, K - A[N - 1] + A[0]);
    cout << tot - max_dis << endl;
    return 0;
}


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

Measured memory_bytes: 86288
/***
 ** " All that we are is the result of what we have thought. "
 **     -- Buddha
***/

/**
  *  Author: dhruv_gheewala
  *  Problem: __________
  *  Date:   27.04.2020
  *  Time:   03:02:31
**/

#define header_file "Lib/debug.h"
#if __has_include(header_file)
    #include header_file
#else
    #include<bits/stdc++.h>
    using namespace std;
    
    #define fundri 108
    #define debug(...) 1729
#endif

#define int long long
typedef pair<int, int> pii;
typedef vector<int> vi;

const bool testcases = 0;
#define ff first
#define ss second
#define endl '\n'
#define all(s) s.begin(), s.end()

// if vector isn't soted then it will remove consecutive same elements
#define make_unique(vec) vec.erase(unique(all(vec)), vec.end())
#define test int TC = 1;if(testcases)cin >> TC;for(int tc = 1 ; tc <= TC ; tc++)
#define sort_by(cont,expr) sort(all(cont),[&](const auto &lhs,const auto &rhs){return expr;})

void online_judge();
int seed; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = INT_MAX) {return uniform_int_distribution<int>(l, r)(rng);}

template<typename T>bool isPrime(T n) {for(T i = 2; i * i <= n; i++)if(n % i == 0)return 0; return 1;}
template<typename T>inline bool in_range(T a, T l, T r) {return (a >= l && a <= r);}
template<typename T, typename U>inline istream &operator >>(istream &in, pair<T, U> &a) {in >> a.ff >> a.ss; return in;}
template<typename T>inline istream &operator >>(istream &in, vector<T> &a) {for(auto &x : a)in >> x; return in;}

int32_t main(int32_t argc, char **argv)
{
    online_judge();
    
    int s, w;
    
    test {

        cin >> s >> w;
        cout << (w >= s ? "unsafe" : "safe") << endl;
    
        fundri;
    }
    
    return 0;
}

void online_judge() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

#ifdef DHRUV_GHEEWALA
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

}

Measured memory_bytes: 3644
<?php
while(true){
    list($n,$r) = explode(" ",trim(fgets(STDIN)));
    if($n == 0 && $r == 0) break;
    $arr = [];
    for($i = $n; $i >= 1; $i--){
        $arr[] = $i;
    }
    for($i = 0; $i < $r; $i++){
        list($p,$c) = explode(" ",trim(fgets(STDIN)));
        $arr = array_merge(array_splice($arr,$p-1,$c),$arr);
    }
    echo $arr[0]."\n";
}

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

using namespace std;
typedef long long int ll;
void bssub(vector<ll> &v, ll &a, ll &b, ll t,int st, int end) {
    if ((end-st) <= 1) {
        a = v[st];
        b = v[end];
        return;
    }
    int mid = st + (end-st) /2;
    if (v[mid] <= t) {
        bssub(v,a,b,t,mid,end);
    } else {
        bssub(v,a,b,t,st,mid);
    }
}
void bs(vector<ll> &v, ll &a, ll &b, ll t) {
    bssub(v,a,b,t, 0,v.size() -1);
}
ll s1(vector<ll> &v, ll t) {
    ll a,b;
    bs(v,a,b,t);
    //printf("s1 a=%lld b=%lld\n",a ,b);
    return min(abs(b-t),abs(a-t));
}
ll s(vector<ll> &v1, vector<ll> &v2, ll t) {
    ll a, b;
    bs(v1, a, b, t);
    //printf("s a=%lld b=%lld\n",a ,b);
    return min(abs(a-t)+s1(v2,a), abs(b-t)+s1(v2,b));
}
int main() {
    int a,b, q;
    cin >> a >> b >> q;
    vector<ll> ss, ts;
    for(int i=0;i<a;i++) {
        ll s;
        cin >> s;
        ss.push_back(s);
    }
    for(int i=0;i<b;i++) {
        ll t;
        cin >> t;
        ts.push_back(t);
    }
    sort(ss.begin(), ss.end());
    sort(ts.begin(), ts.end());
    for(int i=0;i<q;i++) {
        ll x;
        cin >> x;
        ll ans = min(s(ss, ts, x), s(ts, ss, x));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    lli a,b;
    cin >> a >> b;
    
    if(a%b == 0){
        cout << -1 << endl;
    }else{
        cout << a*b + a << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int a;
    int b;
    int c;
    scanf("%d %d %d",&a,&b,&c);
    if(a*b >c){
        printf("%d",c);
    }
    else{
        printf("%d",a*b);
        
    }
    
    
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using Tup = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fl cout<<flush;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld pi=3.141592653589793238;

/* RMQ：[0,n-1] について、区間ごとの最大値を管理する構造体
    update(a,b,x): 区間[a,b) の要素を x に更新。O(log(n))
    update(a,x): a番目の要素を x に更新。O(log(n))
    query(a,b): [a,b) での最大の要素を取得。O(log(n))
    get(a): a番目の要素を取得。O(log(n))
*/
template <typename T>
struct RMQ {
    ll n;
    vector<T> dat, lazy;
    RMQ(ll n_) : n(), dat(n_ * 4, -INF), lazy(n_ * 4, -INF) {
        ll x = 1;
        while (n_ > x) x *= 2;
        n = x;
    }
    /* lazy eval */
    void eval(ll k) {
        if (lazy[k] == -INF) return;  // 更新するものが無ければ終了
        if (k < n - 1) {             // 葉でなければ子に伝搬
            lazy[k * 2 + 1] = lazy[k];
            lazy[k * 2 + 2] = lazy[k];
        }
        // 自身を更新
        dat[k] = lazy[k];
        lazy[k] = -INF;
    }
    void update(ll a, ll b, T x, ll k, ll l, ll r) {
        eval(k);
        if (a <= l && r <= b) {  // 完全に内側の時
            lazy[k] = x;
            eval(k);
        } else if (a < r && l < b) {                     // 一部区間が被る時
            update(a, b, x, k * 2 + 1, l, (l + r) / 2);  // 左の子
            update(a, b, x, k * 2 + 2, (l + r) / 2, r);  // 右の子
            dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    void update(ll a, ll b, T x) { update(a, b, x, 0, 0, n); }
    void update(ll a, T x){ update(a, a + 1, x, 0, 0, n); }
    T query_sub(ll a, ll b, ll k, ll l, ll r) {
        eval(k);
        if (r <= a || b <= l) {  // 完全に外側の時
            return -INF;
        } else if (a <= l && r <= b) {  // 完全に内側の時
            return dat[k];
        } else {  // 一部区間が被る時
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
    T query(ll a, ll b) { return query_sub(a, b, 0, 0, n); }
    T get(ll a){ return query_sub(a, a + 1, 0, 0, n); }
    /* debug */
    inline T operator[](ll a) { return query(a, a + 1); }
    void prll() {
        for (ll i = 0; i < 2 * n - 1; ++i) {
            cout << (*this)[i];
            if (i != n) cout << ",";
        }
        cout << endl;
    }
};

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> h(N,0);
    vector<ll> a(N,0);
    for(ll i=0;i<N;++i)cin>>h[i];
    for(ll i=0;i<N;++i)cin>>a[i];
    RMQ<ll> tree(N+1);
    tree.update(0,0);
    for(ll i=0;i<N;++i){
        tree.update(h[i],tree.query(0,h[i])+a[i]);
    }
    prt(tree.query(0,N+1))

    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll I,O,J,L;
    ll i;
    cin>>I>>O>>i>>J>>L>>i>>i;
    ll ans=O;
    ll c=0;
    if(I%2==0)c++;
    if(J%2==0)c++;
    if(L%2==0)c++;
    if(c<=1 && I>0 && J>0 && L>0){
        I--;
        J--;
        L--;
        ans+=3;
    }
    ans+=(I/2)*2;
    ans+=(J/2)*2;
    ans+=(L/2)*2;
    cout<<ans<<endl;
    
    return 0;
}






Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
int main(){
    int a,b;scanf("%d%d",&a,&b);
    double ret=0;
    for(int i=1;i<=a;i++){
        double tmp=1.0/a;
        int now=i;
        while(now<b){
            now*=2;
            tmp/=2; }
        ret+=tmp; }
    printf("%.12f\n",ret);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
    ll ans = LLONG_MAX;
    for(ll req=-100;req<=100;req++){
        ll sum = 0;
        for(ll i=0;i<n;i++)sum+=(a[i]-req)*(a[i]-req);
        ans=min(ans,sum);
    }
    cout<<ans;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d %d", $t, $a);
$h = explode(' ', trim(fgets(STDIN)));
$m = 999;
for ($i = 0; $i < $n; $i++) {
	$v = $t - $h[$i] * 0.006;
	$s = abs($v - $a);
	if ($s < $m) {
		$m = $s;
		$x = $i + 1;
	}
}
echo $x;

Measured memory_bytes: 4728
#include<stdio.h>
#define N 100
int main(){
int n,i,j,temp,mini,count=0;
int A[N];

scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&A[i]);

for(i=0;i<n-1;i++){
mini=i;
for(j=i+1;j<n;j++){
if(A[j]<A[mini]){
mini=j;
}
}
if(i!=mini){
temp=A[i];
A[i]=A[mini];
A[mini]=temp;
count++;
}
}

for(i=0;i<n;i++){
printf("%d",A[i]);
if(i!=n-1) printf(" ");
}
printf("\n");
printf("%d\n",count);

return 0;
}

Measured memory_bytes: 604
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aidu
{
	public static class AiduOnlineJudge
	{
		public static string[] Split(string line)
		{
			return Regex.Split(line, " ");
		}
		public static int[] SplitToInts(string line)
		{
			return Regex.Split(line, " ").Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return Regex.Split(line, " ").Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return Regex.Split(line, " ").Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		public static void Compute(TextReader reader, TextWriter writer)
		{
			string line = null;
			while (null != (line = reader.ReadLine()))
			{
				var values = SplitToInts(line);
				var h = values[0];
				var w = values[1];
				if (0 == h && 0 == w)
				{
					break;
				}
				
				for (int i = 0; i < h; i++)
				{
					if (i == 0 || i == h - 1)
					{
						writer.Write(new string('#', w));
					}
					else
					{
						for (int k = 0; k < w; k++)
						{
							if (k == 0 || k == w - 1)
							{
								writer.Write('#');
							}
							else
							{
								writer.Write('.');
							}
						}
					}
					writer.WriteLine();
				}
				writer.WriteLine();
			}
		}
	}
}

Measured memory_bytes: 7144
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

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

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll a, b;
  cin >> a >> b;
  if (a < b) swap(a, b);
  cout << lcm(a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt(), H = sc.nextInt(), M = sc.nextInt();
        double a_rad = (H * 30 + M * 0.5f) * Math.PI / 180;
        double b_rad = M * 6 * Math.PI / 180;
        double a_x = Math.sin(a_rad) * a;
        double a_y = Math.cos(a_rad) * a;
        double b_x = Math.sin(b_rad) * b;
        double b_y = Math.cos(b_rad) * b;
        //System.out.println(a_x + ", " + a_y + ", " + b_x + ", " + b_y);
        double dist = Math.sqrt((a_x - b_x) * (a_x - b_x) + (a_y - b_y) * (a_y - b_y));
        System.out.println(dist);
    }
}


Measured memory_bytes: 27092
#include <iostream>
using namespace std;
 
int main()
{
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
 
    if(r <= x && x <=  w-r && r <= y && y <= h-r)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

const int NAX = 1e5+5;
vector<int> edges[NAX];
int in_degree[NAX];
int dist[NAX];
bool visited[NAX];

void dfs(int a){
    assert(!visited[a]);
    visited[a] = true;
    for(int b: edges[a]){
        dist[b] = max(dist[b], dist[a]+1);
        --in_degree[b];
        if(in_degree[b] == 0)
            dfs(b);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    while(m--){
        int a,b;
        cin>>a>>b;
        edges[a].push_back(b);
        in_degree[b]++;
    }
    for(int i=1;i<=n;i++){
        if(!visited[i]&&in_degree[i]==0)
            dfs(i);
    }
    int answer = 0;
    for(int i=1;i<=n;i++){
        answer = max(answer,dist[i]);
    }
    cout<<answer;

    return 0;
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
	cin>>n;
    int a[n],max1=0,max2,b[n];
    for(int i=0;i<n;i++)
    {
    	cin>>a[i];
    	b[i] = a[i];
    	if(max1<a[i])
    	{
    		max1=a[i];
		}
	}
	sort(b,b+n);
	max2 = b[n-2];
    for(int i =0;i<n;i++)
    {
    	if(a[i]==max1)cout<<max2<<endl;
    	else cout<<max1<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		if(d==22)System.out.println("Christmas Eve Eve Eve");
		else if(d==23)System.out.println("Christmas Eve Eve");
		else if(d==24)System.out.println("Christmas Eve");
		else if(d==25)System.out.println("Christmas");
		sc.close();
	}
}

Measured memory_bytes: 23764
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt
strToInt s = (read :: String -> Int) s

ccount :: [[Int]] -> Int -> Int
ccount xs i = length $ filter (elem i) xs

main = do
    [n,m] <- (map read . words) <$> getLine
    ab <- replicateM m (map strToInt . words <$> getLine)
    let ans = [ccount ab i |i <- [1..n] ]
    mapM_ print ans

Measured memory_bytes: 1020
import java.util.Scanner;

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

		int[][] gyoretu = new int[num1][num2];
		int[] retu = new int[num2];

		for(int i = 0;i < gyoretu.length; i++ ) {
			for(int j = 0;j < gyoretu[i].length;j++) {
				gyoretu[i][j] = sc.nextInt();
			}
		}
		for(int i = 0;i < retu.length ;i++) {
			retu[i] = sc.nextInt();
		}
		int[] ans = new int[num1];
		for(int i = 0; i < gyoretu.length; i++ ) {
			ans[i] = 0;
			for(int j = 0;j < gyoretu[i].length;j++) {

				ans[i] += gyoretu[i][j] * retu[j];

			}
		}

		for(int i = 0;i < ans.length;i++) {
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 40820
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double

int main() {
  int k;
  cin>>k;
  ll sum=0;
  rep2(a,1,k+1){
    rep2(b,1,k+1){
      rep2(c,1,k+1){
        sum+=gcd(a,gcd(b,c));
      }
    }
  }
  cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 3632
A, B = map(int, input().split())

def f(n):
    if n % 2 == 1:
        if (n // 2 + 1) % 2 == 0:
            return 0
        else:
            return 1
    else:
        return f(n-1) ^ n

print(f(B) ^ f(A-1))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int depth[100100];
int par[100100];

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    void init(int n) { par.assign(n,-1);}
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x){
        return -par[root(x)];
    }
};

int main(){
    string s,t; cin >> s >> t;
    int ns = s.size(); int nt = t.size();
    int dp[3030][3030] = {0};
    for(int i = 0; i < ns; i++){
        for(int j = 0; j < nt; j++){
            if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }
    string res = "";
    while(ns > 0 && nt > 0){
        if(dp[ns][nt] == dp[ns-1][nt]) ns--;
        else if(dp[ns][nt] == dp[ns][nt-1]) nt--;
        else {
            res = s[ns-1] + res;
            ns--; nt--;
        }
    }
    cout << res << endl;
}


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

int main() {
	int n,x,a=0;
    int m, b=1000;

    cin >> n >> x;
    for(int i=0; i<n; i++) {
        cin >> m;
        x -= m;
        a++;
        b = min(b,m);
    }

    a += x/b;
    cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let tmp = read::<String>();
    let mut ab = tmp.split(' ');
    let a = ab.next().unwrap().parse::<i32>().ok().unwrap();
    let b = ab.next().unwrap().parse::<i32>().ok().unwrap();
    println!("{}", [a + b, a - b, a * b].iter().max().unwrap());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i, v in enumerate(b):
    for j in range(2):
        m =  min(a[i+j], v)
        a [i+j] -= m
        v -= m
        ans += m
print(ans)


Measured memory_bytes: 24232
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N,K; cin>>N>>K;
    vint a(N);
    REP(i,N) cin>>a[i];

    int ans=((N-1)+(K-2))/(K-1);
    cout<<ans<<endl;
}

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

using namespace std;
const int N = 2e5+10;
typedef long long LL;
LL h[N], a, b;
int n;
LL  get(LL x,LL y,LL s)
{
    LL l=0, r=x, ans;
    while(l<=r)
    {
        LL mid=(l+r)/2;
        if(a*mid+(y-mid)*b>=s) r=mid-1,ans=mid;
        else l=mid+1;
    }
    return ans;
}

int judge(LL x,LL y)
{
    for(int i=0;i<n;i++)
    {
        if(x*a+(y-x)*b< h[i]) return 0;
        if(y*b>=h[i]) continue;
        x-=get(x,y,h[i]);
        if(x<0) return 0;
    }
    return 1;
}

int main()
{

    scanf("%d %lld %lld", &n, &a, &b);
    for(int i=0;i<n;i++)
    {
        scanf("%lld", &h[i]);
    }
    sort(h,h+n);

    LL l=0, r=2e9+10, ans;
    while(l<=r)
    {
        LL mid=(l+r)/2;
        if(judge(mid,mid)) r=mid-1, ans=mid;
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll dp[3001][3001][4],A[3001][3001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string n;
    cin>>n;
    int a=0;
    rep(i,n.size()) (a+=(n[i]-'0'))%=9;
    if(a==0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3768
using System;
class UOIAUAI {
    static void Main() {
        string input = Console.ReadLine();

        char[] vowel = { 'a', 'e', 'i', 'o', 'u' };

        if (input.IndexOfAny(vowel) == 0) {
            Console.WriteLine("vowel");
        } else {
            Console.WriteLine("consonant");
        }
    }
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pld pair<ld, ld>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);



using namespace std;



int main()
{
    int a, b; cin >> a >> b;
    int now = 1, cnt = 0;
    while(now < b)
    {
        now--; now += a; cnt++;
    }
    cout << cnt;
    return 0;
}


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

using namespace std;
#define ll long long int

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

	int n,k;
  	cin>>n>>k;
  	int arr[n];
  	for(int i=0;i<n;i++){
      cin>>arr[i];
    }
  	for(int i=0;i<n-k;i++){
    	if(arr[k+i]>arr[i])
          cout<<"Yes"<<endl;
      	else
          cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 4432
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		Point red[] = new Point[n];
		for(int i = 0; i < n; i++){
			red[i] = new Point(sc.nextInt(), sc.nextInt());
		}

		Point blue[] = new Point[n];
		for(int i = 0; i < n; i++){
			blue[i] = new Point(sc.nextInt(), sc.nextInt());
		}

		Arrays.sort(red);
		Arrays.sort(blue);

		int result = 0;

		boolean used[] = new boolean[n];
		for(int i = 0; i < n; i++){
			int maxIndex = -1;
			int maxY = -1;
			for(int j = 0; j < n; j++){
				if(red[j].x > blue[i].x){
					break;
				}

				if(!used[j] && red[j].y < blue[i].y && red[j].y > maxY){
					maxY = red[j].y;
					maxIndex = j;
				}
			}

			if(maxIndex >= 0){
				used[maxIndex] = true;
				result++;

//				System.out.println("pair red" + maxIndex + " blue "+i);
			}
		}

		System.out.println(result);
	}

}

class Point implements Comparable<Point>{
	int x;
	int y;

	Point(int x, int y){
		this.x = x;
		this.y = y;
	}

	@Override
	public int compareTo(Point p) {
		// TODO 自動生成されたメソッド・スタブ
		return this.x - p.x;
	}


}

Measured memory_bytes: 22100
#include <iostream>

int main(int argc, char const *argv[]) {
  int n,m,l;
  std::cin >> n >> m >> l;
  long int a[n][m],b[m][l],c[n][l];
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      c[i][j] = 0;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      int x=0;
      std::cin >> x;
      a[i][j] = x;
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<l;j++){
      int x=0;
      std::cin >> x;
      b[i][j] = x;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      for(int k=0;k<m;k++){
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      std::cout << c[i][j];
      if(j!=(l-1))std::cout << " ";
    }
    std::cout << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include <string.h>
#include <math.h>
#include<map>
#include<string.h>
#define ll long long
using namespace std;
char mode[4][15]={"dream","dreamer","erase","eraser"};
int modelen[4]={5,7,5,6};
char str[100050];
bool dp[100050];
int main()
{
    int i,j,k,flag;
    scanf(" %s",str);
    int l=strlen(str);
    dp[0]=1;
    for(i=0;i<l;i++)
    {
        if(dp[i])
        {
            for(j=0;j<4;j++)
            {
                flag=0;
                for(k=0;k<modelen[j];k++)
                {
                    if(str[i+k]!=mode[j][k])
                    {
                        flag=1;
                        break;
                    }
                }
                if(!flag)
                {
                    dp[i+modelen[j]]=1;
                }
            }
        }
    }
    if(dp[l])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 888
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
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();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N,M; cin >> N >> M;
    int ans[N]; REP(i,N) ans[i] = 0;
    REP(i,M){
        int a,b; cin >> a >> b;
        ans[a-1]++; ans[b-1]++;
    }
    REP(i,N) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
//ll a,b,n;
//string s;
//ll ans;
//inline ll make(int i,int j){
//	int num=0;
//	for(int k=i;k<=j;k++)num=num*10+(s[k]-'0');
//	return num;
//}
//int main(){
//	ios_base::sync_with_stdio(false);
//	cin.tie(0);
////	freopen(".in","r",stdin);
////	freopen(".out","w",stdout);
//	cin>>s;n=s.size();
//	for(int i=0;i<n;i++){
//		int j=i+3;
//		a=b=0;
//		a=make(i,j);
//		j++;
////		cout<<i<<' '<<j<<':';
//		while(j<n){
////			cout<<a<<' ';
//			if(a%2019==0){
//				ans++;//cout<<i<<' '<<j<<'\n';//	cout<<a<<' ';
////				cout<<"++ ";
//				a=0;
//				j+=4;
//				a=(s[j]-'0');
//				if(j>=n){
//					a=2020;
//					break;
//				}
//				continue;
//			}
//			else {
//				a%=2019;
//			}
//			a=a*10+(s[j]-'0');
//			j++;
//		}
//		if((j==n)&&a%2019==0){
//			ans++;//cout<<i<<' '<<j<<'\n';//	cout<<a<<' ';
////			cout<<"++ ";
////			a=0;
////			j+=4;
////			continue;
//		}
////		cout<<'\n';
////		cout<<ans;
//	}
//	cout<<ans;
//	return 0;
//}

int a[200010],ans=0;
string s;
int main()
{
    cin>>s;
    a[0]=1;
    for(int i=s.size()-1,j=1,k=0;i>=0;i--,j=j*10%2019)
    {
        k=(k+(s[i]-'0')*j%2019)%2019;
        ans+=a[k];
        a[k]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3636