akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/dp/tasks/dp_b

#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 1000010;
static const ll INFTY = 1e12;
static const ll NUMMAX = 1000000007;
static const ll MOD = 1000000007;
#define LOOP 10000000
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
int H, W;
vector<string> field;
int result = 100;
int dfs_res = 0;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


 
int main() {
 
    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    vector<ll> dp(N+1, INFTY);
    REP(i, N){ cin >>h[i]; }
    int sum = 0;
 
    dp[0] = 0;
    for(int i = 1; i < N; i++){
        if(i == 1){
            dp[i] = abs(h[i] - h[i-1]);            
        }else {
            for(int j = 1; j <= K; j++){
                dp[i] = min( dp[i], abs(h[i] - h[i-j]) + dp[i-j] );
                if(j == i)break;
            }
        }
    //    cout << h[i] << " " <<  h[i-1] << " ";
       // cout << dp[i] << " ";
    }
    cout << dp[N-1] << endl;
 
    return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/




Measured memory_bytes: 1792
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int N, M;
    cin >> N >> M;
    int a[200000], b[200000];
    vector<P> v;
    map<int, int> m;
    for(int i = 0; i < M; ++i){
        cin >> a[i] >> b[i];
        if(a[i] == 1)
            v.push_back(make_pair(a[i], b[i]));
        if(b[i] == N)
            m[a[i]] = b[i];
    }
    for(auto itr = v.begin(); itr != v.end(); ++itr){
        if(m.count(itr->second)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

const ll p = 1e9 + 7;
const ll MAXK = 10009;
const ll MAXD = 109;

ll memo[MAXK][MAXD][2];

int main() {
  string K; cin >> K;
  int D; cin >> D;
  memset(memo, -1, sizeof(memo));
  function<ll(int, int, int)> dp = [&](int i, int rem, int tight) {
    if (i == K.size()) return ll(rem == 0);
    else if (memo[i][rem][tight] != -1) return memo[i][rem][tight];
    else {
      int upperbound = tight ? (K[i] - '0') : 9;
      ll ret = 0;
      for (int d = 0; d <= upperbound; d++) {
        ret = (ret + dp(i + 1, (rem + d) % D, tight && (d == upperbound))) % p;
      }
      return memo[i][rem][tight] = ret;
    }
  };
  cout << ((dp(0, 0, 1) - 1) % p + p) % p << endl;
  return 0;
}


Measured memory_bytes: 18560
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	for(int i = n-1; i >= 0; i--){
		if(s[i] == ')') cnt++;
		else if(cnt > 0 && s[i] == '(') cnt--;
	}
	if(cnt > 0){
		rep(i,cnt) s = "(" + s;
	}
	n += cnt;
	cnt = 0;
	rep(i,n){
		if(s[i] == '(') cnt++;
		else cnt--;
	}
	if(cnt > 0){
		rep(i,cnt) s = s + ")";
	}
	cout << s << endl;
	return 0;
}

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

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

    int maxi = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            maxi = max(maxi, abs(a[i] - a[j]));
        }
    }

    cout << maxi << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#NIKEI B
import sys
import math
import collections
#sys.setrecursionlimit(100000)


n=int(input())

tmp = input().split()
d = list(map(lambda a: int(a), tmp))

max=0
numlist={}
for i in range(0,n):
	if(d[i]>max):
		max=d[i]
	if(d[i] in numlist):
		numlist[d[i]]+=1
	else:
		numlist[d[i]]=1


if(d[0]!=0):
	print(0)
	sys.exit()
for i in range(max):
	if not(i in numlist):
		print(0)
		sys.exit()
if(numlist[0]!=1):
	print(0)
	sys.exit()


ans=1
for i in range(1,max):
	#print(numlist[i])
	ans=ans*numlist[i]**numlist[i+1]

print(ans % 998244353)

Measured memory_bytes: 23788
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,1);
  //約数の個数＝素数1の出現回数+1 * 素数2の出現回数+1 * ・・・
  //素数の出現回数を保持
  var list = new Array(input+1).fill(0);
  var mod = 1000000007;
  for(var i = 1; i <= input; i++){
    if(i == 1){
      list[1] = 1; continue;
    }else{
      var tmp = i;
      for(var j = 2; j <= tmp;){
        if(tmp % j == 0){
           list[j]++;
          tmp /= j;
        }else{
          j++;
        }
      }
    }
  }
  var output = 1;
  for(var i = 2; i < list.length; i++){
    if(list[i] != 0){
       output = output * (list[i]+1) % mod;
    }
  }
  //myout(list);
  myout(output);
}

Main(myin());


Measured memory_bytes: 9420
N, M = map(int, input().split())
Ls = []
Rs = []
for i in range(M):
  L, R = map(int, input().split())
  Ls.append(L)
  Rs.append(R)
Lmax = max(Ls)
Rmin = min(Rs)
r = 0 if Rmin<Lmax else Rmin-Lmax+1
print(r)


Measured memory_bytes: 11028
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

const int maxN = 2e5+5;
char ins[maxN];
int dp[maxN][2];
int len;

int getMaxSizeAt(int x, int y){
    if((x < 0 && x >= maxN)
    || (y < 0 && y >= 2)) {
        return 0;
    }
    return dp[x][y];
}

int main(){
#ifdef LS_DEBUG
    freopen("in", "r", stdin);
#endif
    scanf("%s", ins);
    len = strlen(ins);

    for(int idx = 0; idx < len; ++idx){
        dp[idx][0] = getMaxSizeAt(idx-1, 1)+1;
        if(idx >= 1 && ins[idx] != ins[idx-1]){
            dp[idx][0] = max(getMaxSizeAt(idx,0), getMaxSizeAt(idx-1,0)+1);
        }
        if(idx<1){
            dp[idx][1] = 0;
        }
        else{
            dp[idx][1] = getMaxSizeAt(idx-2,0)+1;
            if(idx>=3 && (ins[idx] != ins[idx-2]
            || ins[idx-1] != ins[idx-3])){
                dp[idx][1] = max(getMaxSizeAt(idx,1), getMaxSizeAt(idx-2,1)+1);
            }
        }
    }

#ifdef LS_DEBUG
    for(int idx = 0; idx < len; ++idx){
        printf("%d %d\n", dp[idx][0], dp[idx][1]);
    }
#endif

    printf("%d\n", max(dp[len-1][0], dp[len-1][1]));
    return 0;
}

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

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		int M  = keyboard.nextInt();
		
		 int[] L = new int[M];
		 int[] R = new int[M];
		
		for(int i = 0; i < M ; i++) {
			L[i] = keyboard.nextInt();
			R[i] = keyboard.nextInt();
		}
		
		int min = L[0];
		int MAX = R[0];
		int ans = 0;
		
		for(int m = 0; m < M; m++) {
			
			if(min <= L[m]) {
				min = L[m];
			}
			if(MAX >= R[m]) {
				MAX = R[m];
			}
		}
		
		ans = MAX - min + 1;
		ans = Math.max(ans, 0);
		
		System.out.println(ans);
		keyboard.close();	
	}
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    string s;cin >> s;
    lint k;cin >> k;
    char pre=' ';
    lint count=0;
    lint ans=0;
    //s += s[0];

    if(SZ(s)==1){
        ans = k / 2;
        cout << ans << "\n";
        return 0;
    }
    int leftcount = 0, rightcount = 0;
    if(s[0]==s[SZ(s)-1]){
        REP(i,SZ(s)){
            if(s[i]==s[0]){
                leftcount += 1;
            }else{
                break;
            }
        }
        IREP(i, SZ(s))
        {
            if (s[i] == s[0])
            {
                rightcount += 1;
            }
            else
            {
                break;
            }
        }
        /*
        if(rightcount==1||leftcount%2==0){
            s=s.substr(1,SZ(s)-1);
            cout << s << "\n";
        }else{
            s=s.substr(0,SZ(s)-1);
            cout << s << "\n";
        }
        */
        lint sum = leftcount + rightcount;
        if(sum==SZ(s)*2){
            ans=SZ(s) * k / 2;
            cout << ans << "\n";
            return 0;
        }else{
            ans += (leftcount + rightcount) / 2;
            s = s.substr(leftcount, SZ(s) - leftcount - rightcount);
            //cout << s << "\n";
            //cout << sum/2 <<"\n"<<(sum/2 +1)*k << "\n";
        }
    }

    REP(i,SZ(s)){
        if(pre==s[i]){
            count += 1;//連続した数の個数
            if(i!=SZ(s)&&s[i]==s[i+1]){
                //ans += 1;
            }else{
                ans += (count+1)/2;
                count = 0;
            }
        }else{
            
        }
        pre = s[i];
    }

    cout << ans*k -((leftcount%2)*(rightcount%2))<<"\n";

    return 0;
}

Measured memory_bytes: 256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
T = ri_()
M = ri()
wa = sum(T)
for _ in range(M):
    P, X = ri_()
    ans = wa + X - T[P - 1]
    print(ans)

Measured memory_bytes: 9064
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

struct Box {
	int count = 1;
	bool red = false;
};
Box b[100010];
int main()
{
	int N;
	int A[100010];
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans += A[i] / 2;
		A[i] %= 2;
		ans += min(A[i], A[i + 1]);
		A[i + 1] -= min(A[i], A[i + 1]);
	}
	ans += A[N - 1] / 2;
	cout << ans << endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <iostream>
using namespace std;
long long dp[101][21] = { 0 };
int main() {
	int n;
	scanf("%d", &n);
	int  math[101] = { 0 };
	for (int i = 1;i <= n;++i) {
		scanf("%d", &math[i]);


	}
	dp[1][math[1]] = 1;
	for (int i = 1;i <= n;++i) {
		for (int q = 0;q <= 20;++q) {
			if (q + math[i] <= 20)dp[i][q + math[i]] += dp[i-1][q];
			if (q - math[i] >= 0) dp[i][q - math[i]] += dp[i - 1][q];
		}
	}
	printf("%lld\n", dp[n-1][math[n]]);
	return 0;
}


Measured memory_bytes: 1204
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,0,a.size()){
        cin>>a[i];
    }
    int ss = 0;
    int cnt = 1;
    rep(i,0,a.size()){
        ss += a[i];
        if ( ss <= x ){
            cnt++;
        }
        else
        {
            break;
        }
    }
    cout<<cnt<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


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


    int n, k, c;
    string s;
    cin>>n>>k>>c>>s;
    vector<int> nxo(n+1,n), maxdays(n+1,0), pos(n+1,0);
    for (int i = n-1; i >= 0; i--){
        if (s[i]=='o'){
            nxo[i] = i;
            maxdays[i] = 1;
            if (i+c+1<n) maxdays[i] += maxdays[nxo[i+c+1]];
        }
        else nxo[i] = nxo[i+1];
    }
    
    int i = 0, p = 1;
    while ((i<n) && (s[i]=='x')) i++;

    while (i<n){
        pos[i] = p;
        p++;
        if (i+c+1<n) i = nxo[i+c+1];
        else i = n;
    }

    for (int i = 0; i < n; i++){
        if ((pos[i]!=0) && (pos[i]-1+maxdays[nxo[i+1]]<k)){
            cout<<i+1<<"\n";
        }
    }

    return 0;
    
}



Measured memory_bytes: 4244
def a(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N=int(input())
L=a(N)
#N=r(m+1)
ans=0
for i in L:
  if (N//i)-1>i:
    ans+=(N//i)-1
print(ans)

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;


int main(){
    int64_t x, a = 100, ans = 0;
    double b;
    cin >> x;

    while(a < x){
        ans++;
        b = (double)a * 1.01;
        a = (int64_t)b;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    var minSum = Int.MAX_VALUE
    for (a in 1 until n) {
        val b = n - a
        val sum = sum(a) + sum(b)
        if (sum < minSum) {
            minSum = sum
        }
    }
    println(minSum)
}

private fun sum(n: Int): Int {
    var sum = 0
    var v = n
    while (v > 0) {
        sum += v % 10
        v /= 10
    }
    return sum
}

Measured memory_bytes: 31868
# coding: utf-8
# Your code here!
num = int(input())
s = list(map(int,input().split()))
res = 1
for i in s:
    res *= i
    if res >= 10 ** 18:
        break

if 0 in s:
    print(0)
elif res <= 10 ** 18:    
    print(res)
else:
    print(-1)
    

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

ll a[10], x, ans;
int main()
{
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6];                    
	
	x = 0;
	if(x <= a[0] && x <= a[3] && x <= a[4])
		ans = max(ans, (a[0] - x) / 2 * 2 + a[1] + (a[3] - x) / 2 * 2 + (a[4] - x) / 2 * 2 + x * 3);
	
	x = 1;
	if(x <= a[0] && x <= a[3] && x <= a[4])
		ans = max(ans, (a[0] - x) / 2 * 2 + a[1] + (a[3] - x) / 2 * 2 + (a[4] - x) / 2 * 2 + x * 3);
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
def main():
    k = int(input())
    A = [0 for i in range(k)]
    m = 7%k
    M = 7%k
    cnt = 1
    while  True:
        if A[m] != 0:
            print(-1)
            return
        else:
            if m==0:
                print(cnt)
                return
            else:
                cnt += 1
                A[m] = 1
                M = M*10 % k
                m = (M+m) % k

if __name__ == "__main__":
    main()


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define mod 1000000007

int main()
{

    ll n,t, l,r,ans=0;
    cin >> n >> t;
    vector<ll> v;
    for(ll i=0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    l = 0, r=t;
    for(ll i=1; i < v.size(); i++)
    {

        ll cl=v[i], cr=v[i]+t;
        if(cl > r)
        {

            ans+=(r-l);
            l=cl, r=cr;
        }
        else if(cr <= r) continue;
        else r=cr;
    }
    ans+=(r-l);
    cout << ans;
}


Measured memory_bytes: 2420
// AOJ 2105: Rhythm Machine
// 2018.1.2 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct { int a, b, s; } T;
T tbl[1024*8]; int sz;
int ans[1025];
char buf[2050], *p;

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

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

int main()
{
	int cno, n, i, j, s, g, len;

	fgets(buf, 10, stdin), cno = atoi(buf);
	while (cno--) {
		fgets(buf, 10, stdin), n = atoi(buf);
		sz = 0;
		for (i = 0; i < n; i++) {
			fgets(p=buf, 2050, stdin);
			len = strlen(p) >> 1;
			for (j = 0; *p >= ' '; j++) {
				s = *p++ & 0xf;
				s = (s<<4) + (*p++ & 0xf);
				if (s) {
					if (j == 0) tbl[sz].a = 0, tbl[sz].b = 1;
					else {
						g = gcd(j, len);
						tbl[sz].a = j/g, tbl[sz].b = len/g;
					}
					tbl[sz++].s = s;
				}
			}
		}

		if (sz == 0) { puts("00"); goto done; }
		g = 1;
		for (i = 0; i < sz; i++) {
			g = lcm(g, tbl[i].b);
			if (g > 1024) { puts("Too complex."); goto done; }
		}

		memset(ans, 0, sizeof(ans));
		for (i = 0; i < sz; i++) {
			j = tbl[i].a * g / tbl[i].b;
			ans[j] |= tbl[i].s;
		}
		for (i = 0; i < g; i++) printf("%02X", ans[i]);
		putchar('\n');
done:;
	}
	return 0;
}


Measured memory_bytes: 1768
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int cnt = 1;
  if(b != a){
    cnt++;
  }
  if(c != a && c != b){
    cnt++;
  }
  printf("%d",cnt);
  return 0;
}

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

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<ll> a(3 * N);

  for (int i{}; i < 3 * N; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<int>());

  ll ans{};
  for (int i{0}; i < N; ++i) {
    ans += a[i * 2 + 1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5612
#include <iostream>

using namespace std;

unsigned long int lcm(unsigned long int C, unsigned long int D)
{
  unsigned long int remain;
  unsigned long int x = C * D;
  if(C < D)
  {
    remain = C;
    C = D;
    D = remain;
  }
  remain = C % D;
  while(remain != 0)
  {
    C = D;
    D = remain;
    remain = C % D;
  }
  return x/D;
}

unsigned long int howmany(unsigned long int A, unsigned long int B, unsigned long int C)
{
  return ((B/C) - ((A-1)/C));
}

int main(void)
{
  unsigned long int A, B, C, D;
  cin >> A >> B >> C >> D;
  unsigned long int CD = lcm(C, D);
  cout << (B-A+1) - (howmany(A, B, C) + howmany(A, B, D) - howmany(A, B, CD));

  return 0;
}


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

class Dice{
public:
	int face[6];
	Dice(int a, int b, int c, int d, int e, int f){
		face[0] = a;
		face[1] = b;
		face[2] = c;
		face[3] = d;
		face[4] = e;
		face[5] = f;
	}

	void move(char dire){
		int t;
		if (dire == 'E'){
			t = face[0];
			face[0] = face[3];
			face[3] = face[5];
			face[5] = face[2];
			face[2] = t;
		}
		if (dire == 'W'){
			t = face[0];
			face[0] = face[2];
			face[2] = face[5];
			face[5] = face[3];
			face[3] = t;
		}
		if (dire == 'N'){
			t = face[0];
			face[0] = face[1];
			face[1] = face[5];
			face[5] = face[4];
			face[4] = t;
		}
		if (dire == 'S'){
			t = face[0];
			face[0] = face[4];
			face[4] = face[5];
			face[5] = face[1];
			face[1] = t;
		}
		if (dire == 'T'){
			t = face[1];
			face[1] = face[2];
			face[2] = face[4];
			face[4] = face[3];
			face[3] = t;
		}
	}

};

int main(){
	int a0, b0, c0, d0, e0, f0;
	cin >> a0 >> b0 >> c0 >> d0 >> e0 >> f0;
	
	string st = "TTTTSTTTTSTTTTSTTTTSETTTTWWTTTT";

	int n, p, q;
	cin >> n;

	for (int j = 0; j < n; j++){
		Dice dice1(a0, b0, c0, d0, e0, f0);
		cin >> p >> q;
		for (int i = 0; i < st.size(); i++){
			char di = st[i];
			dice1.move(di);
			if (dice1.face[0] == p && dice1.face[1] == q){
				cout << dice1.face[2] << endl;
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3144
#include<stdio.h>
#include<algorithm>
using namespace std;
int t[110][110];
int main(){
    int a,b,c;scanf("%d%d%d",&a,&b,&c);
    for(int i=0;i<c;i++){
        int p,q,r;scanf("%d%d%d",&p,&q,&r);
        if(r==1){
            for(int j=0;j<p;j++)for(int k=0;k<b;k++)t[j][k]=1;
        }
        if(r==2){
            for(int j=p;j<a;j++)for(int k=0;k<b;k++)t[j][k]=1;
        }
        if(r==3){
            for(int j=0;j<a;j++)for(int k=0;k<q;k++)t[j][k]=1;
        }
        if(r==4){
            for(int j=0;j<a;j++)for(int k=q;k<b;k++)t[j][k]=1;
        }
    }
    
    int ret=0;
    for(int i=0;i<a;i++)for(int j=0;j<b;j++)if(t[i][j]==0)ret++;
    printf("%d\n",ret);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = s[0];
            long k = s[1];
            long q = s[2];

            if (k>q)
            {
                for (int i = 0; i < n; i++)
                {
                    WriteLine("Yes");
                }
                return;
            }


            long[] pt = new long[n];
            for (int i = 0; i < n; i++)
            {
                pt[i] = 0;
            }


            for (int i = 0; i < q; i++)
            {
                int input = int.Parse(ReadLine());
                pt[input-1]++;
            }

            for (int i = 0; i < n; i++)
            {
                if (pt[i] > q - k)
                {
                    WriteLine("Yes");
                }
                else WriteLine("No");
            }

        }
    }
}



Measured memory_bytes: 18272
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	n = I()
	top = LI()
	under = LI()
	candy = 0

	if n == 1:
		print(sum(top) + sum(under))
	else:
		for i in range(1,n):
			candy = max(candy,sum(top[:i])+sum(under[i-1:]))
		print(candy)

if __name__ == '__main__':
	main()

Measured memory_bytes: 3828
#include <stdio.h>
   
int main(void){   
    int n, b;
    int S[14], H[14], C[14], D[14];
    int i;
    char a;
     
    for(i=0; i<13; i++){
        S[i] = 0;
        H[i] = 0;
        C[i] = 0;
        D[i] = 0;
    }
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%*c%c %d", &a, &b);
        if(a == 'S') S[b] = 1;
        else if(a == 'H') H[b] = 1;
        else if(a == 'C') C[b] = 1;
        else if(a == 'D') D[b] = 1;
    }
    for(i=1; i<=13; i++) if(S[i] != 1)  printf("S %d\n", i);
 	for(i=1; i<=13; i++) if(H[i] != 1) printf("H %d\n", i);
  	for(i=1; i<=13; i++) if(C[i] != 1)  printf("C %d\n", i);
 	for(i=1; i<=13; i++) if(D[i] != 1) printf("D %d\n", i);
    return 0;
}


Measured memory_bytes: 2048
//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 P=1e9+7,inv3=333333336;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e6+5;
int inv[N],bin[N],n,res,now;
int main(){
	scanf("%d",&n);
	inv[0]=bin[0]=inv[1]=1,bin[1]=inv3;
	fp(i,2,n+1){
		inv[i]=mul(P-P/i,inv[P%i]);
		bin[i]=mul(bin[i-1],inv3);
	}
	R int ret=1;
	fp(i,1,n-1){
		upd(now,inv[n-i+1]);
		upd(res,mul(bin[i],mul(now,2)));
		upd(ret,P-mul(bin[i],2));
	}
//	printf("%d %d %d\n",res,ksm(6,P-2),ret);
	upd(now,1);
	upd(res,mul(ret,now));
	res=mul(res,inv[n]);
	res=mul(res,inv3);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>
#include <iomanip>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	for (int c[3]; cin >> c[0] >> c[1] >> c[2]; ) {
		int sum = c[0] + c[1];
		vi left;
		rep (i, 10) {
			bool flg = true;
			rep (j, 3) if (c[j] == i + 1) flg = false;
			if (flg) left.pb(i + 1);
		}
		int safe = 0;
		rep(i, 7) if (sum + left[i] <= 20) safe++;
		if(safe * 100 / 7 >= 50) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#Coding:Utf-8

N,Q=input().split()
S=input()
S= S.replace("AC","Ac")


def judge(x):
  if x=="c":
    return 1
  else:
    return 0


t=[]
t.append(0)

for i in range(1,int(N)):
  t.append(t[i-1]+judge(S[i]))

for j in range(int(Q)):
  a,b=list(map(int, input().split()))
  print(t[b-1]-t[a-1])

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

int main() {

int a,b;
double ag,bg;
cin >> a >> b;
for (int i = 0; i < 10500; i++) {
  ag = i*0.08;
  bg = i*0.1;
  if((int)ag==a&&(int)bg==b){
    cout << i << endl;
    return 0;
    }
  }
  cout << -1 << endl;

}


Measured memory_bytes: 256
N,X,Y = map(int,(input().split()))
cn = [[] for _ in range(N+1)]
for i in range(1,N+1):
    if i-1 >= 1:
        cn[i].append(i-1)
    if i+1 <= N:
        cn[i].append(i+1)
    if i == X:
        cn[X].append(Y)
    if i == Y:
        cn[Y].append(X)

result = {}

for i in range(1,N+1):

    dis = [0]*(N+1)

    not_visit = [True]*(N+1) 
    stack = [i]
    not_visit[i] = False

    while stack:
        now = stack.pop(0)
        for j in cn[now]:
            if not_visit[j]:
                not_visit[j] = False
                stack.append(j)
                dis[j] = dis[now] + 1

    for i in range (0,len(dis)):
        item = dis[i]
        if item in result:
            result[item] = result[item]+1
        else:
            result[item] = 1

for i in range(1,N):
    if i in result:
        print(result[i]//2)
    else:
        print(0)

Measured memory_bytes: 50396
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int N = (int) 2e5 + 100;

int a[N];
int sl[N], sr[N];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n;
    scanf("%d", &n);

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

    vector <int> st;
    st.push_back(0);
    
    for (int i = 1; i <= n; i++)
    {
        while (a[i] < a[st.back()])
            st.pop_back();
        sl[i] = st.back();
        st.push_back(i);
    }

    st.clear();
    st.push_back(n + 1);

    for (int i = n; i >= 1; i--)
    {
        while (a[i] < a[st.back()])
            st.pop_back();
        sr[i] = st.back();
        st.push_back(i);
    }

    long long ans = 0;
    for (int i = 1; i <= n; i++)
    {
        //eprintf("[%d, %d, %d] %d\n", sl[i], i, sr[i], a[i]);
        ans += (sr[i] - i) * 1LL * (i - sl[i]) * 1LL * a[i];
    }

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

	return 0;
}




Measured memory_bytes: 3448
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	k := scanInt()
	s := scanString()
	n := len(s) + k

	combInit(n)

	ans := 0
	for i := 0; i < n; i++ {
		if i < len(s)-1 {
			continue
		}
		ans += comb(i, len(s)-1) * mpow(25, i-len(s)+1) % mod * mpow(26, n-i-1) % mod
		ans %= mod
	}

	fmt.Fprintln(wr, ans)
}

const mod = 1000000007

var fac, ifac, inv []int

func combInit(n int) {
	fac = make([]int, n+1)
	ifac = make([]int, n+1)
	inv = make([]int, n+1)

	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[1] = 1

	for i := 1; i < n; i++ {
		fac[i+1] = fac[i] * (i + 1) % mod
		inv[i+1] = mod - inv[mod%(i+1)]*(mod/(i+1))%mod
		ifac[i+1] = ifac[i] * inv[i+1] % mod
	}
}

func comb(a, b int) int { return (fac[a] * ifac[b] % mod) * ifac[a-b] % mod }
func perm(a, b int) int { return fac[a] * ifac[a-b] % mod }

func mpow(a, n int) int {
	res := 1
	for n > 0 {
		if n&1 == 1 {
			res = res * a % mod
		}
		a = a * a % mod
		n >>= 1
	}
	return res
}


Measured memory_bytes: 53572
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
vector<vector<pair<int, int> > > v;
int colour[maxn];
void dfs(int node, int pre, int t)
{
	int ct=1;
	for(auto i: v[node])
	{
		int next=i.fi;
		if(next==pre)
			continue;
		if(ct==t)
			++ct;
		colour[i.se]=ct;
		dfs(next,node,ct);
		++ct;
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,k=0,x=0,y=0;
    cin>>n;
    v.resize(n);
    for(int i=0;i+1<n;++i)
    {
    	cin>>x>>y;
    	--x;--y;
    	v[x].pb({y,i});
    	v[y].pb({x,i});
    	k=max({k,(int)v[x].size(),(int)v[y].size()});
    }
    cout<<k<<endl;
    dfs(0,-1,-1);
    for(int i=0;i+1<n;++i)
    {
    	cout<<colour[i]<<endl;
    }
}

Measured memory_bytes: 8320
using System;
namespace MyConsoleAppBulletinBoard
{    
 //
 // Bulletin Board
 //
 class Program
        {
            static void Main(string[] args)
            {
            //
            // 入力
            //
            // 整数の入力
            int n = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());
            int w = int.Parse(Console.ReadLine());

            int count_h;
            int count_w;
            //
            count_h = n - h + 1;
            count_w = n - w + 1;
            //
            // 出力
            //
            Console.WriteLine(count_h*count_w);
            }
        }
    }


Measured memory_bytes: 13140
#include<cstdio>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main(){
  int n,q; scanf("%d %d",&n,&q);
  unordered_map<int, int> v;
  for(int i=0;i<n;i++) v[i]=i;
  for(int i=0;i<q;i++){
    int com,x,y; scanf("%d %d %d",&com,&x,&y);
    for(;;)
      if(x==v[x]) break;
      else x=v[x];
    for(;;)
      if(y==v[y]) break;
      else y=v[y];
    if(com){
      printf("%d\n", v[x]==v[y]?1:0);
    } else{
      if(x>y) swap(x,y);
      if(v[x]>v[y])
	v[x]=v[y];
      else{
	int tmp=x;
	for(;;){
	  if(tmp==v[tmp]){
	    v[y]=tmp;
	    break;
	  }
	  else{
	    tmp=v[tmp];
	  }
	}
      }
    }
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <ctype.h>

using namespace std;

int main() {

	string a;
	char A;

	for (int i = 0; i < 3; i++) {
		cin >> a;
		A = toupper(a[0]);
		cout << A;
	}

	cout << endl;

	return 0;
}



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

int main(void){
    int a, b;
    std::cin >> a >> b;
    for(int i = 1; i < 10001; i++){
        if( floor(i*0.08) == a && floor(i * 0.10) == b){
            std::cout << i << std::endl;
            break;
        }else if(i == 10000){
            std::cout << -1 << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
# Code for A - We Love Golf
# Use input() to fetch data from STDIN
import sys
n = int(input())
[a, b] = [int(x) for x in input().split()]

for x in range(1000):
    s = x * n
    if b >= s and a <= s:
        print("OK")
        sys.exit()

print("NG")


Measured memory_bytes: 9172
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def func(A, B, bit_len):
    if bit_len == 1:
        return [A, B]
    X = A ^ B
    for i in range(bit_len):
        if (X >> i) & 0x01 >= 1:
            break
    del_bit = i
    A_prime = ((A >> (del_bit + 1)) << del_bit) + (A & ((2 ** del_bit) - 1))
    B_prime = ((B >> (del_bit + 1)) << del_bit) + (B & ((2 ** del_bit) - 1))
    C = A_prime ^ 0x01
    retA = func(A_prime, C, bit_len - 1)
    retB = func(C, B_prime, bit_len - 1)
    ret = [0 for i in range(len(retA) + len(retB))]
    for i in range(len(retA)):
        ret[i] = (retA[i] & ((2 ** del_bit) - 1)) + (A & (2 ** del_bit)) + ((retA[i] & (~((2 ** del_bit) - 1))) << 1)
    for i in range(len(retB)):
        ret[len(retA) + i] = (retB[i] & ((2 ** del_bit) - 1)) + (B & (2 ** del_bit)) + ((retB[i] & (~((2 ** del_bit) - 1))) << 1)

    return ret




def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B] = [int(input_raw[0]), long(input_raw[1]), long(input_raw[2])]
    countA = 0
    countB = 0
    for i in range(N):
        countA += (A >> i) & 0x01
    for i in range(N):
        countB += (B >> i) & 0x01
    if countA % 2 == countB % 2:
        print "NO"
        return
    ret = func(A, B, N)
    print "YES"
    for i in range(len(ret)):
        print ret[i],
    print

##    data_list = [0 for i in range(2 ** N)]
##    data_list[0] = A
##    pre_i = 0L
##    X = A
##    gray = [v ^ (v >> 1L) for v  in range(2 ** N)]
##    print gray
##
##    B_idx = 0
##    already = set([X])
##    for i in range(1L, 2L**N):
##        X = X ^ ((gray[i] ^ gray[i-1]))
##        if X in already:
##            print "NO"
##            return
##        already.add(X)
##        data_list[i] = X
##        if X== B:
##            B_idx = i
##    Z = data_list[B_idx - 1] ^ data_list[2 ** N - 1]
##
##    count = 0
##    for i in range(N + 1):
##        count += (Z >> i) & 0x01
##    if count != 1:
##        Z = data_list[B_idx - 1] ^ data_list[2 ** N - 3]
##        count2 = 0
##        for i in range(N + 1):
##            count2 += (Z >> i) & 0x01
##        if count2 != 1:
##            print "NO"
##            return
##        else:
##            tmp = data_list[2 ** N - 3]
##            data_list[2 ** N - 3] = data_list[2 ** N - 1]
##            data_list[2 ** N - 1] = tmp
##
##    print "YES"
##    for i in range(B_idx):
##        print data_list[i],
##    for i in range(2 ** N - 1, B_idx - 1, -1):
##        print data_list[i],
##
##    print

if __name__ == '__main__':
    main()


Measured memory_bytes: 137500
N, M, V, P = map(int, input().split())
*A, = map(int, input().split())
A.sort(reverse=True)

ans = P
s = A[P-1]
for i in range(P, N):
    if A[i]+M>=A[P-1]:
        a = V-(N-i+P-1)
        ans += (a*M<=(i-P+1)*(A[i]+M)-s)
        s += A[i]

print(ans)


Measured memory_bytes: 14964
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 21:05:16 2019

@author: doppe
"""
count = [0, 0, 0, 0]

for i in range (0, 3):
    a, b = map(int, input().split())
    count[a - 1] += 1
    count[b - 1] += 1
flag = 0
for i in count:
    if(i >= 3):
        flag = 1
        break
if (flag == 1):
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}

vector<vector<int>> v(100010);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string s;
    cin>>s;
    if(s=="ABC")cout << "ARC\n";
    else cout << "ABC\n";
}

Measured memory_bytes: 5440
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll A,B;
  cin>>A>>B;
  ll gcd;
  for(ll i=1;i<=min(A,B);i++) {
    if(A%i==0&&B%i==0) {
gcd=i;
    }
  }
  
  cout<<gcd*(A/gcd)*(B/gcd)<<endl;
}

  
  
  
  

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);

    for(int i=0;i < n;i++)
    {
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }//input

    int dp[n+1][3];//どこで何を選ぶか

    for(int k=0;k < 3;k++)
    {
        dp[0][k]=0;
    }//初期条件

    for(int i=1;i <= n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+b.at(i-1),dp[i-1][2]+c.at(i-1));    
        dp[i][1]=max(dp[i-1][0]+a.at(i-1),dp[i-1][2]+c.at(i-1));
        dp[i][2]=max(dp[i-1][0]+a.at(i-1),dp[i-1][1]+b.at(i-1));
    }

    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        long k = Long.parseLong(sc.next());

        char c[] = s.toCharArray();

        char cs = '1';

        for(int i = 0; i < k; i++){
            if(c[i] != '1'){
                cs = c[i];
                break;
            }
        }

        System.out.println(cs);

        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Y;
  cin >> N>>Y;
  int a = -1,b=-1,c=-1;
  for(int i=0; i<=N;i++){
    for(int j=0;i+j<=N;j++){
      int k = N-i-j;
      int total = 10000*i + 5000 *j +1000*k;
      if(total == Y){
        a = i;
        b = j;
        c = k;
      }
    }
  }
  cout << a <<" " << b <<" "<<c<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int si=s.size();
  if(s[0]!='A'){
    cout<<"WA"<<'\n';
    return(0);
  }
  int fg=0;
  REP(i,2,si-1){
    if(s[i]=='C'){
      if(fg!=0){
        cout<<"WA"<<'\n';
        return(0);
      }
      fg=i;
    }
  }
  if(fg==0){
    cout<<"WA"<<'\n';
    return(0);
  }
  rep(i,si){
    if(i==0 || i==fg){
      continue;
    }
    bool flag=false;
    if(isupper(s[i])){
      cout<<"WA"<<'\n';
      return(0);
    }
  }
  cout<<"AC"<<'\n';
  return(0);
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    { 
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long a = s[0];
            long b = s[1];
            long x = s[2];
            WriteLine(func(b,x) - func(a-1,x));
            
        }

        static long func(long n ,long x)
        {
            if (n >= 0)
            {
                return n / x + 1;
            }
            else return 0;
        }
    }
}


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

const int mod = 1e9 + 7;
const long long INF = 1LL<<60;
using ll = long long;
using P = pair<int,int>;

// https://qiita.com/1natsu172/items/b951aa33451dad36bd7c
// atcoddr-cli用
// [URL]/tasks_print
// acc new  
// cd 
// cd 
// code -n main.cpp

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

    int n = s.size();

    if (n %2 == 1){
        cout << "No" << endl;
        return 0;
    }

     // n is even
    for (int i = 0; i < n-1; i += 2){
        if (s[i] == 'h' && s[i+1] == 'i'){
            continue;
        }
        else{
        cout << "No" << endl;
        return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
failflag=0
m=[]
for i in range(x):
  m.append(input())
for i in range(x):
  for j in range(y):
    if m[i][j]=='#':
      if i<x-1 and j>0:
        if m[i+1][j-1]=='#':
          failflag=1
if failflag==0:
  print('Possible')
else:
  print('Impossible')

Measured memory_bytes: 61920
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
ll a,v,b,w,t;
cin >> a >> v >> b >> w >> t;

ll x = abs(b-a);
ll y = v-w;
if(y*t < x) cout << "NO" << endl;
else cout << "YES" << endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x <= k-x) {
            ans += x*2;
        } else {
            ans += (k-x)*2;
        }
    }
    cout << ans << endl;
}


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

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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll AB = A + B;

    ll cnt = N / AB;
    ll res = N % AB;
    cout << cnt * A + min(A, res) << endl;
}


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

ac = 0
wa = 0
tle = 0
re = 0

for _ in range(count):
    i = input()
    if i == 'AC':
        ac += 1
    if i == 'WA':
        wa += 1
    if i == 'TLE':
        tle += 1
    if i =='RE':
        re += 1

print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
    std::vector<int> v(3);
    REP(i, 3) cin >> v[i];
    sort(v.begin(), v.end());
    if(v[0] == v[1] && v[1] == v[2]) cout << "1" << endl;
    else if(v[0] != v[1] && v[1] != v[2]) cout << "3" << endl;
    else cout << "2" << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {

    var n = input;
    var ans = 1;

    for( i = 1; i <= n; i = i * 2) {
        ans = i;
    }

    console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 11468