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

int main(){
    int n, k;
    cin >> n >> k;
    
    int ans = 0;
    
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    
    //iを左端、jを右端とする
    //とらないという選択肢もあるので、それをi=-1とj=nで表している
    for (int i = - 1; i < n; i++){
        for (int j = i + 1; j <= n; j++){
            //とる数の総数は右が(n-j)、左が(i+1)個でそれがk以下のとき可能
            if (n - j + i + 1 <= k){
                //tmpはこのときの最大値
                int tmp = 0;
                //このvectorにはとった値を保存しておく
                vector<int> tmp_v;
                
                if (i >= 0){
                    for (int k = 0; k <= i; k++){
                        tmp_v.push_back(v[k]);
                        tmp += v[k];
                    }
                }
                
                if (j < n){
                    for (int k = j; k < n; k++){
                        tmp_v.push_back(v[k]);
                        tmp += v[k];
                    }
                }
                
                sort(tmp_v.begin(), tmp_v.end());
                
                //とったもののうち、負のものを小さい方から戻せるだけ戻す
                if (tmp_v.size() > 0){
                    int num = min((int)tmp_v.size(), k - (int)tmp_v.size());
                    for (int s = 0; s < num; s++){
                        if (tmp_v[s] < 0) tmp -= tmp_v[s];
                    }
                }
                ans = max(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}








Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        while (true){
            int n=scan.nextInt();
            if (n==0){
                break;
            }
            List<Integer> list=new ArrayList<>();
            int min=1000000;
            for(int i=0;i<n;i++){
                int input=scan.nextInt();
                for(int j=0;j<list.size();j++){
                    int temp=list.get(j)-input;
                    if(temp<0){
                        temp=temp*-1;
                    }
                    if(min>temp){
                        min=temp;
                    }
                }
                list.add(input);
            }
            System.out.println(min);
        }
    }
}


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

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

	int k;
	cin >> k;
	int sum = 0;
	for(int i = 1;i <= k;i++){
		for(int j = 1;j <= k;j++){
			for(int q = 1;q <= k;q++){
				sum += __gcd(i,__gcd(j,q));
			}
		}
	}
	cout << sum;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	long long int r, d, m;
	cin >> r >> d >> m;
	for (int i = 0; i < 10; i++) {
		cout << r*m - d << endl;
		m = r*m - d;
	}

	return 0;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int,int>;
const int INF = 1e18;
const int MOD = 1e9+7;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

signed main(){
    string s;
    cin >> s;
    int p = 0;
    
    for(auto c : s) if(c == 'p') p++;

    cout << s.size()/2 - p << endl;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] A = new long[N];
		Arrays.setAll(A, i -> sc.nextLong());
		long x = 0, ans = 0;
		for(int i = 39; i >= 0; i--) {
			int c = 0;
			for(long l : A)
				c += (1 & (l >> i));
			if(c <= N/2)
				if((x| 1l << i) <= K)
					x = x| 1l << i;
		}
		for(long l : A)
			ans += x^l;
		System.out.println(ans);

	}

}

Measured memory_bytes: 61364
H, W = gets.split.map(&:to_i)
N = gets.to_i
a = gets.split.map(&:to_i)

colors = [].tap do |y|
  a.each.with_index(1) { |num, color| num.times { y << color } }
end

grid = []
H.times do |i|
  grid << []
  W.times do |j|
    if i.even?
      grid[-1].push(colors.shift)
    else
      grid[-1].unshift(colors.shift)
    end
  end
end
grid.each { |row| puts row * " " }


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

int main() {
  int n, W;
  cin >> n >> W;
  vector<int> w(n);
  vector<int> v(n);
  rep(i, n) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(W + 1, 0));

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= W; j++) {
      if (w[i - 1] > j) {
        dp[i][j] = dp[i - 1][j];
      } else {
        dp[i][j] = max(dp[i-1][j], dp[i -1][j - w[i -1]] + v[i -1]);
      }
    }
  }
  cout << dp[n][W] << endl;

  return 0;
}

Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int a,b;
  cin>>a>>b;

  if(a>8||b>8){
    cout<<":("<<endl;
  }else{
    cout<<"Yay!"<<endl;
  }
}


Measured memory_bytes: 256
import java.math.*;
import java.io.*;
import java.util.*;

public class Main{
	
	public static void main(String []args)
	{
		Scanner cin=new Scanner(System.in);
		int n = cin.nextInt();
		while(n--!=0){
			BigInteger b=cin.nextBigInteger(),a=cin.nextBigInteger();
			if(a.add(b).toString().length()>80){
				System.out.println("overflow");
			}else System.out.println(a.add(b).toString());
			
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <array>
#include <vector>
using namespace std;

struct Dice
{
    array<int, 6> roll;
    Dice(){}
    Dice (const Dice& x) : roll(x.roll){}
    
    void toNorth()
    {
        array<int, 6> t = roll;
        roll[4] = t[0];
        roll[0] = t[1];
        roll[5] = t[4];
        roll[1] = t[5];
    }

    void toCW()
    {
        array<int, 6> t = roll;
        roll[3] = t[1];
        roll[1] = t[2];
        roll[4] = t[3];
        roll[2] = t[4];
    }

    int isSame(Dice &d2)
    {
        for (int i=0; i<4; i++) {
            for (int j=0; j<4; j++){
                for (int k=0; k<4; k++){
                    if (roll[0] == d2.roll[0] &&
                        roll[1] == d2.roll[1] &&
                        roll[2] == d2.roll[2] &&
                        roll[3] == d2.roll[3] &&
                        roll[4] == d2.roll[4] &&
                        roll[5] == d2.roll[5]){
                            return true;
                        }
                    toCW();
                }
                toNorth();
            }
            toCW();
        }
        return false;
    }
};

int main()
{
    int count;
    vector<Dice> dices;
    cin >> count;

    for (int i=0; i<count; i++) {
        Dice d;
        for (int j=0; j<6; j++) {
            cin >> d.roll[j];
        }
        dices.push_back(d);
    }
    
    bool judge = true;
    for (int i=0; i<count; i++) {
        for (int j=i+1; j<count; j++) {
            if(dices[i].isSame(dices[j])) {
                judge = false;
            }
        }
    }

    cout << (judge ? "Yes" : "No") << endl;
 }



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  in6 n;
  cin >> n;
  in6 ans = 0;
  vi numbera(n);
  vii x(n,vi(20)), y(n,vi(20));
  rep(i,n) {
    cin >> numbera[i];
    rep(j,numbera[i]) {
      cin >> x[i][j] >> y[i][j];
    }
  }
  for(in6 i = 0; i < (1 << n); i++) {
    bool check = 1;
    rep(j,n) {
      if(i & (1 << j)) {
        rep(k,numbera[j]) {
          if(y[j][k] == 0) {
            if(i & (1 << (x[j][k]-1))) check = 0;
          }
          else if(y[j][k] == 1) {
            if(!(i & (1 << (x[j][k]-1)))) check = 0;
          }
        }
      }
    }
    if(check) {
      in6 count = 0;
      rep(j,n) {
        if(i & (1 << j)) count++;
      }
      ans = max(ans,count);
    }
  }
  cout << ans;
  hinata;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<ll,ll> mll;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
// #define mod 998244353
#define mod 1000000007 

#define trace1(x)                       cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                    cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(x, y, z , t)             cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<endl
#define trace5(x, y, z , t , u)         cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<endl
#define trace6(x, y, z , t , u , v)     cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<" | "<<#v<<": "<<v<<endl

#define repa(i,sta,end,inc) for(int i = sta ; i <= end ; i += inc)
#define repb(i,sta,end,inc) for(int i = sta ; i >= end ; i -= inc)

ll power(ll x , ll y , ll z){ll res = 1;x %= z;while(y){if(y&1){res = res * x % z;}x = x*x % z;y /= 2;}return res%z;}
ll gcd(ll a , ll b){return (b == 0 ? a : gcd(b , a % b));}

const int N = 2 * 100000 + 5;
const int inf = (1<<30);

void solve(){
    int n;
    cin >> n;
    int a[n+1] = {0} , x;
    repa(i,1,n-1,1)cin >> x , a[x]++;
    repa(i,1,n,1){
        cout << a[i] << endl;
    }

}


int main(){
    FIO;
    int T = 1;
    // cin >> T;
    repa ( i , 1 , T , 1){
        solve();
    }
    return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define rep0(i, n) for (int i = 1; i <= (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LO

int main(){
    double n;
    double d;
    cin>>n>>d;
    cout<<ceil(n/(d*2+1))<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  string T;
  cin >> T;
  int N = S.size();
  int M = T.size();
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    if (S[i] == 'A'){
      A[i] = 1;
    } else {
      A[i] = 2;
    }
  }
  vector<int> sumA(N + 1, 0);
  for (int i = 0; i < N; i++){
    sumA[i + 1] = sumA[i] + A[i];
  }
  vector<int> B(M);
  for (int i = 0; i < M; i++){
    if (T[i] == 'A'){
      B[i] = 1;
    } else {
      B[i] = 2;
    }
  }
  vector<int> sumB(M + 1, 0);
  for (int i = 0; i < M; i++){
    sumB[i + 1] = sumB[i] + B[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    c--;
    if ((sumA[b] - sumA[a]) % 3 == (sumB[d] - sumB[c]) % 3){
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 5112
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = [list(map(int, input().split())) for _ in range(Q)]

res = sum(A)
A_counter = Counter(A)
for i, j in B:
    # if i not in A_counter:
    #     A_counter[i] = 0
    # if j not in A_counter:
    #     A_counter[j] = 0

    res += (j - i) * A_counter[i]
    print(res)

    A_counter[j] += A_counter[i]
    A_counter[i] = 0


Measured memory_bytes: 40256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

//nCkを求める(n<∞ , k<300000)
const ll M=1000000007;
vector<ll> fac(300001); //n*(n-1)*…(n-k+1)(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//フェルマーの小定理 : X/Y=X*Y^-1 , Y^-1≡Y^(M-2) (mod M 素数)

//O(logn)でx^n(mod M)を求める
ll mpow(ll x,ll n){
  if(n==0) return 1;
  ll res=mpow(x*x%M,n/2);
  if(n&1) res=res*x%M; //nが奇数の場合
  return res;
}

ll comb(int n,int k){ //nCk(mod M)を計算
  if(n==0&&k==0)return 1;
  if(n<k||n<0)return 0;
  ll tmp=ifac[k]%M;
  return tmp*fac[k-1]%M;//n*(n-1)*…*(n-k+1)/k!
}

//O(k)で階乗の計算の準備
void set_comb(ll n){
  fac[0]=n;
  ifac[0]=1;
  for(ll i=0;i<300000;i++){
    if(n-i-1>0)
    fac[i+1]=fac[i]*(n-i-1)%M;//fac[i] : n*(n-1)*…*(n-i)
    ifac[i+1]=ifac[i]*mpow(i+1,M-2)%M; // k!^{M-2} (mod M)
  }
}

int main(){
  ll n,a,b; cin>>n>>a>>b;
  set_comb(n);
  ll ans=mpow(2,n)-1;
  ll d=(comb(n,a)+comb(n,b))%M;
  if(ans-d<0) ans+=M;
  ans=(ans-d)%M;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4992
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	if(n>=2&&m>=2)
	{
		cout<<(n-2)*(m-2);
		return 0;
	}
	if(n==1&&m==1)
	{
		cout<<1;
		return 0;
	}
	else cout<<max(n*m-2,(long long)0);
	return 0;
}

Measured memory_bytes: 256
n,p=map(int,input().split())
x=[0 for i in range(int(p**0.5)+1)]
if n==1:
    print(p)
else:
    for i in range(2,int(p**0.5)+1):
        while(p%i==0):
            p//=i
            x[i]+=1
    j=1
    for i in range(len(x)):
        for k in range(x[i]//n):
            j*=i
    print(j)

Measured memory_bytes: 114032
A,B,C,D = map(int, input())
ans = list(str(A))
for b in [-B,B]:
    for c in [-C,C]:
        for d in [-D,D]:
            if sum([A,b,c,d]) == 7:
                ans += ["+" + str(x) if x>=0 else str(x) for x in [b,c,d]]
                break
        else:
            continue
        break
    else:
        continue
    break
for i in ans:
    print(i, end = "")
print("=7")

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k,n;
  cin >>n>>k;
  int p[n];
  for(int i=0; i<n;i++) cin >> p[i];

  long sum[n-k+1];
  sum[0] = 0;
  for(int i=0; i<k; i++)
    sum[0] += p[i];

  for(int i=1; i<n-k+1; i++) {
    sum[i] = sum[i-1] - p[i-1] + p[i-1+k];
  }
  long maxs = 0;
  for(int i=0; i<n-k+1; i++){
    maxs = max(maxs, sum[i]);
  }

  cout << fixed;
  cout << setprecision(7)  << (maxs + k) / 2. << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main(){
    string s ;
    cin >> s ;
    string s1 =  s ;
    reverse(s1.begin(),s1.end()) ;
    if (s != s1)
    {
        cout << "No" << endl ;
        return 0 ;
    }
    
    string sub1,sub2;
    sub1 = s.substr(0,s.size()/2 ) ;
    sub2 = sub1 ;
    reverse(sub2.begin(),sub2.end()) ;
    if (sub1 != sub2)
    {
        cout << "No" << endl ;
        return 0 ;
    }
    sub1 = s.substr((s.size()+3)/2 -1) ;
    sub2 = sub1 ;
    reverse(sub2.begin(),sub2.end()) ;
    if (sub1 != sub2)
    {
        cout << "No" << endl ;
        return 0 ;
    }
    cout << "Yes" << endl ;

}

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

// a より b の方が小さかったら，a の値を b の値に置き換える (そして true を返す)
// そうでなかったら、何もしない (そして false を返す)
template<class T> inline bool change_min(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

// a より b の方が大きかったら，a の値を b の値に置き換える
// そうでなかったら、何もしない (そして false を返す)
template<class T> inline bool change_max(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

// 無限大の値を設定
const long long INF = 1LL << 60;

// 高さテーブルを用意
long long h[100010];

// DP テーブルを用意
long long dp[100010];

int main(void) {
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    // DP テーブル全体を初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) {
        dp[i] = INF;
    }
    // 初期条件を設定
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        change_min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) {
            change_min(dp[i], dp[i - 2] + abs(h[i] - h[i -2]));
        }
    }
    cout << dp[N - 1] << '\n';
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, rm=numeric_limits<int>::max(), ans=numeric_limits<int>::min(), r;
    cin>>n;
    for(int i=0; i<n; i++) {
        cin>>r;
        ans=max(ans, r-rm);
        rm=min(rm, r);
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 1200
a , b = map(int,input().split())
c = []
bool = False
for i in range(1250):
    if i * 8 //100 ==a and i * 10 // 100 == b:
        bool = True
        c.append(i)
        exit
if bool == True:
    print(min(c))
if bool == False:
    print(-1)        

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n)for(ll i=0;i<n;i++)
#define MP make_pair
#define F first
#define S second
typedef long long ll;
using namespace std;
int main(){
    ll n,k,s,t,a[50];cin>>n>>k>>s>>t;
    REP(i,n)cin>>a[i];
    map<pair<ll,ll>,ll> dp[50];
    REP(i,n){
        for(ll j=k-2;j+1;j--){
            for(const auto&l:dp[j]){
                dp[j+1][MP((l.F.F)&a[i],(l.F.S)|a[i])]+=(l.S);
            }
        }
        dp[0][MP(a[i],a[i])]=1;
    }
    n=0;
    REP(i,k)n+=(dp[i][MP(s,t)]);
    cout<<n;
}

Measured memory_bytes: 153904
#include <iostream>
#include <vector>
#include <queue>
#include <cctype>

typedef std::pair<std::string,int> task;

int main()
{
	int n, q;
	std::cin >> n >> q;
	std::string *name = new std::string[n];
	int* time = new int[n];
	for (int i=0; i<n; i++) std::cin >> name[i] >> time[i];
	
	std::queue<task> que;
	for (int i=0; i<n; i++) que.push( task(name[i], time[i]) );
	
	int process_time = 0;
	while ( !que.empty() ) {
		task t = que.front(); que.pop();
		if (t.second <= q) {
			process_time += t.second;
			std::cout << t.first << " " << process_time << std::endl;
		} else {
			process_time += q;
			t.second -= q;
			que.push(t);
		}
	}
	
	return 0;
}




Measured memory_bytes: 6696
#include <stdio.h>
#include <stdlib.h>

int f(int n)
{
    int i,flag=0;
    for(i=2; i<=n*1.0/2; i++)
    {
        if(n%i==0)
        {
            flag=1;
            break;
        }
    }
    return flag;
}
int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0,j=3; i<n; i++)
    {
        do
        {
            j+=10;
        }
        while(f(j)!=0);
        printf("%d ",j);
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
oddlist = []
tmp = 0
c = 0

for i in range(100):
  if 2*i+1 <= n:
    oddlist.append(2*i+1)
    
for j in oddlist:
  for k in range(1,201):
    if j%k == 0:
      tmp += 1
  if tmp == 8:
    c += 1
  tmp = 0
  
print(c)

Measured memory_bytes: 3060
n,k = map(int,input().split())
mod = 10**9 + 7

def comb(n,k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk
  
for i in range(1,k+1):
  a = comb(k-1,i-1)%mod
  b = comb(n-k+1,i)%mod
  print(a*b%mod)


Measured memory_bytes: 74412
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=5005;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int f[N],a[N],n;
void dfs(int u,int fa){
	f[u]=0;
	go(u)if(v!=fa&&a[u]>a[v])dfs(v,u),f[u]|=f[v]^1;
}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	fp(i,1,n)dfs(i,0);
	fp(i,1,n)if(f[i])printf("%d ",i);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define NOT_ZERO 1
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long ll;
typedef unsigned short int usi;

int main()
{
    int len, i, j;
    char s[100], t[7]="keyence";
    scanf("%s",s);
    len = strlen(s);
    for(i=0; i<7 && s[i]==t[i]; i++);
    for(j=0; j<7 && s[len-1-j]==t[6-j]; j++);
    printf(i+j>=7?"YES":"NO");

    return 0;
}


Measured memory_bytes: 128
using System;

namespace AtCoder0727
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int a = Int32.Parse(str[0]);
            int b = Int32.Parse(str[1]);
            if (Math.Abs(a - b) % 2 == 0)
            {
                Console.WriteLine( (a + b) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);

int main(){
    int n,w;
    cin >> n>>w;
    vector<vector<int>>dp(n+3,vector<int>(w+1010,0));  
    vector<pair<int,int>>data(n,mp(0,0));
    rep(i,n){
        cin>>data[i].F>>data[i].S;
    }
    

    for(int i=0;i<n;i++){
        for(int j=0;j<=w+2;j++){
            chmax(dp[i+1][j],dp[i][j]);
            
               
            chmax(dp[i+1][j+data[i].S],dp[i][j]+data[i].F);
            chmax(dp[i][j+data[i].S],dp[i][j]+data[i].F);   
             
            
          //  clog<<dp[i][j]<<" ";

        }//clog<<endl;
    }


    cout << dp[n][w]<< endl;
}


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

const static int MAX = 1400;

int dp[MAX][MAX], G[MAX][MAX];

int getLargesetSquare(int H, int W){
    int maxWidth = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dp[i][j] = (G[i][j] + 1) % 2;
            maxWidth |= dp[i][j];
        }
    }

    for(int i = 1; i < H; i++){
        for(int j = 1; j < W; j++){
            if(G[i][j]){
                dp[i][j] = 0;
            }else{
                dp[i][j] = std::min( dp[i-1][j-1], std::min( dp[i-1][j], dp[i][j-1] ) ) + 1;
                maxWidth = std::max(maxWidth, dp[i][j]);
            }
        }
    }

    return maxWidth * maxWidth;
}

int main(void){
    int H, W;
    scanf("%d %d", &H, &W);

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) scanf("%d", &G[i][j]);
    }

    printf("%d\n", getLargesetSquare(H, W));

    return 0;
}


Measured memory_bytes: 18536
inputs = gets.split.map(&:to_i)
sum_num = inputs[0]
sum = inputs[1]

(0..sum_num).each do |bilion|
                (0..sum_num).each do |five_tho|
                                one_tho = sum_num - (bilion+five_tho)
                                if one_tho >= 0

                                                if bilion*10000+five_tho*5000+one_tho*1000 == sum && bilion+five_tho+one_tho == sum_num

        puts "#{bilion} #{five_tho} #{one_tho}"

        exit

                                                end
                                end
                end

end

puts "-1 -1 -1"


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

int main(){
    int n,m,v;
    scanf("%d %d",&n,&m);
    int sum = 0;
    while(m--) {
        scanf("%d",&v);
        sum += v;
    }
    n -= sum;
    if(n<0) n = -1;
    printf("%d\n", n);
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int main() {
  int a, b, c, K;
  cin >> a >> b >> c >> K;
  int cnt = 0;
  while(a>=b) {
      b = (b<<1);
      cnt += 1;
  }
  while(b>=c) {
    c = (c<<1);
    cnt += 1;
  }
  if(cnt <= K) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
n,k = map(int,input().split())
s = list(input())
count = 0
for i in range(n):
    if i == 0:
        if s[i] == "R":
            if i < n-1:
                if s[i+1] == "R":
                    count += 1
    elif i == n-1:
        if s[i] == "L":
            if i > 0:
                if s[i-1] == "L":
                    count += 1
    else:
        if s[i] == "L":
            if s[i-1] == "L":
                count += 1
        else:
            if s[i+1] == "R":
                count += 1
print(min(n-1,count+2*k))

Measured memory_bytes: 4084
#include <iostream>

int calc(int a, char op, int b) {
    switch(op){
    case '+': return a + b;
    case '-': return a - b;
    case '*': return a * b;
    case '/': return a / b;
    }
    return 0;
}

int main(void) {
    while(true){
        int a, b;
        char op;
        std::cin >> a >> op >> b;
        if(op == '?') break;
        std::cout << calc(a, op, b) << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <stdlib.h>

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(long long a, long long b, long long c)
{
    if(c - a - b < 0) {
        printf("No\n");
        return;
    }
    if(0 < (c - a - b) * (c - a - b) - 4 * a * b)
        printf("Yes\n");
    else {
        printf("No\n");
    }
}

int
main(int argc, char *argv[])
{
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    long long a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    solver(a, b, c);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>

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

    int ans = 1;
    bool f;
    for(int i = 1; i < n; i++){
        f = true;
        for(int j = 0; j < i; j++){
            if(h[j] <= h[i]){
                continue;
            }else{
                f = false;
                break;
            }
        }
        if(f == true){
            ans++;
        }
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int N,M,X;
bool A[100];
int main(){
  cin>>N>>M>>X;
  FOR(i,0,M){
    int a;
    cin>>a;
    A[a]=true;
  }
  int M=0;
  FOR(i,X,N){
    if(A[i]){
      M++;
    }
  }
  int m=0;
  FOR(i,0,X){
    if(A[i]){
      m++;
    }
  }
  cout<<min(M,m)<<endl;
  return 0;
}
 

Measured memory_bytes: 256
import sys
from itertools import islice
from collections import deque
read = map(int, sys.stdin.read().split())

N = next(read)
A = [deque()] + [deque(islice(read, N - 1)) for _ in range(N)]
days = 1
available_players = deque(range(1, N + 1))
next_opponent = [0] * (N + 1)
played = set()

while available_players:
    player = available_players.popleft()
    if not A[player]:
        continue

    opponent = A[player].popleft()
    if next_opponent[opponent] == player:
        available_players.append(player)
        available_players.append(opponent)
        next_opponent[player] = 0
        next_opponent[opponent] = 0
        if player in played:
            days += 1
            played = set()
        played.add(player)
        played.add(opponent)
    else:
        next_opponent[player] = opponent

for i in A:
    if len(i) > 0:
        print(-1)
        exit()
else:
    print(days)

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B) << ' ' << max(A + B - N, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;

int main()
{
    int n,d,a[20][20],i,j,k,sum,integer=0;
    double sq;
    cin>>n>>d;
    for(i=0;i<n;i++)
    {
        for(j=0;j<d;j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i==j)
                continue;
            sum=0;
            for(k=0;k<d;k++)
            {
                sum=sum+pow((a[i][k]-a[j][k]),2);
            }
            sq=sqrt(sum);
            //cout<<"sum "<<sum<<" sq "<<sq<<"\n";
            sq=sq/(int)sq;
            if(sq==1)
                integer++;
        }
    }
    cout<<integer/2;

    return 0;
}


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

public class Main
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		int a[] =new int[3];
		a[0]=in.nextInt();
		a[1]=in.nextInt();
		a[2]=in.nextInt();
		Arrays.sort(a);
		int d = Math.min(in.nextInt(), in.nextInt());
		System.out.println(a[0]+d-50);
	}

}

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

int main() {
	long long N, P, ANS = 0;
	string S;
	cin >> N >> P >> S;
	if (P == 2) {
		for (int i = 0; i < N; i++) {
			if ((S[i] - '0') % 2 == 0) {
				ANS += i + 1;
			}
		}
		cout << ANS << endl;
		return 0;
	}
	if (P == 5) {
		for (int i = 0; i < N; i++) {
			if ((S[i] - '0') % 5 == 0) {
				ANS += i + 1;
			}
		}
		cout << ANS << endl;
		return 0;
	}
	vector<long long> V(N);
	for (int i = 0; i < N; i++) {
		V[N - 1 - i] = S[i] - '0';
	}
	map<long long, long long> mp;
	mp[0]++;
	long long COUNT = 0, NOW = 1;
	for (int i = 0; i < N; i++) {
		COUNT += V[i] * NOW;
		COUNT %= P;
		NOW *= 10;
		NOW %= P;
		ANS += mp[COUNT];
		mp[COUNT]++;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 2564
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(c-e<0||d-e<0||c+e>a||d+e>b)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
    return 0;
}




Measured memory_bytes: 3088
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def mat_mul_opt(_mat_info):
    r, c = map(int, _mat_info[0])
    rc_info.extend([r, c])
    for each in _mat_info[1:]:
        rc_info.append(int(each[1]))

    for l in range(2, mat_num + 1):
        for i in range(1, mat_num - l + 2):
            j = i + l - 1
            ans[i][j] = 1e7
            for k in range(i, j):
                ans[i][j] = min(ans[i][j], ans[i][k] + ans[k + 1][j] +
                                rc_info[i - 1] * rc_info[k] * rc_info[j])

    return ans[1][mat_num]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    mat_num = int(_input[0])
    mat_info = tuple(map(lambda x: x.split(), _input[1:]))

    rc_info = []
    ans = [[0] * (mat_num + 1) for _ in range(mat_num + 1)]
    print(mat_mul_opt(mat_info))

Measured memory_bytes: 7816
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto b = readln.chomp.split.to!(int[]);
  auto a = new int[](n);
  a[0] = b[0];
  a[$-1] = b[$-1];
  foreach (i; 1..n-1) {
    a[i] = min(b[i-1], b[i]);
  }
  a.sum.writeln;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int min = (int) 10e10;
    for(int i = 0; i < N - K + 1; i++) {
        int min_height = h[i];
        int max_height = h[i + K - 1];
        if(min > max_height - min_height) {
            min = max_height - min_height;
        }
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 640
N,W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
inf = float('inf')    
dp=[[inf for i in range(N+1)] for j in range(N*1000+1)] 

dp[0][0]=0

for i in range(1,N+1):
    for j in range(N*1000+1):
        if j-v[i-1]>=0:
            dp[j][i]=min(dp[j][i-1],dp[j-v[i-1]][i-1]+w[i-1])
        else:
            dp[j][i]=dp[j][i-1]


            
for i in reversed(range(N*1000+1)):
    if dp[i][N]<=W:
        print(i)
        break
#for i in reversed(range(N*1000+1)):
 #   print('{} '.format(i),dp[i][N])
    

Measured memory_bytes: 292452
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  cout << 800*n - 200*(n/15) << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
    string s;
    ll K;
    cin >> s >> K;
    int ans = 1;

    for(int i = 0;i < K;i++){
        if(s[i] != '1'){
            char thisnum = s[i];
            int num = (int) (s[i] - '0');
            ans = num;
            break;
            
        }

        

        if(i >= s.length()){
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
S = gets.strip

a=(S[0]+S[1]).to_i
b=(S[2]+S[3]).to_i

if 0<a && a<13
    if 0<b && b<13
        puts 'AMBIGUOUS'
    else
        puts 'MMYY'
    end
else
    if 0<b && b<13
        puts 'YYMM'
    else
        puts 'NA'
    end
end




Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    if(n%2!=0){
        ans = 0;
        cout << 0 << endl;
    }else{
        ll d=10;
        while(d<=n){
            ans+=n/d;
            d*=5;
        }
        cout <<ans<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import glob

class InputGenerator(object):
    def __init__(self, input_path=None):
        if input_path != None:
            self.g = self.input_generator(input_path)
        else:
            self.g = None

    def input_generator(self, input_path):
        with open(input_path) as f:
            for line in f:
                yield line

    def get_input(self):
        if self.g == None:
            return input()
        else:
            return next(self.g)

def triable(a, b, c):
    cond_0 = a != b and a != c and b != c
    cond_1 = a + b > c
    cond_2 = b + c > a
    cond_3 = c + a > b
    return cond_0 and cond_1 and cond_2 and cond_3

def solve(gen):
    N = int(gen.get_input().rstrip())
    len_list = gen.get_input().rstrip().split()
    len_list = list(map(int, len_list))

    # print(N)
    # print(len_list)

    cnt = 0
    for i in range(0, N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                a = len_list[i]
                b = len_list[j]
                c = len_list[k]
                # print(i+1, j+1, k+1)
                # print(triable(a, b, c))
                if triable(a, b, c) == True:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    test_flag = len(sys.argv) > 1

    if test_flag == True:
        file_path_list = sorted(glob.glob('test/*'))
    else:
        file_path_list = [None]

    for file_path in file_path_list:
        gen = InputGenerator(file_path)
        solve(gen)


Measured memory_bytes: 9976
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int a[3];
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	cout << max(a[0],max(a[1],a[2])) - min(a[0],min(a[1],a[2])) << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  ls <- replicateM 4 getLine
  mapM_ print $ solve (map (map read . words) ls)

solve :: [[Int]] -> [Int]
solve = map func 
  where
    func :: [Int] -> Int
    func [x,y]
      | x == 1 = y * 6000
      | x == 2 = y * 4000
      | x == 3 = y * 3000
      | otherwise = y * 2000

Measured memory_bytes: 3652
package main
import (
  "fmt";
)


func main() {
  
  var N, M int
  fmt.Scanf("%d %d", &N, &M)
  
  s := make([]int, N)  
  for i:=0; i<N; i++ {
    var a int
  	fmt.Scanf("%d", &a)
    s[i] = a
  }

  sum := 0
  for _, num := range s {
      sum += num
  }
  sumsum := float32(sum) / (4.0 * float32(M))
  
  vv := make([]int,N, N)
  for i:=0; i<N; i++ {
    if float32(s[i]) >= sumsum {vv[i] = 1} else {vv[i] = 0}
  }
  
  sumsumsum := 0
  for _, num := range vv {
      sumsumsum += num
  }

  if sumsumsum >= M{
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }

}


Measured memory_bytes: 512
import itertools

N, M, Q = map(int, input().split())

a, b, c, d = [], [], [], []
for i in range(Q):
    _a, _b, _c, _d = map(int, input().split())
    a.append(_a)
    b.append(_b)
    c.append(_c)
    d.append(_d)

l = [v for v in range(1, M+1)]
ll = list(itertools.combinations_with_replacement(l, N))

ans = 0
for i in ll:
    anstmp = 0
    for j in range(Q):
        if i[b[j]-1] - i[a[j]-1] == c[j]:
            anstmp += d[j]
    if anstmp > ans:
        ans = anstmp

print(ans)


Measured memory_bytes: 21620
import sys
def input():
	return sys.stdin.readline().strip()

N, Q = list(map(int, input().split()))
S = input()

i = 0
num = 0
num_acc2 = [0]*N
for i in range(N - 1):
	if S[i:i + 2] == "AC":
		num += 1
	num_acc2[i + 1] = num

for i in range(Q):
	l, r = list(map(int, input().split()))
	print(num_acc2[r - 1] - num_acc2[l - 1])





Measured memory_bytes: 53848
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class  Main{
    public static void main(String[] args) throws Exception{
    	MScanner sc = new MScanner(System.in);
        //MScanner sc = new MScanner("reduce.in");
        PrintWriter pw=new PrintWriter(System.out);
        int n=sc.nextInt();
        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=sc.nextInt();
        Arrays.sort(in);
        int mid=n/2;
        pw.println(in[mid]-in[mid-1]);
        pw.flush();
    }
    static StringBuilder tosb(int[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    static StringBuilder tosb(long[]in) {
    	StringBuilder s=new StringBuilder();
    	for(int i=0;i<in.length;i++) {
    		s.append(in[i]+" ");
    	}
    	return s;
    }
    
    static class MScanner {
		StringTokenizer st;
		BufferedReader br;
 
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

int main(void){
    string a, b;
    cin >> a >> b;
    if(a.size()==b.size()){
        if(a>b){
            cout << "GREATER" << endl;
        }else if(a<b){
            cout << "LESS" << endl;
        }else{
            cout << "EQUAL" << endl;
        }
    }else{
        if(a.size()>b.size()) cout << "GREATER" << endl;
        else cout << "LESS" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..

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

int main(void) {
  int n;
  cin >> n;
  ll t[n];
  rep (i, n) cin >> t[i];

  ll start = t[0];
  rep (i, n - 1) {
    ll now = gcd(start, t[i + 1]);
    
    now = (ll) now * (start / now) * (t[i + 1] / now); 
    
    start = now;
  }
  cout << start << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())

edge = [[int(s) - 1 for s in input().split()] for _ in range(N-1)]
graph = [[] for _ in range(N)]
weight_odd = {}

for i, j, w in edge:
    graph[i].append(j)
    graph[j].append(i)
    weight_odd[(i, j)] = (w % 2 != 0)
    weight_odd[(j, i)] = (w % 2 != 0)

dq = deque([0])
visited = [False] * N
color = [1] * N
while(dq):
    search_obj = dq.pop()
    col1 = color[search_obj]
    col2 = 0 if col1 == 1 else 1
    for candidate_obj in graph[search_obj]:
        if not visited[candidate_obj]:
            if weight_odd[(candidate_obj, search_obj)]:
                color[candidate_obj] = col1
            else:
                color[candidate_obj] = col2
            dq.appendleft(candidate_obj)
            visited[candidate_obj] = True

for c in color:
    print(c)

Measured memory_bytes: 65504