akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
 	ll n,ct=0;cin>>n;
 	ll a[n],b[n];for(ll i=0;i<n+1;i++) cin>>a[i];
 	for(ll i=0;i<n;i++) cin>>b[i];
 	for(ll i=0;i<n;i++)
 	{
 		if(a[i]>=b[i]) ct+=b[i];
 		else
 		{
 			ct+=a[i];b[i]-=a[i];
			ct+= min(a[i+1],b[i]);
 			a[i+1]-=min(a[i+1],b[i]);
		 }
	 }
	 cout<<ct;
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n + 1), b(n);
  rep(i, n + 1) cin >> a[i];
  rep(i, n) cin >> b[i];
  ll ans = 0;
  rep(i, n) {
    ll kill = min(a[i], b[i]);
    a[i] -= kill;
    b[i] -= kill;
    ans += kill;
    if (b[i] > 0) {
      ll kill2 = min(a[i + 1], b[i]);
      a[i + 1] -= kill2;
      ans += kill2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
class Combination:
    '''MOD上の
    計算量：階乗・逆元テーブルの作成O(N)
    nCkを求めるO(1)'''

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i], MOD - 2, MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


n, k = list(map(int, input().split()))
MOD = 10 ** 9 + 7
comb = Combination(5 * 10 ** 5 + 10, MOD)

ans = 0

# 0の個数で場合分けする
for cnt_0 in range(0, min(n, k + 1)):
    ball = n
    box = n - cnt_0
    tmp = comb.combination(ball - 1, box - 1)
    tmp *= comb.combination(n, cnt_0)
    ans += tmp
    ans %= MOD

print(ans)


Measured memory_bytes: 81120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  long long ma=0;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  vector<int> s(0);
  for(int a=0;a<=min(k,n);a++){
    for(int b=0;a+b<=min(k,n);b++){
      s.clear();
      for(int i=0;i<a;i++){
        s.push_back(v[i]);
      }
      for(int j=0;j<b;j++){
        s.push_back(v[n-1-j]);
      }
      sort(s.begin(),s.end());
      int x=0;
      while((a+b+x)<k&&x<s.size()){
        if(s[x]<0){
        s[x]=0;
        x++;
        }
        else break;
      }
      long long sum=0;
      for(int l=0;l<s.size();l++){
        sum+=(long long)s[l];
      }
      ma=max(ma,sum);
    }
  }
  cout<<ma<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    if (100 <= n && n <= 111)
        cout << 111 << endl;
    else if (112 <= n && n <= 222)
        cout << 222 << endl;
    else if (223 <= n && n <= 333)
        cout << 333 << endl;
    else if (334 <= n && n <= 444)
        cout << 444 << endl;
    else if (445 <= n && n <= 555)
        cout << 555 << endl;
    else if (556 <= n && n <= 666)
        cout << 666 << endl;
    else if (667 <= n && n <= 777)
        cout << 777 << endl;
    else if (778 <= n && n <= 888)
        cout << 888 << endl;
    else if (889 <= n && n <= 999)
        cout << 999 << endl;
    return 0;
}

Measured memory_bytes: 256
alpha_dict = {}
id_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  alpha_dict[chr(c)] = i + 1
  id_dict[i+1] = chr(c)

N = int(input())
S = list(input())
T = []
for s in S:
  n = alpha_dict[s]
  n += N
  if n > 26:
    n -= 26
  T += [id_dict[n]]
print("".join(T))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ll N;  cin>>N;
    string S;   cin>>S;
    vector<ll> countW(N,0);
    vector<ll> countE(N,0);
    for(int i=1;i<N;i++){   //左にあるWの数を累積和
        if(S[i-1]=='W'){
            countW[i]=countW[i-1]+1;
        }
        else{
            countW[i]=countW[i-1];
        }
    }
    for(int i=N-2;i>=0;i--){
        if(S[i+1]=='E'){
            countE[i]=countE[i+1]+1;
        }
        else{
            countE[i]=countE[i+1];
        }
    }
    ll ans=99999999;
    for(int i=0;i<N;i++){
        ans=min(ans,countW[i]+countE[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5380
import java.util.Arrays;
import java.util.Scanner;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int a[]=new int[3];
a[0]=sc.nextInt();
a[1]=sc.nextInt();
a[2]=sc.nextInt();    
Arrays.sort(a);
System.out.println(a[0]==a[1] ?a[2]:a[0]);
    }
}
  


Measured memory_bytes: 21844
n = gets.to_i
s, t = gets.chomp.split(' ').map{ |i| i.split('') }
r = ''
(0...(2 * n)).each do |i|
  if i % 2 == 0
    r += s[i / 2]
  else
    r += t[i / 2]
  end
end
puts r

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

static const double PI = 3.14159265358979;

int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  
  H *= 60;
  
  double angle = abs((H + M) / 720 - M / 60);
  //cout << (H + M) / 720;
  if (angle < 0.5) angle = 1 - angle;
  //cout << angle;
  angle = angle * 2 * PI;

  
  double edge1 = sin(angle) * A;
  double edge2 = B - cos(angle) * A;
  
  double edge3 = sqrt(edge1 * edge1 + edge2 * edge2);
  
  cout << setprecision(13) << edge3;
  
  return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    ll n, k;
    ll ans = 1e17;
    cin >> n >> k;
    vector<ll> neg, pos;
    for(int i = 0, a; i < n; i++){
        cin >> a;
        if(a <= 0)
            neg.push_back(a);
        else
            pos.push_back(a);
    }
    reverse(neg.begin(), neg.end());
    if(neg.size() == 0)
        cout << pos[--k];
    else if(pos.size() == 0)
        cout << -1 * neg[--k];
    else{
        if(pos.size() >= k)
            ans = pos[k - 1];
        if(neg.size() >= k)
            ans = min(ans, -1 * neg[k - 1]);
        for(int i = 0; i < neg.size(); i++) {
            if((k - (i + 1) - 1 < pos.size()) && (k - (i + 1) - 1 >= 0)){
                ll cur = neg[i] * -1 * 2;
                cur += pos[k - (i + 1) - 1];
                ans = min(ans, cur);
            }
        }
        for(int i = 0; i < pos.size(); i++){
            if((k - (i + 1) - 1 < neg.size()) && (k - (i + 1) - 1 >= 0)){
                ll cur = pos[i] * 2;
                cur += -1 * neg[k - (i + 1) - 1];
             //   cout << pos[i] << " " << neg[k - (i + 1) - 1] << endl;
                ans = min(ans, cur);
            }
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 1656
#include<iostream>

using namespace std;

int main(){
  int i,j,a,b,k=0;
  
  cin>>a>>b;
  for(i=1;i<=1000;i=i*10){
    if(b/i<=0&&b%i!=0)
      break;
  }
  j=a*i+b;
  
  for(i=1;i<j;i++){
    if(i==j/i&&j%i==0){
      k++;
      break;
    }
  }
  
  cout<<(k>0?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(N)]

cnt = [0]*M

for i in range(N):
    K = List[i][0]
    for j in range(1, K+1):
        cnt[List[i][j]-1]+=1

print(cnt.count(N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    vector<ll> A(n);
    map<ll,ll> m;
    rep(i,n){
        ll a;cin>>a;
        A[i]=a;
        m[a]++;
    }
    ll ans = 0;
    for(pair<ll,ll> p:m){
        ans += p.second*(p.second-1)/2;
    }
    rep(i,n){
        ll sec = m[A[i]];
        cout<<ans-sec*(sec-1)/2+(sec-1)*(sec-2)/2<<endl;
    }
    return 0;
}

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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
/***** MAIN *****/
signed main() {
  int n = in();
  map<int, int> b_count;
  REP(i,n-1) {
    int tmp = in();
    ++b_count[tmp];
  }
  REPS(i,1,n+1) {
    cout << b_count[i] << "\n";
  }
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 16136
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

const int W_MAX = 20;

int H, W;
int h, w;

void solve() {
  int ans = 0;
  ans = (H - h) * (W - w);
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &H, &W);
  scanf("%d%d", &h, &w);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String s = sc.next();
        s = s.substring(s.length() - 1);
        if(s.equals("3")){
        	System.out.println("bon");
        }else if(s.equals("0") || s.equals("1") || s.equals("6") || s.equals("8")){
        	System.out.println("pon");
        }else{
        	System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35548
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a,b;
	cin>>a>>b;
	double x=(a+b)/2*10;
	int an=(int)x;
	int l=an%10; 
	if(l<5)
	an=an-l;
	else
	an=an-l+10;
	double ans=an/10;
	cout<<ans;  
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N,K,X,Y;

void solve(){
    if(N >= K)
        cout << K*X + (N-K)*Y << endl;
    else
        cout << N*X << endl;
}

int main(){
    cin >> N >> K >> X >> Y;

    solve();
}


Measured memory_bytes: 256
//ó¯æélªå«¢ÌÅ¶ÆµÄó¯æé
#include<stdio.h>

int main(void){
	char c,a[200],b[200],ans[200],dummy;
	int N,ia[200],ib[200],ians[200],Acnt=0,Bcnt=0,cnt;
	int i,j,z;
	
	for(i=0;i<200;i++){
		ia[i]=0;
		ib[i]=0;
		ians[i]=0;
		
	}
	scanf("%d",&N);
	scanf("%c",&dummy);
	
	for(z=0;z<N;z++){
		//üÍ
		for(i=0;i<200;i++){
			scanf("%c",&c);
			if(c=='\n'){
				a[i]='\0';
				break;
			}
			else{
				a[i]=c;
				Acnt++;
			}
		}
		for(i=0;i<200;i++){
			scanf("%c",&c);
			if(c=='\n'){
				b[i]='\0';
				break;
			}
			else{
				b[i]=c;
				Bcnt++;
			}
		}
		
		//í¹
		if(Acnt>Bcnt){
			cnt=Acnt;
			for(i=0;i<Acnt-Bcnt;i++){
				for(j=Bcnt+i;j>=0;j--)
					b[j+1]=b[j];
				b[0]='0';
			}
		}
		else if(Acnt<Bcnt){
			cnt=Bcnt;
			for(i=0;i<Bcnt-Acnt;i++){
				for(j=Acnt+i;j>=0;j--)
					a[j+1]=a[j];
				a[0]='0';
			}
		}
		else
			cnt=Acnt;
		
		//¶ðlÉÏ·
		for(i=0;i<cnt;i++){
			ia[i]=(int)(a[i]-'0');
			ib[i]=(int)(b[i]-'0');
		}
		
		//vZ
		for(i=cnt;i>=0;i--){
			ians[i]+=ia[i]+ib[i];
			if(ians[i]>=10){
				ians[i]%=10;
				if(i==0){
					for(j=cnt;j>=0;j--)
						ians[j+1]=ians[j];
					ians[0]=1;
					cnt++;
				}
				else
					ians[i-1]++;
			}
		}
		if(cnt>80){
			printf("overflow\n");
			for(i=0;i<200;i++){
			ia[i]=0;
			ib[i]=0;
			ians[i]=0;
			}
			Acnt=0;
			Bcnt=0;
			continue;
		}
		
		//vZµ½lð¶ÉÏ·
		for(i=0;i<cnt;i++)
			ans[i]=(char)(ians[i]+48);
		ans[cnt]='\0';
		
		//oÍ
		printf("%s\n",ans);
		
		//ú»
		for(i=0;i<200;i++){
		ia[i]=0;
		ib[i]=0;
		ians[i]=0;
		}
		Acnt=0;
		Bcnt=0;
		
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
struct BiconectedGraph{
  typedef pair<int,int> P;
  int n;
  vector<vector<int> > G,C,T;
  vector<int> ord,low,belong;
  vector<P> B;
  BiconectedGraph(){}
  BiconectedGraph(int sz):n(sz),G(sz),C(sz),T(sz){}
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  void input(int m,int offset=0){
    int a,b;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      add_edge(a+offset,b+offset);
    }
  }
  
  bool is_bridge(int u,int v){
    if(ord[u]>ord[v]) swap(u,v);
    return ord[u]<low[v];
  }
  
  void dfs(int v,int p,int &k){
    ord[v]=low[v]=k;
    ++k;
    for(int u:G[v]){
      if(u==p) continue;
      if(ord[u]>=0){
	low[v]=min(low[v],ord[u]);
      }else{
	dfs(u,v,k);
	low[v]=min(low[v],low[u]);
      }
      if(is_bridge(v,u)) B.push_back(P(v,u));
    }
  }
  
  void fill_component(int c,int v){
    C[c].push_back(v);
    belong[v]=c;
    for(int u:G[v]){
      if(belong[u]>=0||is_bridge(v,u)) continue;
      fill_component(c,u);
    }
  }
  
  void add_component(int v,int &k){
    if(belong[v]>=0) return;
    fill_component(k++,v);
  }
  
  int build(){
    int k=0;
    ord.resize(n);
    low.resize(n);
    belong.resize(n);
    fill(ord.begin(),ord.end(),-1);
    fill(belong.begin(),belong.end(),-1);
    for(int v=0;v<n;v++){
      if(ord[v]>=0) continue;
      dfs(v,-1,k);
    }
    k=0;
    for(int i=0;i<(int)B.size();i++){
      add_component(B[i].first,k);
      add_component(B[i].second,k);
    }
    for(int v=0;v<n;v++) add_component(v,k);
    for(int i=0;i<(int)B.size();i++){
      int u=belong[B[i].first],v=belong[B[i].second];
      T[u].push_back(v);
      T[v].push_back(u);
    }
    return k;
  }
};
//END CUT HERE

signed main(){
  int v,e;
  cin>>v>>e;
  BiconectedGraph bcc(v);
  bcc.input(e,0);
  bcc.build();
  typedef pair<int,int> P;
  vector<P> B=bcc.B;
  for(P &p:B) if(p.first>p.second) swap(p.first,p.second);
  sort(B.begin(),B.end());
  for(P p:B) cout<<p.first<<" "<<p.second<<endl;
  return 0;
}

/*
  verified on 2017/12/20
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B&lang=jp
*/

Measured memory_bytes: 4908
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
 int n,m,x;
 scanf("%d%d%d",&n,&m,&x);
  
 int a[n][m],c[n];
 int b,d;
 for(b=0;b<n;b++){
  scanf("%d",&c[b]);
  for(d=0;d<m;d++)
   scanf("%d",&a[b][d]);
 }
 
 int bit,cnt[m],money=0,ok,ans=1200001;
 for(bit=1;bit<(1<<n);bit++){
  ok=0;
  for(b=0;b<m;b++)
   cnt[b]=0;
  money=0;
  for(b=0;b<n;b++){
   if(bit&(1<<b)){
    for(d=0;d<m;d++)
     cnt[d]+=a[b][d];
    money+=c[b];
  //  printf("%d %d %d %d\n",bit,b,money,c[b]);
    }} 
   for(b=0;b<m;b++)
    if(cnt[b]<x){
      ok=1;
      break;}
   if(ok==0&&ans>money){
    ans=money;}
   }
 if(ans==1200001){
  puts("-1");return 0;}
 else
  printf("%d\n",ans);
  
return 0;}

Measured memory_bytes: 1728
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n;
string s;
int main()
{
	cin>>n>>s;
	if(s.substr(0,n/2)==s.substr(n/2))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

N, X, Y = map(int, input().split())
cnt_dict = defaultdict(int)

for i in range(1,N):
    for j in range(i+1, N+1):
        if j<=X or i>=Y:
            path = j-i
        else:
            path = min(j-i, abs(X-i)+abs(j-Y)+1)
        cnt_dict[path] += 1

for i in range(1,N):
    print(cnt_dict[i])

Measured memory_bytes: 9744
k, n = map(int, input().split())
a = list(map(int, input().split()))
res = 0
ans = float('inf')
for i in range(n - 1):
	res+= a[i + 1] - a[i]
	ans= min(k-a[i+1]+a[i], ans)
print(min(res, ans))

Measured memory_bytes: 26444
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b&&b>=c){
		cout<<a-c<<endl;
	}
	else if(a>=c&&c>=b){
		cout<<a-b<<endl;
	}
	else if(b>=c&&c>=a){
		cout<<b-a<<endl;
	}
	else if(b>=a&&a>=c){
		cout<<b-c<<endl;
	}
	else if(c>=a&&a>=b){
		cout<<c-b<<endl;
	}
	else if(c>=b&&b>=a){
		cout<<c-a<<endl;
	}
}


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

int main()
{
    int n;
    std::cin >> n;
    std::map<std::string, bool> dic;
    std::vector<std::string> answer;
    for (auto i = 0; i < n; ++i)
    {
        std::string cmd, name;
        std::cin >> cmd >> name;
        if (cmd == "insert")
        {
            dic[name] = true;
            continue;
        }
        if (cmd == "find")
        {
            answer.emplace_back(dic.count(name) > 0 ? "yes" : "no");
        }
    }
    std::copy(answer.begin(), answer.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
    return 0;
}



Measured memory_bytes: 59680
n = gets.to_i
s = gets.chomp.split("")
hidarihosii = 0
migihosii = 0

for i in 0..n-1
	case s[i]
	when ')' then
		if migihosii == 0
			hidarihosii += 1		
		else
			migihosii -= 1
		end
	when '(' then
		migihosii += 1
	end
end
for i in 0..migihosii-1
	s << ')'
end

for i in 0..hidarihosii-1
	s.insert(0, '(')
end

#p [hidarihosii, migihosii].join(" ")
puts s.join

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

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

    int l;
    int r;
    int ans = 0;

    for(int i = 0; i < N; i++){
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3556
extern crate core;

use core::cmp::max;

fn main() {
    let const_mod = 10_u64.pow(9)+ 7;
    let input: Vec<usize> = read_vec();
    let n = input[0];
    let k = input[1];

    let mut dp: Vec<Vec<u64>> = vec![vec![0; 2000 + 1]; 2000 + 1];

    dp[0][0] = 1;
    for i in 1..(max(n - k + 1, k - 1) + 1) as usize {
        dp[i][0] = 1;
        for j in 1..(k + 1) as usize {
            dp[i][j] = (dp[i-1][j] + dp[i - 1][j - 1]) % const_mod;
        }
    }

    for i in 1..(k + 1) as usize{
        println!("{}", dp[n - k + 1][i] * dp[k - 1][i - 1] % const_mod);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 45436
/*input
6 6 8
..##..
.#..#.
#....#
######
#....#
#....#
*/

// Nihesh Anderson - knandy

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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{ll res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(ll* a, ll* b){shuffle(a,b,grndm);}

ll h, w, k;

vector<string> v;

bool check(ll x, ll y) {
	vector<string> now = v;
	for(ll i = 0; i < h; i++) {
		if(x & (1 << i)) {
			for(ll j = 0; j < w; j++) {
				now[i][j] = 'R';
			}
		}
	}
	for(ll j = 0; j < w; j++) {
		if(y & (1 << j)) {
			for(ll i = 0; i < h; i++) {
				now[i][j] = 'R';
			}
		}
	}
	ll sum = 0;
	for(ll i = 0; i < h; i++) {
		for(ll j = 0; j < w; j++) {
			sum += (now[i][j] == '#');
		}
	}
	return sum == k;
}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	cin >> h >> w >> k;
	v.resize(h);
	for(ll i = 0; i < h; i++) {
		cin >> v[i];
	}
	ll cnt = 0;
	for(ll i = 0; i < (1 << h); i++) {
		for(ll j = 0; j < (1 << w); j++) {
			cnt += check(i, j);
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3648
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int a[11][11];
	int n, d;
	cin >> n >> d;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= d; j++)
			cin >> a[i][j];

	int res = 0;
	for(int i = 1; i < n; i++) {
		for(int j = i+1; j <= n; j++) {
			int dist = 0;
			for(int k = 1; k <= d; k++)
				dist += (a[i][k] - a[j][k])*(a[i][k] - a[j][k]);
			int x = sqrt(dist);
			if(x*x == dist) res++;
		}
	}
	cout << res;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int a[4], b[4];

int main() {
	while (scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF) {
		scanf ("%d%d%d%d", &b[0], &b[1], &b[2], &b[3]);
		int hit = 0, blow = 0;
		for (int i=0; i<4; ++i) {
			if (a[i] == b[i]) ++hit, b[i] = -1;
		}
		for (int i=0; i<4; ++i) {
			for (int j=0; j<4; ++j) {
				if (a[i] == b[j] && b[j] != -1 && i != j) ++blow, b[j] = -1;
			}
		}
		printf ("%d %d\n", hit, blow);
	}
	return 0;
}

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

int main() {
	vector<int> x(5);
	int idx;
	rep(i,5) {
		cin >> x.at(i);
		if (x.at(i) == 0){
			idx = i + 1;
		}
	}
	cout << idx << "\n";

	return 0;
}


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

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		cout.println("ABC" + cin.next());
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

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

}


Measured memory_bytes: 23124
n = int(input())
a = list(map(int,input().split()))
tmp = [0] * (n+1)
ans = 0
for i in range(n):
    tmp[a[i]] += 1
for i in range(1,len(tmp)):
    if tmp[i] > 1:
        ans += int(tmp[i] * (tmp[i] - 1) / 2)
for i in range(n):
    if tmp[a[i]] > 1:
        print(ans - int(tmp[a[i]] * (tmp[a[i]] - 1) / 2) + int((tmp[a[i]] - 1) * (tmp[a[i]] - 2) / 2))
    else:
        print(ans)

Measured memory_bytes: 32216
A = [pow(n, 5) for n in range(300)]
B = [pow(n, 5) for n in range(300)]
a = -1
b = -1
x = int(input())
for n in range(300):
  for m in range(300):
    if A[n] - B[m] == x:
      a = n
      b = m
      break
    if A[n] + B[m] == x:
      a = n
      b = -m
      break
  if a >= n:
    break
print(a, b)

Measured memory_bytes: 63792
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

    int n;
    cin >> n;
    map<string, int>mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int ma = 0;
    for (auto x : mp) {
        chmax(ma, x.second);
    }
    for (auto x : mp) {
        if (ma == x.second) {
            cout << x.first << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 23808
solve :: Int -> Int -> Int -> String
solve x a b
    | da < db = "A"
    | otherwise = "B"
    where
        da = abs (x - a)
        db = abs (x - b)


main :: IO ()
main = do
    [x, a, b] <- map read . words <$> getLine :: IO [Int]
    putStrLn $ solve x a b


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

int main()
{
    int n;
    int ac, wa, tle, re;
    ac = wa = tle = re = 0;

    string result;

    cin >> n;

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

        if (result == "AC") ac++;
        else if(result == "WA") wa++;
        else if (result == "TLE") tle++;
        else if (result == "RE") re++;
    }

    cout << "AC x " << ac <<endl;
    cout << "WA x " << wa <<endl;
    cout << "TLE x " << tle <<endl;
    cout << "RE x " << re <<endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define gcd(n,m)   __gcd(n,m)
#define lcm(n,m)   ((n)/__gcd(n,m))*(m)
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI         2*acos(0.0)

ll arraySortedOrNot(vector<ll>arr , ll n)
{
    if (n == 1 || n == 0)
        return 1;
    if (arr[n - 1] < arr[n - 2])
        return 0;
    return arraySortedOrNot(arr, n - 1);
}

ll MEX(vector<ll>arr,ll n)
{
    sort(all(arr));
    for(ll i=0;i<n;i++)
    {
        if(arr[i]!=i) return i;
    }
    return n;
}

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
   ci>>n;
   map<string,ll>mp;
   f(0,n)
   {
     string s;
     ci>>s;
     mp[s]++;
   }
   co<< "AC x "<<mp["AC"]<<endl<< "WA x "<<mp["WA"]<<endl<< "TLE x "<<mp["TLE"];
  en
    co<< "RE x "<<mp["RE"];
    return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
#define what(x) cerr << #x << " is " << x << endl;
const ll INF = 1LL << 60;
ll h[100010];
ll dp[100100];

int main() {
    int N, K;
    cin >> N >> K;
    // vl h(N + K, 0);
    for (int i = 0; i < N; ++i) {
        cin >> h[i];
    }
    // vl dp(N + K, INF);
    for (int i = 0; i < 100100; ++i) {
        dp[i] = INF;
    }
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            dp[i + j] = min(dp[i + j], abs(h[i] - h[i + j]) + dp[i]);
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979

struct LazySegmentTree{
private:
	lli n;
	vector<lli> node;
	vector<lli> lazy;

public:
	LazySegmentTree(vector<lli> &v){
		lli size = v.size();
		n = 1;while(n<size)n*=2;

		node.resize(2*n-1);

		REP(i,0,size)node[i+n-1]=v[i];
		for(lli i=n-2;i>=0;i--)node[i] = node[2*i+1]+node[2*i+2];
	}

	void add(lli k,lli x){
		lli s = k+n-1;
		while(s>0){
			node[s]+=x;
			s = (s-1)/2;
		}
		node[0]+=x;
	}

	lli getSum(lli a,lli b,lli k=0,lli l=0,lli r=-1){
		if(r<0)r=n;
		if(b<=l || r<=a)return 0;

		if(a<=l && r<=b)return node[k];
		lli vl = getSum(a,b,2*k+1,l,(l+r)/2);
		lli vr = getSum(a,b,2*k+2,(l+r)/2,r);
		return vl+vr;
	}
};

signed main(){

	lli n,q;
	cin>>n>>q;

	vector<lli> v(n,0);
	LazySegmentTree lazyTree(v);

	REP(i,0,q){

		lli k;
		cin>>k;
		if(k==0){
			lli x,y;
			cin>>x>>y;
			lazyTree.add(x-1,y);
		}
		else{
			lli s,t;
			cin>>s>>t;
			cout<<lazyTree.getSum(s-1,t)<<endl;
		}

	}

	return 0;
}


Measured memory_bytes: 5728
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define var auto
#define ll long long
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++) 
#define inp(a) int a; cin >> a;
#define inps(s) std::string s; cin >> s;
#define out(a) cout<<a<<endl;
#define pb(a) push_back((a))
#define endl "\n"
#define vi vector<int>


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

	int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    int n = N - 1;
    int x = n / A + 1;
    int y = n / C + 1;

    // cerr << n << endl << x << endl << y;
    cout << min(x * B, y * D) << endl;
	return 0;
}


Measured memory_bytes: 3180
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int n, sum = 0, l[15];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
	}
	sort(l, l + n);
	for (int i = 0; i < n - 1; i++) {
		sum += l[i];
	}
	if (sum > l[n - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

int main(void) {
	int q;
	int l, r;
	bool prime[100001] = {};
	int c[100001] = {};

	for (int i = 2; i <= 100000; i++) {
		if (!prime[i]) {
			for (int j = i+i; j <= 100000; j+=i) {
				prime[j] = true;
			}
		}
	}

	for (int i = 3; i <= 100000; i+=2) {
		if (prime[i] == false && prime[(i + 1) / 2] == false) {
			c[i]++;
		}
	}

	for (int i = 3; i <= 100000; i++) {
		c[i] += c[i - 1];
	}

	cin >> q;

	for (int i = 1; i <= q; i++) {
		cin >> l >> r;

		cout << c[r] - c[l - 1] << endl;
	}
	
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int even = N/2;
  cout << float(N-even) / float(N);
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main{ // 

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = cin.nextInt();

		long start = now();

		long ans = solve(n, a);
		cout.println(ans);

		trace("elapsed", now() - start);
	}

	private static long solve(int n, int[] a) {
		long total = Arrays.stream(a).mapToLong(x -> x).sum();
		long ans = Long.MAX_VALUE;
		long s = 0;
		for (int i = 0; i < n - 1; i++) {
			s += a[i];
			ans = Math.min(ans, Math.abs(total - 2 * s));
		}
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

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

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

}


Measured memory_bytes: 46436
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)


// ------------debug用------------
#define FALSE cout<<"false"<<endl;
#define TRUE cout<<"true"<<endl;
// ------------debug用------------


// ------------計算用------------
#define ALL(x) (x).begin(),(x).end()
#define FOR(x) for(ll i = 0;i < x;++i)
// ------------計算用------------


// ------------出力用------------
#define PRINT(x) cout<<x<<endl;
// ------------出力用------------


using namespace std;
typedef long long ll;

int main(){
  int A,X;
  cin>>X>>A;
  int ans = 10;
  if(X < A)ans = 0;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>

using namespace std;

struct Node {
    int key;
    Node* left;
    Node* right;

    Node() : key(0), left(NULL), right(NULL) {}
};

void insert(Node** root, int key) {
    Node* new_node = new Node;
    new_node->key = key;

    if (*root == NULL) {
        *root = new_node;
    } else {
        Node* node1 = *root;
        Node* node2;
        while (node1 != NULL) {
            node2 = node1;
            if (node1->key > key)
                node1 = node1->left;
            else
                node1 = node1->right;
        }

        if (node2->key > new_node->key)
            node2->left = new_node;
        else
            node2->right = new_node;
    }
}

void find(Node* root, int key) {
    Node* node = root;
    while (node != NULL) {
        if (node->key == key)
            break;
        if (node->key > key)
            node = node->left;
        else
            node = node->right;
    }

    if (node != NULL)
        cout << "yes\n";
    else
        cout << "no\n";
}

void print_inorder(Node* node) {
    if (node == NULL)
        return;

    print_inorder(node->left);
    cout << ' ' << node->key;
    print_inorder(node->right);
}

void print_preorder(Node* node) {
    if (node == NULL)
        return;

    cout << ' ' << node->key;
    print_preorder(node->left);
    print_preorder(node->right);
}

void delete_tree(Node* node) {
    if (node->left != NULL)
        delete_tree(node->left);
    if (node->right != NULL)
        delete_tree(node->right);
    if (node != NULL)
        delete node;
}

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

    Node* root = NULL;

    for (int i = 0; i < n; ++i) {
        string inst;
        cin >> inst;

        if (inst == "insert") {
            int k;
            cin >> k;
            insert(&root, k);
        } else if (inst == "find") {
            int k;
            cin >> k;
            find(root, k);
        } else {
            print_inorder(root);
            cout << '\n';
            print_preorder(root);
            cout << '\n';
        }
    }

    delete_tree(root);
}



Measured memory_bytes: 15540
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll sup = 1000000000000000000;
int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    bool zero_flag = false;
    rep(i, n) if (a[i] == 0) {zero_flag = true; break;}
    if (zero_flag) {cout << 0; return 0;}
    ll seki = 1;
    rep(i, n) {
        if (a[i] > sup/seki) {
            cout << -1;
            return 0;
        }
        seki *= a[i];
    }
    cout << seki;
}


Measured memory_bytes: 3948
#include <stdio.h>
#include <inttypes.h>

#define INF INT64_C(77777777777777777)

int N;
int64_t A[271828];

int64_t memo[271828][3];
char valid[271828][3];

int64_t search(int pos, int skip) {
	int64_t answer = -INF;
	int64_t candidate;
	if (pos >= N) return (skip <= 1) ? 0 : -INF;
	if (valid[pos][skip]) return memo[pos][skip];

	/* 選ぶ */
	candidate = search(pos + 2, skip) + A[pos];
	if (candidate > answer) answer = candidate;
	/* 選ばない */
	if (skip > 0) {
		candidate = search(pos + 1, skip - 1);
		if (candidate > answer) answer = candidate;
	}

	memo[pos][skip] = answer;
	valid[pos][skip] = 1;
	return answer;
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &A[i]) != 1) return 1;
	}
	printf("%" PRId64 "\n", search(0, N % 2 == 0 ? 1 : 2));
	return 0;
}


Measured memory_bytes: 14812
package main

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

func main() {
	H, _, K := nextInt(), nextInt(), nextInt()
	y1, x1, y2, x2 := nextInt(), nextInt(), nextInt(), nextInt()

	grid := make([]string, H)
	for i := 0; i < H; i++ {
		grid[i] = next()
	}
	fmt.Println(solve(grid, K, x1-1, y1-1, x2-1, y2-1))
}

func solve(grid []string, k, x1, y1, x2, y2 int) int {
	h := len(grid)
	w := len(grid[0])

	dist := make([][]int, h)
	for i := range dist {
		dist[i] = make([]int, w)
		for j := range dist[i] {
			dist[i][j] = -1
		}
	}

	q := make([][]int, 0)
	q = append(q, []int{y1, x1, 0})
	dist[y1][x1] = 0
	dirX := []int{-1, 0, 1, 0}
	dirY := []int{0, 1, 0, -1}
	for len(q) > 0 {
		now := q[0]
		q = q[1:]
		y, x, st := now[0], now[1], now[2]
		for i := range dirX {
			dx, dy := dirX[i], dirY[i]
			for j := 1; j <= k; j++ {
				nx, ny := x+dx, y+dy
				if nx >= 0 && nx < w && ny >= 0 && ny < h && grid[ny][nx] == '.' {
					dx += dirX[i]
					dy += dirY[i]
					if dist[ny][nx] != -1 {
						if dist[ny][nx] <= st {
							break
						} else {
							continue
						}
					}
					dist[ny][nx] = st + 1
					q = append(q, []int{ny, nx, st + 1})
				} else {
					break
				}
			}
		}
	}

	if dist[y2][x2] == -1 {
		return -1
	}
	return dist[y2][x2]
}

func solve2(grid []string, K, x1, y1, x2, y2 int) int {
	H := len(grid)
	W := len(grid[0])

	startX, startY := x1-1, y1-1
	goalX, goalY := x2-1, y2-1

	q := []State{State{startX, startY, 0}}
	visited := make([][]bool, H)
	for i := 0; i < H; i++ {
		visited[i] = make([]bool, W)
	}

	for len(q) > 0 {
		var now State
		q, now = q[1:], q[0]

		dirx := []int{1, -1, 0, 0}
		diry := []int{0, 0, 1, -1}

		for dir := 0; dir < 4; dir++ {
			for i := 1; i <= K; i++ {
				x := now[0] + i*dirx[dir]
				y := now[1] + i*diry[dir]
				if x < 0 || x >= W || y < 0 || y >= H {
					break
				}
				if grid[y][x] == '@' {
					break
				}

				nextX, nextY := x, y
				nextCount := now[2] + 1
				if goalX == nextX && goalY == nextY {
					return nextCount
				}
				if visited[nextY][nextX] {
					continue
				}
				visited[nextY][nextX] = true

				q = append(q, State{nextX, nextY, nextCount})
			}
		}
	}
	return -1
}

type State []int

// type State struct {
// 	X, Y  int
// 	Count int
// }

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 36668
from bisect import bisect_left
from random import randint
from time import time
 
start = time()

D = int(input())
*C, = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(D)]
T = [randint(1, 26) for _ in range(D)]

days = [[0] for _ in range(26)]

def init():
    global T, days
    score = 0
    last = [0] * 26
    for d, t in enumerate(T, 1):
        score += S[d - 1][t - 1]
        last[t - 1] = d
        for c, l in zip(C, last): score -= c * (d - l)
        days[t - 1].append(d)
    for i in range(26): days[i].append(D+1)
    return score

def diff(d, q):
    global T, C, S, days
    dif = 0
    p = T[d - 1]
    dif += S[d - 1][q - 1] - S[d - 1][p - 1]
    
    idx_p = bisect_left(days[p - 1], d)
    bef_p, aft_p = days[p - 1][idx_p - 1], days[p - 1][idx_p + 1]
    
    idx_q = bisect_left(days[q - 1], d)
    bef_q, aft_q = days[q - 1][idx_q - 1], days[q - 1][idx_q]
    dif += C[q - 1] * (d - bef_q) * (aft_q - d) - C[p - 1] * (d - bef_p) * (aft_p - d)
    
    return idx_p, idx_q, dif
    
score = init()
while time() - start < 1.8:
    d, q = randint(1, D), randint(1, 26)
    idx_p, idx_q, dif = diff(d, q)
    if dif > 0:
        p = T[d - 1]
        T[d - 1] = q
        del days[p - 1][idx_p]
        days[q - 1].insert(idx_q, d)
        score += dif
print(*T, sep='\n')

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

int main() {
  int n;
  cin >> n;
  int64_t ans = 0;
  for (int64_t i = 1; i <= n; i++) {
    int64_t j = n/i;
    ans += i*j*(j+1)/2;
  }
  
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  if(N%2!=0) cout << "No" << endl;
  else if(S.substr(0, N/2)==S.substr(N/2, N/2)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,k; cin>>n>>k;
    vector<int> a(n,0);
    rep(i,n) cin>>a[i];
    cout<<(n-1+k-1-1)/(k-1)<<endl;
}

Measured memory_bytes: 640