akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    ll N, K; cin >> N >> K; vll h(N);
    for(auto &x: h) cin >> x;

    vector<ll> dn(N+1);

    dn[0] = 0;
    dn[1] = abs( h[N-1] - h[N-2] );

    for(ll i = 2; i <= N; ++i){
        ll mn = INF;
        for(ll j = 1; j <= min(K, i); ++j){
            mn = min(mn, dn[i - j] + abs(h[N - i - 1] - h[N - i + j - 1]));
        }
        dn[i] = mn;
        //dn[i] = min(dn[i-1] + abs(h[N - i - 1] - h[N - i]), dn[i-2] + abs(h[N - i - 1] - h[N - i + 1]));
    }
    cout << dn[N-1] << endl;

    return 0;
}

//cikisir



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    int A, P;
    cin >> A >> P;

    P += A*3;

    cout << P/2 << endl;
    return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
    ll n, x, cnt = 0, prev = 0, now;
    cin >> n >> x;
    for (ll i = 0; i < n; ++i) {
        cin >> now;
        prev = now - max(prev + now - x, 0LL);
        cnt += now - prev;
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
	int A,B;
 	int C,K;
  	cin>>A>>B>>C>>K;
  	if(K<=A){
      cout<<K<<endl;
    }
  	else if(K<=A+B){
      cout<<A<<endl;
    }
  	else{
      cout<<2*A+B-K<<endl;
    }
  
}



Measured memory_bytes: 3592
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  if(s=="SAT"){
    cout<<1<<endl;
    
  }else if(s=="MON"){
    cout<<6<<endl;
  }else if(s=="TUE"){
    cout<<5<<endl;
  }else if(s=="WED"){
    cout<<4<<endl;
  }else if(s=="THU"){
    cout<<3<<endl;
  }else if(s=="FRI"){
    cout<<2<<endl;
  }else if(s=="SUN"){
    cout<<7<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
const ll INF = 1000000007;
const ld PI = 3.141592653589;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}

int main(){
    FAST_IO;
    ll _=1;
    //cin>>_;
    for(ll ii=1;ii<=_;ii++)
    {
		ll a,b,v,w,t;
		cin>>a>>v>>b>>w>>t;
        ll d=abs(a-b),dd=(v-w)*t;
        cout<<((d<=dd)?"YES":"NO");
	}
	//cout<< "Done in " <<fixed<<setprecision(15)<<(double)clock()/7.33e8<<"sec"<< endl;
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
main(){
  int i,n,m;
  for(i=1;;i++){
    scanf("%d %d",&n,&m);
    if(n==0 && m==0)break;
    if(n>m)printf("%d %d\n",m,n);
    else printf("%d %d\n",n,m);
  }
  return 0;
}


Measured memory_bytes: 2092
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
using namespace std;
vector<string> v;
string s;
int N,M,chk;
int main(void)
{
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
    {
        cin >> s;
        v.push_back(s);
    }
    scanf("%d",&M);
    for(int i=1;i<=M;i++)
    {
        cin >> s;
        vector<string>::iterator it = find(v.begin(), v.end(), s);
        if(it!=v.end()) v.erase(it);
    }
    for(int i=0;i<v.size();i++){
        int now=0;
        for(int j=0;j<v.size();j++)
            if(v[i]==v[j]) now++;
        chk = max(chk,now);
    }
    printf("%d",chk);
}


Measured memory_bytes: 256
import fractions
N = int(input())
a = list(map(int, input().split()))


def lcm(m, n):
    return (m // fractions.gcd(m, n)) * n


mod = 10**9+7
lc = a[0]
for i in range(N):
    lc = lcm(lc, a[i])
ans = 0
for i in range(N):
    ans += (lc // a[i])
print(ans % mod)


Measured memory_bytes: 6112
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();

    if a < b {
        for _ in 0..b {
            print!("{}", a);
        }
        println!();
    } else {
        for _ in 0..a {
            print!("{}", b);
        }
        println!();
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long a,b;
  cin>>a>>b;
  if(a==1 ||b==1){
    if(a+b>=3){
      cout<<a+b-3<<endl;
    }
    else if(a+b==2){
      cout<<1<<endl;
    }
  }
  
    else {
      cout<<a*b-2*a-2*b+4<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  int r, g, b;
  cin >> r >> g >> b;

  int sum = stoi(to_string(r) + to_string(g) + to_string(b));

  puts(sum % 4 == 0 ? "YES" : "NO");

  return 0;
}

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

struct	UnionFind {
	int		size;
	int		*par;
	int		*rank;
	int		num_group;
	UnionFind(int size): size(size), par(NULL), rank(NULL), num_group(size) {
		assert(size > 0);
		par = new int[size];
		rank = new int[size];
		assert(par != NULL && rank != NULL);
		for (int i = 0; i < size; ++i) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	~UnionFind() {
		delete [] par;
		delete [] rank;
		par = NULL;
		rank = NULL;
	}
	int		find(int idx) {
		if (par[idx] == idx)
			return idx;
		return (par[idx] = find(par[idx]));
	}
	bool	same(int lhs, int rhs) {
		if (find(lhs) == find(rhs))
			return true;
		return false;
	}
	void	unite(int lhs, int rhs) {
		int	par_l = find(lhs), par_r = find(rhs);
		if (par_l == par_r)
			return;
		if (rank[par_l] < rank[par_r]) {
			par[par_l] = par_r;
		} else {
			par[par_r] = par_l;
			if (rank[par_l] == rank[par_r])
				++rank[par_l];
		}
		--num_group;
	}
};

int	main()
{
	int	V, E;
	cin >> V >> E;
	vector<tuple<int64_t, int, int>>	edge(E);
	UnionFind							uf(V);
	int									s, t;
	int64_t								w;
	for (int i = 0; i < E; ++i) {
		cin >> s >> t >> w;
		edge.at(i) = make_tuple(w, s, t);
	}
	sort(edge.begin(), edge.end());
	int64_t	total = 0;
	for (auto tpl : edge) {
		tie(w, s, t) = tpl;
		if (uf.same(s, t))
			continue;
		total += w;
		uf.unite(s, t);
		if (uf.num_group == 1)
			break;
	}
	cout << total << endl;
}



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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 5e3 + 5;

int P[N], C[N][N], M[N][N];
ll DP[N][N];
// C[i][j] : # k : i <= k <= j && A[i] > A[k] 
// M[i][j] : index maximum A[k] <= j && k <= i
// DP[i][j] : answer for first i element and numbers less than j
int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n, A, B; cin >> n >> A >> B;
	for (int i = 1; i <= n; i++) cin >> P[i];
	for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) C[i][j] = C[i][j - 1] + (P[i] > P[j]);
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) M[i][j] = (P[i] <= j && P[i] > P[M[i - 1][j]]) ?  i : M[i - 1][j];
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
		if (!M[i][j]) continue;
		DP[i][j] = min(A + DP[i][P[M[i][j]] - 1], DP[M[i][j] - 1][j] + 1LL * C[M[i][j]][i] * B);
	}
	cout << DP[n][n] << endl;

	return 0;
}


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

#define ll long long int

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> ep(n, 0), es(n, 0);
    if(s[0] == 'E')
        ep[0] = 1;
    for(int i = 1; i < n; i++) {
        ep[i] = ep[i - 1] + (s[i] == 'E');
    }
    if(s[n - 1] == 'E')
        es[n - 1] = 1;
    for(int i = n - 2; i >= 0; i--) {
        es[i] = es[i + 1] + (s[i] == 'E');
    }
    int ans = INT_MAX;
    for(int i = 0; i < n; i++) {
        int countw = (i - (i > 0 ? ep[i - 1] : 0));
        int counte = (i < n - 1 ? es[i + 1] : 0);
        // cout << countw << " " << counte << endl;
        ans = min(ans, countw + counte);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3076
N=int(input())
W=list(map(int,input().split()))
SUM=sum(W)
a=[]
b=[]
c=[]
for i in range (N):
    a.append(0)
for i in range (N):
    b.append(0)
for i in range (N):
    c.append(0)
for i in range(0,N):
    for j in range(0,i+1):
        a[i]=a[i]+W[j]
for i in range(0,N):
    b[i]=SUM-a[i]
for i in range(0,N):
    c[i]=abs(a[i]-b[i])
print(min(c))

Measured memory_bytes: 9252
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

long long upperfloor(long long n) {
	long long ans = 1;
	while (n) {
		ans *= n;
		--n;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	cout << upperfloor(n) << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    string s;
    int k;
    cin >> s >> k;
    unordered_set<string> us;
    priority_queue<string> pq;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k && i + j <= n; j++) {
            string ss = string(s.begin() + i, s.begin() + i + j);
            if (us.find(ss) != us.end()) continue;
            pq.push(ss);
            us.insert(ss);
            if (pq.size() > k) pq.pop();
        }
    }
    cout << pq.top() << endl;
}


Measured memory_bytes: 4676
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  long long int n, x, y;
  cin>>n>>x>>y;
  vector<long long int> ans(n, 0);
  for(long long int i=1; i<=n; i++){
    for(long long int j=i+1; j<=n; j++){
      long long int preans=j-i;
      preans=min(preans, abs(x-i)+1+abs(y-j));
      ans.at(preans)++;
    }
  }
  for(long long int i=1; i<n; i++){
    cout<<ans.at(i)<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>


using namespace std;

int main() {
    long long int ans = 0;
    int N, K;

    cin >> N >> K;

    ans = K * pow(K - 1, N - 1);

    cout << ans;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <cstdlib>
#include <queue>
typedef std::pair<int, int> pi;
int m[505][505];
std::vector<pi> v;
std::vector<pi> vt;
int main()
{
    int h,w;
    scanf("%d%d", &h, &w);
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            scanf("%d", &m[i][j]);
        }
    }
    bool state = 0;
    for(int i=1;i<=h;i++)
    {
        if(i%2)
        {
            for(int j=1;j<=w;j++)
            {
                state = state ^ (m[i][j] % 2);
                if(m[i][j] % 2 && state == 0)
                {
                    for(pi p : vt)
                    {
                        v.push_back(p);
                    }
                    vt.clear();
                }
                if(state)
                {
                    vt.push_back({i,j});
                    if(j != w) vt.push_back({i,j+1});
                    else vt.push_back({i+1,w});
                }
            }
        }
        else
        {
            for(int j=w;j;j--)
            {
                state = state ^ (m[i][j] % 2);
                if(m[i][j] % 2 && state == 0)
                {
                    for(pi p : vt)
                    {
                        v.push_back(p);
                    }
                    vt.clear();
                }
                if(state)
                {
                    vt.push_back({i,j});
                    if(j != 1) vt.push_back({i,j-1});
                    else vt.push_back({i+1,1});
                }
            }
        }
    }
    printf("%d\n", v.size()/2);
    for(int i=0;i<v.size();i++)
    {
        printf("%d %d", v[i].first, v[i].second);
        if(i%2) puts("");
        else putchar(' ');
    }
}

Measured memory_bytes: 5232
#include <iostream>

using namespace std;

int main(void) {
    int64_t a, b, c;
    cin >> a >> b >> c;
    if(4*a*b < (c-a-b)*(c-a-b) && c > a+b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> H(n);
	for (int& h : H) {
		cin >> h;
	}
	int dp[n + 1];
	dp[0] = dp[1] = 0;
	dp[2] = abs(H[0] - H[1]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(abs(H[i - 2] - H[i - 1]) + dp[i - 1],
		            abs(H[i - 3] - H[i - 1]) + dp[i - 2]);
	}
	cout << dp[n];
	return 0;
}

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

int main(){int x,a,b,A,B;cin>>x>>a>>b;
           A=max(x,a)-min(x,a);
           B=max(x,b)-min(x,b);
           if(A>B)cout<<'B'<<endl;
           else{cout<<'A'<<endl;}}

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

int main() {
	string s,t,u;
	int a,b;
	cin >> s >> t >> a >> b >> u;
	if(u == s){
		a--;
	}else{
		b--;
	}
	cout << a << " " << b << endl;

  	return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define INPUT(X) cin >> X
#define OUTPUT(X) cout << X << endl
#define REPEAT(i,n) for(int i=0;i<n;i++ )

using namespace std;

typedef unsigned long long int ull;


int main(void) {

	string S;
	ull L,R;
	int Length;
	int amari;
	bool flag=true;
	INPUT(L);
	INPUT(R);
	Length = min(int(R-L),2019);
	for( ull i = L ; i <= L+Length-1 ; i++ ){
	for( ull j = i+1 ; j <= L+Length ; j++ ){

		int temp = (i*j) % 2019;
		if( flag ){ amari = temp; flag=false;
//		}else if( temp==0 ) { amari = temp; break;
		}else if( temp < amari ){ amari = temp;}
	}
	}

	
	OUTPUT(amari);

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int one = 111;
	int two = 222;
	int three = 333;
	int four = 444;
	int five = 555;
	int six = 666;
	int seven = 777;
	int eight = 888;
	int nine = 999;
	if (n <= 111)
		cout << one << endl;
	else if (n <= 222)
		cout << two << endl;
	else if (n <= 333)
		cout << three << endl;
	else if (n <= 444)
		cout << four << endl;
	else if (n <= 555)
		cout << five << endl;
	else if (n <= 666)
		cout << six << endl;
	else if (n <= 777)
		cout << seven << endl;
	else if (n <= 888)
		cout << eight << endl;
	else
		cout << nine << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> A(N);

  int pos1 = 0;
  rep(i, N)
  {
    cin >> A[i];
    if (A[i] == 1)
      pos1 = i + 1;
  }
  int ans = (N - 1 + K - 2) / (K - 1);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[201];
    char z[201];
    int m;
    int h[201] = {0};
    int length;

    while (1){

        scanf("%s", s);
        length = strlen(s);

        if( s[0] == '-'){
            break;
        }
        
        scanf("%d", &m);

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

            strncpy(z, s, h[i]);
            z[h[i]] = '\0';
            strcpy(s, s+h[i]);
            strcat(s, z);
        }
        printf("%s\n", s);
        
    }
    return (0);
}




Measured memory_bytes: 2100
import numpy as np
N,M = map(int,input().split())
S = [int(x) for x in input().split()]
T = np.array(input().split(), dtype = np.int32)
dp = np.ones(M+1, dtype = np.int64)
for s in S:
  dp[1:] = ((dp[:-1] * (T == s)).cumsum() + dp[1:]) % (10**9 + 7)
print(dp[M])

Measured memory_bytes: 12516
#include <stdio.h>

int main(void)
{
  int n;
  int i;

  scanf("%d",&n);

  int ai[n];

  for(i=0; i<n; i++)
    scanf("%d",&ai[i]);

  for(i=(n-1); i>=0; i--){
    printf("%d",ai[i]);
    if(i>0)
      printf(" ");
  }
    
  puts("");
  
  return(0);
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n,m;cin>>n>>m;
    vector<P>as(m);
    rep(i,m){
        int a,b;cin>>a>>b;
        int x =0;
        rep(i,b){
            int y;cin>>y;
            y--;
            x|=1<<y;
        }
        as[i]={x,a};
    }
    vl dp(1<<n+1,INFL);
    dp[0]=0;
    rep(bit,1<<n){
        rep(i,m){
            dp[bit|as[i].first]=min(dp[bit|as[i].first],dp[bit]+as[i].second);
        }
    }
    if(dp[(1<<n)-1]==INFL)cout<<-1<<endl;
    else
    {
         cout<<dp[(1<<n)-1]<<endl;
    }
    
}

Measured memory_bytes: 3692
m = input().split()
n = int(m[0])
m = int(m[1])
food = list(range(1,m+1))
for i in range(n):
    inputvalue = input().split()
    del inputvalue[0]
    for j in range(1,m+1):
        if not str(j) in inputvalue and j in food:
            food.remove(j)
print(len(food))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int M,A[100001],B[100001],l[100001],n[100001];
long long F,N,o[100001];
//N:島の数、M:橋の本数、i(=1,2,...M)本目の橋は島A[i]と島B[i]を結ぶ。
//l[i]:島iのリーダー n[i]:サイズ　リーダ以外は0
int leader(int i){//島iのリーダーを探す。リーダーの付け替えも一緒に
  int j=i,t;
  while(n[i]==0)i=l[i];
  while(n[j]==0){t=l[j];l[j]=i;j=t;}
  return i;
}

int main() {
  cin >> N>>M;
  for(int i=1;i<=M;i++)cin>>A[i]>>B[i];
  for(int i=1;i<=N;i++){l[i]=i;n[i]=1;}
  //o[i]は橋i(1,2,...,M)が落ちたときに出力する数。
  F = N*(N-1)/2;//最初の不便さ
  for(int i=M;i>0;i--){//iは橋番号  
    o[i]=F;
    int a,b,la,lb;
    a=A[i];b=B[i];
    la=leader(a);lb=leader(b);//laはaのリーダー lbはbのリーダー
    if(la!=lb){
      F -= n[la]*n[lb];//便利さの増加分を引く
      l[lb]=la;
      n[la] += n[lb];
      n[lb] = 0;
    }
    if(0){
      cout<<"\nl:";for(int j=1;j<=N;j++)cout<<l[j];
      cout<<"\nn:";for(int j=1;j<=N;j++)cout<<n[j];
      cout<<" i="<<i<<" A[i]="<<A[i]<<" B[i]="<<B[i]<<" F="<<F<<endl;
    }
  }
  for(int i=1;i<=M;i++)cout<<o[i]<<endl;
  return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
const ll mod = 1000000007;
const int inf = 1e9+7;
const ll infl = 1e18+7;

int main() {
    fastcin;
    vi a;
    rep(i, 0, 3) {
        int in;
        cin >> in;
        a.push_back(in);
    }
    VSORT(a);
    int ans = abs(a[1]-a[0]) + abs(a[2]-a[1]);
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int x_max = -101;
  int y_min = 101;
  REP(i,n) { int a; cin >> a; x_max = max(a,x_max); }
  REP(i,m) { int a; cin >> a; y_min = min(a,y_min); }
  FOR(z,x+1,y+1) {
    bool flag = true;
    if(x >= z) flag = false;
    if(z > y) flag = false;
    if(x_max >= z) flag = false;
    if(y_min < z) flag = false;
    if(flag) { cout << "No War" << endl; return 0; }
  }
  cout << "War" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)	cin>>a[i];
  int flag=-1;
  int tmp;
  int j=0;
  while(j<N){
    if(a[j]<a[j+1]){
      tmp=a[j+1];
      a[j+1]=a[j];
      a[j]=tmp;
      flag=1;
    }
    j++;
    if(flag==1 && j==N){
      //cout<<called
      j=0;
      flag=-1;
    }
    
  }
  //for(int i=0;i<N;i++) cout<<a[i]<<" "; ok
  int A=0,B=0;
  for(int k=0;k<N;k++){
    if(k%2==0)	A+=a[k];
    if(k%2==1)	B+=a[k];
  }
  int C=A-B;
  cout<<C<<endl;
  return 0;
}

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

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int nS = in.nextInt();
		int len = in.nextInt();
		ArrayList<String> arr = new ArrayList<>();
		for(int i = 0; i < nS; i++) {
			arr.add(in.next());
		}
		arr.sort((o1, o2)->(o1.compareTo(o2)));
		for(int i = 0; i < nS; i++) {
			System.out.print(arr.get(i));
		}
		in.close();
	}
}


Measured memory_bytes: 29240
from bisect import bisect_left
a,b,q,*stx = map(int,open(0).read().split())
s = [-1e10] + stx[:a] + [2*1e10]
t = [-1e10] + stx[a:-q] + [2*1e10]
x = stx[-q:]
for i in x:
    pos_s = bisect_left(s,i)
    pos_t = bisect_left(t,i)
    sl = s[pos_s-1]; sr = s[pos_s]
    tl = t[pos_t-1]; tr = t[pos_t]
    ans = min( i-min(sl,tl), max(sr,tr)-i, (sr*2-i-tl), (tr*2-i-sl), (i+tr-sl*2), (i+sr-tl*2) )
    print(ans)

Measured memory_bytes: 36612
/* ***********************************************
Author        :yang12138
Created Time  :2018/4/28 20:03:47
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;

const int N=2e5+10;
int a[N];

void solve(){
	map<ll,int>mp;
	int n;
	scanf("%d",&n);
	ll s=0,ans=0;
	mp[0]++;
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		s+=a[i];
		ans+=mp[s];
		mp[s]++;
	}
	cout<<ans<<endl;
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 13568
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0)->ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
int fact[int(2e5+1)];
int inv[int(2e5+1)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA  
   string s;cin>>s;
   reverse(all(s));
   string v;
   for(int i=0;i<sz(s);++i)
   {
    int cnt=0;
    if(s[i]=='B')
    {
      cnt++;
      for(int j=i+1;j<sz(s);++j)
        if(s[j]=='B')cnt++;
        else
          break;
    }
    if(cnt>0)
    {
      i+=(2*cnt-1);
    }
    else
      v.pb(s[i]);   }
   reverse(all(v));
   cout<<v<<endl;


}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

from collections import Counter

# 最大値は相手が決まる -> greedy

N = int(input())
A = [int(x) for x in input().split()]

counter = Counter(A)
A.sort()

answer = 0
for x in A[::-1]:
    while counter[x] > 0:
        counter[x] -= 1
        target = (1 << x.bit_length()) - x
        if counter[target] > 0:
            counter[target] -= 1
            answer += 1

print(answer)



Measured memory_bytes: 33424
n, m, q = map(int, input().split())
edges = [[0]*(n+1) for _ in range(n+1)]

for _ in range(m):
    L, R = map(int, input().split())
    edges[L][R] += 1

for i in range(1, n+1):
    for j in range(n):
        edges[i][j+1] += edges[i][j]

for i in range(n):
    for j in range(1, n+1):
        edges[i+1][j] += edges[i][j]


for _ in range(q):
    p, q = map(int, input().split())
    ans = edges[q][q]-edges[q][p-1]-edges[p-1][q]+edges[p-1][p-1]
    print(ans)

Measured memory_bytes: 57432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();
		int count=0;
		
		for(int i=1;i<=9;i++) {
			for(int j=1;j<=9;j++) {
				int result=i*j;
				if(result==N) {
					count++;
				}
			}
			
		}
		
		if(count!=0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35732
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
const ll MOD=1e9+7;
const int N=500000;

main(){
    int h=in(),w=in(),k=in();
    vector<string> v;
    vec emp(h);
    rep(i,h){
        string s;cin>>s;
        v.pb(s);
        bool flag=false;
        for(auto e:s){
            if(e=='#')flag=true;
        }
        emp[i]=1-flag;
        // cout<<emp[i]<<endl;
    }
    vector<vec> ans(h,vec(w));
    int now=1;
    rep(i,h){
        bool flag=true;
        rep(j,w){
            if(i&&emp[i])ans[i][j]=ans[i-1][j];
            else if(i==0&&emp[i])ans[i][j]=now;
            else {
                if(v[i][j]=='#'){
                    now++;
                    if(flag)now--;
                    flag=false;
                }
                ans[i][j]=now;
            }
        }
        if(emp[i]==0)now++;
    }
    if(emp[0]){
        int t;
        rep2(i,1,h-1){if(emp[i]==0){t=i;break;}}
        // cout<<t;
        rep3(i,t-1,0){
            rep(j,w)ans[i][j]=ans[i+1][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1280
import numpy as np
if __name__ == '__main__':
    N = int(input())
    H = np.array(list(map(int, input().split())))
    
    count = 0
    while H.sum() != 0:
        start = 0
        for i in range(N):
            if H[i] == 0:
                end = i
                if len(H[start:end]) > 0:
                    num = H[start:end].min()
                    H[start:end] -= num
                    count += num
                start = i+1
        if len(H[start:i+1]) > 0:
            num = H[start:i+1].min()
            H[start:i+1] -= num
            count += num
    print(count)

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

int main(void) {
	int A[3];
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &A[i]);
		ans += A[i];
	}
	printf(ans >= 22 ? "bust" : "win");

	return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int a;
  int sum = 0;
  REP (i, n) {
    scanf("%d", &a);
    sum += a;
  }

  cout << sum - n << endl;
}


Measured memory_bytes: 256
S = str(input())
max = 0
for i in range(len(S)):
    k = 0
    if not(S[i] in {'A','T','G','C'}):
        continue
    k = 1
    for j in range(i+1,len(S)):
       if S[j] in {'A','T','G','C'}:
           k+=1
       else:
           break

    if k > max:
        max = k

print(max)


Measured memory_bytes: 38384
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){

	int N;
	cin>>N;
	long long int ans=1,A[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
		if(A[i]==0){
			cout<<"0"<<endl;
			return 0;
		}
	}
	for(int i=0;i<N;i++){
		if((log10(ans))+(log10(A[i]))>18){
			cout<<"-1"<<endl;
			return 0;
		}
		ans = ans*A[i];
		if(1000000000000000000<ans){
			cout<<"-1"<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4596
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
y=[x[i+1]-x[i] for i in range(m-1)]
y.sort()
if n>=m:
    print('0')
else:
    ans=x[m-1]-x[0]-sum(y[i] for i in range(m-n,m-1))
    print(ans)

Measured memory_bytes: 13968
import java.util.Scanner;

class Main {
	Scanner sc=new Scanner(System.in);

	public void run() {
		int i=sc.nextInt();
		ln(i*i*i);
	}

	public static void main(String[] args) {
		new Main().run();
	}
	
	public static void pr(Object o) {
		System.out.print(o);
	}
	
	public static void ln(Object o) {
		System.out.println(o);
	}
	
	public static void ln() {
		System.out.println();
	}
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    ll N;
    cin >> N;
    ll ans = 1+N;
    for(ll i = 2; i*i <= N; i++){
        if(N % i == 0){
            ans = min(ans, i+N/i);
        }
    }
    cout << ans - 2 << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))

sum_l = [0]+list(accumulate(a))
sum_r = [0]+list(accumulate(a[-1::-1]))

cost = sum_r[-1]
for i in range(n+1):
    cost = min(cost, abs(sum_l[i]-sum_r[n-i]))
print(cost)

Measured memory_bytes: 118348
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	long long A, B, K;
	scanf("%lld %lld %lld", &A, &B, &K);
	if (K <= A) printf("%lld %lld", A - K, B);
	else printf("0 %lld", max(0LL, A + B - K));
	return 0;
}

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

int main(int argc, const char * argv[]) {
    int H,W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i=0;i<H;i++){
        cin >> S[i];
    }
    for(int i=0;i<H;i++){
        cout << S[i] << endl;
        cout << S[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long a = scan.nextLong();
    long b = scan.nextLong();
    long c = scan.nextLong();
    long d = scan.nextLong();
    long max = 0;
    
    if(b<=0 && d<=0){
      System.out.println(a*c);
    }else if(a>=0 && c>=0){
      System.out.println(b*d);
    }else if(b<=0 && c>=0){
      System.out.println(b*c);
    }else if(a>=0 && d<=0){
      System.out.println(a*d);
    }else{
      long ac = a*c;
      long bd = b*d;
      if(ac >= bd){
        System.out.println(ac);
      }else{
        System.out.println(bd);
      }
    }
    
  }
}
    

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

int main() {
  int N, K, A=1;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    if(A*2 < A+K){
      A = A*2;
    }
    else{
      A = A+K;
    }
  }
  
  cout << A << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n;
		int ans = 0;
		
		for(int i = 0; i < 10; i++){
			n = scan.nextInt();
			ans += n;
		}
		System.out.println(ans);
	}
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    const int n = (int)s.size();
    int K;
    cin >> K;
    vector<string> vec;
    rep(i,n){
        for(int j = 1; j <= min(K, n-i); ++j){
            vec.push_back(s.substr(i, j));
        }
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    cout << vec[K-1] << "\n";
}

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

int main() {
  int n; 
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);}
  
  reverse(a.begin(),a.end());
  
  for(int i=0;i<n;i++){
   cout<<a.at(i);
   if(i+1<n){cout<<" ";}}
  
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
main()
{
    int n,i;
    cin>>n;
    int x[n];
    for(i=0;i<n;i++) {
        cin>>x[i];
    }
    for(i=0;i<n;i++) {
        if(x[i]%2==0) {
            if(x[i]%5 && x[i]%3) {
                cout<<"DENIED"<<endl;
                break;
            }
        }
    }
    if(i==n) cout<<"APPROVED"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if(Math.abs(m-n) > 1){
            System.out.println(0);
            return;
        }
        long ans = 0;

        if(n == m){
            ans = hoge(n) * hoge(m) * 2 % 1000000007;
        }else {
            ans = hoge(n) * hoge(m) % 1000000007;
        }
        System.out.println(ans);
    }

    public static long hoge(long n){
        long sum = 1;
        for(int i = 1; i < n+1; i++){
            sum = sum * i % 1000000007;
            //System.out.println(sum);
        }
        return sum;
    }
}

Measured memory_bytes: 21716
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

acgt = ["A", "C", "G", "T"]

ans = ""

for i in range(len(s)):
    t = ""
    for j in range(i, len(s)):
        if s[j] in acgt:
            t += s[j]
        else:
            break
        if len(t) > len(ans):
            ans = t

print(len(ans))


Measured memory_bytes: 62056
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

int a, b, c, d, e, f, g, h;
//int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here
struct thing {
	int left, right;
}arr[n + 50];
bool cmp(thing a, thing b)
{
	return a.right < b.right;
}
void solve()
{
	cin >> a;
	for(int i=0; i<a; i++)
	{
		cin >> c >> d;
		arr[i].left = c - d;
		arr[i].right = c + d; 
	} 
	sort(arr, arr + a, cmp);
	int cnt = 1, li = arr[0].right;
	for(int i=1; i<a; i++)
	{
		if(arr[i].left >= li)
		{
			li = arr[i].right;
			cnt ++;
		}
	}
	cout << cnt;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

ll f(ll n) {
    ll pc = (n + 1) / 2;
    ll add = pc % 2;
    if ((n + 1) % 2 == 0) {
        return add;
    } else {
        return n ^ add;
    }
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll fa = f(a - 1);
    ll fb = f(b);
    cout << (fa ^ fb) << endl;
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 解説youtube後
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        long ans = solve(a, b);
        System.out.println(ans);
    }

    static long solve(long a, long b) {
        long gcd = gcd(a, b);
        long ans = primeFactorize(gcd);
        return ans;
    }

    private static long primeFactorize(long gcd) {
        // 素因数分解の数値をキー、回数をバリューで保持る
        Map<Long, Long> m = new HashMap<>();
        for (long i = 2; i * i <= gcd; i++) {
            // System.err.printf("--%s \n", i);
            if (gcd % i != 0) {
                continue;
            }
            while (gcd % i == 0) {
                // System.err.printf(" %s ÷ %s \n", gcd, i);
                gcd /= i;
                m.put(i, m.getOrDefault(i, 0L) + 1);
            }
        }

        if (gcd > 1) {
            m.put(gcd, m.getOrDefault(gcd, 0L) + 1);
        }

        // System.err.println(m);
        return m.keySet().size() + 1;
    }

    static long gcd(long x, long y) {
        // y != 0 の場合、再帰的に実行される。
        if (y == 0) {
            return x;
        }

        if (x >= y) {
            x = x % y;
        }
        return gcd(y, x);
    }
}


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

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

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int main()
{
    int N;

    cin >> N;

    for ( int i = 1; i <= N; i++ ) {
        if ( i * 108 / 100 == N ) {
            cout << i << endl;
            return ( 0 );
        }
    }

    cout << ":(" << endl;
    return ( 0 );
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    ll sum=0;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i],sum+=a[i];
    sort(a,a+n,greater<ll>() );
    for(ll i=0;i<m;i++){
        if(4*m*a[i]<sum)return cout<<"No" , 0;
    }
    cout<<"Yes";
}



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

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

    string s;
    cin >> s;

    int qualifier_a=0, qualifier_b=0;
    for(int i=0; i<(int)s.length(); i++){
        if(s[i]=='a') {
            if(qualifier_a+qualifier_b<a+b) {
                cout << "Yes" << endl;
                qualifier_a++;
            }
            else {
                cout << "No" << endl;
            }
        }
        else if(s[i]=='b'){
            if(qualifier_a+qualifier_b<a+b && qualifier_b<b){
                cout << "Yes" << endl;
                qualifier_b++;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<vector<pair<int,int>>> S(N);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        for(int j=0;j<a;j++){
            int b,c;cin>>b>>c;
            b--;
            S[i].push_back({b,c});
        }
    }
    
    int ans=0;
    
    for(int bit=0;bit<(1<<N);bit++){
        bool ok=true;
        
        for(int i=0;i<N;i++){
            if(!(bit&(1<<i))) continue;
            
            for(int j=0;j<S[i].size();j++){
                int a=S[i][j].first,b=S[i][j].second;
                
                if(b==0){
                    if(bit&(1<<a)) ok=false;
                }else{
                    if((bit&(1<<a))==0) ok=false;
                }
            }
        }
        
        if(ok){
            ans=max(ans,__builtin_popcount(bit));
            //cout<<bit<<endl;
        }
    }
    
    cout<<ans<<endl;
}



Measured memory_bytes: 256