akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    int cnt  = 0;
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b; a--; b--;
        if(!uf.findSet(a, b)){
            uf.unionSet(a, b);
            cnt++;
        }
    }
    cout << (N-1)-cnt << endl;
}

Measured memory_bytes: 3728
from collections import deque

n = int(input())
graph = [[0]]
for _ in range(n):
    u, k, *v = map(int, input().split())
    graph.append(v)

queue = deque([1])
ans = [-1 for _ in range(n + 1)]
ans[1] = 0
while queue:
    cur = queue.popleft()
    for next in graph[cur]:
        if ans[next] != -1:
            continue
        ans[next] = ans[cur] + 1
        queue.append(next)
for i in range(1, n + 1):
    print(i, ans[i])


Measured memory_bytes: 6036
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

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

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}



vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	int n ; 
	cin >> n ; 
 	int N = 1e6 ; 
 	vt<bool> primes(N) ; 
 	vt<bool> vis(N);
 	primes[1] = 0 ; 
 	rep(i,2,N) {
 		if(!vis[i]) {
 			primes[i] = 1 ; 
 			if(i >= n) {
 				cout << i ; 
 				return 0 ; 
 			}
 			for(int j = i ; j < N ; j+= i) {
 				vis[j] = 1 ; 
 			}
 		}
 	}

	return 0 ; 
}

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

int ri() {
    int n;
    scanf("%d", &n);
    return n;
}
std::vector<std::vector<std::pair<int, int> > > hen;
std::vector<int> res;
void dfs(int i, int prev, int prev_color) {
	int cnt = 0;
	for (auto j : hen[i]) {
		if (j.first == prev) continue;
		if (cnt == prev_color) cnt++;
		res[j.second] = cnt;
		dfs(j.first, i, cnt++);
	}
}
int main() {
	int n = ri();
	hen.resize(n);
	for (int i = 0; i + 1 < n; i++) {
		int a = ri() - 1;
		int b = ri() - 1;
		hen[a].push_back({b, i});
		hen[b].push_back({a, i});
	}
	res.resize(n - 1);
	dfs(0, -1, -1);
	int k = *std::max_element(res.begin(), res.end()) + 1;
	std::cout << k << std::endl;
	for (int i = 0; i + 1 < n; i++) std::cout << res[i] + 1 << std::endl;
	
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int n;
    cin >> n;
    cout << n + (n * n) + (n * n * n);
    
    return 0;
}

Measured memory_bytes: 3608
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);

    ll i,j,h;

    vector<int> aa;
    
   ll N;

   cin >> N;


   if(N%1000==0){
       cout << 0<<endl;
   }else{
    cout<< 1000-N%1000 <<endl;
   }
    return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//mod計算用のクラス
class ModInt{
public:
    long long int x;
    long long int mod;
	ModInt(){}
    ModInt(long long int _x, long long int _mod = 1000000007){
        this->x = _x % _mod;
        this->mod = _mod;
    }
	ModInt operator+(ModInt other){
		return ModInt(this->x + (other.x % this->mod),this->mod);
	}
	ModInt operator-(ModInt other){
		long long int res = this->x - (other.x % this->mod);
		if (res < 0) return ModInt(res + this->mod, this->mod);
		return ModInt(res);
	}
	ModInt operator*(ModInt other){
		return ModInt(this->x * (other.x % this->mod),this->mod);
	}
	ModInt operator/(ModInt other){
		return ModInt(*this * other.inv());
	}
	ModInt pow(long long int n){
		ModInt res(1, this->mod), a(this->x, this->mod);
		while (n){
			if (n & 1){
				res = res * a;
			}
			n >>= 1;
			a = a * a;
		}
		return res;
	}
	ModInt inv(){
		return ModInt(this->pow(this->mod - 2));
	}
	void disp(){
		cout << this->x << endl;
	}
};
ostream& operator<<(ostream& stream, const ModInt m){
	stream << to_string(m.x);
	return stream;
}

//mod nCrを返す関数.何回も計算するときはこっち.ModIntが必要.
class modcomb{
	public:
		vector<ModInt> fact;
		vector<ModInt> ifact;
		modcomb(){}
		modcomb(int n){
			this->fact.resize(n + 1, ModInt(1));
			this->ifact.resize(n + 1, ModInt(1));
			for (int i = 1; i <= n;i++)
				this->fact[i] = this->fact[i - 1] * i;
			this->ifact[n] = fact[n].inv();
			for (int i = n; i >= 1; --i)
				this->ifact[i - 1] = ifact[i] * i;
		}
		ModInt operator()(int n, int k){
			if (k < 0 || k > n)
				return 0;
			return this->fact[n] * this->ifact[k] * this->ifact[n - k];
		}
};

int main()
{
	int n, k;
	cin >> n >> k;
	vector<long long int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	ModInt max_(0);
	ModInt min_(0);
	modcomb c(n + 1);
	rep(i, n)
	{
		max_ = max_ + (ModInt(a[i]) * c(i, k - 1));
		min_ = min_ + (ModInt(a[i]) * c(n - 1 - i, k - 1));
	}
	cout << max_ - min_ << endl;

	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag,                    //if using ll change int to ll
        tree_order_statistics_node_update> pbset;
#define fob(x) find_by_order(x)
#define ook(x) order_of_key(x)
int main()

{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	string s;  ll l, r; l = 0; r = 0; vector<pair<int, pair<int, int>>> v1, v2;
	vector<int> ans, ans1;
	for (int i = 1; i <= n; i++)
	{
		cin >> s; int a = 0; int b = 0; //cout << s << endl;
		for (int j = 0; j < s.size(); j++)
		{

			if (s[j] == '(')
				a++;
			else
			{
				if (a == 0)
					b++;
				else
					a--;
			}
		}
		if (a == 0 && b == 0)
		{
			ans.pb(i);
		}
		else if (a == 0)
		{
			r += b;
			ans1.pb(i);
		}
		else if (b == 0)
		{
			l += a; ans.pb(i);
		}
		else
		{
			if (a >= b)
			{
				v1.pb(mk(b, mk(a, i)));
			}
			else
			{
				v2.pb(mk(a, mk(b, i)));
			}
		}
	}

	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	int flag = 0;
	for (int i = 0; i < v1.size(); i++)
	{
		int b = v1[i].ff;
		int a = v1[i].ss.ff;
		ans.pb(v1[i].ss.ss);
		l -= b;
		if (l < 0)
		{
			flag = 1; break;
		}
		l += a;
	}
	if (flag == 1)
	{
		cout << "No" << endl; return 0;
	}
	for (int i = v2.size() - 1; i >= 0; i--)
	{
		int a = v2[i].ff;
		int b = v2[i].ss.ff;
		ans.pb(v2[i].ss.ss);
		l -= b;
		if (l < 0)
		{
			flag = 1; break;
		}
		l += a;
	}

	if (flag == 1 || l != r)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
		
	}
	return 0;
}


Measured memory_bytes: 7396
from collections import Counter
N = int(input())
A = list(map(int, input().split())) 
ans = set(A)
for k, v in Counter(A).items():
    if v != 1:
        ans.discard(k)
    temp = {k*i for i in range(2,10**6//k + 1)}
    ans -= ans&temp
print(len(ans))

Measured memory_bytes: 136700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const ll mod = 5*1e15;
int T, n, cnt[maxn];
int main() {
    string s;
    ll k;
    cin >> s >> k;
    for(auto ch : s) {
        if(ch == '1') k--;
        else {
            cout << ch << endl;
            return 0;
        }
        if(k <= 0) {
            cout << ch << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int a,b,c,x,y;
  int ans = 500000005;
  int minans = 500000005;

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

  ans = a*x + b*y;
  minans = ans;
  int mx = min(x, y);

  //
  for(int i = 0; i <= mx; i++) {
    int aa = i * a;
    int bb = i * b;
    if(mx > x){
      aa = x * a;
    }
    if(mx > y){
      bb = y * b;
    }
    ans = a*x + b*y;
    ans = ans - aa - bb + c*2*i;
    minans = min(ans, minans);
  }
  //cだけで良い場合
  ans = max(x, y)*c*2;
  minans = min(ans, minans);

  cout << minans << endl;
}


Measured memory_bytes: 3632
import sys

input = sys.stdin.readline

def LcpByZ(target):
    len_t = len(target)
    lcp = [-1] * len_t
    top = 1  # 右の箱において、左の箱の0に対応する点
    right = 0  # 左の箱の右端
    lcp[0] = 0
    while top < len_t:
        # 箱を右に広げていく
        while top + right < len_t and target[right] == target[top + right]:
            right += 1
        # 右の箱左端のlcpを記録
        lcp[top] = right
        left = 1
        # 左端＝右端だったらtopを動かして、このターン終了
        if right == 0:
            top += 1
            continue
        # lcpを記録しながら箱を左に縮めていく（最初の条件重要）
        while left + lcp[left] < right and left < right:
            lcp[top + left] = lcp[left]
            left += 1
        # topを右の箱の左端にして、左の箱を0まで戻す
        top += left
        right -= left
    return max(min(i,x) for i,x in enumerate(lcp))

def main():
    n = int(input())
    s = input()[:-1]
    ans = 0
    for i in range(n):
        ans = max(ans, LcpByZ(s[i:]))
    print(ans)

main()


Measured memory_bytes: 56028
#include <iostream>
using namespace std;
int main(){
    long long int a,b;
    cin>>a>>b;
    long long int  ans;
    ans = a+b;
    if(ans<a-b){
        ans = a-b;
    }
    if(ans<a*b){
        ans = a*b;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception{
        
        Scanner sc = new Scanner(System.in);
  
        long n;
        long m;

         n = sc.nextLong();
      m = sc.nextLong();
       
      if(m>n){
        long k= Math.abs(m-n);
        if(k>=n){
          System.out.println(n);
        }
        else{
          System.out.println(k);
        }
      }else if(m==n){
         System.out.println(0);
      } else {
    	  if(m==0) {
    		  System.out.println(n);
    	  }else {
        long l = n/m;
        long rem = n%m;
        long x = Math.abs(rem-m);
         if(x>=rem){
          System.out.println(rem);
        }
        else{
          System.out.println(x);
        }
    	  }
      }
          
          
          
       
       
        
  }
}
        


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k; cin >> n >> k;
	vector<int>x(n);
	rep(i, n)cin >> x[i];

	int sum = 0;
	for (int i = 0; i < n; i++) {
		int nl = x[i] * 2;
		int ml = (k - x[i]) * 2;
		sum = sum + min(nl, ml);
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;

	int n = (int)s.length();
	int apos = -1;
	int zpos = -1;

	for (int i = 0; i < n; ++i){
		if (s[i] == 'A'){
			apos = i;
			break;
		} // end if
	} // end for

	for (int i = n - 1; i >= 0; --i){
		if (s[i] == 'Z'){
			zpos = i;
			break;
		} // end if
	} // end for

	string res = s.substr(apos, zpos - apos + 1);
//	cerr << res << endl;
	cout << (int)res.length() << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define INF 1e9

int N;
string S;

int ssW[maxn];
int ssR[maxn];

int main(){
	fast;
	
	cin>>N>>S;
	S = " " + S;
	
	FOR(i,1,N) ssW[i] = ssW[i-1] + (S[i] == 'W');
	DEC(i,N,1) ssR[i] = ssR[i+1] + (S[i] == 'R');
	
	if (ssW[N] == 0 || ssR[1] == 0){
		cout<<0;
		return 0;
	}
	int ans = INF;
	FOR(i,1,N){
		ans = min(ans, min(ssW[i-1], ssR[i]) + ssR[i] + ssW[i-1] - 2 * min(ssW[i-1], ssR[i]));
		//cout<<i<<' '<<min(ssW[i-1], ssR[i]) + ssR[i] + ssW[i-1] - 2 * min(ssW[i-1], ssR[i])<<'\n';
	}
	cout<<ans;
		
	
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  bool yes = false;
  const ll Y = B - A;
  for (ll p = 0; p <= N-1; p++) {
    ll m = N - 1 - p;
    if (p*C-m*D <= Y && Y <= p*D-m*C) {
      yes = true;
    }
  }
  cout << (yes?"YES":"NO") << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
def main():
    s = input()
    t = input()
    si = 0
    ti = 0
    sm = dict()
    tm = dict()
    ans = True
    for i in range(len(s)):
        sidx = 0
        if s[i] in sm:
            sidx = sm[s[i]]
        else:
            sidx = si
            sm[s[i]] = si
            si += 1

        tidx = 0
        if t[i] in tm:
            tidx = tm[t[i]]
        else:
            tidx = ti
            tm[t[i]] = ti
            ti += 1
        
        if sidx != tidx:
            ans = False
            break
    
    yn = "Yes" if ans else "No"
    print(yn)


            

if __name__ == '__main__':
    main()

Measured memory_bytes: 3632
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    count = 0

    for j in range(1, n+1):
        for y in range(j+1, n+1):
            for z in range(y+1, n+1):
                if j + y + z == x:
                    count += 1

    print(count)



Measured memory_bytes: 5596
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};


int main(){
  ll n;cin>>n;
  n%=10;
  if(n==3){
    cout<<"bon"<<endl;
  }
  else if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    int n;
    cin>>n;
    while(n>0){
        string a,b;
        cin>>a>>b;
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        if(b.size()>a.size()){
            swap(a,b);
        }
        int keta=0;
        int ans[200];
        rep(i,n)ans[i]=0;
        int kuri=0;
        for(int i=0;i<b.size();i++){
            keta++;
            int aa=a[i]-'0';int bb=b[i]-'0';
            ans[i]=(aa+bb+kuri)%10;
            kuri=(aa+bb+kuri)/10;
        }
        for(int i=b.size();i<=200&&i<a.size();i++){
            keta++;
            int aa=a[i]-'0';
            ans[i]=(kuri+aa)%10;
            kuri=(aa+kuri)/10;
            
        }
        if(kuri!=0){
            ans[keta]=1;
            keta++;
        }
        if(keta>=81){
            cout<<"overflow"<<endl;
        }else{
            for(int i=keta-1;i>=0;i--){
                cout<<ans[i];
            }
            cout<<endl;
        }
    n--;
    }
    
    return 0;
}



Measured memory_bytes: 3156
#include<stdio.h>
int main()
{
	int d;
	scanf("%d", &d);
	int c[30];
	int i;
	for (i = 0; i < 26; i++)
		scanf("%d", &c[i]);
	int j;
	int s[400][30];
	for (i = 0; i < d; i++)
		for (j = 0; j < 26; j++)
			scanf("%d", &s[i][j]);
	int ans;
	for (i = 0; i < d; i++)
	{
		ans = 0;
		for (j = 0; j < 26; j++)
			if (s[i][j] > s[i][ans])
				ans = j;
		printf("%d\n", ans + 1);
	}
	return 0;
}

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

int solve(int n, vector<int> const &a, vector<int> const &b, vector<int> const &c)
{
    vector<vector<int> > dp(3,vector<int>(n,0));
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    for(int i=1 ; i<n ; ++i)
    {
        dp[0][i]=max(dp[1][i-1]+a[i],dp[2][i-1]+a[i]);
        dp[1][i]=max(dp[0][i-1]+b[i],dp[2][i-1]+b[i]);
        dp[2][i]=max(dp[0][i-1]+c[i],dp[1][i-1]+c[i]);
    }
    return max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int> a(n), b(n), c(n);
    for(int i=0 ; i<n ; ++i)
    cin>>a[i]>>b[i]>>c[i];
    cout<<solve(n,a,b,c)<<endl;
    return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define MOD 1000000007
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define OTP(s) cout<<s<<endl;
#define FOR(i,j,k,l) for(int i=j;i<k;i+=l)
#define REP(i,j) FOR(i,0,j,1)
inline ll add(ll a, ll b){a += b; if(a >= MOD)a -= MOD; return a;}
inline ll sub(ll a, ll b){a -= b; if(a < 0)a += MOD; return a;}
inline ll mul(ll a, ll b){return (ll)((ll) a * b %MOD);}
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

ll min(ll a,ll b)
{
    return a>b?b:a;
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}

ll n,w;
ll dp[200][100001];
ll we[200],v[200];

int main()
{
    IOS
    cin>>n>>w;
    REP(i,n)
    {
        cin>>we[i+1]>>v[i+1];
    }

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if(we[i]>j)
            {
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-we[i]]);
            }
        }
    }
    // REP(i,n+1)
    // {
    //     REP(j,w+1)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[n][w]<<endl;
    
}

Measured memory_bytes: 80128
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;

int main(){
  int i;
  int n;
  map<string, int> p;
  cin >> n;
  int num;
  string name;
  map<string, int>::iterator it;
  for(i = 0; i < n; i++){
    cin >> name >> num;
    if(p.find(name) != p.end()) p[name] += num;
    else p[name] = num;
  }

  for(i=1; i<=5; i++){
    it = p.begin();
    while( it != p.end()){
      if(it->first.size() == i){
	cout <<it->first << " " << it->second << endl;
      }
      it++;
    }
  }
  return 0;
}

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

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

  int card[4][13] = {};
  for(int i=0;i<n;i++){
    string suit;
  int num;
  cin>>suit>>num;

  if(suit == "S") card[0][num-1] = 1;
  if(suit == "H") card[1][num-1] = 1;
  if(suit == "C") card[2][num-1] = 1;
  if(suit == "D") card[3][num-1] = 1;
}

string str[4] = {"S", "H", "C", "D"};
for(int i=0;i<4;i++){
  for(int j=0;j<13;j++){
    if(card[i][j] == 1) continue;
    cout<<str[i]<<" "<<j+1<<endl;
  }
 }

return 0;

}



Measured memory_bytes: 3140
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int button[100000];
    for(int i=0;i<n;i++){
        cin >>button[i];
        button[i]--;
    }
    int current=0;
    int count=0;//1;
    while(button[current]!=1){
        int prev=current;
        current=button[current];
        count++;
        button[prev]=-1;
        if(button[current]==-1){
            count=-2;
            break;
        }
    }
    count++;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"

)

func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func()
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx++
		return cur
	}
	this.initWordIdx = func() {
		idx = 0
	}
	return &this
}

func (me *ReaderEx) ScanAndSplit() (isScanned bool) {
	isScanned = me.baseScanner.Scan()

	me.words = strings.Fields(me.baseScanner.Text())
	me.initWordIdx()
	return
}

func (me *ReaderEx) Scan() (ok bool) {
	ok = me.baseScanner.Scan()
	return
}
func (me *ReaderEx) getString() string {
	return me.baseScanner.Text()
}

func (me *ReaderEx) getInt() int {
	n, err := strconv.Atoi(me.baseScanner.Text())
	defer func() {
		if err != nil {
			panic(err)
		}
	}()

	return n
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, fa)
		}
	}
	if n > 1 {
		facts = append(facts, factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func solve(stdin io.Reader, stdout io.Writer) {
	r := NewScannerEx(stdin)
	r.Scan()
	r.getInt()
	r.ScanAndSplit()
	a := r.nextStringArray().toInts()
	for i := range a {
		a[i] -= i + 1
	}
	sort.Sort(sort.IntSlice(a))

	x := a[len(a)/2]
	s := 0
	for _, ai := range a {
		s += abs(x - ai)
	}
	fmt.Fprintln(stdout, s)
}



Measured memory_bytes: 9600
# 初期入力
import sys
input = sys.stdin.readline
W,H,x,y = (int(x) for x in input().split())
ans1 =0
ans2 =0
if W/2 ==x and H/2 ==y:
    ans2= 1
else:
    ans2 =0
ans1 =W *H/2
print(ans1,ans2)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

double N, D, X;
double ans;

int main() {
	register int i;
	scanf("%lf%lf%lf", &N, &D, &X);
	for(i = 1; i <= N; ++i)
		ans += 1.0L / (i + 1);
	printf("%.19lf\n", ans * (N + 1) * (D + X * (2 * N - 1) / 2));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main(){
    bool check=true;
    while(check){
        int H,W;
        cin >> H >> W;
        if(H*W != 0){
            rep(i,H){
                rep(j,W){
                    if(i==0 || i==H-1 || j==0 || j==W-1){
                        cout << '#';
                    }
                    else{
                        cout << '.';
                    }
                }
                cout << endl;
            }
            cout << endl;
        }
        else{
            check = false;
        }
    }
}


Measured memory_bytes: 3004
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <queue>

using namespace std;

template <typename T> void chkmax (T &x, T y) {x = x > y ? x : y;}
template <typename T> void chkmin (T &x, T y) {x = x > y ? y : x;}

typedef long long ll;

const int INF = 2139062143;

#define DEBUG(x) std::cerr << #x << " = " << x << std::endl

template <typename T> void read (T &x) {
    x = 0; bool f = 1; char ch;
    do {ch = getchar(); if (ch == '-') f = 0;} while (ch > '9' || ch < '0');
    do {x = x * 10 + ch - '0'; ch = getchar();} while (ch >= '0' && ch <= '9');
    x = f ? x : -x;
}

template <typename T> void write (T x) {
    if (x < 0) x = ~x + 1, putchar ('-');
    if (x > 9) write (x / 10);
    putchar (x % 10 + '0');
}


int a, b;

int main () {
	read (a); read (b);
	if (a % b == 0) write (a / b);
	else write (a / b + 1);
	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int INF = 1 << 27;

//////////////////////////////
// ?????????(Dinic)
//
const int MAX_V = 101;
class Edge{
  public:
    int to, cap, rev;
    Edge(int _to, int _cap, int _rev){ to = _to; cap = _cap; rev = _rev; }
};
vector<Edge> G[MAX_V];
int level[MAX_V], iter[MAX_V];
void add_edge(int from, int to, int cap){
  G[from].push_back(Edge(to, cap, G[to].size()));
  G[to].push_back(Edge(from, 0, G[from].size() - 1));
}
void bfs(int s){
  memset(level, -1, sizeof(level));
  queue<int> q;
  level[s] = 0;
  q.push(s);
  while(!q.empty()){
    int v = q.front(); q.pop();
    REP(i, G[v].size()){
      Edge &e = G[v][i];
      if(e.cap > 0 && level[e.to] < 0){
        level[e.to] = level[v] + 1;
        q.push(e.to);
} } } }
int dfs(int v, int t, int f){
  if(v == t) return f;
  for(int &i = iter[v]; i < G[v].size(); ++i){
    Edge &e = G[v][i];
    if(e.cap > 0 && level[v] < level[e.to]){
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
  } } }
  return 0;
}
int max_flow(int s, int t){
  int flow = 0;
  while(true){
    bfs(s);
    if (level[t] < 0) return flow;
    memset(iter, 0, sizeof(iter));
    int f;
    while((f = dfs(s, t, INF)) > 0)
      flow += f;
  }
}

int main() {
	int v, n; cin >> v >> n;
	while(n--) {
		int a,b,c; cin >> a >> b >> c;
		add_edge(a, b, c);
	}
	cout << max_flow(0, v-1) << endl;


	return 0;
}

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

int main() {

	int sec;
	int hour, minute, second;

	cin >> sec;

	hour = sec / 3600;
	minute = (sec % 3600) / 60;
	second = (sec % 3600) % 60;

	cout << hour << ":" << minute << ":" << second << endl;

	return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >>b >> c;
    if(
        (a == 5 && b == 7 && c == 5)||
        (a == 5 && b == 5 && c == 7)||
        (a == 7 && b == 5 && c == 5)
        ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
#include <cstdio>

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

	char mark[n];
	int rank[n];

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

	int buff_S[13] = {0}, buff_H[13] = {0}, buff_C[13] = {0}, buff_D[13] = {0};

	for(int i = 0; i < n; i++){

		if (mark[i] == 'S'){

			for(int j = 1; j <= 13; j++){

				if(rank[i] == j) buff_S[j - 1] = 1;
			}
		}

		else if (mark[i] == 'H'){

			for(int j = 1; j <= 13; j++){

				if(rank[i] == j) buff_H[j - 1] = 1;
			}
		}

		else if (mark[i] == 'C'){

			for(int j = 1; j <= 13; j++){

				if(rank[i] == j) buff_C[j - 1] = 1;
			}
		}

		else if (mark[i] == 'D'){

			for(int j = 1; j <= 13; j++){

				if(rank[i] == j) buff_D[j - 1] = 1;
			}
		}
	}

	for(int i = 0; i < 13; i++){
		if (buff_S[i] == 0) printf("S %d\n", i + 1);
	}
	for(int i = 0; i < 13; i++){
		if (buff_H[i] == 0) printf("H %d\n", i + 1);
	}
	for(int i = 0; i < 13; i++){
		if (buff_C[i] == 0) printf("C %d\n", i + 1);
	}
	for(int i = 0; i < 13; i++){
		if (buff_D[i] == 0) printf("D %d\n", i + 1);	
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {

    string S;
    cin >> S;

    bool res = true;

    REP(i,S.size())
    {
        if(i % 2 == 0)
        {
            cout <<S[i];
        }
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 512
n,k = map(int, input().split())
if n==1 or n==2:
    if k==1:
        print('YES')
    else:
        print('NO')
elif n%2==0:
    cnt = n/2
    if(cnt>=k):
        print('YES')
    else:
        print('NO')
else:
    cnt = n//2 + 1
    if(cnt>=k):
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<P> Vp; typedef map<int,int> MP; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

  Int n,k,ans=1e18; cin>>n>>k; Int a[2*n],b[n][n]; 
  for (int i = 0; i < n; i++){cin>>a[i]; a[i+n]=a[i];}
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if(j)b[i][j]=min(b[i][j-1],a[i+n-j]);
      else b[i][j]=a[i];
    }
  }
  for (int i = 0; i < n; i++){
    Int an=i*k;
    for (int j = 0; j < n; j++){
      an+=b[j][i];
    }
    cmin(ans,an);
  }
  END
}

Measured memory_bytes: 31488
import Control.Monad                                                                                                       
import Data.List                                                                                                           
import Data.Maybe                                                                                                          
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- readLn                                                                                                              
  ss <- map (\x -> (head x,length x)) . group . sort <$> replicateM n getLine                                              
  m <- readLn                                                                                                              
  ts <- map (\x -> (head x,length x)) . group . sort <$> replicateM m getLine                                              
  print $ maximum . map (\(x,y) -> max 0 (y - (fromMaybe 0 . lookup x) ts)) $ ss

Measured memory_bytes: 636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int result = 0;
        if(x<600){
            result = 8;
        }else if(x<800){
            result = 7;
        }else if(x<1000){
            result = 6;
        }else if(x<1200){
            result = 5;
        }else if(x<1400){
            result = 4;
        }else if(x<1600){
            result = 3;
        }else if(x<1800){
            result = 2;
        }else if(x<2000){
            result = 1;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 35716
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int a[N][4],dp[N][4];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=3;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			for(int k=1;k<=3;k++)
			{
				if(j==k)
					continue;
				dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	printf("%d\n",max(dp[n][1],max(dp[n][2],dp[n][3])));
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <functional>
#include <ctime>
#include <iomanip>
#include <sstream>
#include <algorithm>
#define ll long long
#define ull unsigned long long
#define dd double
#define mes(x,y) memset(x,y,sizeof(x))\

const ll maxn=1e5+10;
using namespace std;
ll GCD(ll a,ll b) {//最大公约数
    return b == 0 ? a : GCD(b, a % b);
}
int main() {
    std::ios::sync_with_stdio(false);
    ll n,x,y;
    while(cin>>n>>x>>y){
        ll minn=min(x*n,y);
        cout<<minn<<endl;
    }
}

Measured memory_bytes: 256
H,W = map(int,input().split())
S = [input() for i in range(H)]

dp = [[-1]*W for i in range(H)]
if S[0][0] == "#":
    dp[0][0] = 1
else:
    dp[0][0] = 0
    
for w in range(1,W):
    if S[0][w] == "#" and S[0][w-1] == ".":
        dp[0][w] = dp[0][w-1] + 1
    else:
        dp[0][w] = dp[0][w-1]
        
for h in range(1,H):
    if S[h][0] == "#" and S[h-1][0] == ".":
        dp[h][0] = dp[h-1][0] + 1
    else:
        dp[h][0] = dp[h-1][0]
        
for h in range(1,H):
    for w in range(1,W):
        if S[h][w] == "#" and S[h][w-1] == ".":
            dw = dp[h][w-1] + 1
        else:
            dw = dp[h][w-1]
            
        if S[h][w] == "#" and S[h-1][w] == ".":
            dh = dp[h-1][w] + 1
        else:
            dh = dp[h-1][w]
            
        dp[h][w] = min(dw,dh)
        
print(dp[-1][-1])

Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

void dfs(const string &present_str, int N)
{
  // 現在の頂点が葉かどうか
  if (present_str.size() == N) {
    cout << present_str << endl;
    return;
  }
  else {
    char max_character;
    for (auto &&i : present_str) {
      max_character = max(max_character, i);
    }
    for (char i = 'a'; i <= max_character + 1; i++) {
      dfs(present_str + i, N);
    }
  }

  return;
}

int main()
{
  int N;

  cin >> N;

  dfs("a", N);

  return 0;
}


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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 105;

int n;
double a[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];

    double sum=0.0;
    for(int i=1;i<=n;i++){
        sum+=(double)1.0/a[i];
    }

    cout<<fixed<<setprecision(9)<<(double)1.0/sum;

    return 0;
}


Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
import math
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
from collections import deque
inf = 10 ** 15
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
preoya = 1
arieruoya = [0 for i in range(n+1)]
for i in range(n):
    arieruoya[i] = preoya
    l = a[i]
    if l > preoya*2-1:
        print(-1)
        sys.exit()
    preoya = min((preoya-l)*2,10**13)
if a[n] > preoya:
    print(-1)
    sys.exit()
arieruoya[n] = 0

a.reverse()
premax = a[0]
premin = (a[0]+1)//2
ans=premax
for i in range(1,n+1):
    l = a[i]
    premax = min(arieruoya[n-i], premax+l)
    ans+=premax
print(ans)

Measured memory_bytes: 95836
import java.util.Scanner;

public class Main {
	
	
	void main() {
		try(Scanner sc = new Scanner(System.in)) {
            for(;;) {
            	int x = sc.nextInt();
            	int y = sc.nextInt();
            	if(y == 0 && x == 0) break;
            	
            	System.out.println(Math.min(x,  y) + " " + Math.max(x,  y));
            }
        }
	}
	
	public static void main(String[] args) {
	    new Main().main();
	}

}


Measured memory_bytes: 35872
# -*- coding: utf-8 -*-
# モジュールのインポート
import statistics

# 標準入力を取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
A = [A[i] - (i + 1) for i in range(N)]
b = statistics.median_high(A)
ans = sum([abs(A[i] - b) for i in range(N)])

# 結果出力
print(ans)


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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	int n;
	cin >> n;
	unordered_set<int> s;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		s.insert(x);
	}
	cout << (int)s.size();
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,k,ans,a[1000010],b[1000010];
int main()
{
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=1; i<=m; i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
    }
    for(int i=0; i<=n; i++)
    {
        if(a[i]>k)
            break;
        while(m>0&&b[m]+a[i]>k)
            m--;
        ans=max(ans,i+m);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> p(n),q(n),v(n);
	REP(i,n) cin >> p[i];
	REP(i,n) cin >> q[i];
	REP(i,n) v[i] = i+1;
	int a,b;
	int cnt=1;
	do {
		if(p==v) a=cnt;
		if(q==v) b=cnt;
		cnt++;
  	} while(next_permutation(ALL(v)));
	cout << abs(a-b) << '\n';
	return 0;
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll x; cin >> x;
	cout << (x >= 30 ? "Yes" : "No") << endl;

}



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

using namespace std;

string s;
int n, r, k;

int main() {
	cin >> n >> s;
	for (auto c : s) r += (c == 'W');
	for (int i = 1; i <= r; i++) 
		k += (s[n - i] == 'R');
	cout << k << endl;

	return 0; 
}	

Measured memory_bytes: 3748
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto N = RD;
	auto M = RD;

	long m = -1;
	if (N % 2 == 0)
		m = N / 2;
	long l = 1, r = N;
	foreach (i; 0..M)
	{
		debug writeln(r-l, ":", N-(r-l) - (r-l));
		if (m != -1)
		{
			if (m == r-l || (N-(r-l) - (r-l) == 2))
			{
				++l;
			}
		}
		writeln(l, " ", r);
		++l;
		--r;
	}

	stdout.flush;
	debug readln;
}

Measured memory_bytes: 2748
/*
❤️❤️❤️I_love_QMsh❤️❤️❤️
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // <int> .find_by_order(int) .order_of_key(int)

template<typename T> bool smin(T &a, const T &b) { bool ret = b < a; return a = (ret ? b : a), ret; }
template<typename T> bool smax(T &a, const T &b) { bool ret = a < b; return a = (ret ? b : a), ret; }

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

mt19937 rnd;

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int h, w, n;
  cin >> h >> w >> n;
  map<pair<int, int>, int> mp;

  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    for (int d1 = max(x - 2, 1); d1 <= min(x, h - 2); d1++) {
      for (int d2 = max(y - 2, 1); d2 <= min(y, w - 2); d2++) {
        mp[{d1, d2}]++;
      }
    }
  }

  int sum = 0;
  vector<ll> ans(10);
  for (auto &i : mp) {
    ans[i.y]++;
    sum++;
  }
  ans[0] = 1ll * (h - 2) * (w - 2) - sum;
  for (ll i : ans) {
    cout << i << "\n";
  }

  return 0;
}

Measured memory_bytes: 59828
#include<cstdio> 
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;

char ss[210000];
int L[210000],R[210000];
int main()
{
	int n;
	scanf("%d%s",&n,ss+1);
	for(int i=1;i<=n;i++)
	{
		L[i]=L[i-1];
		if(ss[i]=='#')L[i]++;
	}
	for(int i=n;i>=1;i--)
	{
		R[i]=R[i+1];
		if(ss[i]=='.')R[i]++;
	}
	int ans=(1<<30);
	for(int i=1;i<=n;i++)
	{
		if(ss[i]=='#')
		{
			ans=min(ans,L[i-1]+R[i]);
		}
		else
		{
			ans=min(ans,L[i]+R[i+1]);
		}
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 2048
n = int(input())
h = list(map(int,input().split()))
count = 0
c = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        c += 1
    else:
        count = max(count,c)
        c = 0
count = max(count,c)
print(count)

Measured memory_bytes: 14224