akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <set>
#include <vector>
#define x(p) p.real()
#define y(p) p.imag() 

namespace std{
	bool operator < (const complex<int> &a,const complex<int> &b){
		return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
	}
};
using namespace std;
typedef complex<int> P;
typedef pair<P,int> node;

P size[10];
P pos[10];

vector<int> used;

set<node> search(set<node> K){
	if(K.empty()) return K;
	node get = *K.begin();
	K.erase(get);
	used.push_back(get.second);
	y(get.first) += y(size[get.second]);
	while(x(get.first) != 501){
		bool f = false;
		for(set<node>::iterator it = K.begin(); it != K.end() ; ++it){
			if( y((*it).first) < y(get.first) && y(get.first) < y((*it).first) + y(size[(*it).second]) && x((*it).first) == x(get.first) ){
				f = true; break;
			}
		}
		if(f) break;
		x(get.first)++;
	}
	set<node> R;
	for(set<node>::iterator it = K.begin(); it != K.end() ; ++it){
		if( y(get.first) >= y((*it).first) + y(size[(*it).second]) && x((*it).first)+x(size[(*it).second]) <= x(get.first) ){
			R.insert(*it);
		}
	}
	for(set<node>::iterator it = R.begin(); it != R.end() ; ++it){
		K.erase(*it);
	}
	while(R.size() != 0){
		R = search(R);
	}
	return K;
}
int main(){
	int n;
	int cnt = 0;
	while(cin >> n , n){
		used.clear();
		if(cnt++)cout << endl;
		for(int i = 0 ; i < n ; i++){
			int x1 , x2 , y1 , y2;
			cin >> x1 >> y1 >> x2 >> y2;
			if(x1 > x2) swap(x1,x2);
			if(y1 > y2) swap(y1,y2);
			pos[i]  = P(x1,y1);
			size[i] = P(x2-x1,y2-y1);
		}
		set<node> L;
		for(int i = 0 ; i < n ; i++)
			L.insert(make_pair(pos[i],i));
		while(L.size() != 0){
			L = search(L);
		}
		int view[10] = {0};
		for(int i = 0 ; i < n ; i++)
			view[used[i]] = i+1;
		for(int i = 0 ; i < n ; i++)
			cout << view[i] << endl;
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> mochi(N);
  rep(i, N) cin >> mochi.at(i);
  sort(mochi.begin(), mochi.end());
  
  int count = 1;
  rep(i, N-1) {
    if (mochi.at(i) < mochi.at(i+1)) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import scala.math.min

object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val b = Array.fill(n-1)(sc.nextInt())
  val initDigit = 100000
  var a = Array.fill(n)(initDigit)
  for (i <- n-1 to 0 by -1) {
    if (i == n-1) {
      a(i) = b(i-1)
    } else if (i == 0) {
      a(i) = b(i)
    } else {
      a(i) = min(b(i), b(i-1))
    }
  }
  println(a.sum)
}

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

long long k, a, b;

int main() {
  cin >> k >> a >> b;
  b *= -1;

  if (k <= a) {
    cout << 1 << endl;
    return 0;
  }

  if (a + b <= 0) {
    cout << -1 << endl;
  }
  else {
    cout << (k + b - 1) / (a + b) * 2 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,a,i,d[300010];
  long long s=0;
  scanf("%d",&n);
  for(i=0;i<3*n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<3*n;i++)d[i]=N[hout()];
  for(i=0;i<n;i++)s=s+d[i*2+n];
  printf("%lld\n",s);
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

typedef long long ll;
typedef long long int64;

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

  if(a < 3200) cout << "red" << endl;
  else cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
S = raw_input().split(" ")
S[0] = int(S[0])
S[1] = int(S[1])

while S[0] != 0 or S[1] != 0:
  if(S[0] < S[1]):
    print(str(S[0]) + " " + str(S[1]))
  else:
    print(str(S[1]) + " " + str(S[0]))
  S = raw_input().split(" ")
  S[0] = int(S[0])
  S[1] = int(S[1])

Measured memory_bytes: 6464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int n,k; cin >> n >> k;
    map<int,int> m;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        auto result = m.find(x);
        if(result == m.end()){
            m.insert(make_pair(x,1));
        }else{
            result->second+=1;
        }
    }
    vector<int> vec;
    for(auto a:m){
        vec.push_back(a.second);
    }
    sort(vec.begin(),vec.end());
    int cnt = vec.size();
    int ans = 0,i = 0;
    while(cnt > k){
        ans+=vec[i];i++;
        cnt--;
    }
    cout << ans;
}




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

int main(){
int n;
cin>>n;
int p=7;
for(int i=1;i<=n+1;i++){
	if(p%n==0){
	cout<<i;
	return 0;		
	}
	p=p%n*10+7;
}
cout<<-1;
return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include <cstdio>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

int a, b, k;

int main(void) {
	cin >> a >> b >> k;
	int i, cnt = 0;
	for (i = min(a, b); i >= 1; i--) {
		if (a % i == 0 && b % i == 0) {
			cnt++;
			if (cnt == k)
				break;
		}
	}
	cout << i << endl;
	return 0;
}

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

using namespace std;

int n;

void solve()
{
    int i,j;
    string str;
    cin >> n;
    int x,y;
    cin >> x >> y;
    int bx = 1,by = 1;
    if(x < 0)
    {
        bx = -1;
        x = -x;
    }
    if(y < 0)
    {
        by = -1;
        y = -y;
    }
    vector<int> sx,sy;
    int xay = x+y;
    int r = xay % n;
    int b;
    if(r % 2 == 1 && n % 2 == 0)
    {
        cout << -1 << endl;
        return;
    }
    sx.push_back(0);
    sy.push_back(0);
    if(n > xay && r % 2 == 1)
    {
        sx.push_back(-n);
        sy.push_back(0);
    }
    if(r != 0)
    {
        int xx = x-sx.back();
        int yy = y-sy.back();
        int xxayy = xx+yy;
        b = -r;
        if(n > xxayy)
            b += 2*n;
        else
        {
            b += n;
            if(b%2 == 1)
                b += n;
        }
        b /= 2;
        if(xx+b < n)
        {
            sx.push_back(sx.back()-b);
            sy.push_back(sy.back()+n-b);
        }
        else
        {
            sx.push_back(sx.back()+n-b);
            sy.push_back(sy.back()-b);
        }
    }
    /*
    cout << sx.size() << endl;
    for(i = 0; i < sx.size(); i++)
    {
        cout << bx*sx[i] << ' ' << by*sy[i] << endl;
    }*/
    while(sx.back() != x || sy.back() != y)
    {
        if(sx.back() != x)
        {
            b = x-sx.back();
            if(b>=n)
            {
                sx.push_back(sx.back()+n);
                sy.push_back(sy.back());
            }
            else
            {
                sx.push_back(x);
                sy.push_back(sy.back()+n-b);
            }
        }
        else
        {
            sx.push_back(sx.back());
            sy.push_back(sy.back()+n);
        }
    }
    cout << sx.size()-1 << endl;
    for(i = 1; i < sx.size(); i++)
    {
        cout << bx*sx[i] << ' ' << by*sy[i] << endl;
    }
}

int main()
{
    solve();
}


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

#define fi first
#define se second
#define pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;

int n, x, t;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    clock_t ck;
    ck = clock();
    cin >> n >> x >> t;
    cout << (n/x + (n%x != 0)) * t << '\n';
    ck = clock()-ck;
    cerr << "It took " << 1.0*ck/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&c^-1;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
int a[3]={read(),read(),read()};
sort(a,a+3);
if (a[0]!=5||a[1]!=5||a[2]!=7) puts("NO");
else puts("YES");
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A+B > C+D){
    cout << "Left" << endl;
  }
  else if(A+B == C+D) {
    cout << "Balanced" <<endl;
  }
  else { cout << "Right" << endl;
       }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    ll mi = min(a, min(b, min(c, min(d, e))));
    if (n%mi==0) {
        cout << 4 + n/mi << endl;
    }
    else {
        cout << 5 + n/mi << endl;
    }
}

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

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}
	
	long inv(long a,long M) {
		return a==1?a:(M+(-M*inv(M%a,a)+1)/a);
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long N=2*sc.nextLong();
		if (N==2) {
			System.out.println(1);
			return;
		}
		long ans=(long)1e18;
		for (long d=2;d*d<=N;++d) if (N%d==0) {
			for (long P:new long[] {d,N/d}) {
				long Q=N/P;
				if (gcd(P,Q)!=1) continue;
				ans=Math.min(ans, (inv(P,Q)*P-1)/Q*Q);
			}
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

Measured memory_bytes: 36828
import java.util.Scanner;

class Main {
public static void main(String[] args){
  Scanner stdIn = new Scanner(System.in);
  int S = stdIn.nextInt();
  int m;
  int h;
  h = S/3600;
  S = S%3600;
  m = S/60;
  S = S%60;
  System.out.println(h + ":"+ m + ":"+ S);
  
}
  
}


Measured memory_bytes: 26304
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
#define   rep(i, s, t)       for(int i = int(s); i < int(t); ++i)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


signed main()
{
  int n, k;
  string s;

  cin >> n >> k >> s;
  s[k-1] = tolower(s[k-1]);

  cout << s << endl;

  return 0;
}



Measured memory_bytes: 256
from itertools import permutations

n=int(input())
li = list(range(1,n+1))
lis = list(permutations(li))

def solve(x):
	for i in range(len(lis)):
		if list(lis[i]) == x:
			return i

p = list(map(int,input().split()))
q = list(map(int,input().split()))
print(abs(solve(p) - solve(q)))

Measured memory_bytes: 45296
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
int ans[3][3],a[3][3],b[3][3],d[3][3],o[3][3];
int x[maxn],sta[80];
int i,j,k,l,t,n,m,now,num,top;
void mult(int a[3][3],int b[3][3],int c[3][3]){
	int i,j,k;
	fo(i,0,2)
		fo(j,0,2)
			o[i][j]=0;
	fo(k,0,2)
		fo(i,0,2)
			fo(j,0,2)
				o[i][j]=(o[i][j]+(ll)a[i][k]*b[k][j]%mo)%mo;
	fo(i,0,2)
		fo(j,0,2)
			c[i][j]=o[i][j];
			
}
void work(int n){
	int i,j;
	fo(i,0,2)
		fo(j,0,2)
			d[i][j]=(i==j);
	top=0;
	while (n){
		sta[++top]=n%2;
		n/=2;
	}
	while (top){
		mult(d,d,d);
		if (sta[top--]) mult(d,a,d);
	}
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,m) scanf("%d",&x[i]);
	x[++m]=n;
	ans[0][0]=ans[0][2]=1;
	ans[0][1]=2;
	a[0][0]=a[0][2]=a[1][1]=a[1][2]=a[2][0]=1;
	a[0][1]=a[2][1]=a[2][2]=2;
	fo(i,0,2)
		fo(j,0,2)
			b[i][j]=a[i][j];
	b[2][0]--;
	b[2][1]-=2;
	b[2][2]--;
	now=1;
	fo(i,1,m){
		work(x[i]-now);
		mult(ans,d,ans);
		if (i==m) break;
		mult(ans,b,ans);
		now=x[i]+1;
	}
	num=ans[0][2];
	(num+=mo)%=mo;
	printf("%d\n",num);
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
MOD = 1000000007
N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

# 0-num段目までのパターン数を取得する
# numは連続した階段の一番高いところが何段目かを意味する


def getPatternNum(num):
    pattern = [0] * num
    for i in range(num):
        if i == 0 or i == 1:
            pattern[i] = 1
            continue
        pattern[i] = (pattern[i - 2] + pattern[i - 1]) % MOD
    return pattern


def solve():
    # 階段の連続してる数のリスト

    if M > 0:
        stepsList = [0] * (M + 1)
        maxSteps = 0
        stepsList[0] = a[0]
        for j in range(1, M):
            stepsList[j] = a[j] - a[j - 1] - 1
            if stepsList[j] == 0:
                return 0
        stepsList[M] = N - a[M - 1]
    else:
        stepsList = [N + 1]

    # 連続数が一番大きいところの一番上の段を引数でわたす
    pattern = getPatternNum(max(stepsList) + 1)

    # こわれてるところ以外のパターンを掛ける
    for k in range(len(stepsList)):
        if k == 0:
            # 連続段数が３なら一番上の段は０段目から数えて２段目になるため１引く
            total = pattern[stepsList[k] - 1]

        else:
            total = (total * (pattern[stepsList[k] - 1])) % MOD

    return total


print(solve())


Measured memory_bytes: 7816
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}
int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int ans=(n-h+1)*(n-w+1);
  cout << ans<< endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long int;

using namespace std;

int main() {
    i64 n, t;
    cin >> n >> t;
    vector<i64> a(n), b(n);
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
    vector<vector<i64>> dp(n + 10, vector<i64>(t + 10)), r(n + 10, vector<i64>(t + 10));
    for (int i = 0; i < n; ++i) {
        for (int w = 0; w <= t; ++w) {
            if (w >= a[i]) {
                if (dp[i + 1][w] < dp[i][w - a[i]] + b[i]) {
                    dp[i + 1][w] = dp[i][w - a[i]] + b[i];
                }
            }
            if (dp[i + 1][w] < dp[i][w]) {
                dp[i + 1][w] = dp[i][w];
            }
            if (w >= a[i]) {
                if (r[i + 1][w] < r[i][w - a[i]] + b[i]) {
                    r[i + 1][w] = r[i][w - a[i]] + b[i];
                }
            }
            if (r[i + 1][w] < r[i][w]) {
                r[i + 1][w] = r[i][w];
            }
            r[i + 1][w] = max(dp[i][w] + b[i], r[i + 1][w]);
        }
    }
    cout << r[n][t - 1] << endl;
}


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

int main(){
	int A,B,i,j;
	cin >> A >> B;
	cout <<(2*(ceil(((double)A-1.0)/50.0)+ceil(((double)B-1.0)/50.0))+2) <<" 100" <<endl;
	for(i=1;i<=100;i++){
		cout << '.';
	}
	cout <<endl;
	for(j=1;j<=((B-1)/50);j++){
		for(i=1;i<=50;i++){
			cout << ".#";
		}
		cout <<endl;
		for(i=1;i<=100;i++){
			cout << '.';
		}
		cout <<endl;
	}
	if((B-1)%50>0){
		for(i=1;i<=50;i++){
			cout <<'.';
			if(i<=(B-1)%50) cout <<'#';
			else cout <<'.';
		}
		cout <<endl;
		for(i=1;i<=100;i++){
			cout <<'.';
		}
		cout <<endl;
	}
	
	for(i=1;i<=100;i++){
		cout << '#';
	}
	cout <<endl;
	for(j=1;j<=((A-1)/50);j++){
		for(i=1;i<=50;i++){
			cout << "#.";
		}
		cout <<endl;
		for(i=1;i<=100;i++){
			cout << '#';
		}
		cout <<endl;
	}
	if((A-1)%50>0){
		for(i=1;i<=50;i++){
			cout <<'#';
			if(i<=(A-1)%50) cout <<'.';
			else cout <<'#';
		}
		cout <<endl;
		for(i=1;i<=100;i++){
			cout <<'#';
		}
		cout <<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++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int cnt[100001];
int main()
{
    cin >> N;
    memset(cnt, 0, 100001);
    int ans = 0;
    rep(i, N){
        cin >> A;
        if(A > 100000) ans++;
        else cnt[A]++;
    }
    rep(i, 100001){
        if(cnt[i] < i) ans += cnt[i];
        else ans += (cnt[i] - i);
    }
    cout << ans;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String N = sc.next();
    int ans = 0;
    for (int i = 0; i < N.length(); i++) {
      char n = N.charAt(i);
      ans += Integer.valueOf(String.valueOf(n));
    }
    if (ans == 1) {
      ans = 10;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> a={1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin >>x>>y;
  if(a[x-1]-a[y-1]==0)
     cout <<"Yes";
  else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
/* const int MOD = 1000000007; */
const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, S;
  cin >> N >> S;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int dp[N+1][S+1][3];
  REP(i, N+1) REP(j, S+1) REP(k, 3) dp[i][j][k] = 0;
  dp[0][0][0] = 1;

  REP(i, N) REP(j, S+1){
    (dp[i+1][j][0] += dp[i][j][0]) %= MOD;
    (dp[i+1][j][1] += dp[i][j][0]+dp[i][j][1]) %= MOD;
    (dp[i+1][j][2] += dp[i][j][0]+dp[i][j][1]+dp[i][j][2]) %= MOD;
    if(j+A[i] <= S){
      (dp[i+1][j+A[i]][1] += dp[i][j][0]+dp[i][j][1]) %= MOD;
      (dp[i+1][j+A[i]][2] += dp[i][j][0]+dp[i][j][1]) %= MOD;
    }
  }

  cout << dp[N][S][2] << "\n";

  return 0;
}

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

int main(){
	int n;
	while(1){
		cin >>n;
		if(n == 0) break;
		int dx[101] = {0};
		for(int i = 0; i < n; i++){
			cin >>dx[i];
		}
		int comp = n, cnt = 0;
		while(comp != 1){
			for(int i = 0; i < (comp - 1); i++){
				if(dx[i] > dx[i + 1]){
					swap(dx[i], dx[i + 1]);
					cnt++;
				}
			}
			comp--;
		}
		cout <<cnt <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcount((unsigned int)x);};

const ll mod = 1e9+7;

const ll size = 3100;
ll fact[size+100], finv[size+100];

ll nCk(ll n, ll k){
    if(n < k) return 0;
    return fact[n] * (finv[k]*finv[n-k]%mod) %mod;
}

ll modpow(ll x, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll inv(ll x){
    return modpow(x, mod-2);
}

void prepare(){
    fact[0] = 1;
    rep(i, size-1) fact[i+1] = fact[i]*(i+1)%mod;
    finv[size-1] = inv(fact[size-1]);
    for (ll i = size-1; i > 0; i--) {
        finv[i-1] = finv[i]*i%mod;
    }
}

int main(){
    ll N, K; cin >> N >> K;
    prepare();
    ll rc = N-K;
    ll bc = K;
    
    FOR(i, 1, K+1){
        ll ans = nCk(rc+1, i);
        ll rem = bc-i;
        ans = ans * nCk(rem+i-1, rem) %mod;
        cout << ans%mod << endstr;
    }
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  
   val n = StdIn.readLine().toInt
   val k = StdIn.readLine().toInt
   val i = StdIn.readLine().split(' ').map(_.toInt)
   val r = (0 until n).foldLeft(0){ (acc, h) =>
      acc + scala.math.min((i(h) - 0)*2, scala.math.abs((k - i(h))*2))
   }
   
   println(r)
}

Measured memory_bytes: 25544
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  ll n,ans = 1;
  string s;
  cin >> n >> s;

  char tmp = s.at(0);

  for(int i=1;i<n;i++){
    if(s.at(i)!=tmp){
      ans++;
      tmp = s.at(i);
    }
  }


  cout << ans << endl;
}


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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
  ll a,b,c;
  cin >> a >> b >> c;
  if(a-b >= c) cout << "0" << endl;
  else cout << c-a+b << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;
const int MOD = 1000000007;

int main(){
  ll n,k;
  std::cin >> n >> k;

  ll ans = 0;
  while(k <= n+1) {
    ll p = (k-1)*k/2;
    ll q = ((n + n-k+1)*k)/2;

    ans += q-p+1;
    ans %= MOD;
    k++;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll A, B;
    cin >> A >> B;
    if(A > B)swap(A, B);
    if((B - A) % 2)cout << "IMPOSSIBLE" << endl;
    else cout << A + (B - A) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 5223372036854775807
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=200105;
const int NN=200005;
const ll md=1e9+7;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    ll a[N]={0};
    for (int i=2;i<=n;i++){
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i=1;i<=n;i++){
        cout << a[i] << E;
    }
    r0;
}
/*











*/





Measured memory_bytes: 5212
#include <iostream>
#include <stdio.h>
using namespace std;

bool has3(int x){
        while (x) {
                if (x%10 == 3) return true;
                x /= 10;
        }
        return false;
}

void call(int n){
        for (int x=1; x<=n; x++) {
                if (x%3 ==0 || has3(x)) {
                        cout << " " << x;
                }
        }
        cout << endl;
}

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

        return 0;
}

Measured memory_bytes: 3084
from fractions import gcd

n, m = map(int, input().split())
s = input()
t = input()

gcd_nm = gcd(n, m)
ans = n * m // gcd_nm
n_tmp = n // gcd_nm
m_tmp = m // gcd_nm
for i in range(gcd_nm):
    if s[i * n_tmp] != t[i * m_tmp]:
        print(-1)
        break
else:
    print(ans)

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

int main(){
	int n;

	while (1){
		cin >> n;
		if (n == 0) break;

		double ave = 0;
		int a[n] = {};
		for (int i = 0; i < n; i++){
			cin >> a[i];
			ave += a[i];
		}
		ave /= n;

		double aa = 0;
		for (int j = 0; j < n; j++){
			aa += pow(a[j]-ave, 2);
		}

		aa /= n;

		double s = sqrt(aa);
		printf("%lf\n", s);

	}

	return 0;
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		if(A + B >= C) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23124
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman010 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;
int n , k , ans;
ll sum[N];
int main() {
    abdelrahman010
    cin >> n >> k;
    for(int i = 1;i <= n + 1;i++)
        sum[i] = i + sum[i - 1];
    for(int i = n + 1;i >= k;i--) {
        ll mn = sum[i - 1];
        ll mx = sum[n] - sum[n - i];
        ans = (ans + (mx - mn + 1 + mod) % mod) % mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5160
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const ll INF = LLONG_MAX;
// const int MOD = (int)1e9 + 7;
// const double EPS = 1e-10;
#define PI acosl(-1)
#define MAX_N 100 + 2

void exec(){
  string s;
  cin >> s;
  for (int i = 2; i < s.length(); i+=2){
    int len = s.length() - i;
    string s1 = s.substr(0, len / 2);
    string s2 = s.substr(len / 2, len / 2);
    // cout << "s1" + s1 << endl;
    // cout << "s2" + s2 << endl;
    if (s1 == s2){
      cout << len << endl;
      break;
    }

  }

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


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

int main(){
  int n,m;
  cin>>n>>m;
	string str[n];
	for(int i=0;i<n;i++){
    cin>>str[i];
  }
  sort(str,str+n);
  for(int i=0;i<n;i++){
    cout<<str[i];
  }
  cout<<endl;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    ll N, M, X;
    cin >> N >> M >> X;
    vec C(N);
    mat A(N, vec(M));
    REP(i,0,N) {
        cin >> C[i];
        REP(j,0,M) cin >> A[i][j];
    }

    ll sum, m = INF;
    vec S(N);
    bool f;
    REP(i,0,1<<N) {
        sum = 0;
        f = true;
        REP(j,0,M) {
            S[j] = 0;
            REP(k,0,N) {
                if(i & (1 << k)) S[j] += A[k][j];
            }
            if(S[j] < X) {
                f = false;
                break;
            }
        }
        if(f) {
            REP(k,0,N) {
                if(i & (1 << k)) sum += C[k];
            }
            m = MIN(m,sum);
        }
    }
    if(m != INF) PR(m);
    else PR(-1);

    return 0;
}

/*



*/

Measured memory_bytes: 3632
def max_honest(n_ppl, testimonies):
    formating_str = "{0:0" + str(n_ppl) + "b}"
    max = 0
    for i in range(1, 2**n_ppl + 1):
        current_val = formating_str.format(2**n_ppl - i)
        potential = True
        valid_testemonies = []
        for j in range(0, len(current_val)):
            if current_val[j] == "1":
                for k in range(0, len(testimonies[j])):
                    valid_testemonies.append(testimonies[j][k])
        for j in range(0, len(valid_testemonies)):
            if str(valid_testemonies[j][1]) != current_val[valid_testemonies[j][0] - 1]:
                potential = False
                break
        if potential:
            if current_val.count("1") > max:
                max = current_val.count("1")
    return max

testimonies = []
n_ppl = int(input())

for i in range(0, n_ppl):
    tests = []
    n_tests = int(input())
    for j in range(0, n_tests):
        test = input().split(" ")
        test = (int(test[0]), int(test[1]))
        tests.append(test)
    testimonies.append(tests)
    
print(max_honest(n_ppl, testimonies))

Measured memory_bytes: 3064
#include <iostream>

int main()
{
    int S;
    std::string ans;
    bool one = false;
    bool two = false;
    std::cin >> S;
    int fs = S / 100;
    int sc = S % 100;

    if (fs > 0 && fs <= 12) one = true;
    if (sc > 0 && sc <= 12) two = true;
    
    if (one && two) ans = "AMBIGUOUS";
    else if (one) ans = "MMYY";
    else if (two) ans = "YYMM";
    else ans = "NA";

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, l;
    cin >> n >> l;
    string str[10000];
    for(int i=0; i<n; i++){
        cin >> str[i];
    }
    sort(str, str+n);
    string ans = "";
    for(int i=0; i<n; i++){
        ans+=str[i];
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> C(N), E(N - 1);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    E.at(i) = --b, C.at(b) = --a;
  }

  int K = 1;
  vector<int> X(N);

  for (int i = 1; i < N; i++) {
    int c = C.at(i);
    int x = X.at(c) + 1;
    X.at(c) = C.at(i) = (x == C.at(c) ? ++x : x);
    K = max(K, x);
  }

  cout << K << "\n";
  for (int e : E) cout << C.at(e) << "\n";
}

Measured memory_bytes: 1664
#E
N = int(input())
A = list(map(int,input().split()))
p = {}

ans = 0
for i in range(N):
    if i+1-A[i] in p:
        ans += p[i+1-A[i]]
    if A[i] + (i+1) in p:
        p[i+1+A[i]] += 1
    else:
        p[i+1+A[i]] = 1
    
#print(p)
print(ans)

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

int main() {
  int N , l , r , sum;
  cin >> N;
  sum = 0;

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

cout << sum << endl;

}

Measured memory_bytes: 256
import math


def main():

    while True:
        # 引数を受け取る
        args = input().split(' ')

        num1 = int(args[0])
        num2 = int(args[2])
        op = args[1]

        if op == '?':
            break
        elif op == '+':
            print(num1 + num2)
        elif op == '-':
            print(num1 - num2)
        elif op == '*':
            print(num1 * num2)
        else:
            print(math.floor(num1 / num2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5668
#include<stdio.h>
int main(){
    char s[3];
    char t[3];
    int i;
 
    scanf("%s",s);
    scanf("%s",t);
    int count = 0;
    for(i=0;i<3;i++){
        if(s[i]==t[i]){
        count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int n;
    while (cin >> n) {
        vector<string> a(n);
        for (auto& s : a) cin >> s;
        vector<int> b(n, 0);
        for (int y = 0; y < n; ++y) {
            for (int x = 0; x < n; ++x) {
                char c = a[y][x];
                int x2 = x;
                int y2 = y;
                for (int i = 0; i < n; ++i) {
                    char c2 = a[y2][x2];
                    if (c == c2) ++b[(i + x - y + n) % n];
                    x2 = (x2 + 1) % n;
                    y2 = (y2 - 1 + n) % n;
                }
            }
        }
        long long sm = 0;
        for (int& p : b) {
            if (p == n * n)
                sm += n;
        }
        cout << sm << endl;
    }
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1000000007;
int fac[2000010],inv[2000010];
int qpow(int x,int y)
{
	int ans=1;
	for(;y;y>>=1,x=x*x%mod)
		if(y&1)
			ans=ans*x%mod;
	return ans;
}
int C(int x,int y)
{
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
signed main()
{
	int k,i,ans=0;
	string s;
	cin>>k>>s;
	fac[0]=inv[0]=1;
	for(i=1;i<k+s.size()+5;i++)
	{
		fac[i]=fac[i-1]*i%mod;
		inv[i]=qpow(fac[i],mod-2);
	}
	for(i=0;i<=k;i++)
		ans=(ans+qpow(26,i)*qpow(25,k-i)%mod*C(k-i+s.size()-1,s.size()-1))%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 35616
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freopen("output.txt","w",stdout)
#define read freopen("street.in","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);

using namespace std;


int main()
{
    int x,y;
    cin >> x >> y;

    if(x == y)cout << 0;

    else if(x >= 0 && y >= 0)
    {
        if(x > y)  cout << x-y+ 1 + (y != 0);
        else cout << y-x;
    }
    else if(x < 0 && y < 0)
    {
        if(x > y)
            cout << abs(abs(y)-abs(x)) + 2;
        else
            cout << abs(abs(x)-abs(y));
    }
    else
    {
        cout << abs(abs(y) - abs(x)) + (y != 0);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T
{
    std::io::Read::bytes(std::io::stdin())
                    .map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>()
                    .parse().ok().unwrap()
}

fn main() {
    let s: String = read();

    let price: i32 = s.chars()
                        .fold(700, |acc, x| if x == 'o' {acc + 100} else {acc});
    
    println!("{}", price);
}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll snuke(ll x){
    ll t = x;
    vll pl(40);
    int id=0;
    ll plsum=0;
    while(t>0){
        pl[id]=t%10;
        t/=10;
        plsum+=pl[id];
        id++;
    }
    ll ret = x;
    ll ten = 1;
    REP(i,id){
        if(ret>ten*plsum){
            plsum+=9-pl[i];
            ret+=ten*(9-pl[i]);
            pl[i]=9;
        }
        ten*=10;
    }
    return ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin >> k;
    cout << 1 << endl;
    ll ans = 1;
    REP(i,k-1){
        ans = snuke(ans+1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    INF = 10 ** 18
    N = int(input())
    A = list(map(int, input().split(' ')))
    K = 1 + N % 2  # 余分な×を入れられる個数
    # dp[i][j]: i個目までの要素で余分な×をj個使った際の最大値
    dp = [[- INF for _ in range(K + 1)] for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(K + 1):
            if j < K:
                # 余分な×を使う場合
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j])
            # 余分な×を使わない場合
            now = dp[i][j]
            if (i + j) % 2 == 0:
                # 基本はi % 2 == 0の時にA[i]を足していく
                # ただ、余分な×がj個入っていると、その分ずれる
                now += A[i]
            dp[i + 1][j] = max(dp[i + 1][j], now)
    print(dp[N][K])


if __name__ == '__main__':
    main()


Measured memory_bytes: 72568
cnv [m,r,f] =
  let m' = read m :: Int
      r' = read r :: Double
      r''= toRational r'
      f' = read f :: Int
  in
    (m',r'',f')

interest t r = floor( r * (fromIntegral t) ) 

cal (0, r, f) t 0 = t
cal (0, r, f) t y =
  let i = interest t r
      t'= t - f
  in
    i + cal (0, r, f) t' (y-1)

cal (1, r, f) t 0 = t
cal (1, r, f) t y =
  let i = interest t r
      t'= t + i - f
  in
    cal (1, r, f) t' (y-1)

ans [] = []
ans x =
  let [t,y,n] = map read $ take 3 x :: [Int]
      d = map (cnv . words) $ take n $ drop 3 x
      a = maximum $ map (\c -> cal c t y) d
      r = drop (n+3) x
  in
    a:(ans r)

main = do
  _ <- getLine
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ print o



Measured memory_bytes: 5700
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,Q;
	int i,j;
	string S;
	cin>>N>>Q;
	cin>>S;
	vector<int> pos(N);
	char *p=(char*)S.c_str();
	char *q=p;
	int num=0;
	while (q=strstr(q,"AC")){
		num++;
		pos[(int)(q-p)+1]=num;
		q+=2;
	}
	num=0;
	for (i=0;i<N;i++){
		if (pos[i]==0 && i>0){
			pos[i]=pos[i-1];
		}
	}
	int l,r;
	for (i=0;i<Q;i++){
		num=0;
		cin>>l>>r;
		num+=pos[r-1]-pos[l-1];
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
def main():
    n, m = map(int, input().split())
    costs = [None]*m
    keys = [None]*m
    pattern = 2**n
    inf = 10**12
    dp = [inf]*pattern
    for i in range(m):
        costs[i] = int(input().split()[0])
        keys[i] = sum([1<<(int(i)-1) for i in input().split()])
    dp[0] = 0
    for i in range(pattern):
        for cost, key in zip(costs, keys):
            pi = i|key
            if dp[pi] > cost + dp[i]:
                dp[pi] = cost + dp[i]
    if dp[pattern-1] == inf:
        print(-1)
    else:
        print(dp[pattern-1])
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
N, M, X, Y = [int(i) for i in input().split()]
x_pos = sorted([int(i) for i in input().split()])
y_pos = sorted([int(i) for i in input().split()])

interbal = range(X + 1, Y + 1)
ans = 'War'
for z in interbal:
    if max(x_pos) < z <= min(y_pos):
        ans = 'No War'
        break
print(ans)

Measured memory_bytes: 3064
import math
import sys

while True:
	try:
		a,b,c,d,e,f = map(float, input().split())
		if a*e == b*d:
			continue
		x = (c*e - b*f)/(a*e - b*d)
		y = (c*d - a*f)/(b*d - a*e)
		if x == 0:
			x = 0
		if y == 0:
			y = 0
		print('{0:.3f} {1:.3f}'.format(x,y)) 
	except EOFError:
		break

Measured memory_bytes: 7592
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    bool ok = false;
    if(a > b)swap(a,b);
    n--;
    ll mi = a, ma = a;
    while(n--){
    	ma -= c;
    	mi -= d;
    	if((b - ma) <= n * d && (b - mi) >= n * c) ok = true;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3592
a,b,c,d,e,f=map(int,input().split())

i=0
mizu=[]
while a*i*100<=f:
    j=0
    while b*j*100<=f:
        if a*i+b*j!=0 and (not (a*i+b*j)*100 in mizu):
            mizu.append((a*i+b*j)*100)
        j+=1
    i+=1

# print(mizu)

i=0
sato=[]
while c*i<=f:
    j=0
    while d*j<=f:
        if not c*i+d*j in sato:
            sato.append(c*i+d*j)
        j+=1
    i+=1
# print(sato)

ans=[sato[0],mizu[0]]
for i in range(len(mizu)):
    for j in range(len(sato)):
        if sato[j]+mizu[i]<=f and sato[j]*100<=e*mizu[i]:
            if ans[0]/(ans[0]+ans[1])<sato[j]/(mizu[i]+sato[j]):
                ans=[sato[j], mizu[i]]

print("{0} {1}".format(ans[0]+ans[1], ans[0]))

Measured memory_bytes: 40176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  string s; cin>>s;
  reverse(al(s));
  int64_t ans=0,cnt,n=s.size()-1;
  rep(i,(1<<n)){
    bitset<9> b(i);
    ans+=s[0]-'0';
    cnt=10;
    rep(j,n){
      if(b.test(j)) cnt=1;
      ans+=(s[j+1]-'0')*cnt;
      cnt*=10;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    string str;

    cin>>n;
    cin>>str;

    int rCnt = 0;
    for(int i = 0; i < n; i++) {
        if(str[i] == 'R')
            rCnt++;
    }

    int ans = 0;
    for(int i = 0; i < rCnt; i++) {
        if(str[i] == 'W')
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3700
#include<iostream>
using namespace std;
int main(){
	int num;
	int remainder=0 ;
	int reverse=0;
	cin>>num; 
	int n=num;
	while (num!=0)
	{
		remainder=num%10;
		reverse=reverse*10+remainder;
		num=num/10;
	}
if(n==reverse)
cout<<"Yes";
else
cout<<"No";

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main() {
  int N;
  cin >> N;
  ll ans = 0;
  ll L[N];
  rep(i,N) cin >> L[i];
  for(int i=0; i<N; i++) {
	for(int j=i+1; j<N; j++) {
	  for(int k=j+1; k<N; k++) {
		ll a = L[i];
		ll b = L[j];
		ll c = L[k];
		if(a == b || b == c || c == a) continue;
		if(a + b + c <= 2*max(a,max(b,c))) continue;
		ans++;;
	  }
	}
  }
  cout << ans << endl;
}



Measured memory_bytes: 3180
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

int n;
string s;
cin >> n;
cin >> s;
int b=0, r=0;
for(int i=0; i<n; i++){
	if(s[i]=='R'){
		r++;
	} else {
		b++;
	}
}
if(r>b){
	cout << "Yes" << endl;
} else {
	cout << "No" << endl;
}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;

int main(){
    ll N,M,buy;
    ll i=-1;
    ll ans=0;
    cin>>N>>M;
    vvl vec(N,vl(2));
    for(ll i=0;i<N;i++){
        cin>>vec[i][0]>>vec[i][1];
    }
    
    sort(vec.begin(),vec.end());
    
    while(M){
        i++;
        buy=min(M,vec[i][1]);
        ans+=buy*vec[i][0];
        M=max((ll)0,M-buy);
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 5760