akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 75;

inline int qPow(int b, int e) {
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int Fac[100005], iFac[100005];
inline void Init(int N) {
	Fac[0] = 1;
	for (int i = 1; i <= N; ++i) Fac[i] = (LL)Fac[i - 1] * i % Mod;
	iFac[N] = qPow(Fac[N], Mod - 2);
	for (int i = N; i >= 1; --i) iFac[i - 1] = (LL)iFac[i] * i % Mod;
}

int Len;
char Str[MN];
int posr[MN], nxposb[MN], rcnt;

int N, Ans;

int stk[MN];
inline void Calc(int cnt, int csum) {
	int Sum = 0;
	if (!cnt) Sum = 1;
	else if (cnt <= rcnt) {
		static int vis[MN];
		for (int i = 1; i <= cnt; ++i) vis[i] = posr[i];
		int tot = cnt, mxp = 1;
		for (int i = 1; i <= cnt && stk[i] >= 2; ++i)
			mxp = vis[++tot] = nxposb[std::max(mxp, vis[i])];
		if (mxp <= Len) {
			std::inplace_merge(vis + 1, vis + cnt + 1, vis + tot + 1);
			int nwp = Len + 1, sum = 0, now = cnt, ok = 1;
			while (now && stk[now] == 1) --now;
			for (int i = tot; i >= 1; --i) {
				sum += nwp - vis[i] - 1;
				if (Str[vis[i]] == 'b') {
					sum -= stk[now] - 2;
					if (sum < 0) { ok = 0; break; }
					--now;
				}
				nwp = vis[i];
			}
			if (ok) {
				Sum = Fac[cnt];
				int len = 0, num = 1;
				for (int i = 1; i <= cnt; ++i) {
					++len;
					num += stk[i] * 2;
					if (i == cnt || stk[i] != stk[i + 1]) {
						Sum = (LL)Sum * iFac[len] % Mod;
						len = 0;
					}
				}
				Sum = (LL)Sum * Fac[N - csum + num] % Mod * iFac[num - 1] % Mod * iFac[N - csum + 1] % Mod;
			}
		}
	}
	Ans -= (Ans += Sum) >= Mod ? Mod : 0;
}
void DFS(int st, int mx, int sum) {
	Calc(st - 1, sum);
	if (sum < N) {
		stk[st] = 1;
		DFS(st + 1, 1, sum + 2);
	}
	for (int i = 2; i <= mx; ++i) {
		if (sum + i * 2 <= N + 3) {
			stk[st] = i;
			DFS(st + 1, i, sum + i * 2 - 2);
		}
	}
}

int main() {
	scanf("%d%d%s", &N, &Len, Str + 1);
	Init(100000);
	for (int i = 1; i <= Len; ++i)
		if (Str[i] == 'r')
			posr[++rcnt] = i;
	int nwposb = Len + 1;
	nxposb[Len + 1] = Len + 1;
	for (int i = Len; i >= 1; --i) {
		nxposb[i] = nwposb;
		if (Str[i] == 'b')
			nwposb = i;
	}
	DFS(1, (N + 3) / 2, 0);
	printf("%d\n", Ans);
	return 0;
}

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

int main() {
    string s;
  	cin >> s;
  	int counter = 0;
  	if (s[0] == '1') ++counter;
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    
    ll power(ll a, ll b)    //a is base, b is exponent
    {
        if(b==0)
            return 1;
        if(b==1)
            return a;
        if(b%2 == 1)
            return (power(a,b-1)*a)%mod;
        ll q = power(a,b/2);
        return (q*q)%mod;
    }

    ll fact[100001],inv[100001];

    void init()
    {
        fact[0]=1,inv[0]=1;
        for(int i=1;i<=100000;++i)
        {
            fact[i]=(fact[i-1]*i)%mod;
            inv[i]=power(fact[i],mod-2);
        }
    }

    ll ncr(int n,int r)
    {
        return ((fact[n]*inv[r])%mod*inv[n-r])%mod;
    }

    ll func(ll n,ll r)
    {
        return ncr(n+r-1,r-1);
    }

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        init();
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll s,ans=0,i,j;
            cin>>s;
            for(i=1;i<=s;++i)
            {
                if(i*3>s)
                    break;
                ans=(ans+func(s-3*i,i))%mod;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 5212
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll n;  cin>>n;
    ll arr[n];
    rep(i,0,n)  cin>>arr[i];
    sort(arr,arr+n);
    cout<<arr[n/2]-arr[n/2-1];
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


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

int main() {
    int n; cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i ++) cin >> s[i];
    int m; cin >> m;
    vector<string> t(m);
    for(int i = 0; i < m; i ++) cin >> t[i];
    vector<int> ans(n);
    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < n; j ++) {
            if(s[i]==s[j]) ans[i] ++;
        }
        for(int j = 0; j < m; j ++) {
            if(s[i]==t[j]) ans[i] --;
        }
    }
    cout << max(*max_element(ans.begin(), ans.end()), 0) << endl;
}

Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2440

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int output(int isLock, string id, vector<string> id_list)
{
	bool flag=false;

	rep(i,id_list.size()){
		if(id_list[i] == id){flag=true;}
	}

	if(flag){
		if(isLock < 0){
			cout << "Opened by " << id << endl;
			return isLock*-1;
		}else{
			cout << "Closed by " << id << endl;
			return isLock*-1;
		}
	}else{
		cout << "Unknown " << id << endl;
		return isLock;
	}

}

int main() {
	
	int N,M;
	int isLock=-1;
	vector<string> id_list;

	cin >> N;
	string id;
	rep(i,N){
		cin >> id;
		id_list.push_back(id);
	}

	cin >> M;
	rep(i,M){
		cin >> id;
		isLock = output(isLock, id, id_list);
	}
	return 0;
}

Measured memory_bytes: 1228
MAX_N = 10**5 + 10
INF = float('inf')

import numpy as np
N = int(input())
h = list(map(int, input().split()))

# dp table
# dp[i] := 足場iに行くのにかかる最小のコスト
dp = [INF]*MAX_N
dp[0] = 0

for i in range(1,N):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int p, q, r;
    cin >> p >> q >> r;
    cout << p + q + r - max({p, q, r}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    vi h(n);
    for(int i=0; i<n; i++){
        cin >> h.at(i);
    }
    int max_count = 0;
    int counter = 0;
    for(int i=0; i<n-1; i++){
        if(h.at(i+1) - h.at(i) <= 0){
            counter++;
        }else{
            max_count = (max_count >= counter) ? max_count : counter;
            counter = 0;
        }
    }
    max_count = (max_count >= counter) ? max_count : counter;
    cout << max_count << endl;
}


Measured memory_bytes: 640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter out = new PrintWriter(System.out);

    int n = in.nextInt();

    double sum = 0;

    for (int i = 0; i < n; i++) {
      double x = in.nextDouble();
      String u = in.next();

      sum += (u.equals("BTC")) ? x * 380000.0 : x;
    }

    out.println(sum);

    out.close();
  }
  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}

Measured memory_bytes: 21204
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

total = r_cnt * g_cnt * b_cnt

for i in range(n):
    for j in range(n):
        ptr1 = j
        ptr2 = j + i
        ptr3 = j + 2 * i
        if ptr3 >= n:
            break
        else:
            if s[ptr1] != s[ptr2] and s[ptr2] != s[ptr3] and s[ptr1] != s[ptr3]:
                total -= 1

print(total)


Measured memory_bytes: 68028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<ll> A(N), C(M);
  vector<int> B(M);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> B[i] >> C[i];
  }
  map<ll, ll, greater<ll>> m;
  for (int i = 0; i < N; i++) {
    m[A[i]]++;
  }
  for (int i = 0; i < M; i++){
    m[C[i]] += B[i];
  }
  ll ans = 0;
  ll cnt = 0;
  for (auto i = m.begin(); i != m.end(); i++) {
    //cout << i -> first << "\n";
    if (cnt > N) break;
    if (cnt + i -> second >= N) {
      ans += (N - cnt) * i -> first;
      break;
    } else {
      ans += i -> second * i -> first;
      cnt += i -> second;
    }
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    pii s, t;
    str r = "", u = "", l = "", d = "";
    cin >> s.first >> s.second >> t.first >> t.second;
    REP(i, t.first - s.first) r += "R";
    REP(i, t.second - s.second) u += "U";
    REP(i, t.first - s.first) l += "L";
    REP(i, t.second - s.second) d += "D";
    cout << (r + u + l + d + "D" + r + "R" + u + "ULU" + l + "LD" + d + "R") << "\n";
    return 0;
}


Measured memory_bytes: 256
let lines = [];
let reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  const N = parseInt(lines[0]);
  
  var array = [];
  for (var i = 0; i < N; i++) {
    array.push(parseInt(lines[1].split(' ')[i]));
  }
  
  selectionSort(array, N);
});

function selectionSort(array, N) {
  var cnt = 0;
  for (var i = 0; i < N - 1; i++) {
    var min_i = i;
    for (var j = i + 1; j < N; j++) {
      if (array[min_i] > array[j]) min_i = j;
    }
    if (array[i] > array[min_i]) cnt++;
    var tmp = array[i];
    array[i] = array[min_i];
    array[min_i] = tmp;
  }
  console.log(array.join(' '));
  console.log(cnt);
}


Measured memory_bytes: 17472
n,k=map(int,input().split())
*h,=map(int,input().split())

dp=[0]*n
for i in range(1,n):
    dpmin=[]
    for j in range(max(0,i-k),i):
        dpmin.append(dp[j]+abs(h[i]-h[j]))
    dp[i]=min(dpmin)
print(dp[-1])

Measured memory_bytes: 56160
n, m = gets.strip.split.map(&:to_i)
mn = 0
mx = n
m.times do |i|
    l, r = gets.strip.split.map(&:to_i)
    mn = [mn, l].max
    mx = [mx, r].min
end

ans = mx - mn + 1
ans = 0 if ans < 0

puts ans

Measured memory_bytes: 1788
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

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

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------

int main(void){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}

	int ans = 0;
	while(1){
		bool ok = true;
		for(int i = 0; i < n; i++){
			if(a[i] % 2 == 0){
				a[i] /= 2;
			} else {
				ok = false;
				break;
			}
		}
		if(!ok)break;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    ll n;
    set<string> s;
	cin >> n;

    rep(i,0,n){
        string t;
        cin >> t;
        s.it(t);
    }
    
    if(s.size() > 3)P("Four");
    else P("Three");
        
	
	return  0;
}

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



public class Main{
    static int INFTY=Integer.MAX_VALUE;
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // try{
            // int n = Integer.parseInt(br.readLine());
            
        int n=sc.nextInt();
        int[] arr = new int[n];
        int ans =0;

        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        
        Arrays.sort(arr);
        if(arr[n/2-1]==arr[n/2]){
            ans=0;
        }else{
            ans=arr[n/2]-arr[n/2-1];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50816
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class BTripleDots {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll k;
        string s;
        in>>k>>s;
        if(s.size()<=k) out<<s<<endl;
        else {
            out<<s.substr(0,k)<<"..."<<endl;
        }
	}
};


int main() {
	BTripleDots solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3104
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
if S[0..6].join("")=="keyence" or S[N-1-6..N-1].join("")=="keyence"
    puts "YES"
    exit
end
keyence=["k","e","y","e","n","c","e"]
flag=false
6.times do|i|
    if keyence[0..i].join("")==S[0..i].join("") and keyence[i+1..N-1].join("")==S[N-6+i..N-1].join("")
      flag=true
      break
    end
end
puts yn_judge(flag,"YES","NO")

Measured memory_bytes: 1788
// 2011/08/02 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prm[], int n)
{
	if(n>=1)
		prm[0] = false;
	if(n>=2)
		prm[1] = false;

	for(int i=2; i<n; i++)
		prm[i] = true;

	for(int i=2; i<n; i++)
		if(prm[i])
			for(int j=i+i; j<n; j+=i)
				prm[j] = false;
}

int main()
{
	bool prm[1000001];
	eratos(prm, 1000001);

	while(true){
		int n, x;
		cin >> n >> x;
		if(n==0&&x==0)
			break;

		int K[30];
		for(int i=0; i<n; i++)
			cin >> K[i];

		bool DP[1000001];
		DP[0] = true;
		for(int i=1; i<=x; i++)
			DP[i] = false;

		for(int i=0; i<n; i++)
			for(int j=0; j<=x; j++)
				if(DP[j]&&j+K[i]<=x)
					DP[j+K[i]] = true;

		int ans = -1;
		for(int i=x; i>=0; i--)
			if(DP[i]&&prm[i]){
				ans = i;
				break;
			}

		if(ans!=-1)
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}

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

int main() {
  int n;
  string S;
  cin >> n >> S;
  //int count = 0;
  ll r = 0, g = 0, b = 0; 
  for (int i = 0; i < n; i++)
  {
      if (S[i] == 'R')  r++;
      if (S[i] == 'G')  g++;
      if (S[i] == 'B')  b++;
  }
  ll sum = r * g * b;
  for (int i = 0; i < n; i++)
  {
      for (int j = i + 1; 2 * j - i < n; j++)
      {
        int k = 2 * j - i;
        //if (k >= n)  continue;
        if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i])  sum--;
      }
  }
  cout << sum << endl;
  return 0;

}
    
    


Measured memory_bytes: 3636
#include<stdio.h>
int isPrime(int);

int main(){
  int x[10000];
  int N,i,n=0;
  
  scanf("%d",&N);
  for(i = 0; i < N; i++){
    scanf("%d",&x[i]);
    
    if(isPrime(x[i]) == 1){n++;}
  }
  printf("%d\n",n);
  return 0;
}

int isPrime( int x ){
  int i;
 
 if(x < 2)     return 0;
    else if(x == 2)  return 1;
    if(x % 2 == 0)  return 0;
 for(i = 3; i <= x / i; i += 2)
   if(x % i == 0)   return 0;
 return 1;
}

Measured memory_bytes: 632
#include<iostream>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    if (K == 1) {
        cout << 0;
        return 0;
    }   
    int rest_boll = N - K;
    int ans = rest_boll;
    cout <<  rest_boll;
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <stdio.h>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[20];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    int res = arr1[ch[0] - '0'][ch[7] - '0'];
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            res = '4' - ch[2];
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            res = ch[2] - '0';
        }
        else
            res = arr1[ch[0] - '0'][ch[6] - '0'];
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            res = 22888;
        }
        else if (ch[0] == '9') {
            res = 25436;
        }
    }
    puti(res);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1524
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

// 素因数分解する
// たとえば 60 = 2^2 x 3 x 5 だったら {(2, 2), (3, 1), (5, 1)} を返す
// o(sqrt(n))
vector<pair<ll, ll> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll n; cin >> n;
	vector<pair<ll, ll> > ans = prime_factorize(n);

	ll t = 0;
	rep(i, ans.size()){
		pair<ll, ll> f = ans[i];
		ll ma = 1;
		while(1){
			if((ma + 1) * (ma + 2) / 2 > f.second){
				break;
			}
			ma ++;
		}
		t += ma;
	}
	cout << t << endl;

	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,k,sum=0;
	cin>>n>>k;
	for(long long i=k;i<=n+1;i++){
		sum+=(n*i-i*i+i+1);
	}
	cout<<sum%1000000007;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define LL long long
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF INT_MAX
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
using namespace std;

const int N = 2e5 + 5;

int ans[N];
vector < int > G[N];
vector < int > Q[2];
vector < int > P[3];

void dfs(int u, int fa, int op) {
    Q[op].pb(u);
    for(auto v : G[u]) {
        if(v == fa) continue;
        dfs(v, u, op ^ 1);
    }
}

void add(int op1, int op2) {
    while(!Q[op1].empty() && !P[op2].empty()) {
        ans[Q[op1].back()] = P[op2].back();
        Q[op1].pop_back();
        P[op2].pop_back();
    }
}

void solve() {

    int n;
    scanf("%d", &n);
    rep(i, 1, n) P[i % 3].pb(i);
    rep(i, 1, n - 1) {
        int u, v;
        scanf("%d %d", &u, &v);
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(1, 0, 0);

    if(Q[0].size() > Q[1].size()) add(0, 1);
    else add(1, 1);

    if(Q[0].size() > Q[1].size()) add(0, 2);
    else add(1, 2);

    add(0, 0);
    add(1, 0);

    rep(i, 1, n) printf("%d ", ans[i]); puts("");
}


int main() {
//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define mo 1000000007
#define MAX 1000004
#define fast_io ios::sync_with_stdio(false)

int a[MAX];
long long dp1[MAX];
long long dp2[MAX];
int main()
{
	fast_io;
	int n;
	cin >> n;
	for(int i=1;i<=3*n;i++)
		cin >> a[i];
	priority_queue<int, vector<int>, greater<int> > pq;
	long long sum = 0;
	for(int i=1;i<=n;i++)
	{
		sum+=a[i];
		pq.push(a[i]);
	}
	dp1[n] = sum;
	for(int i = n+1;i<=2*n;i++)
	{
		if(pq.top()<a[i])
		{
			int temp = pq.top();
			pq.pop();
			pq.push(a[i]);
			sum+=a[i]-temp;
		}
		dp1[i] = sum;
	}
	priority_queue<int> pq1;
	sum = 0;
	for(int i=3*n;i>2*n;i--)
	{
		sum+=a[i];
		pq1.push(a[i]);

	}
	dp2[2*n+1] = sum;
	for(int i = 2*n;i>n;i--)
	{
		if(pq1.top()>a[i])
		{
			int temp = pq1.top();
			pq1.pop();
			pq1.push(a[i]);
			sum+=a[i]-temp;
		}
		dp2[i] = sum;
		//cout << sum << "\n";
	}
	long long ans = -2e18;
	for(int i=n;i<=2*n;i++)
	{
		ans = max(ans, dp1[i] - dp2[i+1]);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 8056
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
int main()
{ 
    cool;
    int n,i,sum=0;
    cin>>n;
    int b[n-1];
    for(i=0;i<n-1;i++)
    cin>>b[i];
    int a[n];
    a[0]=b[0];
    for(i=0;i<n-2;i++)
    	a[i+1]=min(b[i],b[i+1]);
    	a[n-1]=b[n-2];
    	for(i=0;i<n;i++)
    	sum+=a[i];
    cout<<sum;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int sum = 0;
	int maxL = 0;
	for(int i = 0; i < n; i++){
		int l;
		cin >> l;
		sum += l;
		maxL = max(maxL, l);
	}

	if(sum > maxL * 2){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,a) for(int i = 0; i < (a); i++)
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

int main(){
    ll a,b,ans=0;
    cin>>a>>b; 
    if(a==0&&b==0){ cout<<0<<endl; return 0;}
    else if((a==0&&b<0)||(a>0&&b==0)) ans++;
    else if(a*b!=0){
        if(a*b<0) ans++;
        else { if(a>b) ans+=2;}
    }
    cout<<ans+abs(abs(a)-abs(b))<<endl;
    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int use[11111][1300];
int N,M,r,q;

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>N>>M;
		if(N==0)break;
		memset(use,0,sizeof(use));
		cin>>r;
		rep(i,r){
			int t,n,m,s;
			cin>>t>>n>>m>>s;
			n--; m--;
			if(s==1){
				use[m][t]+=1;
			}else{
				use[m][t]-=1;
			}
		}
		rep(i,M)repl(j,540,1300){
			use[i][j+1]+=use[i][j];
		}
		cin>>q;
		rep(i,q){
			int ts,te,m;
			cin>>ts>>te>>m;
			m--;
			int res=0;
			repl(j,ts,te){
				if(use[m][j]>0)res++;
			}
			cout<<res<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 59524
import java.util.Scanner;


public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		for(; scanner.hasNext();)
		{
			String str = scanner.next();
			String[] w = str.split(",");
			
			int[] l = new int[10];
			int d = 0;
			for(int i=0; i<10; i++)
			{
				l[i] = Integer.parseInt(w[i]) * 100;
				d += l[i];
			}
			int v1 = Integer.parseInt(w[10]);
			int v2 = Integer.parseInt(w[11]);
			
			int t;
			for(t=0; (v1+v2)*t<d; t++);
			
			d = l[0];
			int s=0;
			for(; d<v1*t; d+=l[++s]);
			
			System.out.println(s+1);
		}	
	}
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int ans = a[1] - a[0] + a[2] -a[1];
        System.out.println(ans);
    }
}

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

#include <iostream>
#include <string>
#include <typeinfo>
int main(){
int n;
cin>>n;
for (int i = 0; i < n; ++i) {
string s;
int maxv=0,minv=0;
int data[8]={0};

cin>>s;
for (int i = 0; i < 8; ++i) {
	data[i]=s[i]-'0';
}
std::sort(data,data+8,greater<int>());//???????????????
	maxv=data[0]*10000000+data[1]*1000000+data[2]*100000+data[3]*10000+data[4]*1000+data[5]*100+data[6]*10+data[7]*1;
	minv=data[7]*10000000+data[6]*1000000+data[5]*100000+data[4]*10000+data[3]*1000+data[2]*100+data[1]*10+data[0]*1;
	cout<<maxv-minv<<endl;
}
}
//data.begin(),data.end(),std::greater<int>()
//const std::string str("123");
//auto num = std::atoi(str.c_str())

Measured memory_bytes: 3048
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int L[n], R[n]; for (int i = 0; i < n; i++) cin >> L[i] >> R[i];
    vector<int> p(n);
    iota(p.begin(), p.end(), 0);
    vector<int> q = p;
    sort(p.begin(), p.end(), [&](int i, int j) { return R[i] < R[j]; });
    sort(q.begin(), q.end(), [&](int i, int j) { return L[i] > L[j]; });
    int pos = 0;
    long long sum1 = 0;
    auto itp = p.begin(), itq = q.begin();
    for (;;) {
        if (R[*itp] < pos) {
            sum1 += pos - R[*itp];
            pos = R[*itp];
            itp++;
        } else if (L[*itq] > pos) {
            sum1 += L[*itq] - pos;
            pos = L[*itq];
            itq++;
        } else break;
    }
    sum1 += abs(pos);
    long long sum2 = 0;
    itp = p.begin(), itq = q.begin();
    pos = 0;
    for (;;) {
        if (L[*itq] > pos) {
            sum2 += L[*itq] - pos;
            pos = L[*itq];
            itq++;
        } else if (R[*itp] < pos) {
            sum2 += pos - R[*itp];
            pos = R[*itp];
            itp++;
        } else break;
    }
    sum2 += abs(pos);
    cout << max(sum1, sum2) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	cout << a/b << " " << a%b << " " ;
	double c = 1.0*a/b;
	cout << fixed << setprecision(5) << c << endl;
	return 0;
} 


Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  double ans = 0;
  for(int i=1; i<=n; i++) {
    int cnt = 0;
    int n = i;
    while(n < k) {
      cnt++;
      n *= 2;
    }
    ans += pow((double)1/2, cnt);
  }
  cout << fixed << setprecision(10) << ans/n << "\n";
  return 0;
}


Measured memory_bytes: 4120
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  int n;
  double x1,y1,x2,y2,x3,y3,x4,y4;
  cin >> n;
  while(n--){
  cin >>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;

  if(fabs((y1-y2)*(x3-x4)-(x1-x2)*(y3-y4))<10e-12){
      cout << "YES" << endl;
    }else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
	string A;
	cin>>A;
	REP(i,4){
	    cout<<A[i];
	}
	cout<<" ";
	for(int i=4;i<12;i++){
	    cout<<A[i];
	}
        cout<<endl;
	return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i= 0; i <b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int main() {
	int i, j, k;

	int N, M, K;

	ll dp[51][5001] = { {0} };
	int A;
	cin >> N >> A;
	vector<int> X;
	int Max = 0;
	rep(i, 0, N) {
		int x;
		cin >> x;
		Max = max(Max, x);
		X.push_back(x);
	}
	Max = max(Max, A);
	rep(i, 0, N) {
		 X[i] -= A;	
	}

	int NX = N * Max;
	dp[0][NX] = 1;
	rep(i, 1, N+1) {
		int y = X[i-1];

		rep(j, 0, 2 * NX) {
			if (j - y < 0 || j - y > 2 * NX) {
				dp[i][j] = dp[i - 1][j];
				continue;
			}
			dp[i][j] = dp[i - 1][j] + dp[i - 1][j - y];

		}

	}
	cout << dp[N][NX] - 1;


	return 0;
}

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

long long n;
vector<int> a, id;

int main() {
  cin >> n;
  a.resize(n);
  id.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    id[i] = i;
  }
  auto f = [](int l, int r) { return a[l] < a[r]; };
  sort(id.begin(), id.end(), f);
  int cnt = 0;
  for (int i = 0; i < n; i += 2)
    if ((i ^ id[i]) & 1) ++cnt;
  cout << cnt << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VVI g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
  }
  vector<bool> used(n, false);
  VI prev(n, -1);
  VI ans(n, -1);
  int cur = -1;
  queue<int> q;
  VI dis(n, INF);
  int min_cy = INF;
  rep(i, n) {
    q.push(i);
    used[i] = true;
    dis[i] = 0;
    while(!q.empty()) {
      int v = q.front(); q.pop();
      for(const int u : g[v]) {
        if(u == i) {
          if(min_cy > (dis[v] + 1)) {
            min_cy = dis[v] + 1;
            ans = prev;
            cur = v;
          }
          break;
        }
        else {
          if(used[u]) continue;
          dis[u] = dis[v] + 1;
          q.push(u);
          prev[u] = v;
          used[u] = true;
        }
      }
    }
    dis.assign(n, INF);
    used.assign(n, false);
    prev.assign(n, -1);
  }
  VI o;
  if(min_cy == INF) out(-1);
  else {
    int v = cur;
    while(true) {
      if(ans[v] == -1) {
        o.push_back(v);
        break;
      }
      else {
        o.push_back(v);
        v = ans[v];
      }
    }
    out(min_cy);
    reverse(all(o));
    for(auto u : o) {
      out((u + 1));
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n, m;
	cin >> n >> m;
	int edge[101][101] = {};
	bool isused[101][101];
	for(int i = 0; i <= n; i++){
		for(int j = 0; j <= n; j++){
			isused[i][j] = true;
		}
	}
	for(int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		edge[a][b] = c;
		edge[b][a] = c;
		isused[a][b] = false;
		isused[b][a] = false;
	}
	for(int i = 1; i <= n; i++){
		vector<int> kyori(n + 1, mod);
		priority_queue<pair<int, pair<int, int> > > qu;
		qu.push(make_pair(0, make_pair(i, 0)));
		while(!qu.empty()){
			int nowkyori = -(qu.top()).first;
			int nownode = ((qu.top()).second).first;
			int beforenode = ((qu.top()).second).second;
			qu.pop();
			// cout <<beforenode << " " << nownode << " " << nowkyori << endl;
			if(nowkyori > kyori[nownode]) continue;
			kyori[nownode] = nowkyori;
			isused[beforenode][nownode] = true;
			isused[nownode][beforenode] = true;
			for(int j = 1; j <= n; j++){
				if(edge[nownode][j] > 0){
					qu.push(make_pair(-(nowkyori + edge[nownode][j]), make_pair(j, nownode)));
				}
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		for(int j = i + 1; j <= n; j++){
			if(!isused[i][j]) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
s = input()
s = s.replace("BC","D").replace("B","E").replace("C","E")
s = s.split("E")

def solve(s):
    ans = 0 ; tmp = 0
    for char in s:
        if char == "A": tmp += 1
        else: ans += tmp
    return ans

ans = 0
for ele in s: ans += solve(ele)
print(ans)


Measured memory_bytes: 5412
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
#define FOR(i,N) for(int i=0; i < (int)N; i++)
int N;
ll A[202020];
 
ll dp[202020][2][3];
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	FOR(i,N+1) FOR(x,2) FOR(y,3) dp[i][x][y]=-1LL<<60;
	dp[0][1][0]=0;
	
	FOR(i,N) {
		cin>>x;
		FOR(j,2) FOR(k,3) {
			// not take
			if(k+j<3) dp[i+1][1][k+j]=max(dp[i+1][1][k+j],dp[i][j][k]);
			// take
			if(j==1) dp[i+1][0][k]=max(dp[i+1][0][k],dp[i][j][k]+x);
		}
	}
	
	if(N%2==0) cout<<max(dp[N][1][0],dp[N][0][1])<<endl;
	else cout<<max(dp[N][0][2],dp[N][1][1])<<endl;
}

int main(){
	solve();
}

Measured memory_bytes: 13000
D, G = map(int, input().split())
PC = [tuple(map(int, input().split())) for _ in range(D)]
minNum = 10**3

for i in range(2**D):
    point = 0
    num = 0
    leftOvers = []
    for j in range(D):
        if ((i>>j) & 1):
            num += PC[j][0]
            point += PC[j][1] + 100 * (j+1) * PC[j][0]
        else:
            leftOvers.extend([100*(j+1)]*PC[j][0])

    while point < G:
        if not leftOvers:
            break
        point += leftOvers.pop()
        num += 1
    minNum = min(num, minNum)
print(minNum)


Measured memory_bytes: 3064
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) { os << p.first << " " << p.second; return os; }

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; }return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>a(N); rep(i, 0, N) { cin >> a[i]; }
	vector<int>b(N); rep(i, 0, N) { cin >> b[i]; }
	int ans = 0;
	vector<int>c(N); rep(i, 0, N) { c[i] = a[i] - b[i]; if (c[i] > 0)ans += c[i]; }
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 256
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int y1, m1, d1, y2, m2, d2;
		Scanner sc = new Scanner(System.in);
		while(true) {
			y1 = sc.nextInt();
			m1 = sc.nextInt();
			d1 = sc.nextInt();
			y2 = sc.nextInt();
			m2 = sc.nextInt();
			d2 = sc.nextInt();
			if(y1 == -1) break;
			LocalDateTime t1 = LocalDateTime.of(y1, m1, d1, 0, 0);
			LocalDateTime t2 = LocalDateTime.of(y2, m2, d2, 0, 0);
			Duration dur = Duration.between(t1, t2);
			System.out.println(dur.toDays());
		}
	}

}



Measured memory_bytes: 32540
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, Q;
string S;
char T[200200], D[200200];

template<typename... Args>
void debug(Args... args) {
    for (auto arg:{args...})cerr << arg << " ";
    cerr << endl;
}


//左-1
//消滅しない0
//右1
int simulation(int i) {
    char s = S[i];
    int x = i;
    rep(j, Q) {
        if (s == T[j]) {
            if (D[j] == 'L') {
                --x;
                if (x == -1)return -1;
                s = S[x];
            } else {
                ++x;
                if (x == N)return 1;
                s = S[x];
            }
        }
    }
    return 0;
}

bool syoumetu[200200];

signed main() {
    cin >> N >> Q;
    cin >> S;
    rep(i, Q) {
        cin >> T[i] >> D[i];
    }

    int leftsyoumetu = -1;
    int leftnotsyoumetu = N;
    while (leftnotsyoumetu - leftsyoumetu > 1) {
        int m = (leftnotsyoumetu + leftsyoumetu) / 2;
        if (simulation(m) == -1)leftsyoumetu = m;
        else leftnotsyoumetu = m;
    }
    int rightsyoumetu = N;
    int rightnotsyoumetu = -1;
    while (rightsyoumetu - rightnotsyoumetu > 1) {
        int m = (rightnotsyoumetu + rightsyoumetu) / 2;
        if (simulation(m) == 1)rightsyoumetu = m;
        else rightnotsyoumetu = m;
    }
    int ans = N;
    ans -= leftsyoumetu + 1;
    ans -= N - rightsyoumetu;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
def f(x):
    
    if x%2==0:
        ans = x/2
    else:
        ans = 3*x+1
    return int(ans)

def main():

    s = int(input())
    
    count = 1
    
    a = [s]
    b = set(a)
    while len(a) == len(b):
        a.append(f(a[-1]))
        b = set(a)
        count += 1
        
    print(count)
    
main()


Measured memory_bytes: 3060