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

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second 

int main()
{
	ll x,a;
	cin>>x>>a;

	if(x < a)
	{
		cout<<0<<endl;
	}
	else
	{
		cout<<10<<endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n, m, p, a, i, j, sum;
    int t[101];
    scanf("%d", &n);
    for (i=1; i<=n; i++)
        scanf("%d ", &t[i]);
    for (i=1; i<=n; i++)
        sum += t[i];
    scanf("%d", &m);
    for (i=0; i<m; i++){
        scanf("%d %d", &p, &a);
        int ret = sum + a - t[p];
        printf("%d\n", ret);
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(){
  int n,m[30],t,d[21][31],i,j,p[30],min,mi;
  char s[20][12];
  while(scanf("%d",&n),n){
    int c[30]={0};
    for(i=0;i<n;i++){
      scanf("%s %d",s[i],&m[i]);
      p[i]=m[i]*(n+1);
      for(j=0;j<m[i];j++){
	scanf("%d",&d[i][j]);
	c[d[i][j]]++;
      }
    }
    for(i=0;i<n;i++){
      for(j=0;j<m[i];j++){
	p[i]-=c[d[i][j]];
      }
      if(i){
	if(min==p[i]){
	  if(strcmp(s[mi],s[i])>0) mi=i;
	}
	if(min>p[i]){
	  min=p[i];
	  mi=i;
	}
      }
      else{
	min=p[0];
	mi=0;
      }
    }
    printf("%d %s\n",min,s[mi]);
  }
  return 0;
}

Measured memory_bytes: 612
import std.stdio;
import std.array;
import std.string;

char[3] type = ['r', 'g', 'b'];
string s;
int n;
bool f;

void main(){
	while (s = chomp(readln()), s != "0") {
		bool[string] memo;
		string[] queue;
		int[] depth;
		queue ~= s;
		depth ~= 0;
		f = false;
		while (queue.length) {
			s = queue.front;
			n = depth.front;
			queue.popFront();
			depth.popFront();
			if (s in memo) continue;
			memo[s] = true;

			// check answer
			foreach (ch; type) if (replace(s, ch ~ "", "") == "") f = true;
			if (f) break;

			// bfs
			for (int i = 0; i < s.length-1; i++) {
				if (s[i] != s[i+1]) {
					char rest;
					foreach (ch; type)
						if (s[i] != ch && s[i+1] != ch) rest = ch;
					char[] cs = s.dup;
					cs[i] = cs[i+1] = rest;
					queue ~= cs.idup;
					depth ~= n+1;
				}
			}
		}
		if (f) writeln(n);
		else writeln("NA");
	}
}

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

int main() {
    string s, t;
    cin >> s >> t;
    int res = 1001;
    for (size_t i = 0; i <= s.size() - t.size(); i++) {
        int cnt = 0;
        for (size_t j = 0; j < t.size(); j++) {
            cnt += s[i + j] != t[j];
        }
        res = min(res, cnt);
    }
    cout << res << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define N 100010
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll INF = 1LL<<55;
vector<P> G[N];
ll n,H[N],X;

ll dijkstra(){
  vector<ll>D(N,INF);
  priority_queue<PP,vector<PP>,greater<PP> >Q;
  Q.push(PP(0,P(0,X)));
  D[0] = 0;
  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    ll pos = t.second.first;
    ll h = t.second.second;
    ll cost = t.first;
    if(pos==n-1) return cost+H[n-1]-h;
    if(D[pos]<cost) continue;
    for(int i=0;i<G[pos].size();i++){
      ll npos = G[pos][i].first;
      ll ncost = cost + G[pos][i].second;
      ll nh = h-G[pos][i].second;
      if(nh>H[npos]) ncost+=nh-H[npos],nh = H[npos];
      if(nh<0) ncost+=-nh,nh=0;
      if(D[npos]<=ncost)continue;
      Q.push(PP(ncost,P(npos,nh)));
      D[npos] = ncost;
    }
  }
  return -1;
}

int main(){
  int m;
  cin>>n>>m>>X;
  for(int i=0;i<n;i++)cin>>H[i];
  for(int i=0,a,b,c;i<m;i++){
    cin>>a>>b>>c; a--,b--;
    if(H[a]>=c)G[a].push_back(P(b,c));
    if(H[b]>=c)G[b].push_back(P(a,c));
  }  
  cout<<dijkstra()<<endl;
  return 0;
}

Measured memory_bytes: 23800
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys
#from heapq import heapify, heappush, heappop
#from heapq import nlargest, nsmallest

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
# puorquoi le sys.stdin.buffer.readline() ne fonctionne plus sur atcoder?
#sys.setrecursionlimit(10 ** 7)
#INF = 1 << 30 # 大体 1e9


def debug(*x):
    print(*x, file=sys.stderr)


# s == self
class atcoder():
    def __init__(s):
        f = open(0)
        s.N = int(f.readline())
        s.A = list(map(int, f.readline().split()))

    def çözmek(s):
        res = []
        res.append(s.関数(s.N, s.A))
        print(*res)	
    
    def 関数(self, n, a):
        guusuu = True
        cnt = 0
        while(guusuu):
            for i in range(n):
                if(a[i] % 2 != 0):
                    guusuu = False
                    break;
                else:
                    a[i] /= 2
            if(guusuu): cnt += 1
        return cnt 

if __name__ == "__main__":
    ima = atcoder()
    ima.çözmek()


Measured memory_bytes: 9256
import java.util.*;
import java.util.function.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextLong();
    }
    sc.close();
    
    long m = 1000000007;
    long ans = 0;
    for (int i = 0; i < 60; i++) {
      long c = 0;
      for (int j = 0; j < N; j++)
        if (((A[j] >>> i) & 1) == 1) c++;
      long a = (c * (N - c)) % m;
      for (int j = 0; j < i; j++) 
        a = (a << 1) % m;
      ans += a;
      ans %= m;
    }
    System.out.println(ans);
  }
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    if (n < 10) {
        cout << n << endl;
    } else if (n < 100) {
        cout << 9 << endl;
    } else if (n < 1000) {
        cout << 9 + (n - 99) << endl;
    } else if (n < 10000) {
        cout << 909 << endl;
    } else if (n < 100000) {
        cout << 909 + (n - 9999) << endl;
    } else if (n == 100000) {
        cout << 90909 << endl;
    }
}


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;
using P = pair<int, int>;

int main() {
  ll n;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0, d = 10;
  while (d <= n) {
    ans += n / d;
    d *= 5;
  }

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


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;

const i64 mod = 1e9 + 7;
i64 ipow(i64 a, i64 b) {
    i64 x = a, y = 1;
    for (; b > 0; b >>= 1) {
        if (b & 1) (y *= x) %= mod;
        (x *= x) %= mod;
    }
    return y;
}
i64 inv(i64 x) {
    return ipow(x, mod - 2);
}
i64 fact(i64 x) {
    static vector<i64> f;
    i64 i = f.size();
    if (x >= i) {
        f.resize(x + 1);
        for (; i <= x; ++i) {
            f[i] = i == 0 ? 1 : i * f[i - 1] % mod;
        }
    }
    return f[x];
}
i64 perm(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(n - k)) % mod : 0;
}
i64 comb(i64 n, i64 k) {
    return k <= n ? fact(n) * inv(fact(k) * fact(n - k) % mod) % mod : 0;
}
i64 dp[1001][1001];
int main() {
    i64 n, k;
    cin >> n >> k;
    dp[0][0] = 1;
    for (i64 i = 1; i <= n; ++i) {
        for (i64 j = 1; j <= i; ++j) {
            dp[i][j] = (j * dp[i - 1][j] + dp[i - 1][j - 1]) % mod;
        }
    }
    i64 ans = 0;
    cout << dp[n][k] << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

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

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll A, B, C;
  cin >> A >> B >> C;
  ll K;
  cin >> K;
  while(K>0) {
    if (B <= A) {
      B *= 2;
    } else if (C <= B) {
      C *= 2;
    }
    K--;
  }
  if (C > B && B > A) {
    PRINT("Yes");
  } else {
    PRINT("No");
  }
  return 0;
} 


Measured memory_bytes: 3676
S = input()
ACGT = [ 'A', 'C', 'G', 'T' ]
listResult = []
sum = 0

for i in S:
    if i in ACGT:
        sum += 1
    else:
        listResult.append(sum)
        sum = 0
else:
    listResult.append(sum)
    
print(max(listResult))


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


int main() {
	int n, min,max=-1000000000;
	cin >> n;
	int R[200000];
	for (int i = 0; i < n; i++) cin >> R[i];

	min = R[0];
	for (int i = 0; i < n-1; i++) {
		if (min > R[i]) min = R[i];
		if (max < R[i+1]-min) max = R[i+1]-min;
	}
	cout << max << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> g[100000];
int dp[100000];

int rec(int x) {
  if (0 <= dp[x]) return dp[x];
  int res = 0;
  for (int i = 0; i < g[x].size(); ++i) {
    int to = g[x][i];
    res = max(res, rec(to) + 1);
  }
  return dp[x] = res;
}

int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    g[x].push_back(y);
  }
  for (int i = 0; i < n; ++i) {
    dp[i] = -1;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, rec(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
bool greater_pair(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first!=b.first){
        return a.first>b.first;
    }else{
        return a.second>b.second;
    }
}

int main() {
    ios::sync_with_stdio(false);
    ll N=in();
    ll M=in();
    if(N>M){
        swap(N,M);
    }
    ll ans=0;
    if(N==1){
        if(M==1){
            ans=1;
        }else{
            ans=M-2;
        }
    }else{
        ans=N*M-(N+N+M+M-4);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    for (int i = 0; i < S.size(); ++i){
        if(S[i] + N > 'Z' ){
            S[i] = S[i] + N-26;
        }
        else
            S[i] = S[i] + N;
    }

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

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

long long int gcd(long long int a,long long int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
long long int fac(long long int n){
    if(n==0){
        return 1;
    }
    else{
        return n*(fac(n-1))%1000000007;
    } 
}

int main(){
    long long int n,k,ans=0;
    cin>>n>>k;
    vector<long long int>a(300000);
    for(int i=0;i<n;i++){
        cin>>a[i];
            }
    for(int i=0;i<n-1;i++){
        if(a[i+1]-a[i]>k){
            ans+=k;
        }
        else{
            ans+=a[i+1]-a[i];
        }
    }
    ans+=k;


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

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

int main()
{
	int n;
	cin >> n;
	int H[100000];
	for (int i = 0; i < n; ++i)
	{
		cin >> H[i];
	}
	int ma = 0;
	for (int i = 0; i < n; ++i)
	{
		ma = max(H[i], ma);
		if (ma >= H[i] + 2)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
l = list(map(int,input().split()))
k = [0 for i in range(n)]
t = []
for i in range(n-1,-1,-1):
  a = l[i]
  s = 0
  for j in range(i,n,i+1):
    if j ==i:
      continue
    if k[j]==1:
      s += 1
      s %= 2
  if a!=(k[i]+s)%2:
    t.append(i+1)
    k[i] += 1
    k[i] %= 2
    
if len(t)==0:
  print(0)
else:
  print(len(t))
  print(*t)

        

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

int main(void){
    
    ll a;
    string s;
    
    cin >> a;
    cin >> s;
    
    if(a<3200){
        
        cout << "red" << endl;
        
    } else {
        
        cout << s << endl;
        
    }
    
    return 0;
    
}

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

#define PI acosl(-1)
using namespace std;

int main() {
  double ans,rad,deg,A,B;
  double H,M;
  cin >> A >> B >> H >> M;
  H = 30*H + 0.5*M;
  M *= 6;
  if(H > M){
    deg = H - M;
  }
  else{
    deg = M - H;
  }
  /*
  rad = cos((deg*PI)/180.0);
  ans = A*A + B*B - rad*2*A*B;
  cout << setprecision(20) << sqrt(ans) << endl;
  */
  rad = cos((deg*M_PI)/180.0);
  ans = A*A + B*B - rad*2*A*B;
  cout << setprecision(11) << sqrt(ans) << endl;
  return 0;
}


Measured memory_bytes: 4248
while true
  a, b, c = gets.split
  a = a.to_i
  c = c.to_i
case b
  when  "+"
    w = a + c
  when "-"
    w = a - c
  when "*"
    w = a * c
  when "/"
    w = a / c
  else
    break if b == "?"
  end
  puts w
end

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

int main() {
  long X;
  cin >> X;
  long N = 1001;
  vector<long> V(N);
  long v = -501;
  for (long i = 0; i < N; i++) V.at(i) = ++v;
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      if (pow(V.at(i), 5) - pow(V.at(j), 5) == X) return cout << V.at(i) << " " << V.at(j) << "\n", 0;
    }
  }
}

Measured memory_bytes: 4116
def gcd(x, y):
    if x < y:
        x, y = y, x
    if x % y == 0:
        return y
    else:
        x = x % y
        return gcd(x, y)


n = int(input())
num_list = list(map(int, input().split()))
tmp = num_list[0]
for i in range(n):
    tmp = gcd(tmp, num_list[i])

divisor_list = []
for i in range(1, int(tmp**0.5) + 1):
    if tmp % i == 0:
        divisor_list.append(i)
        if i != (tmp //i):
            divisor_list.append(tmp // i)
divisor_list.sort()
for element in divisor_list:
    print(element)



Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;

#define N_MAX 100001
int A[100001], B[100001], color[100010];
vector<int> nxt[100010]; //

int main()
{
    ll N;
    int max_c = 0;
 
    cin >> N;
    rep(i, N - 1){ 
        cin >> A[i]>> B[i];
        nxt[A[i]].push_back(i);
        nxt[B[i]].push_back(i);
        color[i] = 0;
        //fprintf(stderr ,"%d, %d\n",A[i], B[i]);
    }    
    queue<int> que;
    que.push(1);
    while (!que.empty()) {
        int i = que.front(); que.pop(); // �擪�v�f���폜
        int ngc = -1, ngj = -1;
        //fprintf(stderr, "FFFF %d\n", i);
        for (int j = 0; j < nxt[i].size(); j++){
            
            int id = nxt[i][j]; // 0-(n-2) edge
            if (color[id]){
                ngc = color[id];
                ngj = j;
                break;
            }
        }
        int len = nxt[i].size();
        int c = 1;
        for (int j = 0, c = 1; j < len; j++){
            if (c == ngc){
                c++;
            }
            //fprintf(stderr, "c = %d, ngc = %d, len = %d\n", c, ngc, len);
            
            int id = nxt[i][j];   // 0-(n-2) edge
            if (j != ngj /*&& !color[id]*/){
                //print3(i, id, color[id]);
                
                color[id] = c;
                //print4(id, color[id], A[id], B[id]);
                if (A[id] == i){
                    que.push(B[id]);
                } else {
                    que.push(A[id]);
                }
                max_c = max(c, max_c);
                c++;
            }
        }
        //exit(1);
        
    }
//    print2(N, max_c);
    cout << max_c << endl;
    for (int i = 0; i < N - 1; i++){
        cout << color[i] << endl;
    }
    return 0;
}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int64_t i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int64_t i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll md = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ll n, m, k;
    cin >> n >> m >> k;
    VI A(n), B(m);
    REP(i, n) cin >> A[i];
    REP(i, m) cin >> B[i];
    int b = m - 1;
    ll ans = 0;
    vector<ll> AA(n), BB(m);
    ll suma = 0;
    REP(i, n) {
    	suma += A[i];
    	AA[i] = suma;
    }
    ll sumb = 0;
    REP(i, m) {
    	sumb += B[i];
    	BB[i] = sumb;
    }
    while (b >= 0 && BB[b] > k) {
    	b--;
    }
    ans = b + 1;
    FOR(i, 0, n - 1) {
	    while (b >= 0 && BB[b] + AA[i] > k) {
	    	b--;
	    }
	    if (b < 0) {
	    	if (AA[i] <= k) {
	    		ans = max(ans, i + 1);
	    	} else {
	    		break;
	    	}
	    } else {
	    	ans = max(ans, i + 1 + b + 1);
	    }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7916
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static int[] ans;
//	 static int mod = 998244353;
   public static void main(String[] args) {
	          
	   Scanner sc = new Scanner(System.in);
       long  A = sc.nextLong();
       long  B = sc.nextLong();

       long tmpA=A*100/8;
       long tmpB=B*10;
       
       long[] mA=new long[100];
       int Acnt=0;
       for(long i=tmpA-50;i<tmpA+50;i++) {
    	   if((i*108/100)-(i)==A) {
    		   mA[Acnt]=i;
    		   Acnt++;
    	   }
       }
       long[] mB=new long[100];
       int Bcnt=0;
       for(long i=tmpB-50;i<tmpB+50;i++) {
    	   if((i*110/100)-(i)==B) {
    		   mB[Bcnt]=i;
    		   Bcnt++;
    	   }
       }
       long ans=-1;
       for(int i=0;i<Acnt;i++) {
    	   for(int j=0;j<Bcnt;j++) {
    		   if(mA[i]==mB[j]) {
    			   ans=mA[i];
    			   System.out.println(ans);
    			   return;
    		   }
    	   }
       }
       
       System.out.println(ans); 
       return;
   }

}


Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int fpow(int x,int y)
{
	if(y==0)
		return 1;
	int ret=fpow(x,y>>1);
	ret=(long long)ret*ret%mod;
	if(y&1)
		ret=(long long)ret*x%mod;
	return ret;
}
int q[10101],qn;
int f[10101];
int main()
{
	int n,k;
	int ans=0;
	scanf("%d%d",&n,&k);
	qn=0;
	for(int i=1;i*i<=n;i++)
		if(n%i==0)
		{
			q[++qn]=i;
			if(i*i!=n)
				q[++qn]=n/i;
		}
	sort(q+1,q+1+qn);
	for(int i=1;i<=qn;i++)
	{
		f[i]=fpow(k,(q[i]+1)>>1);
		for(int j=1;j<i;j++)
			if(q[i]%q[j]==0)
				(f[i]+=mod-f[j])%=mod;
	}
	for(int i=1;i<=qn;i++)
		if(q[i]&1)
			ans=((long long)f[i]*q[i]+ans)%mod;
		else
			ans=((long long)f[i]*q[i]/2+ans)%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int X = 1;
  for (int i = 0; i < N; i++) {
    if (X <= K) { X *= 2;}
    else { X += K;}
  }
  cout << X << endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < c; i++)
int inf = 1000000000; // 10^9
int main() {
int N;
cin >> N;
vector<int> X(N);
rep(i, N) cin >> X[i];
int ans = inf;
for(int i = 1; i <= 100; i++) { // L やR の計算が不要
int cost = 0;
rep(j, N) cost += (X[j] - i) * (X[j] - i);
ans = min(ans, cost);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int r, g, b;
  cin >> r >> g >> b;
  const int n = r * 100 + g * 10 + b;
  if (n % 4 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Trim().Select(x => x == '.' ? 0 : 1).ToArray();

        var sum = new int[s.Length + 1][];
        sum[0] = new int[2];
        for (int i = 1; i < sum.Length; i++)
        {
            sum[i] = new int[sum[i - 1].Length];
            for (int j = 0; j < sum[i].Length; j++)
            {
                sum[i][j] = sum[i - 1][j];
            }
            sum[i][s[i - 1]]++;
        }

        var minimum = int.MaxValue;
        for (int i = 0; i < sum.Length; i++)
        {
            var w = sum.Last()[0] - sum[i][0];
            var b = sum[i][1]; // - sum.First()[1];
            minimum = Math.Min(minimum, w + b);
        }
        Console.WriteLine(minimum);
    }
}


Measured memory_bytes: 28380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main() {
	string s, t; cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) cout << "Yes\n";
	else cout << "No\n";
	return 0; 
} 

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

class Node():
    def __init__(self, parent=-1, left=-1, right=-1):
        self.parent = parent
        self.left = left
        self.right = right

T = [Node() for _ in range(N)]

for _ in range(N):
    id, left, right = map(int, input().split())

    T[id].left = left
    T[id].right = right

    if left != -1:
        T[left].parent = id
    if right != -1:
        T[right].parent = id


def preorder(id):
    preorder_list.append(id)

    if T[id].left != -1:
        preorder(T[id].left)
    if T[id].right != -1:
        preorder(T[id].right)

def inorder(id):
    left = T[id].left
    right = T[id].right

    if left != -1:
        inorder(T[id].left)
    inorder_list.append(id)

    if right != -1:
        inorder(right)

def get_right_sibling(id):
    parent_id = T[id].parent
    if parent_id == -1:
        return -1
    if T[parent_id].right != id:
        return T[parent_id].right

    return -1

def postorder(id):
    left = T[id].left
    right = T[id].right

    if left != -1:
        postorder(left)

    if right != -1:
        postorder(right)

    postorder_list.append(id)

preorder_list = []
inorder_list = []
postorder_list = []
for id in range(N):
    if T[id].parent == -1:
        preorder(id)
        inorder(id)
        postorder(id)
        break


print("Preorder")
print(" "+" ".join(map(str, preorder_list)))
print("Inorder")
print(" "+" ".join(map(str, inorder_list)))
print("Postorder")
print(" "+" ".join(map(str, postorder_list)))


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int p = 0, g = 0;
    int score = 0;
    for (char c : s) {
        if (p + 1 <= g) {
            if (c == 'g') {
                ++score;
            }
            ++p;
        } else {
            if (c == 'p') {
                --score;
            }
            ++g;
        }
    }
    cout << score;
    return 0;
}

Measured memory_bytes: 512
class HitBlow
  def check(a, b)
    hit_target = [a, b].transpose
    hit_target.delete_if { |x, y| x == y }
    hit_count = 4 - hit_target.count
    return [hit_count, 0] if hit_count == 4
    blow_target = hit_target.transpose
    blow_count = 4 - hit_count - (blow_target[0] - blow_target[1]).count
    [hit_count, blow_count]
  end
end

inputs = STDIN.read.split("\n")

loop do
  break if inputs.empty?
  a = inputs.shift.split.map(&:to_i)
  b = inputs.shift.split.map(&:to_i)
  result = HitBlow.new.check(a, b)
  printf "%s %s\n", result[0], result[1]
end

Measured memory_bytes: 8536
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = ''
if s[-1] == 's':
    ans = s + 'es'
else:
    ans = s + 's'
print(ans)

Measured memory_bytes: 74480
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    long long n, x;
    cin >> n >> x;
    vector<long long> p(n + 1), num(n + 1);
    p[0] = 1;
    num[0] = 1;
    for (int i = 0; i < n; ++i) {
        p[i + 1] = p[i] * 2 + 1;
        num[i + 1] = num[i] * 2 + 3;
    }
    long long ans = 0;
    while (x > 0) {
        --x;
        if (num[n - 1] <= x) {
            ans += p[n - 1];
            x -= num[n - 1];
        }
        else {
            --n;
            continue;
        }
        if (x > 0) {
            --x;
            ++ans;
        }
        else {
            --n;
            continue;
        }
        if (num[n - 1] <= x) {
            ans += p[n - 1];
            x -= num[n - 1];
        }
        else {
            --n;
            continue;
        }
        --x;
    }
    cout << ans << "\n";
    return 0;
}


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



int main(void){
    int prime[101010] = {};
    for (int i = 2; i < 314; i++) {
        if (prime[i] != 0) continue;
        int t = i+i;
        while (t < 101010) {
            prime[t]--;
            t += i;
        }
    }
    //for (int i = 2; i < 100; i++) if (prime[i] == 0) cout << i << " ";
    
    int a, b, c;
    int d, e, f;
    while (cin >> a >> b >> c && a) {
        d = 0; e = 0; f = 0;
        for (int i = 2; i < a; i++) {
            if (prime[i] != 0) continue;
            for (int j = 2; j <= i; j++) {
                if (prime[j] != 0) continue;
                if (i*j > a) break;
                
                if ((float)j/i >= (float)b/c) {
                    if (i*j > d) {
                        d = i*j;
                        e = i;
                        f = j;
                    }
                }
            }
        }
        cout << f << " " << e << endl;
    }
}

Measured memory_bytes: 3372
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
vector<int> res; vector<int> ser;
void divisor(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			res.push_back(i); if (i != n / i) res.push_back(n / i);
		}
	}
	if (n != 1) { res.push_back(n); }
}
void asd(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			ser.push_back(i); if (i != n / i) ser.push_back(n / i);
		}
	}
	if (n != 1) { ser.push_back(n); }
}
signed main() {
	int n, ans = 0; cin >> n; divisor(n); asd(n - 1);
	for (int h = 0; h < res.size(); h++) {
		int a = n;
		while (a % res[h] == 0) { a /= res[h]; }
		if ((a - 1) % res[h] == 0) { ans++; }
	}
	for (int h = 0; h < ser.size(); h++) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int A, B, C;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> A >> B >> C;

  int x = A + B;
  if (C <= x) {
    cout << B + C << endl;
  } else {
    cout << B + x + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
 
int main(void){
    int s = 0, d;
    for(string in; cin >> in;){
        rep(i, in.size()) if(in.at(i) < '0' || '9' < in.at(i)) in[i] = ' ';
        
        stringstream ss; ss << in;
        while(ss >> d) s += d;
    }
    cout << s << endl;
 
    return 0;
}

Measured memory_bytes: 1224
using System;
using System.Text;

namespace Main
{
  class Program
  {
    static void Main(string[] args)
    {
      var lines = Console.ReadLine().Split(' ');
      var a = int.Parse(lines[0]);
      var b = int.Parse(lines[1]);
      var k = int.Parse(lines[2]);

      StringBuilder buf = new StringBuilder();
      if (b - a < k * 2)
      {
        for (var i = a; i <= b; i++)
          if (a <= i && i < a + k || b - k < i && i <= b)
            buf.Append(i).Append('\n');
      }
      else
      {
        for (var i = a; i < a + k; i++)
          buf.Append(i).Append('\n');
        for (var i = b - k + 1; i <= b; i++)
          buf.Append(i).Append('\n');
      }

      Console.Write(buf);
    }
  }
}


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

int dist(int x,int y){
	return x*x+y*y;
}

int main(){
	int N;
	cin>>N;
	while(N-->0){
		int nowx=0,nowy=0;
		int dx,dy;
		int ansx,ansy;
		int distance = 0;
		while(true){
			cin>>dx>>dy;

			if(dx==0&&dy==0)break;

			nowx+=dx;
			nowy+=dy;

			if( distance < dist(nowx,nowy) ){
				distance = dist(nowx,nowy);
				ansx=nowx;
				ansy=nowy;
			}else if( distance == dist(nowx,nowy) && ansx < nowx ){
				ansx=nowx;
				ansy=nowy;
			}
		}
		cout << ansx << ' ' << ansy << endl;
	}
	return 0;
}

Measured memory_bytes: 0
// C++ program to count number of factors 
// of an array of integers 
#include <bits/stdc++.h> 
using namespace std; 

const int MAX = 1000001; 

// array to store prime factors 
int factor[MAX] = { 0 }; 

// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
	factor[1] = 1; 

	// Initializes all the positions with their value. 
	for (int i = 2; i < MAX; i++) 
		factor[i] = i; 

	// Initializes all multiples of 2 with 2 
	for (int i = 4; i < MAX; i += 2) 
		factor[i] = 2; 

	// A modified version of Sieve of Eratosthenes to 
	// store the smallest prime factor that divides 
	// every number. 
	for (int i = 3; i * i < MAX; i++) { 
		// check if it has no prime factor. 
		if (factor[i] == i) { 
			// Initializes of j starting from i*i 
			for (int j = i * i; j < MAX; j += i) { 
				// if it has no prime factor before, then 
				// stores the smallest prime divisor 
				if (factor[j] == j) 
					factor[j] = i; 
			} 
		} 
	} 
} 

// function to calculate number of factors 
int calculateNoOFactors(int n) 
{ 
	if (n == 1) 
		return 1; 

	int ans = 1; 

	// stores the smallest prime number 
	// that divides n 
	int dup = factor[n]; 

	// stores the count of number of times 
	// a prime number divides n. 
	int c = 1; 

	// reduces to the next number after prime 
	// factorization of n 
	int j = n / factor[n]; 

	// false when prime factorization is done 
	while (j != 1) { 
		// if the same prime number is dividing n, 
		// then we increase the count 
		if (factor[j] == dup) 
			c += 1; 

		/* if its a new prime factor that is factorizing n, 
		then we again set c=1 and change dup to the new 
		prime factor, and apply the formula explained 
		above. */
		else { 
			dup = factor[j]; 
			ans = ans * (c + 1); 
			c = 1; 
		} 

		// prime factorizes a number 
		j = j / factor[j]; 
	} 

	// for the last prime factor 
	ans = ans * (c + 1); 

	return ans; 
} 

// Driver program to test above function 
int main() 
{ 
	// generate prime factors of number 
	// upto 10^6 
	generatePrimeFactors(); 

// 	int a[] = { 10, 30, 100, 450, 987 }; 
  int n;
  cin>>n;
  int sum=0;
  for(int i=1;i<n;i++)
  sum+=calculateNoOFactors(i);
  cout<<sum<<endl;
// 	int q = sizeof(a) / sizeof(a[0]); 

// 	for (int i = 0; i < q; i++) 
// 		cout << calculateNoOFactors(a[i]) << " "; 

	return 0; 
} 


Measured memory_bytes: 7536
#define _USE_MATH_DEFINES //M_PI, M_E
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}
using namespace std;
const int n = int(1e5)+5;
bool primes[n];

void sieve()
{
	primes[0]=primes[1] = 0;
	for(int i = 2; i<=sqrt(n); i++)
		if(primes[i])
			for(int j = i*2; j<n; j+=i)
				primes[j] = 0;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	memset(primes,1,n);
	sieve();
	int q,l,r;
	cin>>q;
	int a[n] = {0};
	for(int i = 3; i<n; i+=2)
	{
		if(primes[i] && primes[((i+1)/2)])
			a[i]++;
	}
	for(int i = 2; i<n; i++)a[i] += a[i-1];
	while(q--)
	{
		cin>>l>>r;
		cout<<a[r]-a[l-1]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

class Main{
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
      	if(X == 3 || X == 5 || X == 7){
			System.out.println("YES");
        }else{
 			System.out.println("NO");       	
        }
	}
}

Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
typedef long long ll;
const int maxn = 2000,maxm = 20005;
const ll inf = 1e11;

struct Edge{
    Edge() {}
    Edge(int a,int b,ll c,int d){v = a;f = b;w = c;nxt = d;}
    int v,f,w,nxt;
};

int n,lmt;
int g[maxn + 10];
Edge e[maxm + 10];
int nume = 1;
int src,sink;

void addedge(int u,int v,int c,ll w){
    e[++nume] = Edge(v,c,w,g[u]);
    g[u] = nume;
    e[++nume] = Edge(u,0,-w,g[v]);
    g[v] = nume;
}

queue<int> que;
bool inq[maxn + 10];
ll dist[maxn + 10];
int prv[maxn + 10],pree[maxn + 10];

bool findpath(){
    while(!que.empty()) que.pop();
    que.push(src);
    memset(dist,63,sizeof dist);
    //for(int i = 0;i < maxn; ++i) dist[i] = inf;
    dist[src] = 0;
    inq[src] = true;
    while(!que.empty()){
        int u = que.front();que.pop();
        for(int i = g[u];i;i = e[i].nxt){
            if(e[i].f > 0 && dist[u] + e[i].w < dist[e[i].v]){
                dist[e[i].v] = dist[u] + e[i].w;
                prv[e[i].v] = u;
                pree[e[i].v] = i;
                if(!inq[e[i].v]){
                    inq[e[i].v] = true;
                    que.push(e[i].v);
                }
            }
        }
        inq[u] = false;
    }
    if(dist[sink] < inf) return true;
    else return false;
}

ll augment(){
    int u = sink;
    ll delta = inf;
    while(u != src){
        if(e[pree[u]].f < delta) delta = e[pree[u]].f;
        u = prv[u];
    }
    u = sink;
    while(u != src){
        e[pree[u]].f -= delta;
        e[pree[u] ^ 1].f += delta;
        u = prv[u];
    }
    return dist[sink] * delta;
}

ll mincostflow(){
    ll cur = 0,ans = 0;
    while(findpath()){
        cur += augment();
        if(cur < ans) ans = cur;
    }
    return ans;
}

int main(){
    scanf("%d",&n);
    src = 2 * n + 1,sink = 2 * n + 2;
    for(int i = 1;i <= n; ++i){
        int x,y,c;scanf("%d%d%d",&x,&y,&c);
        addedge(2 * n + 1,i,c,0);
        addedge(i,2 * n + 3,c,x + y);
        addedge(i,2 * n + 4,c,x - y);
        addedge(i,2 * n + 5,c,-x + y);
        addedge(i,2 * n + 6,c,-x - y);
    }
    for(int i = 1;i <= n; ++i){
        int x,y,c;scanf("%d%d%d",&x,&y,&c);
        addedge(n + i,2 * n + 2,c,0);
        addedge(2 * n + 3,n + i,c,-x - y);
        addedge(2 * n + 4,n + i,c,-x + y);
        addedge(2 * n + 5,n + i,c,x - y);
        addedge(2 * n + 6,n + i,c,x + y);
    }

    ll res = mincostflow();
    printf("%lld",-res);
    return 0;
}




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

int main(void){
    ll A, B, N;
    cin >> A >> B >> N;
    cout << (A*min(B-1, N))/B << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <cstdio>

int main() {
    int n, q;
    int A[1000000];
    int t;
    int count = 0;
    
    
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf ("%d", &t);
        int left = 0;
        int right = n;
        while(left < right) {
            
            int mid = (left + right) / 2;
            if (A[mid] == t){
                count++;
                break;
            } else if ( A[mid] > t) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
    }
    
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2988
#include <iostream>
using namespace std;
typedef long long int ll;
int v[1000];
ll w[1000];

ll Knapsack(int n, ll m){
    ll mem[n+1][m+1];
    for (int i=0;i<=n;i++){
        for (int j=0;j<=m;j++){
            if ( i == 0 || j == 0) mem[i][j] = 0;
            else if ( j >= w[i-1]) mem[i][j] = max(mem[i-1][j],mem[i-1][j-w[i-1]]+v[i-1]);
            else mem[i][j] = mem[i-1][j];
        }
    }return mem[n][m];
}


int main(){
    int n,w2;
    cin >> n >> w2;
    for (ll i=0;i<n;i++) cin >> w[i] >> v[i];
    cout << Knapsack(n,w2);
    return 0;
}

Measured memory_bytes: 79104
# -*- coding:utf-8 -*-
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b / gcd(a, b)

n = int(input())
a = list(map(int,input().split()))
p = lcm(a[0],a[1])
for i in range(n):
    p = lcm(p,a[i])
print(int(p))

Measured memory_bytes: 7744
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

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

const ll MOD = 1000000007;

using namespace std;

ll A[200005];
ll S[200005];
int main()
{
	ll N;
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
		S[i] = A[i];
		if (i > 0)
		{
			S[i] += S[i - 1];
		}
	}

	ll ans = N;
	int last = 1;
	REP(i, N - 1)
	{
		if (i >= last)
		{
			last = i + 1;
		}
		FOR(j, N, last)
		{
			ll s = i > 0 ? S[j] - S[i - 1] : S[j];
			if ((s^A[j]) == (s - A[j]))
			{
				ans += j - i;
				last = j + 1;
				continue;
			}
			last = j;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
n,a=map(int,input().split())
x=[0]+[i-a for i in map(int,input().split())]
d={}
def f(i):
    if i==n+1:
        return {0:1}
    if i in d:
        return d[i]
    d[i]={}
    for j in range(i+1,n+2):
        for k,v in f(j).items():
            d[i].setdefault(x[i]+k,0)
            d[i][x[i]+k]+=v
    return d[i]
print(f(0)[0]-1)

Measured memory_bytes: 5236
import java.util.Scanner


object Main {

  case class Ope(b:Int, c:Long)

  def read() = {
    val sc = new Scanner(System.in)
    val n,m = sc.nextInt()
    val a = IndexedSeq.fill(n)(sc.nextLong())
    val opes = IndexedSeq.fill(m)(Ope(sc.nextInt(), sc.nextLong()))
    (n, m, a, opes)
  }

  //aソートしておく？
  //(b,c)ソートしておく？ ソートしたほうが得。1変換で終わる

  def solve(n:Int,m:Int,a:IndexedSeq[Long],opes:IndexedSeq[Ope]): Long = {
    val sortedOpes = opes.sortBy(ope=> ope.c).reverse// 降順
    val sortedA = a.sorted.toArray

    def opeAll(): Unit ={
      var i = 0
      for(ope <- sortedOpes){

        for(_ <- 0 until ope.b){
          if(sortedA(i) < ope.c){
            sortedA(i) = ope.c
          }else{
            return
          }
          i += 1
          if(i >= n){
            return
          }
        }
      }
    }
    opeAll()

    sortedA.sum
  }

  def main(args: Array[String]): Unit = {
    val (n, m, a, opes) = read()
    println(solve(n,m,a,opes))
  }
}

Measured memory_bytes: 114136
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;

typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};

#define p(x) cout<<x<<endl;
 
ll i,j,k,l,ii,jj;
ll n,m;
ll x,y;
ll a[200005],b[200005];
char s[305][305];
ll ans=0;
ll v=-1,w;
ll num;

 
int main(){
    cin>>n;
	for(i=0;i<n;i++){
		cin>>s[i];
	}
	for(i=0;i<n;i++){
		bool flag=false;
		for(j=0;j<n;j++){
			for(k=0;k<n;k++){
				if(s[(j+i)%n][k]!=s[(k+i)%n][j])flag=true;
			}
		}
		if(!flag)ans+=n;
	}
	p(ans);

	



	return 0;
}

Measured memory_bytes: 6144
from collections import deque
n,u,v = map(int,input().split())
l = [[]for i in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    l[a].append(b)
    l[b].append(a)
rl = [0 for i in range(n+1)]
d = deque()
d.append([l[u],u])
while len(d):
    l0,now = d.popleft()
    for i in l0:
        if i == u:
            continue
        elif rl[i] == 0:
            rl[i] = rl[now] + 1
            d.append([l[i],i])
rl2 = [0 for i in range(n+1)]
d = deque()
d.append([l[v],v])
while len(d):
    l0,now = d.popleft()
    for i in l0:
        if i == v:
            continue
        elif rl2[i] == 0:
            rl2[i] = rl2[now] + 1
            d.append([l[i],i])
dis = rl[v]
nl = []
for i in range(n+1):
    nl.append([rl2[i],i])
nl.sort(key=lambda x:x[0],reverse=True)
for i in range(n+1):
    if nl[i][0] > rl[nl[i][1]]:
        ans = nl[i][0]-1
        break
print(ans)

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

struct Process {
  string name;
  int time;
};

int main() {
  int n, q;
  cin >> n >> q;

  queue<Process> pq;
  for (int i = 0; i < n; i++) {
    Process p;
    cin >> p.name >> p.time;
    pq.push(p);
  }

  int total_time = 0;
  while (!pq.empty()) {
    Process p = pq.front();
    pq.pop();
    total_time += p.time > q ? q : p.time;
    p.time -= q;
    if (p.time <= 0)
      cout << p.name << " " << total_time << endl;
    else
      pq.push(p);
  }

  return 0;
}


Measured memory_bytes: 6360
N,M = map(int, input().split())
H = list(map(int, input().split()))
A, B = [], []
for i in range(M):
  tmp_A, tmp_B = map(int, input().split())
  A.append(tmp_A)
  B.append(tmp_B)

root = [[] for i in range(N)]
for i in range(M):
  #root[A[i]-1].append(B[i])
  root[A[i]-1].append(H[B[i]-1])
  root[B[i]-1].append(H[A[i]-1])

count = 0
for i in range(N):
  if len(root[i]) == 0:
    count+=1
  else:
    if H[i] > max(root[i]):
      count+=1
print(count)
    
  

Measured memory_bytes: 31512