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

#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())

long long gcd(long long a, long long b)
{
	while(b != 0){
    	a %= b;
    	swap(a,b);
	}
	return a;
}

int main() {
    long long a, b;
    cin >> a >> b;
	long long ans = 1;
	long long c = gcd(a, b);
/*
    for (int i = 1; i <= gcd(a, b); ++i) {
        if ( a%i == 0 && b%i == 0 ) {
			if ( IsPrime(i)) {
	            ans++;
	        }
        }
    }
*/
	for (long long i = 2; i*i <= c; ++i) {
		if ( c%i == 0 ) {
			ans++;
			while ( c%i == 0 ) {
				c /= i;
			}
		}
	}

	if ( c != 1 ) {
		ans++;
	}
    cout << ans << endl;
    return 0;
}


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

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

    // 特定の1要素からi個以上選ばれる確率
    vector<double> prob(m+1, 0);
    prob[0] = 1;
    for(int i=0; i<m; i++){
        vector<double> nprob(m+1, 0);
        for(int j=0; j<=m; j++) {
            nprob[j] += prob[j] *2.0/3.0;
            if(j < m) nprob[j+1] += prob[j] *1.0/3.0;
        }
        swap(prob, nprob);
    }
    for(int i=m; i>0; i--){
        prob[i-1] += prob[i];
    }

    vector<vector<int>> a(3, vector<int>(n));
    for(int i=0; i<n; i++){
        cin >> a[0][i] >> a[1][i] >> a[2][i];
    }

    // dp[i][j][k] = (iに関して、j回アピールしたときにk位になる確率(k=0,1,2,3))
    vector<vector<vector<double>>> dp(3);
    for(int d=0; d<3; d++){
        dp[d] = vector<vector<double>>(m+1, {1, 0, 0, 1});
        for(int i=1; i<n; i++){
            vector<vector<double>> ndp(m+1, {0, 0, 0, 0});
            for(int j=0; j<=m; j++){
                int point = j*a[d][0];
                int numtolose = (point +a[d][i] -1) /a[d][i];
                // ポイントを抜かれる確率
                double p = (numtolose > m)? 0.0: prob[numtolose];
                ndp[j][0] += dp[d][j][0]*(1-p);
                ndp[j][1] += dp[d][j][1]*(1-p) +dp[d][j][0]*p;
                ndp[j][2] += dp[d][j][2]*(1-p) +dp[d][j][1]*p;
                ndp[j][3] += dp[d][j][3]*p;
            }
            swap(dp[d], ndp);
        }
    }

    vector<vector<int>> gain{{5,5,5,-1}, {3,3,3,-1}, {2,2,2,-1}};
    double ans = -1e9;
    for(int i=0; i<=m; i++){
        for(int j=0; i+j<=m; j++){
            int k = m-i-j;
            vector<int> appeal{i, j, k};
            double exp = 0;
            for(int d=0; d<3; d++){
                for(int t=0; t<4; t++){
                    exp += dp[d][appeal[d]][t] *gain[d][t];
                }
            }
            ans = max(ans, exp);
        }
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int i = 0; i < 15; i++) {
            if (N % 4 == 0) {
                System.out.println("Yes");
                break;
            }
            N -= 7;
            if (N < 0) {
                System.out.println("No");
                break;
            }
        }
    }
}

Measured memory_bytes: 24788
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int ans=n, cnt, t;

    for(int i=0; i<=n; i++) {
        cnt=0;
        
        t=i;
        while(t>0) {
            cnt+=t%6;
            t/=6;
        }
        t=n-i;
        while(t>0) {
            cnt+=t%9;
            t/=9;
        }
        if(ans>cnt) ans = cnt;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
 
typedef pair<int, int> P;

int n, sum;
vector<P> G[20];
bool used[20];
 
int dfs(int p){
  int res = 0;
  used[p] = true;
  for(int i=0;i<G[p].size();i++){
    if(used[G[p][i].first])continue;
    int tmp = dfs(G[p][i].first);
    if(G[G[p][i].first].size() > 1){
      tmp += G[p][i].second;
      sum += G[p][i].second;
    }
    res = max(res, tmp);
  }
  return res;
}
 
main(){
  while(cin>> n && n){
    for(int i=0;i<n;i++) G[i].clear();
    fill(used, used+n, false);
    for(int i=0;i<n-1;i++){
      int a, b, c;
      cin >> a >> b >> c;
      G[a-1].push_back(P(b-1, c));
      G[b-1].push_back(P(a-1, c));
    }
    sum = 0;
    int res = dfs(0);
    cout << 2 * sum - res << endl;
  }
}

Measured memory_bytes: 1192
from itertools import product

def solve(l, r, offset=1):
    size = r-l
    if size==2:
        Ans[l][l+1] = offset
    elif size==3:
        Ans[l][l+1] = offset
        Ans[l][l+2] = offset
        Ans[l+1][l+2] = offset+1
    else:
        c = (l+r)//2
        solve(l, c, offset+1)
        solve(c, r, offset+1)
        for a, b in product(range(l, c), range(c, r)):
            Ans[a][b] = offset

N = int(input())
Ans = [[0]*N for _ in range(N)]
solve(0, N)
for i, a in enumerate(Ans, 1):
    print(" ".join(map(str, a[i:])))


Measured memory_bytes: 5364
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+15
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    ll used[100001]={};
    
    
    int x[100000],y[100000];
    for(int i=0; i<N-1; i++){
        cin >> x[i] >> y[i];
    }

    vector<int> connection[100001];
    for(int i=0; i<N-1; i++){
        connection[x[i]].push_back(y[i]);
        connection[y[i]].push_back(x[i]);
    }
    

    
    queue<int> que;
    que.push(1);
    used[1]=1;
    
    ll states[100001][2]={};
    for(int i=1; i<=N; i++){
        states[i][0]=1;
        states[i][1]=1;
    }
    
    
    int parent[100001]={};
    int num_son[100001]={};

    queue<int> leaf;
    while(!que.empty()){
        int temp = que.front();

        int flag=0;
        for(int i=0; i<connection[temp].size(); i++){
            int next = connection[temp][i];
            
            if(used[next]==0){
                que.push(next);
                used[next]=1;
                parent[next]=temp;
                num_son[temp]++;
                flag=1;
            }

        }
        
        if(flag==0){
            leaf.push(temp);
        }
        que.pop();
    }

    
    while(!leaf.empty()){
        int temp=leaf.front();
        int p = parent[temp];
        
        states[p][0]*=states[temp][1];
        states[p][1]*=states[temp][0]+states[temp][1];
        
        states[p][0]%=MOD;
        states[p][1]%=MOD;
        
        num_son[p]--;
        
        if(num_son[p]==0){
            leaf.push(p);
        }
        
        leaf.pop();
    }
    
    cout<<(states[1][0]+states[1][1])%MOD<<endl;
    return 0;
}


Measured memory_bytes: 10624
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int main(){

	int n,table[200];
	int* dp = new int[1000000];
	int* odd_dp = new int[1000000];

	for(int i=0; i < 200; i++)table[i] = i*(i+1)*(i+2)/6;

	for(int i=0; i < 1000000; i++){
		odd_dp[i] = 20000000;
		dp[i] = 20000000;
	}

	dp[0] = 0;
	dp[1] = 1;

	for(int i = 2; i < 1000000; i++){
		for(int k = 1; k < 200; k++){
			if(table[k] <= i){
				dp[i] = (dp[i] <= dp[i-table[k]]+1)?dp[i]:dp[i-table[k]]+1;
			}else{
				break;
			}
		}
	}

	odd_dp[0] = 0;
	odd_dp[1] = 1;

	for(int i = 2; i < 1000000; i++){
		for(int k = 1; k < 200; k++){
			if(table[k] <= i && table[k]%2 == 1){
				odd_dp[i] = (odd_dp[i] <= odd_dp[i-table[k]]+1)?odd_dp[i]:odd_dp[i-table[k]]+1;
			}else if(table[k] > i)break;
		}
	}

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		printf("%d %d\n",dp[n],odd_dp[n]);
	}

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    long a, b, c, x;

	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;

	long ans = 0;

	long i, j, k;

	repin(i, c) {
		if (i * 50 == x) ans++;
		if (x < i * 50) break;

		repin(j, b) {
			if (j != 0 && i * 50 + j * 100 == x) ans++;
			if (x < i * 50 + j * 100) break;

			repin(k, a) {
				if (k != 0 && i * 50 + j * 100 + k * 500 == x) ans++;
				if (x < i * 50 + j * 100 + k * 500) break;
			}
		}
	}

	Out(ans);
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C092
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] a0 = Console.ReadLine().Split(' ');

            List<int> a = a0.Select(x => int.Parse(x)).ToList();
            a.Insert(0, 0);
            a.Add(0);

            int sum = 0;
            for(int i = 0; i < a.Count - 1; i++)
            {
                int d = Math.Abs(a[i + 1] - a[i]);
                sum += d;
            }

            for (int i = 0; i < a.Count - 2; i++)
            {
                int save = Math.Abs(a[i] - a[i + 1]) + Math.Abs(a[i + 1] - a[i + 2]);
                save -= Math.Abs(a[i] - a[i + 2]);
                int aft = sum - save;
                Console.WriteLine(aft);
            }
        }
    }
}


Measured memory_bytes: 27356
#include <iostream>
using namespace std;
int main () {
  int d, n;
  cin>>d>>n;
  int d2=d;
  int i=1;
  while(d--)i*=100;
  if(d2==0){
    if(n==100)cout<<101<<endl;
    else cout<<n*i<<endl;
  }else if(d2==1){
    if(n==100)cout<<10100<<endl;
    else cout<<n*i<<endl;
  }else if(d2==2){//10000 00
    if(n==100)cout<<1010000<<endl;
    else cout<<n*i<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int mod=1e9+7,N=3005;
const ll inv2=(mod+1)/2;
int f[N][N],g[N],h[N],a[N],n,Q,x,y,pw=1,ans;

void add(int &x,int y){
	x=(x+y>=mod?x+y-mod:x+y);
}

int main(){
	read(n),read(Q);
	rep(i,1,n)read(a[i]);
	rep(i,1,n)rep(j,1,n)
		f[i][j]=(a[i]>a[j]);
	rep(k,1,Q){
		read(x),read(y),pw=pw*2%mod;
		rep(i,1,n)if(i!=x&&i!=y){
			g[i]=inv2*(f[x][i]+f[y][i])%mod;
			h[i]=inv2*(f[i][x]+f[i][y])%mod;
		}
		rep(i,1,n)if(i!=x&&i!=y){
			f[x][i]=f[y][i]=g[i];
			f[i][x]=f[i][y]=h[i];
		}
		f[x][y]=f[y][x]=inv2*(f[x][y]+f[y][x])%mod;
	}
	rep(i,1,n)rep(j,i+1,n)
		add(ans,f[i][j]);
	ans=(ll)ans*pw%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

ll N;
int main(){
    cin>>N;
    vector<ll> A(N);
    ll ans=0;
    cin>>A[0];
    ll max=A[0];
    for(int i=1;i<N;++i){
        cin>>A[i];
        if(max<A[i]){
            max=A[i];
        }
        else{
            ans+=max-A[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4840
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    print(N%2==0?N:N*2);
    return 0;
}

Measured memory_bytes: 256
#define REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <bits/stdc++.h>

using namespace std;
const int maxn = 100010;

int n, k, cnt[maxn], Max;

int main() {
#ifdef CraZYali
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif
	cin >> n;
	REP(i, 1, n) {
		scanf("%d", &k);
		k++;
		cnt[k]++;
		cnt[k+1]++;
		cnt[k-1]++;
	}
	REP(i, 1, 100000) Max = max(Max, cnt[i]);
	cout << Max;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

int main() {
  ll N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vi a(N), b(N), c(N);
  for (ll i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  unordered_map<ll, ll> m1, m2;
  m1[0] = 0;
  m2[0] = 0;
  for (ll i = 0; i < N / 2; i++) {
    vpii v;
    for (auto p: m1) {
      v.push_back(p);
    }
    for (auto p: v) {
      ll j = (p.first / 10000 + a[i]) * 10000 + p.first % 10000 + b[i];
      ll k = p.second + c[i];
      if (m1.find(j) == m1.end()) {
        m1[j] = k;
      } else {
        m1[j] = min(m1[j], k);
      }
    }
  }
  for (ll i = N / 2; i < N; i++) {
    vpii v;
    for (auto p: m2) {
      v.push_back(p);
    }
    for (auto p: v) {
      ll j = (p.first / 10000 + a[i]) * 10000 + p.first % 10000 + b[i];
      ll k = p.second + c[i];
      if (m2.find(j) == m2.end()) {
        m2[j] = k;
      } else {
        m2[j] = min(m2[j], k);
      }
    }
  }

  ll ans = (1ll << 32);
  for (ll i = 1; i <= 400; i++) {
    ll t = (Ma * 10000 + Mb) * i;
    for (auto p: m1) {
      if (m2.find(t - p.first) != m2.end()) {
        ans = min(ans, m2[t - p.first] + p.second);
      }
    }
  }

  if (ans == (1ll << 32)) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
ll n;
int main()
{
    //IOS
    while(cin>>n)
    {
        ll maxx=0,sum=0;
        rep(i,n)
        {
            ll tmp;
            cin>>tmp;
            sum+=tmp;
            maxx=max(tmp,maxx);
        }
        cout<<sum-maxx/2<<"\n";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<functional>
#include<set>
using namespace std;
int main(){
  //ツ素ツ青板青カツ青ャ
  const int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<NUM;i++)
    prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

  while(true){
    int n,x;
    cin>>n>>x;
    if(!n&&!x)break;
    int menu[n];
    for(int i=0;i<n;i++){
      cin>>menu[i];
    }
    int p = -1;
    bool money[x+1];
    money[0] = true;
    for(int i=1;i<x+1;i++){
      money[i] = false;
      for(int j=0;j<n;j++){
	if(i>=menu[j]&&money[i-menu[j]]){
	  money[i] = true;
	  break;
	}
      }
      if(money[i]&&prime[i])p=i;
    }
    if(p==-1)cout<<"NA"<<endl;
    else cout<<p<<endl;
  }
  return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	string s;
	cin >> s;

	ll N = s.size();

	ll ans = INF;

	rep(i, N) {
		vector<ll> a;

		rep(j, N) {
			if (s[j] == s[i]) { a.push_back(j); }
		}

		ll dis = max(a[0], N - a[a.size()-1] - 1);
		rep(j, a.size() - 1) {
			dis = max(dis, a[j + 1] - a[j] -1);
		}

		ans = min(ans, dis);
	}

	cout << ans;

	system("PAUSE");
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(b>a)swap(a,b);
	if(c>a)swap(a,c);
	for(int i=1;i<=d;i++)a=a*2;
	cout<<a+b+c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
  int a,b;
  cin>>a>>b;
  if(5<a&&a<13) cout<<b/2<<endl;
  else if(a<=5) cout<<0<<endl;
  else cout<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;


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


int main(){
  int n;
  string s;
  cin >> n >> s;

  int mi;
  int l = 0;
  int r = 0;
  for(int i = 1; i < n; ++i){
    if(s[i] == 'E') r += 1;
  }
  mi = r;


  for(int i = 1; i < n; ++i){
    if(s[i - 1] == 'W') l++;
    if(s[i] == 'E') r--;
    mi = min(mi, l+r);
  }

  cout << mi << endl;
}


Measured memory_bytes: 900
def input_score(N):
    score = []  # 的の配点をいれる配列、投げないときの点も入れておく
    score.append(0)
    for i in range(N):
        score.append(int(input()))
    return score


def cal_four_sum_score(two_score, M):
    left = 0
    right = len(two_score) - 1
    max_score = 0
    while left != right:
        now_score = two_score[left] + two_score[right]
        if now_score < M:
            # scoreの和がMより小さい時、解の候補である
            max_score = max(max_score, now_score)
            left += 1
        elif now_score > M:
            # scoreの和がMより大きい時、解の候補ではない
            right -= 1
        else:
            # scoreの和がちょうどMになるとき、解である
            max_score = M
            break

    return max_score


def cal_two_sum_score(score):
    two_score = []  # 二回投げた時に取りうる範囲を入れる配列
    contain_sum = {}  # 二回投げたときにその値はすでに存在するか判断する配列
    for i in range(len(score)):
        for j in range(len(score)):
            now_score = score[i] + score[j]
            if not contain_sum.get(now_score):
                contain_sum[now_score] = True
                two_score.append(now_score)

    two_score.sort()  # 尺取り法を用いるためsortしておく
    return two_score


def main():
    while True:
        N, M = map(int, input().split())
        if N == 0 and M == 0:
            break
        score = input_score(N)  # 的の配点の入力
        two_score = cal_two_sum_score(score)  # 二回投げた時に取りうる点の範囲を計算
        max_score = cal_four_sum_score(two_score, M)  # 四回投げたときに取りうる点の範囲を計算
        print(max_score)


if __name__ == "__main__":
    main()



Measured memory_bytes: 83776
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n: usize = lines.next().unwrap().unwrap().parse().unwrap();
    let p: Vec<usize> = lines
        .next()
        .unwrap()
        .unwrap()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();

    let mut min = p[0];
    let mut ans = 1;
    for i in 1..n {
        if p[i] <= min {
            min = p[i];
            ans += 1;
        }
    }

    println!("{}", ans);
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    ll X;
    cin >> X;

    ll a = 100;
    int ans = 0;
    while (a < X) {
        a += a * 0.01;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    char a[51][51], b[51][51];
    for(int i = 0; i < n; i++)scanf("%s", a[i]);
    for(int i = 0; i < m; i++)scanf("%s", b[i]);
    int i, j, ii, jj;
    for(i = 0; i < n; i++)
    {
        for(j = 0; j < n; j++)
        {
            if(a[i][j] == b[0][0] && n-i >= m && n-j >= m)
            {
                for(ii = 0; ii < m; ii++)
                {
                    for(jj = 0; jj < m; jj++)
                    {
                        if(a[i+ii][j+jj] != b[ii][jj])break;
                    }
                    if(jj != m)break;
                }
                if(ii == m)
                {
                    printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
    return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int N;
  while(cin >> N){
    puts_all((N+1) / 2);
  }


  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def main(args:Array[String]) {
    val inputs = StdIn.readLine().split(" ")
    val a = inputs(0).toInt
    val b = inputs(1).toInt
    val result = if (a > b) "a > b" else if (a < b) "a < b" else "a == b"
    println(result)
  }
}

Measured memory_bytes: 43704
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
char s[N][N];
bool full[N];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++ i) {
		scanf("%s", s[i] + 1);
	}
	int sum = 0, tot = 0;
	for (int j = 1; j <= n; ++ j) {
		full[j] = 1;
		for (int i = 1; i <= n; ++ i) {
			if (s[i][j] != '#') full[j] = 0;
			if (s[i][j] == '#') {
				tot ++;
			}
		}
		if (full[j]) sum ++;
	}
	if (tot == 0) return 0 * puts("-1");
	if (sum == n) return 0 * puts("0");
	int ans = -1;
	for (int i = 1; i <= n; ++ i) {
		bool flag = 1;
		for (int k = 1; k <= n; ++ k) if (s[i][k] != '#') flag = 0;
		if (flag) {
			int tmp = 0;
			for (int k = 1; k <= n; ++ k) {
				tmp += 1 - full[k];
			}
			if (ans == -1 || tmp < ans) ans = tmp;
		}
		for (int j = 1; j <= n; ++ j) {
			int tmp = 0;
			if (s[j][i] == '.') {
				tmp = 1;
			}
			bool flag = 1;
			for (int k = 1; k <= n; ++ k) if (s[j][k] != '#') flag = 0;
			for (int k = 1; k <= n; ++ k) if (s[i][k] == '.') tmp += 2 - flag; else tmp += 1 - full[k];
			if (ans == -1 || tmp < ans) ans = tmp;
		}
	}
	printf("%d\n", ans);
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[20], c[20], dp[20][2000];
signed main(){
	int n, G;
	scanf("%lld%lld", &n, &G);
	rep(i,n)scanf("%lld%lld", &a[i], &c[i]);
	rep(i,a[0]+1){
		int score = i*100;
		if(i == a[0])score += c[0];
		dp[0][i] = score;
	}
	//rep(i,a[0]+1)printf("%lld ", dp[0][i]);
	repi(i,1,n)rep(j,1002)rep(k,a[i]+1){
		int score = k*(i+1)*100;
		if(k == a[i])score += c[i];
		dp[i][j] = max(dp[i][j], dp[i-1][j]);
		if(j-k >= 0)dp[i][j] = max(dp[i][j], dp[i-1][j-k]+score);
	}
	
	int ans = 0;
	rep(i,1002){
		if(dp[n-1][i] >= G){ans = i;break;}
	}
	printf("%lld\n", ans);
	return 0;
}







Measured memory_bytes: 384
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079
// Title : Area of Polygon
/*

?????????????????¨???????§£????????¨??????????????£????????????????????????
????????????????????\??????????´???°??¨??????????????±??????1????????????p[0]?????????????????????????????£?????????2??????????????????????????????????§???¢????¬????????????¢???????????????????±?????????????????????????????????????????????????????????¶???????????¨??£????????????????????????????????????
*/
#include <iostream>

#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;
int main() {
	typedef complex<double> xy;
	xy p[20];
	int n = 0;
	double x, y, s;
	while ( ~scanf( "%lf, %lf", &x, &y ) ) {

		p[n++] = xy( x, y );
	}

	for ( int i = 1; i < n - 1; i++ ) {
		s += ( conj( p[i] - p[0] ) * ( p[i + 1] - p[0] ) ).imag() / 2;
	}

	printf( "%.6f\n", abs(s) );
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int begin, end;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'A') {
      begin = i;
      break;
    }
  }
  for (int i = s.size()-1; i >= 0; i--) {
    if (s.at(i) == 'Z') {
      end = i;
      break;
    }
  }
  cout << end - begin + 1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,ans=1;
	cin>>a>>b;
	if(b==1)
	{
		cout<<"0";
		return 0;
	}
	for(int i=1;;i++)
	{
		ans=ans-1+a;
		if(ans>=b)
		{
			cout<<i;
			return 0;
				}		
	}
}

Measured memory_bytes: 256
order_list = []
for _ in range(5):
    order_list.append(int(input()))

a = []
b = []
for i in range(5):
    a.append(((order_list[i]-1)//10+1)*10)
    b.append((order_list[i]-1)%10)

if min(b) != 9:
    ans = sum(a) + min(b) -9
else:
    ans = sum(a)
print(ans)

Measured memory_bytes: 3064
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y


N,Q=LI()
TR=[[] for i in range(N+1)]
TR_score = [0] * (N+1)
RES = [-1]*(N+1)

for i in range(N-1):
    i,j=LI()
    TR[i].append(j)
    TR[j].append(i)

for i in range(Q):
    p, x = LI()
    TR_score[p] += x

ST = [(1, TR_score[1])]
while ST:
    i, score = ST.pop()
    RES[i] = score
    for j in TR[i]:
        if RES[j] == -1:
            ST.append((j, score + TR_score[j]))

for value in RES[1:-1]: print(value, end=" ")
print(RES[-1])


Measured memory_bytes: 113280
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

ll power(ll a,ll n)
{
	if(n==0)
	return 1;
	if(n%2==0)
	return power((a*a)%mod,n/2)%mod;
	return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
}

ll fre[N];
int main()
{
ll n;
  
  lscf(n);
  ll a[n];
  ll sum=0;
  rep(i,0,n){
    lscf(a[i]);
    sum+=a[i];
  fre[a[i]]++;}
  tc{
    ll b,c;
    lscf(b);lscf(c);
    sum=sum-(b*fre[b]);
    sum=sum+(c*fre[b]);
     fre[c]+=fre[b];
    fre[b]=0;
   
    lprin(sum);
  }
return 0;
}

Measured memory_bytes: 5316
#include <bits/stdc++.h>
#define nl "\n"
#define ll long long int
#define MOD 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    if(n%k==0)
        cout<<0<<nl;
    else if(n<k)
    {
        ll res1=abs(n-k);
        ll res2=abs(res1-k);
        cout<<min(res1,res2)<<nl;
    }
    else
    {
        ll div=max(n,k);
        ll q=min(n,k);
        ll rem=div%q;
        ll rem1=abs(q-rem);
        cout<<min(rem,rem1)<<nl;

        
    }
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
	let a=read::<String>().as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>()[0];
    let b=read::<String>().as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>()[1];
    let c=read::<String>().as_bytes().iter().map(|c|*c as char).collect::<Vec<char>>()[2];
    let s=vec![a,b,c];
    println!("{}",s.iter().map(|c|*c).collect::<String>())
}

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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;

const string YES = "Yes";

const string NO = "No";

const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll ans = 0;

string no = "-1 -1 -1";

void print(int a, int b, int c) {
    cout << a << ' ' << b << ' ' << c << endl;
}

bool solve(long long N, long long Y) {
    int Y_par_1000 = Y / 1000;
    if (Y > N * 10000) return false;
    if (Y < N * 1000) return false;
    int i1;
    rep(i10, N + 1) rep(i5, N - i10 + 1) {
        i1 = N - i5 - i10;
        if (Y_par_1000 == i10 * 10 + i5 * 5 + i1) {
            print(i10, i5, i1);
            return true;
        }
    }
    return false;
}
signed main() {
    long long N;
    scanf("%lld", &N);
    long long Y;
    scanf("%lld", &Y);

    if (not solve(N, Y)) print(no);

    return 0;
}


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

struct edge{int to; ll cost; };
vector<vector<edge>> E;
vector<ll> dist;

void dfs(int n){
    for(int i=0; i<E[n].size(); i++){
        int to = E[n][i].to;
        ll cost = E[n][i].cost;
        if(dist[to] > dist[n] + cost){
            dist[to] = dist[n] + cost;
            dfs(to);
        }
    }
}

int main(){
    int N;  cin >> N;
    E = vector<vector<edge>>(N, vector<edge>());
    for(int i=0; i<N-1; i++){
        int a, b;  ll c;
        cin >> a >> b >> c;
        a--;  b--;
        edge e;  e.cost = c;
        e.to = b;
        E[a].push_back(e);
        e.to = a;
        E[b].push_back(e);
    }
    int Q, K;  cin >> Q >> K;
    dist = vector<ll>(N, 1e18);
    dist[K-1] = 0;
    dfs(K-1);

    for(int i=0; i<Q; i++){
        int x, y;  cin >> x >> y;
        x--;  y--;
        cout << dist[x] + dist[y] << endl;
    }
}


Measured memory_bytes: 12800
#include <stdio.h>
#include <math.h>
int main(void){
int a,b;
scanf("%d %d",&a,&b);
 if (a >= 13)
 {
   printf("%d",b);
 } else if (a < 13 && a >= 6)
 {
   printf("%d",b/2);
 }else{
 printf ("0");
 }
  return 0;
 }

Measured memory_bytes: 128
def main():    
    from collections import deque
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    e = [[] for i in range(n)]

    for i in range(m):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        e[a].append([b,c])
        e[b].append([a,-c])


    dis = [float("INF")]*n

    def search(x):

        q = deque([])
        dis[x] = 0
        q.append((x,0))
        while q:
            now,cnt = q.popleft()
            for nex,d in e[now]:
                if dis[nex] == float("INF"):
                    dis[nex] = cnt+d
                    q.append((nex,cnt+d))
                else:
                    if dis[nex] != cnt+d:
                        print("No")
                        exit()
            
    for i in range(n):
        if e[i] and dis[i] == float("INF"):
            search(i)
    print("Yes")

if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  rep (i, N)  cin >> v[i];// N個の具材の価値の表
  double ans = 0;// おそらく、小さい順に具材を作っていくのが価値を最大化する方法（証明？）
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end()); //大きい順
  
  rep (i, N-1) {// i=0~N-2 のN-1回
    double value = (v[v.size()-1] + v[v.size()-2])/2;
    v.pop_back();
    v.pop_back();
    v.push_back(value);//使った具材を引いてできた具材を足す
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
  }
  ans = v[0];

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */





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

    ll n; cin >> n;
    vector<ll> a(5);
    ll minv = 1e18;
    rep(i, 5) cin >> a[i], chmin(minv, a[i]);

    if(n%minv == 0){
        cout << n/minv - 1 + 5 << endl;
    }
    else{
        cout << n/minv + 5 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int sum = 0;
        for(int i = 0; i < N; i++){
            sum += sc.nextInt() - 1;
        }
        sc.close();

        System.out.println(sum);
    }
}

Measured memory_bytes: 26092
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n%2==0||n%5==0){
		cout<<-1<<endl;
		return 0;
	}
	long long mod=0,ans=1;
	for(;;){
		
		mod*=10;
		mod%=n;
		mod+=7;
		mod%=n;
		if(mod==0){
			cout<<ans<<endl;
			return 0;
		}
		ans++;
	}
	
}

Measured memory_bytes: 3616
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	int a,b,c;
	int k;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	for(int i=0;i<k;i++){
		if(a>=b&&a>=c){
			a=a*2;
		}
		if(b>=c&&b>=a){
			b=b*2;
		}
		if(c>=b&&c>=a){
			c=c*2;
		}
	}
	printf("%d",a+b+c);
	return 0;
}

Measured memory_bytes: 256
n = gets().chomp!.to_i

ts = [0]
xs = [0]
ys = [0]

n.times { 
	t, x, y = gets().split.map{ |p|
		p.to_i
	}
	ts << t
	xs << x
	ys << y
}

1.upto(n) { |i|

	dist = (xs[i] - xs[i-1]).abs +  (ys[i] - ys[i-1]).abs
	time = ts[i] - ts[i-1]
	if dist > time then
		puts "No"
		exit
	end

	if (time - dist) % 2 == 1 then
		puts "No"
		exit
	end
}

puts "Yes"



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

int main()
{
	LL n, k, s;
	cin >> n >> k >> s;

	for (LL i = 0; i < k; ++i) {
		cout << s << " ";
	}

	LL nd;
	for (LL i = 1; i <= 100; ++i) {
		if (s%i != 0) {
			nd = i;
			break;
		}
	}

	for (LL i = 0; i < n-k; ++i) {
		cout << nd << " ";
	}
	cout << "\n";
}

Measured memory_bytes: 1280
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)*}
    };
}

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)*}
    };
}

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")
    };
}

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut w = v;
    w.sort();
    let mut f = true;
    if w[0] == 0 {
        for i in 1..n {
            f &= w[i] == (i + 1) / 2 * 2;
            if !f {
                break;
            }
        }
    } else {
        for i in 0..n {
            f &= w[i] == (i / 2) * 2 + 1;
            if !f {
                break;
            }
        }
    }
    if f {
        println!("{}", pow_m(2, n / 2, 1000000007));
    } else {
        println!("0");
    }
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}


Measured memory_bytes: 4352