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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,n;
    cin >> x >> n;
    map<int,int> mp;
    vector<int> a;
    for(int i = 0; i < n; i++) {
        int p;
        cin >> p;
        mp[p]++;
    }

    int dif=0;
    while(true) {
        if(mp.count(x-dif)!=1){
            cout << x-dif << "\n";
            return 0;
        }
        if(mp.count(x+dif)!=1){
            cout << x+dif << "\n";
            return 0;
        }
        dif++;
    }

    return 0;
}

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

int N,W;

struct goods { int w, v; };

vector<goods> a(110);
int dp[110][10010] = {};


int main()
{
    scanf("%d%d", &N, &W);
    for (int i = 0; i < N; i++) scanf("%d%d", &a.at(i).v, &a.at(i).w );

    for (int i = 0; i < N; i++)
    {
        for (int w = 0; w <= W; w++)
        {
            if (a.at(i).w <= w)
            {
                dp[i+1][w] = max( dp[i][w-a.at(i).w] + a.at(i).v , dp[i][w] );
            }
            else
            {
                dp[i+1][w] = dp[i][w];
            }
        }
    }

    printf("%d\n", dp[N][W]);

    return 0;
}


Measured memory_bytes: 7112
n= int(input())
a_list = list(map(int, input().split()))
 
a_list = [n for n in a_list if n!=1]  
#print(a_list)
ans=1

if 0 in a_list:
  ans=0
elif len(a_list)>56:
  ans=-1
else:
  for i in a_list:
    ans=ans*i
  if ans>1000000000000000000:
      ans=-1
  
print(ans)

Measured memory_bytes: 21636
# your code goes here

N,K = map(int,input().split())

A = list(map(int,input().split()))

for i in range(N):
	if A[i] == 1:
		place_one = i
		break

ans_left = (place_one+(K-2))//(K-1)
# print(ans_left)
ans_left += (N-(K-1)*ans_left+(K-3))//(K-1)
# print(ans_left)

ans_right = (N-1-place_one+(K-2))//(K-1)
# print(ans_right)
ans_right += (N-1-(K-1)*ans_right+(K-2))//(K-1)
# print(ans_right)

print(min(ans_left,ans_right))
	

Measured memory_bytes: 13940
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

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

string s = "";
char ch[10];
int n, a, b, c, d, x, m[5];

int main() {
	cin >> n;
	cout << 48 - n << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string numbers,ans;
    cin >> numbers;
    for(int i=0;i<3;i++){
        if (numbers[i] == '7')
        {
            ans = "Yes";
            break;
        }
        else{
            ans = "No";
        }
    }
    cout << ans;
}

Measured memory_bytes: 3644
def solve():
    S = input()
    d = {'SUN': 7,
        'MON': 6,
        'TUE': 5,
        'WED': 4,
        'THU': 3,
        'FRI': 2,
        'SAT': 1
        
    }
    return d[S]

print(solve())

Measured memory_bytes: 2940
def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end
  
S = gets.chomp
ans = (1 ... S.size).inject(S.size) do |s,i| 
  if S[i-1] != S[i]
    min(s, max(S.size - i, i))
  else
    s
  end
end
puts ans


Measured memory_bytes: 1916
#include <stdio.h>
int main(void)
{
	int x, y, z;//関数の定義
	scanf("%d %d", &x, &y);

	while (1)//これ以下の条件式は永遠に続く
	{
		if (x > y)
		{
			z = x;
			x = y;
			y = z;
		}
		if ((x == 0) && (y == 0))
			break;//xもyも0の場合強制的に終了
		printf("%d %d\n", x, y);
		scanf("%d %d", &x, &y);
	}
	return 0;//終了

}


Measured memory_bytes: 2064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

const int MAX_N=1000000;

int n;
ll node[2*MAX_N-1],lazy[2*MAX_N-1];

void init(int _n){
    n=1;
    while(n<_n) n*=2;
}

void eval(int k, int l, int r) {
    if(lazy[k] != 0) {
        node[k] += lazy[k];
        if(r - l > 1) {
            lazy[2*k+1] += lazy[k] / 2;
            lazy[2*k+2] += lazy[k] / 2;
        }
        lazy[k] = 0;
    }
}

void add(int a, int b, ll x, int k, int l, int r) {
    eval(k, l, r);
    if(b <= l || r <= a) return;
    if(a <= l && r <= b) {
        lazy[k] += (r - l) * x;
        eval(k, l, r);
    }
    else {
        add(a, b, x, 2*k+1, l, (l+r)/2);
        add(a, b, x, 2*k+2, (l+r)/2, r);
        node[k] = node[2*k+1] + node[2*k+2];
    }
}

ll getsum(int a, int b, int k, int l, int r) {
    if(b <= l || r <= a) return 0;
    eval(k, l, r);
    if(a <= l && r <= b) return node[k];
    ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
    ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
    return vl + vr;
}

int main(){
    int N,Q;
    cin>>N>>Q;
    init(N);
    rep(i,Q){
        int a;cin>>a;
        if(a==0){
            int s,t;ll x;
            cin>>s>>t>>x;
            s--;t--;
            add(s,t+1,x,0,0,n);
        }else{
            int s,t;
            cin>>s>>t;
            s--;t--;
            cout<<getsum(s,t+1,0,0,n)<<endl;
        }
    }
}


Measured memory_bytes: 6276
#include<stdio.h>
int main(){
  int A, B, sum, dif, pdc, max;
  scanf("%d %d", &A, &B);
  sum = A + B;
  max = sum;
  dif = A - B;
  if(max < dif) max = dif;
  pdc = A * B;
  if(max < pdc) max = pdc;
  printf("%d\n", max);
  return 0;
}

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

using namespace std;

int main()
{
    string s,s2,s3;
    cin>>s;
    int len=s.length();
    for(int i=0;i<(len-1)/2;i++)
    {
        s2+=s[i];
    }
    for(int i=(len+3)/2-1;i<len;i++)
    {
        s3+=s[i];
    }
    string p=s,p2=s2,p3=s3;
    reverse(p.begin(),p.end());
    reverse(p2.begin(),p2.end());
    reverse(p3.begin(),p3.end());
    if(p==s && p2==s2 && p3==s3)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())

loop = True
last2 = 0
last1 = 0
current = N % K
while loop:
  current = abs(K - current)

  if (current == last2):
    loop = False
    break
  else:
    last2 = last1
    last1 = current
    continue

result = last1 if (last1 < last2) else last2
print(result)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdlib>
#include <queue>
#include <ctime>
#include <map>
#include <algorithm>
#include <complex>
using namespace std;
typedef complex<double> P;

struct NODE{
	long long w,t,x,i;
	NODE(){}
	NODE(long long w,long long t,long long x,long long i) : w(w) , t(t) , x(x) , i(i) {}
};
bool cmp(const NODE &a,const NODE &b){ return a.w < b.w; };

typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}

NODE info[100000];
int query[100000];
long long res1[100000];
long long res2[100000];


long long C[3] , S[3] , V[3];

priority_queue< pair<int,pair<int,int> > , vector< pair<int,pair<int,int> > > , greater< pair<int,pair<int,int> > > > remQue;

int main(){
	int N,Q;
	cin >> N >> Q;
	for(int i = 0 ; i < N ; i++){
		cin >> info[i].w >> info[i].t >> info[i].x;
		info[i].i = i;
	}
	for(int i = 0 ; i < Q ; i++){
		cin >> query[i];
	}
	for(int i = 0 ; i < N ; i++) res1[i] = -1;
	sort(info,info+N,cmp);
	long long power = 0;
	int idx = 0 , idx2 = 0;
	
	for(int day = 0 ; day <= 3652425 ; day++){
		while( remQue.size() && remQue.top().first == day ){
			C[remQue.top().second.first] -= 1;
			S[remQue.top().second.first] -= remQue.top().second.second;
			if( remQue.top().second.first == 2 ){
				V[remQue.top().second.first] -= remQue.top().second.second*remQue.top().second.second;
			}
			remQue.pop();
		}
		while( idx < N && power >= info[idx].w ){
			res1[idx] = day; 
			C[info[idx].t]++;
			remQue.push(make_pair(day+info[idx].x,make_pair(info[idx].t,info[idx].x)));
			idx++;
		}
		while( idx2 < Q && day == query[idx2] ) {
			res2[idx2] = power;
			idx2++;
		}
		S[1] += C[1];
		V[2] += 2*S[2]+C[2];
		S[2] += C[2];	
		// by girl
		power += 1;

		// by 1
		power += C[0];

		// by x
		power += S[1];

		// by x2^2
		power += V[2]; 
	}
	for(int i = 0 ; i < N ; i++){
		if( res1[i] == -1 ) cout << "Many years later" << endl;
		else cout << res1[i] << endl;
	}
	for(int i = 0 ; i < Q ; i++)
		cout << res2[i] << endl;
}

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	for (int i=0;i<=100000;i ++)
		if (a*i%b==c%b) {
			puts("YES");
			return 0;
		}
	puts("NO");
	return 0;
}

Measured memory_bytes: 384
n = int(input())
print(n**3) #waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_waiting_for_pudging_

Measured memory_bytes: 2940
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000007;
constexpr int INF = 2000000000;
using namespace std;


int main() {
	int N, M;
	int dp[300];
	while (cin >> N&&N != 0) {
		vector<pair<int, int>>n;
		int a, b;
		for (int i = 0; i < N; i++) {
			cin >> a >> b;
			n.emplace_back(a, b);
		}
		cin >> M;
		for (int i = 0; i < M; i++) {
			cin >> a >> b;
			n.emplace_back(a, b);
		}
		sort(n.begin(), n.end());
		fill(dp, dp + N + M, 1);
		for (int i = 1; i < N + M; i++) {
			for (int j = i - 1; j >= 0; j--) {
				if (n[i].first > n[j].first&&n[i].second > n[j].second) {
					dp[i] = max(dp[j] + 1, dp[i]);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i < N + M; i++)ans = max(ans, dp[i]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3096
n = gets.to_i
s = gets.chomp.split('')

ans = s.join

temp = 0
for i in s do
  if(i == ')')
    if(temp > 0)
      temp = temp - 1
    else
      ans = '(' + ans
    end
  else
    temp = temp + 1
  end
end

puts ans + ')' * temp

Measured memory_bytes: 1916
MOD = 10**9 + 7
def nck(n, k):
    numer, denom = 1, 1
    for i in range(k):
        numer = numer * (n - i) % MOD
        denom = denom * (k - i) % MOD
    return numer * pow(denom, MOD-2, MOD) % MOD

x, y = map(int, input().split())
# (1, 2) 動く回数をm回、(2, 1) 動く回数をn回とする
n = -1
for m in range(min(x//1, y//2) + 1):
    rx = x - m
    ry = y - 2 * m
    if rx == ry * 2:
        n = ry
        break

if n == -1:
    print(0)
else:
    print(nck(m+n, min(m, n)))


Measured memory_bytes: 40044
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    string s;
    cin>>s;
    int len = (int)s.length();
    vector<int >a(len,0);
    if(s[0]=='B')a[0]=1;
    else a[0]=0;
    for(int i=1;i<len;i++){
        if(s[i]=='B')a[i]=a[i-1]+1;
        else a[i]=a[i-1];
    }
    
    long long count=0;
    for(int i=0;i<len;i++){
        if(s[i]=='W')count+=a[i];
    }
    cout<<count;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#define _rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

/***********************/

int main(){
    ssd;
    int x,y,a,b,c;cin>>x>>y>>a>>b>>c;
    VI p(a),q(b),r(c);
    for(auto &it : p) cin>>it;
    for(auto &it : q) cin>>it;
    for(auto &it : r) cin>>it;
    sort(all(p),greater<int>());
    sort(all(q),greater<int>());
    rep(i,0,x) r.pb(p[i]);
    rep(i,0,y) r.pb(q[i]);
    sort(all(r),greater<int>());
    ll sum =0;
    rep(i,0,x+y) sum+= r[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 2552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll pref[101000];
ll suff[101000];
ll ara[101000];
int main()
{
  ll n , d , rem;
  cin >> n;
 // int ara[n+10];
  ara[n+1] = 0 ;
  ara[0] = 0;
  for(int i=1; i<=n; i++)
  {
      cin >> ara[i];
      
  }
  for(int i=1; i<=n; i++)
  {
      pref[i] = pref[i-1]+abs(ara[i]-ara[i-1]);
  }

  for(int i=n; i>=1; i--)
  {

      suff[i] = suff[i+1]+abs(ara[i]-ara[i+1]);
  }


  for(int i=1; i<=n; i++)
  {
      ll lft = pref[i-1],rgt = suff[i+1],mid = abs(ara[i-1]-ara[i+1]);
      //cout << pref[i-1] << endl;
      cout << lft + rgt + mid << endl;
  }




  }


Measured memory_bytes: 5952
// https://atcoder.jp/contests/abc074/tasks/arc083_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int A, B, C, D, E, F, ma, mb;
double cd, md;
set<int> x, y;

int main()
{
  cin >> A >> B >> C >> D >> E >> F;

  REP(i, F / B + 1)
  {
    ll xi = i * B;
    while (xi <= F)
    {
      if (0 < xi)
        x.insert(xi * 100);
      xi += A;
    }
  }
  double ms = 1.0 * F / (100 + E) * E;
  REP(i, ms / D + 1)
  {
    ll yi = i * D;
    while (yi <= ms)
    {
      y.insert(yi);
      yi += C;
    }
  }

  ma = A * 100;
  md = mb = 0;
  for (auto &a : x)
  {
    for (auto &b : y)
    {
      if (100 * b <= a * E && a + b <= F)
      {
        cd = 100.0 * b / (a + b);
        if (md < cd)
        {
          md = cd;
          ma = a + b;
          mb = b;
        }
      }
    }
  }

  cout << ma << " " << mb << '\n';

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
main(){
  const int n_takahashi=[]{
    const int a=[]{int x;cin>>x;return x;}();
    const int b=[]{int x;cin>>x;return x;}();
    int n=0;
    for(int m=1;m<=12;++m){
      for(int d=1;d<=31;++d){
        if(m==d)++n;
        if(m==a&&d==b)return n;
      }
    }
  }();
  cout<<n_takahashi<<endl;
}


Measured memory_bytes: 256
N=int(input())
X=map(int,input().split())
X2 = [(x,i) for i,x in enumerate(X)]
X2.sort()
# 1 2 3 4 5 6
#     3 * * *
# * * * 4    
ans=[0 for i in range(N)]
m1,i1=X2[N//2-1]
m2,i2=X2[N//2]
for j in range(N//2):
    x,i=X2[j]
    ans[i]=m2
for j in range(N//2,N):
    x,i=X2[j]
    ans[i]=m1
for i in range(N):
    print(ans[i])


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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      h: usize,
      w: usize,
      cs: [[usize; 10]; 10],
      aa: [i64; w*h],
    }
    let mut cs = cs;

    for k in 0..10 {
        for i in 0..10 {
            for j in 0..10 {
                cs[i][j] = min(cs[i][j], cs[i][k] + cs[k][j]);
            }
        }
    }

    let mut ans = 0;
    for i in 0..w*h {
        if aa[i] == - 1 || aa[i] == 1 { continue; }
        ans += cs[aa[i] as usize ][1];
    }
    println!("{}", ans);
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int answer;
  if (A-2*B >= 0) {
    answer = A-2*B;
  }
  else {
    answer = 0;
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

struct g{

    lli a, b, cost;

};

void solve()
{

    lli n, m, p;
    cin>>n>>m>>p;
    vector<g> v(m);
    for(int i = 0; i < m; i ++) {
        lli uu, vv, c;
        cin>>uu>>vv>>c;
        c = c - p;
        c *= -1;
        v[i].a = uu;
        v[i].b = vv;
        v[i].cost = c;
    }

    vector<lli> dis(n + 1, inf);
    dis[1] = 0;

    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < m; j ++ ) {
            if(dis[v[j].a] < inf) {
                if(dis[v[j].b] > dis[v[j].a] + v[j].cost) {
                    dis[v[j].b] = dis[v[j].a] + v[j].cost;
                }
            }
        }
    }

    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < m; j ++ ) {
            if(dis[v[j].a] < inf) {
                if(dis[v[j].b] > dis[v[j].a] + v[j].cost) {
                    dis[v[j].b] = -inf;
                }
            }
        }
    }



    if(dis[n] == -inf) {
        cout<<-1;
    }
    else {
        dis[n] = max(0LL, -dis[n]);
        cout<<dis[n];
    }
    cout<<"\n";
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
LLL = 1<<20

N, M = map(int, input().split())
R = []
for _ in range(N):
    a, b = map(int, input().split())
    R.append((a*2, b, 0))
for i in range(M):
    l, r = map(int, input().split())
    R.append((l*2-1, 2, i))
    R.append((r*2+1, 3, i))

R.sort(key=lambda x:x[0])
nodeid = 0
bf = -1
d = []
eid2lid = dict()
G = [set()]
for x, f, i in R:
    if f <= 1:
        d.append(int(f != bf and bf != -1))
        bf = f
        nodeid += 1
        G.append(set())
    else:
        if f == 3:
            lid = eid2lid[i]
            if nodeid != lid:
                G[nodeid].add((lid, i+1))
                G[lid].add((nodeid, i+1))
        eid2lid[i] = nodeid
d.append(int(bf==1))

xxs = [-1]*(nodeid+1)
g2 = [set() for _ in range(nodeid+1)]
vs = set()
cut_edges = set()
for i in range(nodeid+1):
    if i in vs:
        continue
    stack = [i]
    dfs_vs = []
    vs.add(i)
    while stack:
        v = stack.pop()
        dfs_vs.append(v)
        for u, j in G[v]:
            if u in vs:
                continue
            g2[v].add((u, j))
            stack.append(u)
            vs.add(u)
    for v in dfs_vs[::-1]:
        r = d[v]
        for u, j in g2[v]:
            ff = xxs[u]
            if ff:
                cut_edges.add(j)
            r = (r+ff)%2
        xxs[v] = r if v != 0 else 0
    if xxs[i]:
        print(-1)
        break
else:
    print(len(cut_edges))
    print(*sorted(cut_edges))


Measured memory_bytes: 162904
@x, @n, @c = 0, 0, 0

while s = gets
  break if s.nil? || s.chomp == ""
  x, n = s.split(',').map(&:to_f)
  @x += x * n 
  @n += n
  @c += 1
end

puts @x.to_i
puts (@n / @c).round

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

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

    string ans;
    if (4*x < y || y%2 == 1 || 2*x > y) {
        ans = "No";
    } else {
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	ll M;
    cin >> M;
  	vector<ll> d(M), c(M), e(M);
  	
  	ll digit = 0;
  	ll sum = 0;
	rep(i,M){
  		cin >> d[i] >> c[i];
      	e[i] = c[i]*d[i];
		digit += c[i];
      	sum += e[i];      	
    }
  
  	// ll rem; 	// Σ c[i]d[i] を 9 で割った商
  	// ll digit; // c の各桁の総和
  
  	// digit = accumulate(c.begin(), c.end(), 0);
	// rem = accumulate(e.begin(), e.end(), 0);
  	if (sum%9 != 0){
 		sum = (sum - sum%9)/9;
  	}else{
		sum = sum/9 - 1;
    }
  	cout << digit + sum - 1 << endl;
    return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 4992
#ABC137-E Coins Respawn
"""
1の移動に対してpだけコストを支払うと考える事ができる。
pを考慮しても無限にコインを増やすような閉路が存在する場合、-1を出力、そうでないならばコストが最大と
なるようにゴールに行くことが最適である。
すべての辺上のコインをマイナス値でもって、pを足し合わせることによってこれが達成できる。
ベルマンフォード法を用いて負の重みを扱えるようにする。
この時、負の閉路の検出が可能だが、この問題では1→Nへの道とは関係ない場所に負の閉路が存在しても、
それは無限にコインを増やせるとは言わない。
よって、まず1と関係する辺をすべて求めた後、Nと関係する逆辺を求める事により、どちらもに該当しない辺を除去することで達成できる。
"""
import sys
from collections import deque
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m,p = map(int,readline().split())
g = [[] for i in range(n)]
rev = [[] for i in range(n)] #逆辺
for i in range(m):
	x,y,w = map(int,readline().split())
	x,y,w = x-1,y-1,-w
	g[x].append((y,w+p))
	rev[y].append((x,w+p))

res1 = [0]
queue = deque([0])
#頂点1からスタートして、関係のある辺を求める
while True:
	if len(queue) <= 0:
		break
	v = queue.pop()
	for e in g[v]:
		if e[0] not in res1:
			res1.append(e[0])
			queue.append(e[0])
		else:
			continue

res2 = [n-1]
queue = deque([n-1])
#頂点nからスタートして、関係のある辺を求める
while True:
	if len(queue) <= 0:
		break
	v = queue.pop()
	for e in rev[v]:
		if e[0] not in res2:
			res2.append(e[0])
			queue.append(e[0])
		else:
			continue
itr = set([i for i in range(n)])
res3 = itr - (set(res1) & set(res2))

def BellmanFord(edges,num_v,source): #[x,y,weight]のリスト,頂点数,始点
	#グラフの初期化
	inf=float("inf")
	dist=[inf for i in range(num_v)]
	dist[source]=0
	#辺の緩和
	for i in range(num_v):
		for edge in edges:
			if edge[0] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
				dist[edge[1]] = dist[edge[0]] + edge[2]
				if i==num_v-1: return [] #負の閉路が存在する場合,空のリストが帰る
  
	return dist

edges = []
for i in range(n):
	if i in res3:
		continue
	for j in g[i]:
		if j[0] in res3:
			continue
		edges.append([i,j[0],j[1]])

dist = BellmanFord(edges,n,0)

if len(dist) == 0:
	print(-1)
else:
	print(max(0,-dist[n-1]))

Measured memory_bytes: 48748
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
using namespace std;
const int INF=LLONG_MAX-1e10;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;
int node[55][6],f[15],k;
void  dfs(int now,int val)
{
    if(now==n+1) {
        int num=0;
        fu(i,1,k)
        {
            if(f[node[i][2]]-f[node[i][1]]==node[i][3])num+=node[i][4];
        }
        ans=max(ans,num);
        return;
    }
    fu(i,val,m)
    {
        f[now]=val;
        dfs(now+1,i);
        f[now]=-1;
    }
}

main()
{
    IOS
    cin>>n>>m>>k;
    fun(i)f[i]=-1;
    fu(i,1,k)fu(j,1,4)cin>>node[i][j];
    fu(i,1,m) {
        f[1]=i;
        dfs(1, i);
        f[1]=-1;
    }
    out(ans)
    return 0;
}


Measured memory_bytes: 3612
from collections import Counter

s = input().rstrip()
t = input().rstrip()

cs = Counter(s)
ct = Counter(t)
s_v = sorted(cs.values())
c_v = sorted(ct.values())

if len(s_v) != len(c_v):
    print('No')
else:
    for i1, i2 in zip(s_v, c_v):
        if i1 != i2:
            print('No')
            break
    else:
        print('Yes')



Measured memory_bytes: 4144
N=int(input())
ls=[[int(s) for s in input().split()] for i in range(N)]
ans=[0,0,0]
for i in range(N):
  if ls[i][2]!=0:
    a=ls[i][0]
    b=ls[i][1]
    h_base=ls[i][2]
    ls.pop(i)
    break
for x in range(101):
  for y in range(101):
    ##x,yの高さを計算
    h=h_base+abs(x-a)+abs(y-b)
    ##他の条件と合うか？
    flag=1
    for e in ls:
      if (h!=e[2]+abs(x-e[0])+abs(y-e[1]) and e[2]>0): 
        flag=0
        break
      if (h>e[2]+abs(x-e[0])+abs(y-e[1]) and e[2]==0):
        flag=0
        break
    if flag==1:
      ans=[x,y,h]
      break
  if flag==1:
    break
print(*ans)  
      
        
      
      
    
  


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    if (A + B >= C) ans = B + C;
    else ans = B + (A + B) + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;
  int dp1[K+1];
  int dp2[K+1];
  for(int i=0; i<K+1; i++){
    dp1[i] = 1e9*-1;
    dp2[i] = 1e9;
  }
  int pos = 0;
  for(int i=0; i<N; i++){
    if(S.at(i) == 'o' && dp1[pos] + C <= i){
      dp1[pos+1] = i+1;
      pos++;
    }
    if(pos == K){
      break;
    }
  }
  pos = 0;
  for(int i=N-1; i>=0; i--){
    if(S.at(i) == 'o' && dp2[pos] - C > i+1){
      dp2[pos+1] = i+1;
      pos++;
    }
    if(pos == K){
      break;
    }
  }
  
  
  for(int i=0; i<K+1; i++){
    if(dp1[i] == dp2[K+1-i]){
      cout << dp1[i] << endl;
    }
  }
    
}

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

#define eps 1e-8
#define pb push_back
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define clr(a,b) memset(a,b,sizeof(a)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

int main(){
    FAST_IO;
    string s;
    cin>>s;
    if(s.size()==2) cout<<s<<endl;
    else{
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n;
  cin >> n;
  map <string, ll> m;
  rep(i, n) {
    ll a, c;
    string b;
    cin >> a >> b;
    if (a == 0) {
      cin >> c;
      m[b] = c;
    } else {
      cout << m.at(b) << endl;
    }
  }
}


Measured memory_bytes: 27848
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll q;
    cin >> q;

    for(ll i = 0; i < q; i++){
        ll a, b;
        cin >> a >> b;
        ll tmp = sqrt(a * b);
        // cout << tmp << endl;
        // cout << a * b << endl;
        if(a == b){
            cout << (tmp - 1) * 2 << endl;
        } else {
            if(tmp * (tmp + 1) >= a * b){
                if(tmp * tmp == a * b){
                    cout << (tmp - 1) * 2 - 1 << endl;
                } else {
                    cout << tmp * 2 - 2 << endl;
                }
            } else {
                cout << tmp * 2 - 1 << endl;
            }
        }
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
int dy[] = {1, 0, 0, -1};
int dx[] = {0, 1, -1, 0};
vector<string> s(12);

void dfs(int y, int x){
	s[y][x] = '0';
	rep(i, 4){
		int ny = y + dy[i], nx = x + dx[i];
		if(!(0 <= ny && ny < 12 && 0 <= nx && nx < 12)) continue;
		if(s[ny][nx] == '0') continue;
		dfs(ny, nx);
	}
	return;//???????????±?????¢????????¨?????§???????????????
}

int main(void){
	while(1){
		int cnt = 0;
		rep(i, 12){
			if(!(cin >> s[i])) return 0;//??????????????±???????????´???
		}

		rep(y, 12)rep(x, 12){
			if(s[y][x] == '1'){
				dfs(y, x);
				cnt++;
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	ll N;
	cin >> N;
	vector<ll> x(N);
	rep(i,N) cin >> x[i];
	ll L, Q;
	cin >> L >> Q;

	vector<int> ptr(N,-1);
	for(int i = 0, j = 0; i < x.size(); i++) {
		while(x[i] - x[j] > L) {
			ptr[j] = i-1;
			j++;
		}
	}
	rep(i,N) if(ptr[i] < 0) ptr[i] = N;

	vector<vector<int> > pow2ptr;
	pow2ptr.push_back(ptr);
	for(int i = 0; i < 20; i++) {
		vector<int> p(N);
		for(int j = 0; j < N; j++) {
			if(pow2ptr[i][j] < N)
				p[j] = pow2ptr[i][pow2ptr[i][j]];
			else
				p[j] = N;
		}
		pow2ptr.push_back(p);
	}

	rep(i,Q) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(a > b) swap(a, b);

		int l, r;
		int res;
		l = 0; r = 1e6;
		while(l <= r) {
			int m = (l+r)/2;

			int s = a;
			for(int i = 0; i < 20; i++) {
				if(m & (1 << i) && s < N) {
					s = pow2ptr[i][s];
				}
			}

			if(b <= s) {
				r = m-1;
				res = m;
			}
			else {
				l = m+1;
			}
		}
		cout << res << endl;
	}
	return 0;
}


Measured memory_bytes: 10616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        int[] ary = new int[n];
        for (int i = 0; i < q; i++) {
            ary[Integer.parseInt(sc.next()) - 1]++;
        }
        for (int num : ary) {
            if (k - (q - num) > 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 58028
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {

	static List<edge> graph;
	static int V;

	static int total;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] V_E = br.readLine().split(" ");

		V = Integer.parseInt(V_E[0]);

		int E = Integer.parseInt(V_E[1]);

		graph = new ArrayList<>();

		for (int i = 0; i < E; i++) {
			String[] edge = br.readLine().split(" ");

			int from = Integer.parseInt(edge[0]);

			int to = Integer.parseInt(edge[1]);

			int cost = Integer.parseInt(edge[2]);

			graph.add(new edge(from, to, cost));

		}

		System.out.println(kurapika(V));

	}

	static int kurapika(int v) {

		unionFindtree union_tree = new unionFindtree(v);
		Queue<edge> all_edge = new PriorityQueue<>(graph);
		total = 0;

		while (!(all_edge.isEmpty())) {
			edge e = all_edge.poll();
			if (!(union_tree.same(e.from, e.to))) {
				total += e.cost;
				union_tree.united(e.from, e.to);
			}

		}
		return total;

	}

	static class edge implements Comparable<edge> {
		int from;
		int to;
		int cost;

		edge(int a, int b, int c) {
			this.from = a;
			this.to = b;
			this.cost = c;

		}

		@Override
		public int compareTo(edge o) {
			// TODO ?????????????????????????????????????????????
			return this.cost - o.cost;
		}
	}

	static class unionFindtree {
		int[] parent;
		int[] rank;

		public unionFindtree(int n) {
			parent = new int[n];
			rank = new int[n];

			inite(n);
		}

		void inite(int n) {
			for (int i = 0; i < n; i++) {
				parent[i] = i;
				rank[i] = 0;
			}
		}

		int find(int x) {
			if (!(parent[x] == x)) {
				parent[x] = find(parent[x]);
			}
			return parent[x];
		}

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

		void united(int x, int y) {
			int xRoot = parent[x];
			int yRoot = parent[y];

			if (rank[xRoot] > rank[yRoot]) {
				parent[yRoot] = xRoot;
			} else if (rank[xRoot] < rank[yRoot]) {
				parent[xRoot] = yRoot;
			} else if (xRoot != yRoot) {
				parent[yRoot] = xRoot;
				rank[xRoot]++;

			}
		}
	}

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll ans[100];
int main(){
    ll K;
    cin >> K;

    int N = 50;
    cout << N << endl;

    ll y = K/N;
    for(int i = 0; i < N; i++){
        ans[i] = y+N-1;
    }

    ll z = K%N;
    for(int k = 0; k < z; k++){
        for(int i = 0; i < N; i++){
            if(k == i) ans[i] += N;
            else ans[i] -= 1;
        }
    }

    REP(i,N){
        printf("%lld ", ans[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
s = input()
s01 = s[:2]
s02 = s[2:]
if 1 <= int(s02) <= 12:
    if 1 <= int(s01) <= 12:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if 1 <= int(s01) <= 12:
        print("MMYY")
    else:
        print("NA")

Measured memory_bytes: 2940
import itertools
a,b,c = map(int,input().split())

ans = [a,b,c]
sum_1 = 0
sum_2 = 0
for i in range(3):
    if i == ans.index(max(ans)):
        sum_1 += ans[i]
    else:
        sum_2 += ans[i]

if sum_1 == sum_2:
    print('Yes')
else:
    print('No')

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

int N;
int A[100000];

void fail(){
    cout << -1 << endl;
    exit(0);
}

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

    set<int> pool;
    for(int i=1; i<N; i++) pool.insert(i);
    vector<int> ans = {0};

    auto insert_greedy = [&]{
        auto it = pool.begin();
        int ng = A[ans.back()];
        if(*it == ng) it++;
        ans.push_back(*it);
        pool.erase(it);
    };

    for(int i=1; i<N-1; i++) insert_greedy();
    int B = *pool.begin();
    while(ans.size() && A[ans.back()] == B){
        pool.insert(ans.back());
        ans.pop_back();
    }
    vector<int> Ans = {N};

    if(pool.size() == 2){
        if(N == 2) fail();
        pool.insert(ans.back());
        ans.pop_back();
        vector<int> P;
        for(int a : pool) P.push_back(a);
        sort(P.begin(), P.end());
        do{
            for(int a : P) ans.push_back(a);
            bool ok = true;
            for(int i=0; i<N-1; i++) if(A[ans[i]] == ans[i+1]) ok = false;
            if(ok) Ans = min(ans, Ans);
            for(int i=0; i<3; i++) ans.pop_back();
        }while(next_permutation(P.begin(), P.end()));
    }else{
        ans.push_back(B);
        pool.erase(B);
        while(pool.size()) insert_greedy();
        Ans = ans;
    }

    for(int i=0; i<N; i++) cout << Ans[i]+1 << " \n"[i==N-1];
    return 0;
}


Measured memory_bytes: 6400
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    char c;
    cin >> c;
    char o;
    switch(c) {
        case 'A':
            o = 'T';
            break;
        case 'T':
            o = 'A';
            break;
        case 'C':
            o = 'G';
            break;
        case 'G':
            o = 'C';
            break;
        default:
            break;
    }
    cout << o << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
 
int main(){
  int n;
  cin>>n;
  long long d=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    d+=a[i];
  }
  long long ans=600000000000;
  long long h=0;
  for(int i=0;i<n;i++){
    h+=a[i];
    long long hh=d-h;
    ans=min(ans,abs(h-hh));
  }
  cout<<ans<<endl;
}
    

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int x, y;
    std::cin >> x >> y;
    int a[] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
    cout << (a[x] == a[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
/**
*
* Author: MARC
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=222;
int vertex;
vector<int>v;
ll dis [N][N];
vector < pair < int , int > > adj[N];

void dij ( int s )
{
    priority_queue < ii , vector <ii> , greater <ii> > pq ;
    pq.push({0 , s});

    while(pq.size()){

        int v = pq.top().S ;
        pq.pop();

        for( auto x : adj[v] ){
            if ( dis[vertex][v] + x.S < dis[vertex][x.F] ){
                dis[vertex][x.F]  = dis[vertex][v] + x.S ;
                pq.push({dis[vertex][x.F] ,x.F});
            }
        }
    }
}


int main()
{
    for(int i=0 ; i<N ; i++)
        for(int j=0 ; j<N ; j++)
            dis[i][j]=inf;

    int n,m,r; scanf("%d%d%d",&n,&m,&r);
    for(int i=0 ; i<r ; i++){
        int x; scanf("%d",&x);
        v.push_back(x);
    }

    for(int i=0 ; i<m ; i++){
        int u,v,c; scanf("%d%d%d",&u,&v,&c);
        adj[u].push_back({v,c}) ;
        adj[v].push_back({u,c}) ;
    }

    for(int u=1 ; u<=n ; u++){
        vertex=u;
        dis[u][u] = 0 ;
        dij(u);
    }

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

    int ans=inf;

    do{
        int res=0;
        for(int i=0 ; i<v.size()-1 ; i++) res+=dis[v[i]][v[i+1]];
        ans=min(ans,res);
    }while(next_permutation(v.begin(),v.end()));

    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 1152
x, y, z, kk = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

p = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i + 1) * (j + 1) * (k + 1) <= kk:
                p.append(a[i] + b[j] + c[k])
            else:
                break
p.sort(reverse=True)
for i in range(kk):
    print(p[i])

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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

typedef pair<int,int> pii;

const int MOD=1e9+7;

int n,a[10001],la[1000001],d[1000001];
vector<int> prime;

void init()
{
    for (int i=2;i*i<=1000000;++i)
    {
        if (!la[i])
        {
            la[i]=i;
            prime.push_back(i);
            for (int j=i*i;j<=1000000;j+=i)
                if (!la[j]) la[j]=i;
        }
    }
    for (int i=2;i<=1000000;++i)
        if (!la[i])
        {
            la[i]=i;
            prime.push_back(i);
        }
}

vector<pii> cp(int x)
{
    map<int,int> mp;
    vector<pii> v;
    while (la[x])
    {
        mp[la[x]]++;
        x/=la[x];
    }
    mp[x]++;
    for (auto i:mp)
        v.push_back(i);
    sort(v.begin(),v.end());
    return v;
}

vector<pii> gcd(vector<pii> v)
{
    vector<pii> c;
    for (auto i:v)
        c.push_back({i.first,min(d[i.first],i.second)});
    return c;
}

void plux(vector<pii> v,int k)
{
    for (auto i:v)
        d[i.first]+=k*i.second;
}

void nhap()
{
    init();
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
    }
}

void process()
{
    for (int i=1;i<=n;++i)
    {
        vector<pii> v=gcd(cp(a[i]));
        plux(cp(a[i]),1);
        plux(v,-1);
    }
    long long kq=0;
    for (int i=1;i<=n;++i)
    {
        plux(cp(a[i]),-1);
        long long t=1;
        for (auto j:prime)
        {
            int x=d[j];
            while (x)
            {
                t=(t*j)%MOD;
                x--;
            }
        }
        kq=(kq+t)%MOD;
        plux(cp(a[i]),1);
    }
    cout<<kq;
}

int main()
{
    nhap();
    process();
    return 0;
}


Measured memory_bytes: 8184
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = bf.readLine()) != null) {
			System.out.println(line.replaceAll("peach", "~-~").replaceAll("apple", "_-_").replaceAll("~-~", "apple").replaceAll("_-_", "peach"));
		}
	}
}

Measured memory_bytes: 9036
#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>;

ll modpow(ll a, ll b, ll mod = 1000000007) {
   ll res = 1;
   for (a %= mod; b; a = a * a % mod, b >>= 1)
     if (b & 1) res = res * a % mod;
   return res;
 }


int main(void)
{
    int64_t n,ans,a1,a2;

    cin >> n;

    a1 = modpow(10,n,1000000007) - modpow(9,n,1000000007);

    if(a1 < 0)a1+=1000000007;

    a1 *= 2;

    a1 %= 1000000007;

    a2 = modpow(10,n,1000000007) - modpow(8,n,1000000007);

    if(a2 < 0)a2+=1000000007;

    ans = a1-a2;

    if(ans < 0)ans+=1000000007;


    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  int N;
  cin >> N;
  if(N>63){
    cout << "64" << endl;
  }else if(N>31){
    cout << "32" << endl;
  }else if(N>15){
    cout << "16" << endl;
  }else if(N>7){
    cout << "8" << endl;
  }else if(N>3){
    cout << "4" << endl;
  }else if(N>1){
    cout << "2" << endl;
  }else{
    cout << "1" << endl;
  }
}

Measured memory_bytes: 256