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

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

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

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define modulo 998244353



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[2]==s[3] && s[5]==s[4])
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

int main() {
    int n; std::cin >> n;
    std::vector<int> v;
    for (int i = 0; i < 2*n; ++i) {
        int l; std::cin >> l;
        v.push_back(l);
    }
    std::sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 2*n-1; i-1 >= 0; i -= 2) {
        ans += std::min(v[i], v[i-1]);
    }
    std::cout << ans << '\n';
    return 0;
}


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

int main() {
  int N, A, a, b;
  cin >> N >> A;
  a = N / 500;
  b = N - a * 500;
  
  if (b <= A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let s = s.next().unwrap();
	if &s[s.len() - 1..] == "s" {
		println!("{}es", s);
	} else {
		println!("{}s", s);
	}
}


Measured memory_bytes: 2144
def make_time(l, k):
	r = []
	for i in range(k-1, len(l)):
		r.append(l[i] - l[i-k+1])
	return r

if __name__ == '__main__':
	N, K  = list(map(int, input().split()))
	x = list(map(int, input().split()))
	x_time = make_time(x, K)
	times1 = [(x_time[i] + abs(x[i])) for i in range(N - K + 1)]
	x.reverse()
	x_time.reverse()
	times2 = [(x_time[i] + abs(x[i])) for i in range(N - K + 1)]
	times = times1 + times2
	print(min(times))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){

    int k,a,b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" <<endl;
    return 0;
}





Measured memory_bytes: 3636
def main():
    n, k = map(int, input().split())

    ans = 0
    for i in range(1, n + 1):
        t = i
        c = 1
        for j in range(100):
            if t >= k:
                break
            t *= 2
            c += 1
        c -= 1
        ans += (1 / n) * ((1 / 2)**c)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 39280
mod = 10**9+7
rng = 2000100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0 or n<k:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
k = int(input())
s = input()
n = len(s)
ans = pow(26,n+k,mod)
for i in range(n):
  ans -= pow(25,n+k-i,mod)*cmb(n+k,i)
  ans %= mod
print(ans)

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

#define mod 998244353
#define MAX_N 200010
long long inv[MAX_N];
long long factorial[MAX_N];
long long inv_factorial[MAX_N];

void GetInv(){
    for (int i = 1; i < MAX_N; i++) {
        if (i == 1) inv[i] = 1;
        else {
            inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
            if (inv[i] < 0) inv[i] += mod;
        }
    }
}
void GetFactorial(){
    factorial[0] = 1; inv_factorial[0] = 1;
    for (int i = 1; i < MAX_N; i++) {
        factorial[i] = factorial[i-1] * i;
        factorial[i] %= mod;
        inv_factorial[i] = inv_factorial[i-1] * inv[i];
        inv_factorial[i] %= mod;
    }
}

long long combination(int n, int r) {
    if (r < 0) return 0;
    long long ret = factorial[n] * inv_factorial[r];
    ret %= mod;
    ret *= inv_factorial[n-r];
    return ret % mod;
}

long long modpow(int n, int r) {
    if (r < 0) return 0;
    long long ret = 1; long long tmp = (long long) n;
    while (r != 0) {
        if (r % 2) ret *= tmp;
        tmp *= tmp; tmp %= mod; ret %= mod;
        r /= 2;
    }
    return ret;
}

int main() {
    GetInv(); GetFactorial();
    int k, n; cin >> k >> n;
    vector<long long> ans(2*k+1, 0);
    vector<long long> pow2(2*k+1, 1);
    for (int i = 0; i < 2*k; i++) {
        pow2[i+1] = pow2[i] * 2 % mod;
    }
    for (int i = 2; i <= k+1; i++) {
        int pair = ((i-1) - (i % 2 == 0)) / 2;
        int same = (i % 2 == 0);
        int remain = k - pair * 2 - same;
        for (int use = 0; use <= min(pair, n); use++) {
            long long tmp = combination(n+remain-1, remain+use-1) * combination(pair, use) % mod;
            tmp = tmp * pow2[use] % mod;
            ans[i] = (ans[i] + tmp) % mod;
            if (same) {
                tmp = combination(n+remain-2, remain+use-1) * combination(pair, use) % mod;
                tmp = tmp * pow2[use] % mod;
                ans[i] = (ans[i] + tmp) % mod;
            }
        }
        ans[2*k+2-i] = ans[i];
    }
    for (int i = 2; i <= 2*k; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int num;
	scanf("%d", &num);
	multiset<int>se;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		se.insert(z);
	}
	int w;
	scanf("%d", &w);
	for (int i = 0; i < w; i++)
	{
		int z;
		scanf("%d", &z);
		multiset<int>::iterator it = se.find(z);
		if (it == se.end())
		{
			printf("NO\n");
			return 0;
		}
		se.erase(it);
	}
	printf("YES\n");
}

Measured memory_bytes: 9600
N = int(input())
B = list(map(int, input().split()))

res = []
while len(B) > 0:
    idx = -1
    for i in range(len(B) - 1, -1, -1):
        if i + 1 == B[i]:
            idx = i
            break
    if idx == -1:
        print(-1)
        exit(0)
    else:
        res.append(B[idx])
        tmp = []
        for i, b in enumerate(B):
            if i != idx:
                tmp.append(b)
        B = tmp

for ans in res[::-1]:
    print(ans)


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/*
    // 配列の最大値を取得
    int max = *max_element(vec.begin(), vec.end());
    // 配列の最大値のイテレータを取得
    vector<int>::iterator maxIt = max_element(vec.begin(), vec.end());
    // 配列の最大値までの距離を取得
    int maxIndex = distance(vec.begin(), maxIt);
    // 隣り合う重複要素を削除し、末尾のゴミを削除
    // (uniqueは、重複を取り除いた範囲の末尾の次を指すイテレータを返す)
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
*/

int main() {
    int N;  cin >> N;
    int i;  cin >> i;

    cout << N - i + 1;
}




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

int main(){
  int N;
  char S[110];
  cin >> N;
  for(int i=0; i<N; ++i){
    cin >> S[i];
  }
  int x=0;
  int res=0;
  for(int i=0;i<N;++i){
    if(S[i]=='I'){
      x +=1;

    }
    else{
      x -=1;
    }
    if(x>res){
      res=x;
    }
    }
  cout <<res<<endl;
  }

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


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 998244353;

long long int fact(long long int k) {
	long long int sum = 1;
	for (long long int i = 2; i <= k; i++)
	{
		sum *= i;
	}
	return sum;
}

int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}

long long int _pow(int a, int b) {
	long long int  ans = 1;
	for (int i = 0; i < b; i++)
		ans = (ans * a) % MOD;

	return ans;
}


int main()
{
	long long int n, ans = 1;

	cin >> n;

	vector<long long int> d(n);

	int zeroCnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> d[i];

		if (d[i] == 0)
			zeroCnt++;
	}
		

	if (d[0] != 0 || zeroCnt != 1) {
		cout << 0 << endl;

		return 0;
	}


	sort(d.begin(), d.end());

	int num = 1;
	int before_cnt = 1;
	int current_cnt = 0;
	for (int i = 1; i < n; i++) {
		if (d[i] > num + 1) {
			ans = 0;
			break;
		}
		else if (d[i] == num + 1) {
			num++;
			ans = (ans * _pow(before_cnt, current_cnt)) % MOD;
			before_cnt = current_cnt;
			current_cnt = 1;
		}
		else if (d[i] == num) {
			current_cnt++;
		}
	}

	ans = (ans * _pow(before_cnt, current_cnt)) % MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
	while (1){
		int n;
		vector<int> student;
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++){
			int s;
			cin >> s;
			student.push_back(s);
		}
		int ans = 999999999;
		for (int i = 0; i < n; i++){
			for (int j = i + 1; j < n; j++){
				ans = min(ans, abs(student[i] - student[j]));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

struct UnionFind {
  vector<int> par;
  vector<int> sizes;

  UnionFind(int N) : par(N), sizes(N, 1) {
    for (int i = 0; i < N; i++) par.at(i) = i;
  }

  int find(int x) {
    if (par.at(x) == x) return x;
    return par.at(x) = find(par.at(x));
  }

  void unite(int x, int y) {
    int rx = find(x);
    int ry = find(y);
    if (rx == ry) return;
    if (sizes.at(rx) < sizes.at(ry)) swap(rx, ry);
    par.at(ry) = rx;
    sizes.at(rx) += sizes.at(ry);
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sizes.at(find(x)); }

  int num_of_connected_components() {
    int ret = 0;
    for (int i = 0; i < par.size(); i++) {
      if (find(i) == i) ret++;
    }
    return ret;
  }
};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  vector<ll> fr(n, 0), bl(n, 0);
  UnionFind uf(n);
  REP(i, m) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
    fr[a]++;
    fr[b]++;
  }
  vector<ll> ans(n, 0);
  REP(i, n) { ans[i] = uf.size(i) - 1 - fr[i]; }
  REP(i, k) {
    ll c, d;
    cin >> c >> d;
    c--, d--;
    if (uf.same(c, d)) {
      ans[c]--;
      ans[d]--;
    }
  }

  REP(i, n) { cout << ans[i] << " \n"[i == n - 1]; }
}

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


class Program {

	static long mod = 1000000007;
	//static long mod =998244353;
	static int[] ans;
	static void Main(string[] args) {

		char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";


		long res = 0;


		int n = int.Parse(Console.ReadLine());
		int[] vals = parseAry(Console.ReadLine().Split(cs));
		Array.Sort(vals);

		//List<int> zzz = new List<int>(vals);

		int[] bou = new int[2001];
		for ( int i = 0; i < n; i++ ) {
			bou[vals[i]]++;
		}
		List<int> lis = new List<int>();
		List<int> cnt = new List<int>();
		for ( int i = 0; i < 2000; i++ ) {
			if ( bou[i] > 0 ) { lis.Add(i); cnt.Add(bou[i]); }
		}

		int[] d = new int[n];
		d[0] = cnt[0];
		for ( int i = 1; i < cnt.Count; i++ ) {
			d[i] = d[i - 1] + cnt[i];
		}
 


		for ( int i = 0; i < vals.Length; i++ ) {
			for ( int k =i+1; k < vals.Length; k++ ) {

				int max = vals[i] + vals[k]-1;
				int min = Math.Max(vals[i] - vals[k], vals[k] - vals[i]);
				int po = Binary_SearchX(max,lis);


				if ( lis[po] > max ) { po--; }
				int right = po;
				right = Math.Max(right, 0);

				po = Binary_SearchX(min, lis);
				if ( lis[po] > min ) { po--; }
				int left = po;
				left = Math.Max(left, 0);


				if ( lis[left] <= vals[k] ) {
					int q = d[right] - (k+1);
					q = Math.Max(q, 0);
					res += q;
				} else { res += d[right] - d[left]; }

			}

		}




			Console.WriteLine(res);

		return;

	}

	static public int Binary_SearchX(int x, List<int> lis) {
		int Center = 0;
		int Lower = 0;
		int Upper = lis.Count - 1;
		while ( Lower <= Upper ) {
			Center = ( Lower + Upper ) >> 1;
			if ( x > lis[Center] ) {
				Lower = Center + 1;
			} else if ( x < lis[Center] ) {
				Upper = Center - 1;
			} else {
				return Center;
			}
		}
		return Center;
	}



	//	int配列をスペース区切りの文字列に変換
	static string stringBuilderArrayInt(int[] a) {
		StringBuilder sb = new StringBuilder();

		for ( int i = 0; i < a.Length; i++ ) {
			sb.Append(a[i] + " "); 
		}
		if ( sb.Length > 1 ) {
			sb = sb.Remove(sb.Length - 1, 1);
		}
		return sb.ToString(); ;
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 11332
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

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

bool solve() {
  int n;
  if (scanf("%d", &n) != 1) { return false; }
  vector <int> a(n);
  vector <int> b(n);
  int cnt0 = 0;
  int cnt1 = 0;
  int cnt2 = 0;
  ll diff = 0;
  ll sum0 = 0, sum1 = 0, sum2 = 0;
  int max1 = 0;
  int min2 = 1 << 30;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    if (a[i] == b[i]) {
      cnt0 += 1;
      sum0 += a[i];
    } else if (a[i] < b[i]) {
      cnt1++;
      sum1 += a[i];
      diff += b[i] - a[i];
      max1 = max(max1, a[i]);
    } else {
      cnt2++;
      sum2 += b[i];
      min2 = min(min2, b[i]);
    }
  }
  if (cnt1 >= 1) {
    printf("%lld\n", sum0 + sum1 + diff + sum2 - min2);
  } else {
    printf("0\n");
  }
  return true;
}

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

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	while(1){
		int n=0;
		int c[100001];
		int m1[100001];
		int m2[100001];
		int m3[100001];
		int m4[100001];

		int s1[100001];
		int s2[100001];
		int s3[100001];
		int s4[100001];

		int A[100001];
		int Ad[100001];

		int A1=0;
		int A2=0;
		int Ab=0;

		cin>>n;
		if(n==0){
			break;
		}
	
		for(int i=0;n>i;i++){
			cin>>c[i];
			cin>>m1[i];
			cin>>s1[i];
			cin>>m2[i];
			cin>>s2[i];
			cin>>m3[i];
			cin>>s3[i];
			cin>>m4[i];
			cin>>s4[i];
			m1[i]=60*m1[i];
			m2[i]=60*m2[i];
			m3[i]=60*m3[i];
			m4[i]=60*m4[i];
			A[i]=m1[i]
			+m2[i]
			+m3[i]
			+m4[i]
			+s1[i]
			+s2[i]
			+s3[i]
			+s4[i];
			Ad[i]=m1[i]
			+m2[i]
			+m3[i]
			+m4[i]
			+s1[i]
			+s2[i]
			+s3[i]
			+s4[i];
		}
		sort(A,A+n);
		
		for(int i=0;n>i;i++){
			if(A[0]==Ad[i]){
				A1=c[i];
			}
			if(A[1]==Ad[i]){
				A2=c[i];
			}
			if(A[n-2]==Ad[i]){
				Ab=c[i];
			}
		}
		cout<<A1<<endl;
		cout<<A2<<endl;
		cout<<Ab<<endl;
		
}
return 0;
}

Measured memory_bytes: 3364
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const M: usize = 1000000007;

fn f(s: usize, x: usize, cache: &mut HashMap<(usize, usize), usize>) -> usize {
    if x == 0 {
        return 1;
    }

    if s < 2 {
        return s + 1;
    }

    if let Some(&res) = cache.get(&(s, x)) {
        return res;
    }

    let res = (f(s / 2, x / 2, cache) + f((s - 1) / 2, (x - 1) / 2, cache) +
                   f((s - 2) / 2, x / 2, cache)) % M;
    cache.insert((s, x), res);
    res
}

fn main() {
    let n = get!(usize);

    println!("{}", f(n, n, &mut HashMap::new()));
}


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

using namespace std;
typedef long long ll;
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);

    string s,t;
    ll d;
    cin>>s>>t;
    if(s.size()!=t.size()-1){cout<<"No";return 0;}
    for(int i=0;i<t.size();i++)
    {

        string ss=s+t[i];
        if(ss==t){cout<<"Yes";return 0;}
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3656
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)
from collections import deque

n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n + m - 1)]

T = [[] for i in range(n+1)]
RT = [[] for i in range(n+1)]
IN = [0] * (n+1)

for a, b in A:
    T[a].append(b)
    RT[b].append(a)
    IN[b] += 1

P = [0] * (n+1)

def bfs(v):
    q = deque()
    q.append(v)
    P[v] = 0
    while q:
        v = q.pop()
        for t in T[v]:
            IN[t] -= 1
            if IN[t] == 0:
                P[t] = v
                q.append(t)

def root(i):
    if not RT[i]:
        return i
    return root(RT[i][0])

bfs(root(1))
for p in P[1:]:
    print(p)

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

using namespace std;

int main(){
  int n=0,s=0,w=0,e=0;
    string S;
  cin>>S;
  for(int i=0;i<(int)S.size();i++){
    if(S[i]=='N'){
      n+=1; 
    }else if(S[i]=='E'){
      e+=1;
    }else if(S[i]=='S'){
      s+=1; 
    }else if(S[i]=='W'){
      w+=1;
    }
  }
  if(((n==0&&s==0)||(n>0&&s>0))&&((w==0&&e==0)||(w>0&&e>0))){
  cout<<"Yes"<<endl;
  }else{
  cout<<"No"<<endl;
  }
}

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

using namespace std;

using ll = long long;

int main(){
    ll n;
    cin >> n;
    ll arrw[n] = {0};
    ll arre[n] = {0};
    string s; cin >> s;
    for(ll i = 1; i < n; ++i){
        if(s[i - 1] == 'W'){
            arrw[i]++;
            arrw[i] += arrw[i - 1];
        }else arrw[i] += arrw[i - 1];
    }
    for(ll i = n - 2; i >= 0 ; --i){
        if(s[i + 1] == 'E'){
            arre[i]++;
            arre[i] += arre[i + 1];
        }else arre[i] += arre[i + 1];
    }
    ll ans = INT_MAX;
    for(ll i = 0; i < n; ++i){
        ans = min(arrw[i] + arre[i], ans);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5508
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,m;cin>>n>>m;
    priority_queue<ll>pq;
    rep(i,n){
        ll a;cin>>a;
        pq.push(a);
    }
    rep(i,m){
        ll k=pq.top();
        pq.pop();
        pq.push(k/2);
    }
    ll cnt=0;
    rep(i,n){
        ll k=pq.top();
        pq.pop();
        cnt+=k;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 1400
#include <iostream>

using namespace std;
int main() {
	long long a, b, k;
	cin >> a >> b >> k;
	
	for (long long i = 0; i < k; ++i) {
		if (i % 2 == 0) {
			if (a % 2 == 1) {
				--a;
			}
			
			b += a / 2;
			a /= 2;
		} else {
			if (b % 2 == 1) {
				--b;
			}
			
			a += b / 2;
			b /= 2;
		}
	}
	
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();
		long C = GetLong();
		var B = GetLongs(M);
		long cnt = 0;
		for(long i = 0; i < N; i++)
		{
			var A = GetLongs(M);
			if(A.Zip(B, (a, b) => a * b).Sum() + C > 0)
				cnt++;
		}
		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 13524
#include <stdio.h>
   
   int main(void) {
       int sum;
       int r, g, b;
     
       scanf("%d %d %d" , &r, &g, &b);

       sum = 100*r + 10*g + b;

       if(sum % 4 == 0) {
          printf("YES\n");
       }else{
          printf("NO\n");
     }
   return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    from itertools import accumulate
    import heapq
    N, K = MI()
    V = LI()
    left_cum = [0]+list(accumulate(V))
    right_cum = [0] + list(accumulate(V[::-1]))

    minus_left = [[0]*N]
    minus_right = [[0]*N]
    now_minuses = [0]*N

    for i, v in enumerate(V):
        heapq.heappush(now_minuses, v)
        minus_left.append(list(now_minuses))

    now_minuses = [0]*N
    for i in range(N)[::-1]:
        heapq.heappush(now_minuses, V[i])
        minus_right.append(list(now_minuses))

    ans = 0
    for left in range(N+1):
        for right in range(N+1):
            if left + right > N or left + right > K:
                break
            ans_ = left_cum[left] + right_cum[right]
            l, r = list(minus_left[left]), list(minus_right[right])
            for i in range(K - right - left):
                if l[0] > r[0]:
                    pop_item = heapq.heappop(r)
                else:
                    pop_item = heapq.heappop(l)
                if pop_item >= 0:
                    break
                else:
                    ans_ -= pop_item

            ans = max(ans, ans_)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 47068
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <cstdlib>


using namespace std;

int main() {
    

    int h,w;
    while (true) {
        cin >> h >> w;
        if(h == 0 and w == 0){
            break;
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int MOD = 1e9 + 7;

void solve()
{
    int n, k;
    cin >> n >> k;
    k--;
    P(ceil((double)k / (double)(n - 1.0)));
}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int n, m, c, a, b;
    cin >> n >> m >> c;
    vector<int> B;
    for (int i = 0; i < m; i++) {
        cin >> b;
        B.push_back(b);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int source = 0;
        for (int j = 0; j < m; j++) {
            cin >> a;
            source += a*B[j];
        }
        if (source + c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    int mx=0,cnt=0;
    rep(i,n){
        int a,b; cin>>a>>b;
        if(mx<a){
            mx=a;
            cnt=b;
        }
    }
    cout<<mx+cnt<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def main():
	N, T = map(int, input().split(" "))
	tmp = input().split(" ")
	timming = [int(s) for s in tmp]
	
	time = 0
	for i, val in enumerate(timming):
		if i == (len(timming)-1):
			break
		interval = timming[i+1] - timming[i]
		if interval >= T:
			time += T
		else:
			time += interval
	
	print(time + T)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 25196
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val A = new Array[Long](N+1)
  for (i <- 0 to N) {
    A(i) = in.next().toLong
  }

  //
  var flag = true
  val dpMax = new Array[Long](N+1)
  var cnt = 1L
  breakable {
    for (i <- 0 to N) {
      cnt -= A(i)
      if (cnt < 0) {
        flag = false
        break
      }

      dpMax(i) = cnt
      cnt *= 2
      cnt = cnt min (Long.MaxValue / 100)
    }
  }


  if (!flag)
    println(-1)
  else if (N == 0) {
    if (A(0) == 1)
      println(1)
    else
      println(-1)
  }
  else  {
    var ans = 0L
    var nodes = 0L

    breakable {
      for (i <- (0 to N).reverse) {
        val now = A(i)

        if ((nodes+1) / 2 > dpMax(i)) {
          flag = false
          break
        }
        else {
          nodes = (nodes min dpMax(i)) + now
          ans += nodes
        }
      }
    }

    if (!flag)
      println(-1)
    else
      println(ans)
  }
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int main()
{
  	int n, ac, tle=0, i, wa, re;
    cin>>n;
  	string a[n];
  	for(i>1; i<n; i++)
    {
		cin>>a[i];
      	if(a[i]=="AC")
          	ac++;
        if(a[i]=="WA")
          	wa++;
      	if(a[i]=="TLE")
          	tle++;
      	if(a[i]=="RE")
          	re++;
    }
  	cout<<"AC x "<<ac<<endl;
  	cout<<"WA x "<<wa<<endl;
  	cout<<"TLE x "<<tle<<endl;
  	cout<<"RE x "<<re<<endl;
	return 0;
}

Measured memory_bytes: 6740
#include <cstdio>
using namespace std;
const int N = 100;

int n, m, s, a[N], ans;

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++){
		scanf("%d", a + i);
		s += a[i];
	}
	s = (s - 1) / (m << 2) + 1;
	for(int i = 0; i < n; i++)
		ans += a[i] >= s;
	puts(ans >= m ? "Yes" : "No");
	return 0;
}

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

using ll=long long; 

using P=pair<int,int>;

P nextvec(int x1, int y1, int x2, int y2){
	int x=x2-x1;
	int y=y2-y1;
	int nextx, nexty;
	nextx=-y;
	nexty=x;
	return P(nextx+x2, nexty+y2);
}

void solve(){
	int x1, y1, x2, y2;
	cin>>x1>>y1>>x2>>y2;
	int x3, y3;
	P rece=nextvec(x1, y1, x2, y2);
	x3=rece.first;
	y3=rece.second;
	int x4, y4;
	rece=nextvec(x2, y2, x3, y3);
	x4=rece.first;
	y4=rece.second;
	cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
//To debug :  g++ -g file.cpp -o code
//cout<<setprecision(p)<<fixed<<var
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807;
#define big1 LONG_MAX
#define big2 INT_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 INT_MIN
#define sma3 -1000000000;
#define mp make_pair
#define dub double
#define ivec vector<int>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);


ll a[2][3001][3001];
ll v[3001];
ll n;

ll fun(ll p,ll l,ll r,ll sum)
{

	//this player can either choose l or r
	if(l>r)
	{
		return sum;
	}
	else if(a[p][l][r]!=-1)
	{
		return (sum - a[p][l][r]);
	}
	else if(l==r)
	{
		a[p][l][r] = v[l];
		return (sum - v[l]);
	}
	else
	{
		a[p][l][r] = max(fun(1-p,l+1,r,sum-v[l])+v[l],fun(1-p,l,r-1,sum-v[r])+v[r]);;

		return (sum-a[p][l][r]);
	}

}


int main()
{

	memset(a,-1,sizeof(a));
	ll i,n;
	ll sum = 0,ans1,ans2;

	cin>>n;

	for(i=1;i<=n;++i)
	{
		cin>>v[i];
		sum+=v[i];
	}

	//taro (0) will start
	//jiro (1) next

	ans1 = max(fun(1,2,n,sum-v[1])+v[1],fun(1,1,n-1,sum-v[n])+v[n]); //taro can choose either 1st or nth and then
									// jiro will move
	

	//cout<<ans1<<"\n";

	//cout<<sum<<"\n";

	cout<<2*ans1-sum<<"\n";




	return 0;
}

Measured memory_bytes: 141184
/**
 * PrintTestCases.cpp
 * Create:20180418
 * Description:入力をそのまま出力する。
 */
#include <iostream>
#include <vector>

int main(int argc, char* argv[]){
  std::vector<int> vec;
  int input;

  while (true){
    std::cin >> input;
    if (input == 0)
      break;
    vec.push_back(input);
  }

  int counter = 1;
  for(int i:vec){
    std::cout << "Case " << counter++ << ": " << i << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

int main() {

	int x, y;
	cin >> x >> y;

	//鶴i引き　亀x-i引き
	rep(i, 200) {
		if (x >= i && i * 2 + (x - i) * 4 == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

}






Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const int sqrtN = 512;
const int logN = 32;
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int dp[410][410];

int main(){
	int n, ma, mb; cin >> n >> ma >> mb;
	
	REP(i, 0, 410) REP(j, 0, 410) dp[i][j] = INF;
	dp[0][0] = 0;
	
	REP(i, 0, n){
		int a, b, c; cin >> a >> b >> c;
		
		RREP(j, 409, 0){
			RREP(k, 409, 0){
				if(dp[j][k] == INF) continue;
				dp[j + a][k + b] = min(dp[j + a][k + b], dp[j][k] + c);
			}
		}
	}
	
	int mi = INF;
	REP(i, 1, 410){
		REP(j, 1, 410){
			if(i * mb != j * ma) continue;
			mi = min(mi, dp[i][j]);
		}
	}
	
	cout << (mi == INF ? -1 : mi) << endl;
	return 0;
}


Measured memory_bytes: 896
import math
q = int(input())
a = [list(map(int, input().split())) for i in range(q)]

for i in range(q):
    ans = 0
    AB = a[i][0]*a[i][1]
    if a[i][0]<=a[i][1]:
        A, B = a[i][0], a[i][1]
    else:
        A, B = a[i][1], a[i][0]
    x = int(math.sqrt(AB-1))
    while x*x>=AB:
        x-=1
    if A==B:
        ans=2*A-2
    elif A+1==B:
        ans= 2*A-2
    elif x*(x+1)>=AB:
        ans = 2*x-2
    else:
        ans = 2*x-1
    print(ans)

Measured memory_bytes: 3064
# import sys
# sys.setrecursionlimit(10**9)

t = int(input())
for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {0: 0, 1: d}

    def dfs(m):
        if m in memo:
            return memo[m]
        else:
            res1 = m * d

            res2 = (m % 2) * d + a + dfs(m // 2)
            res3 = (m % 3) * d + b + dfs(m // 3)
            res4 = (m % 5) * d + c + dfs(m // 5)

            res5 = ((2 - (m % 2)) % 2) * d + a + dfs(
                (m + (2 - (m % 2)) % 2) // 2)
            res6 = ((3 - (m % 3)) % 3) * d + b + dfs(
                (m + (3 - (m % 3)) % 3) // 3)
            res7 = ((5 - (m % 5)) % 5) * d + c + dfs(
                (m + (5 - (m % 5)) % 5) // 5)

            memo[m] = min(res1, res2, res3, res4, res5, res6, res7)
            return memo[m]

    ans = dfs(n)
    print(ans)


Measured memory_bytes: 10944
#include <bits/stdc++.h>
using namespace std;
struct station{
int tt;
int st;
int p;
station(){
	tt = 0;
	st = 0;
	p = 0;}
};






int main() {
	int t = 0;
	int n;
	cin>>n;
	station cunt[500];
	for(int i = 0; i < n-1 ;i++){
		cin>>cunt[i].tt>>cunt[i].st>>cunt[i].p;
	}
	for(int i = 0; i < n; i++){
		int t = 0;
		if(i == n-1){
			cout<<"0";
			return 0;
		}
		for(int j = i; j<n-1;j++){
			if(t < cunt[j].st)
				t=cunt[j].st;
			if(t == cunt[j].st){
				t+=cunt[j].tt;
				continue;
			}
			if(t%cunt[j].p == 0){
				t+=cunt[j].tt;
				continue;
			}
			t+=(cunt[j].p-(t%cunt[j].p));
			t+=cunt[j].tt;
		}
		cout<<t<<endl;
	}
	return 0;
}

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

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

    int n;
    cin>>n;

    vector<int> adj[n+1];

    for(int i=2;i<=n;i++)
    {
    	int x;
    	cin>>x;

    	adj[x].push_back(i);

    }

    for(int i=1;i<=n;i++)
    	cout<<adj[i].size()<<endl;


    
    
	return 0;
}

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

int main()
{
  string s;
  bool flag = true;

  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if ((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R'))
      flag = false;
  }
  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

vector<int> g[100010];
pair<int, int> gc[100010];
queue<pair<int, int>> q;

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i, n)
    {
        gc[i] = make_pair(INF, -1);
    }
    gc[0] = make_pair(0, 0);
    // for(int i : g[0]){
    //     q.push(make_pair(i,0));
    // }
    q.push(make_pair(0, -1));
    while (!q.empty())
    {
        pair<int, int> p = q.front();
        q.pop();
        int now = p.first;

        for (int i : g[now])
        {
            if(i==p.second)
                continue;
            if (gc[i].first > gc[now].first + 1)
            {
                gc[i] = make_pair(gc[now].first + 1, now);
                q.push(make_pair(i, now));
            }
        }
    }
    cout << "Yes" << endl;
    rep(i, n - 1)
    {
        cout << gc[i + 1].second + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 10956
#include <stdio.h>

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


Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvll = vector<vector<long long>>;
using pii = pair<int, 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 rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define rreps(i,n) for(int i = (int)(n); i > 0; i--)
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RFOR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define call(x) (x).cbegin(), (x).cend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
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 (b<a) {a=b; return 1;} return 0;}
const int INF = INT_MAX;
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int dp[3005][3005];

void solve(std::string s, std::string t){
    //dp[i+1][j+1] == sのi番目までとtのj番目までのLCSの長さ
    //s[i] == t[j]のとき chmax(dp[i+1][j+1], dp[i][j] + 1);
    //s[i] != t[j]のとき chmax(dp[i+1][j+1], dp[i][j+1]);
    //                  chmax(dp[i+1][j+1], dp[i+1][j]);
    //dp[0][0]からdp[s.size()][t.size()]
    rep(i, s.size()) rep(j, t.size()){
        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 = "";
    int i = s.size(), j = t.size();
    while (i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]){
            i--;
            continue;
        }
        if (dp[i][j] == dp[i][j-1]){
            j--;
            continue;
        }
        res = s[i-1] + res;
        i--; j--;
    }

    cout << res << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(s, t);
    return 0;
}


Measured memory_bytes: 35456
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,j,m,n,card[4][14];
    char x;

    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            card[i][j]=0;
        }
    }

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s",&x);
        scanf("%d",&j);

        if(x=='S'){
            m=0;
        }else if(x=='H'){
            m=1;
        }else if(x=='C'){
            m=2;
        }else if(x=='D'){
            m=3;
        }
        card[m][j]=1;
    }
    for(i=0;i<4;i++){
        for(j=1;j<14;j++){
            if(card[i][j]==0){
                if(i==0){
                    printf("S %d\n",j);
                }else if(i==1){
                    printf("H %d\n",j);
                }else if(i==2){
                    printf("C %d\n",j);
                }else if(i==3){
                    printf("D %d\n",j);
                }
            }
        }
    }
    return 0;
}

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

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

using namespace std;

// bubbleSort(A, N) // N 個の要素を含む 0-オリジンの配列 A
//    flag = 1 // 逆の隣接要素が存在する
//    while flag
//         flag = 0
//         for j が N-1 から 1 まで
//             if A[j] < A[j-1]
//                 A[j] と A[j-1] を交換
//                 flag = 1

int bubbleSort(int A[], int n) {
    int i, tmp;
    int cnt = 0;
    bool flag = true;
    while (flag) {
        flag = false;
        for (int j = n-1; j > 0; j--) {
            if (A[j] < A[j-1]) {
                tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = true;
                cnt++;
            }
            //rep(i, 0, n) printf("%d ", A[i]);cout << endl;
        }
    }
    rep(i, 0, n) { 
        if (i == n-1) printf("%d", A[i]);
        else printf("%d ", A[i]);
    }
    cout << endl;
    return cnt;
}

int main () {
    int i, n; cin >> n;
    int A[n];
    rep(i, 0, n) cin >> A[i];
    
    printf("%d\n", bubbleSort(A, n));
}


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

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


void solve(long long A, long long B){
  if(A<=9 and B<=9)
    std::cout << A*B << std::endl;
  else
    std::cout << -1 << std::endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define rep(x, l, r) for(int x = l; x <= r; x++)
#define repd(x, r, l) for(int x = r; x >= l; x--)
#define clr(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define MAXN 100005
#define fi first
#define se second
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
const int INF = 1 << 30;
const int p = 1000000009;
int lowbit(int x){ return x & (-x);}
int fast_power(int a, int b){ int x; for(x = 1; b; b >>= 1){ if(b & 1) x = 1ll * x * a % p; a = 1ll * a * a % p;} return x % p;}

ll a[MAXN];

ll gcd(ll x, ll y){
	if(!x) return y;
	return gcd(y % x, x);
}

ll lcm(ll x, ll y){
	return x * y / gcd(x, y);
}

ll judge(ll x){
	int res = 0;
	while(x % 2 == 0){
		x /= 2;
		res++;
	}
	return res;
}

int main(){
	int n;
	ll m;
	scanf("%d%lld", &n, &m);
	rep(i, 1, n){
		scanf("%d", &a[i]);
		a[i] /= 2;
	} 
	int sum = 1, s = judge(a[1]);
	m >>= s;
	rep(i, 1, n){
		if(judge(a[i]) != s){
			puts("0");
			return 0;
		}
		sum = lcm(sum, a[i] >> s);
		if(sum > m){
			puts("0");
			return 0;
		}
	}
	ll ans = (m / sum + 1) / 2;
	printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1024