akhauriyash/Code-Regression huggingface dataset:
from collections import defaultdict
N,M,K=map(int,input().split())
MOD=998244353
 
def comb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

#https://algo-logic.info/combination/
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

ans=0
col=M
 
for x in range(N-1,-1,-1):
  now=col*comb(N-1,x,MOD)%MOD
  if x<=K:
    ans = (ans+now)%MOD
  col =col*(M-1)%MOD

print(ans%MOD)

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

int main(){
  int N,A;
  cin>>N>>A;
  int x[N];
  for(int i=0;i<N;i++){
    cin>>x[i];
    x[i] -= A;
  }
   long long int dp[N+1][6000];
  for(int i=0;i<N+1;i++){
    for(int j=0;j<6000;j++){
      dp[i][j] = 0;
    }
  }
  dp[0][3000] = 1;
  for(int i=0;i<N;i++){
    for(int j=0;j<6000;j++){
      dp[i+1][j] += dp[i][j] + dp[i][j-x[i]];
    }
  }
  
  cout << dp[N][3000]-1 << endl;
}
    

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

bool check(int m, int d){
	int d10, d1; d10 = d/10; d1 = d%10;
	return d10 >= 2 && d1 >= 2 && m == d10 * d1;
}

int main(){
	int m,d; cin >> m >> d;
	int ans = 0;
	FOR(i,1,m){
		FOR(j,1,d){
			ans += (check(i,j)? 1:0);
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// abc136d.cpp : Gathering Children
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

void p1(vi v){
  for(auto a: v){ot(a);ot(",");}
}
void p2(vvi &x){
  for(auto v: x){ot("[");p1(v);ot("]\n");}
}

void pp(vi &o, int n){
  rp(i,n) cout<<o[i]<<" ";
  ote("");
}

int main(){
  string s;in(s);
  int n = s.length();
  vi o(n);
  vi d(n);
  char L='L';
  char R='R';
  int m=0;
  rp(i,n){
    if(i+1<n && s[i]==R && s[i+1]==L){
      d[m++] = i;
    }
  }

  rp(i,n){
    int step = 0;
    int j;
    if(s[i]==R){
      for(j=0; j<m; j++){
        if(i<=d[j]){
          step = d[j]-i;
          break;
        }
      }
      if(step%2){//残奇数
        o[d[j]+1]++;
      }else{//残偶数
        o[d[j]]++;
      }
    }else{
      for(j=m-1; j>=0; j--){
        if(i>=d[j]){
          step = d[j]-i;
          break;
        }
      }
      if(step%2){//残奇数
        o[d[j]+1]++;
      }else{//残偶数
        o[d[j]]++;
      }
    }
  }

  ot(o[0]);
  up(i,1,n,1) cout<<" "<<o[i];
  ote("");

}

Measured memory_bytes: 1536
def buble_sort(a,n):
    flag = True
    count = 0
    while flag:
        flag = False
        for j in range(n-1,0,-1):
            if a[j] < a[j-1]:
                a[j],a[j-1] = a[j-1],a[j]
                count += 1
                flag = True
    return (a,count)

n = int(input())
a = list(map(int, input().split()))
a,c = buble_sort(a,n)
print(' '.join(map(str, a)))
print(c)

Measured memory_bytes: 7700
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
int n,k;
int p[6000];
int c[6000];
cin>>n>>k;
rep(i,n)cin>>p[i];
rep(i,n)p[i]--;
rep(i,n)cin>>c[i];
ll ans=(ll)-1e18;
for(int i=0;i<n;i++)
{
int si=i;
vector<int>s;
int x=si;

ll tot=0;
while(1)
{
x=p[x];
s.push_back(x);
tot+=c[x];
if(x==si)break;
}
ll t=0;

for(int i=0;i<s.size();i++)
{
if(i+1>k)break;
t+=c[s[i]];
ll now=0;
now=t;
if(tot>0)
{
now+=tot*((k-i-1)/s.size());


}
ans=max(ans,now);

}

}


cout <<ans;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n, x; cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n-1) {
        ll sum = a[i]+a[i+1];
        if(sum > x) {
            ll r = sum - x;
            ans += r;
            if(r > a[i+1]) {
                a[i+1] = 0;
                a[i] -= (r-a[i+1]);
            } else {
                a[i+1] -= r;
            }
        }
    }
    cout << ans;
}



Measured memory_bytes: 640
#include<stdio.h>
int main(){
int a,b,c,d=21,e=0,i;
scanf("%d\n",&a);
for(i=0;i<a;i++){
scanf("%d %d\n",&b,&c);
if(c>e){
d=b,e=c;
}
else if(c==e && b<d){
d=b,e=c;
}
}
printf("%d %d\n",d,e);
return 0;
}



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

set<string> pass_list;

string solve(string now, int length)
{
    assert(now.size() <= 4);

    if (now.size() == length) {
        return pass_list.count(now) ? "" : now;
    }

    rep(i, 26) {
        string tmp = solve(now + (char)('a' + i), length);
        if (tmp.size() > 0) return tmp;
    }

    return "";
}

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    for (auto s : S) {
        rep(i, s.size()) {
            string tmp;
            rep(j, 4) {
                if (i + j < (int)s.size()) {
                    tmp += s[i + j];
                    pass_list.insert(tmp);
                }
            }
        }
    }

    rep(i, 4) {
        string tmp = solve("", i+1); 
        if (tmp != "") {
            cout << tmp << endl;
            break;
        }
    }
}

Measured memory_bytes: 42916
#include<bits/stdc++.h>
#define ll long long
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
using namespace std;
int n,E,T,t,a[100005];
ll dp[100005];
int main(){
	scanf("%d%d%d",&n,&E,&T);
	For(i,1,n) scanf("%d",&a[i]);
	ll mn=1ll<<60;
	For(i,1,n){
		for (;T<=2*(a[i]-a[t+1]);t++)
			mn=min(mn,dp[t]-2*a[t+1]);
		dp[i]=min(dp[t]+T,mn+2*a[i]);
	}
	printf("%lld",E+dp[n]);
}

Measured memory_bytes: 1408
from sys import stdin
import sys

n, y = [int(i) for i in stdin.readline().rstrip().split()]

for p in range(2001):
    for q in range(n-p+1):
        r = n-p-q
        if 10000*p+5000*q+1000*r == y:
            print (str(p),str(q),str(r))
            sys.exit()

print ("-1 -1 -1")








Measured memory_bytes: 9040
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,w = map(int,readline().split())
wv = list(map(int,read().split()))

inf = -1 * 10**10
dp = [[inf] * (301) for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
    wi,vi = wv[i*2:i*2+2]
    wi -= wv[0]
    for j in range(n,0,-1):
        for k in range(wi,301):
            dp[j][k] = max(dp[j][k], dp[j-1][k-wi] + vi)

ans = 0
for i in range(n+1):
    for j in range(301):
        if(i*wv[0] + j <= w):
            ans = max(ans,dp[i][j])

print(ans)

Measured memory_bytes: 74152
#include<stdio.h>

int main(void){
    int n, cnt = 0, g, min= 1000;
    scanf("%d""%d", &n, &g);
    int nums[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &nums[i]);
        g -= nums[i];
        if(min > nums[i]){
            min = nums[i];
        }
    }
    printf("%d\n", cnt = n + g / min);
    return 0;

}

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

int main(){
	int n;
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9){
		cout<<"hon"<<endl;
	}else if(n%10==0||n%10==1||n%10==6||n%10==8){
		cout<<"pon"<<endl;
	}else{
		cout<<"bon"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
float calcy(float,float,float,float,float,float);
float calcx(float,float,float,float);
int main(void)
{
	int a,b,c,d,e,f;
	float x,y;
	int i=0;
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)==6){
		y=calcy(a,b,c,d,e,f);
		x=calcx(a,b,c,y);
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}
float calcy(float a,float b,float c,float d,float e,float f){
	float y;
	b=b/a*-1;
	c=c/a;
	b=d*b;
	c=d*c;
	e=b+e;
	f=f-c;
	y=f/e;
	return y;
}
float calcx(float a,float b,float c,float y){
	float x;
	b=b*y;
	c=c-b;
	x=c/a;
	return x;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T&x)
{
	T ll=1;
    T res=0;
	char ch=getchar();
    while(!isdigit(ch))
    {
		if(ch=='-')
		ll=-1;
		ch=getchar();
	}
    while(isdigit(ch))
	res=(res<<3)+(res<<1)+ch-'0',ch=getchar();
    x=res*ll;
}
template<typename T>void print(T x)
{
    if(x<0)putchar('-'),x=-x;
    if(x<10)
    putchar(x+'0');
    else
    {
        print(x/10);
        putchar(x%10+'0');
    }
}
int main()
{
	string s;
	cin>>s;
	int len=s.length();
	if(s[0]==s[len-1])
	{
		if(len%2==0)
		{
			puts("First");
		}
		else
		{
			puts("Second");
		}
	}
	else
	{
		if(len%2==0)
		{
			puts("Second");
		}
		else
		{
			puts("First");
		}
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
typedef pair<int, int> P;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    P p[100010];
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        p[i] = {b, a};
    }
    int ans = 0;
    sort(p, p + M);
    int r = -1;
    // cout << endl;
    // rep(i, M) {
    //     cout << p[i].second << " " << p[i].first << endl;
    // }
    
    rep(i, M) {
        if(r <= p[i].second) {
            r = p[i].first;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4404
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define LL long long
const int maxn = 100000 + 100;
char str[maxn];

int main() {
    #ifdef LOCAL
        freopen("test.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
    #endif // LOCAL
    ios::sync_with_stdio(false);

    while(scanf("%s", str + 1) != EOF) {
        int len = strlen(str + 1);
        int ans = len;
        for(int i = 1; i < len; ++i) {
            if(str[i] != str[i + 1]) {
                ans = min(ans, max(i, len - i));
            }
        }
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int x, a, b, n = 0;
	cin >> x >> a >> b;
	x = x - a;
	n = x / b;
	x = x - n * b;
	cout << x << 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);
		int N = scan.nextInt();
		System.out.println(search(N));
	}

	public static int search(int N) {
		int work_n;
		int ans = 1;
		int count = 0;
		int max_count = 0;

		for(int n = 1; n <= N; n++) {
			count = 0;
			work_n = n;
			while ((work_n % 2 == 0) && (work_n > 0)) {
				work_n /= 2;
				count++;
			}
			if (max_count < count) {
				ans = n;
				max_count = count;
			}
		}
		return ans;
	}
}


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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define int long long

const int MOD = 1e9 + 7;
const int oo = 1e9;
const int N = 1e5 + 10;

int n, ans;
int pw10[20];

int solve(int pos, int rem, bool spm)   {
    if(pos == 0) return ((rem == 0) ? 1 : 0);
    if(pos == 1) return ((rem == 0) ? 10 : 0);
    int sum = 0ll;
    for(int i = -9; i <= 9; ++i)    {
        int nex = rem - 1ll * i * (pw10[pos - 1] - 1);
        if(nex % 10 == 0)   {
            if(!spm) {
                if(i >= 0) sum += solve(pos - 2, nex / 10, true) * (9 - i);
            } else sum += solve(pos - 2, nex / 10, true) * (10 - abs(i));
        }
    }
    return sum;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    pw10[0] = 1ll; FOR(i, 1, 17) pw10[i] = pw10[i - 1] * 10;
    FOR(i, 1, 18) ans += solve(i, n, false);

    cout << ans;
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;

int dp[2][101][501];
int n ,  x;
vector<int> val;
void add(int & x , ll y){
    x += y % mod;
    if(x >= mod)x -= mod;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> x;
    val.resize(n);
    for(auto & c : val)cin >> c;
    sort(val.begin(),val.end(),greater<int>());
    bool bit = 0;dp[0][0][0] = 1;
    for(auto & l : val){
        for(int i = 0 ; i <= n ; ++i){
            for(int j = 0 ; j <= x ; ++j){
                if(dp[bit][i][j] > 0){
                    if(j + l <= x)add(dp[!bit][i + 1][j + l],(ll)dp[bit][i][j] * (i + 1));
                    if(i >= 1){
                        add(dp[!bit][i][j] , (ll)dp[bit][i][j] * (j - i * (l - 1)));
                        for(int k = 1 ; k <= l && k + j <= x ; ++k){
                            add(dp[!bit][i][j+k],(ll)dp[bit][i][j]*i*2);
                            if(i >= 2){
                                add(dp[!bit][i-1][j+k],(ll)dp[bit][i][j]*(l-k+1)*(i-1));
                            }
                        }
                    }
                    dp[bit][i][j] = 0;
                }
            }
        }
        bit ^= 1;
    }
    cout << dp[bit][1][x];
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n;
    cin >> n;
    if(n == 1)
        cout << "Hello World";
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++) 

int main() {
    int K, N;
    int A[220000];
    cin >> K >> N;
    rep(i, N) cin >> A[i];

    int max1 = 0;
    for (int i = 0; i < N-1; i++) {
        if (max1 < A[i+1] - A[i]) {
            max1 = A[i+1] - A[i];
        }
    } 
    int max2 = K-A[N-1] + A[0];
    int ansmax = max(max1, max2);

    cout << K-ansmax << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n, r;
    scanf("%d%d", &n, &r);
    if (n < 10) {
        printf("%d\n", r + 100 * (10 - n));
    }else {
        printf("%d\n", r);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,n1,total=0;
    scanf("%d",&n);
    n1=n;
    while(n!=0){
            m=n%10;
        total=total+m;
        n=n/10;
    }
    if(n1%total==0){
        printf("Yes\n");
    }
    else{
        printf("No\n");

    }
    return 0;
}


Measured memory_bytes: 128
N=int(input())
A=list(map(int,input().split()))
A.sort()
count=1
ans=A[-1]
id=N-2
while count!=N-1:
    if count+2<=N-1:
        ans+=2*A[id]
        count+=2
        id-=1
    else:
        ans+=A[id]
        count+=1

print(ans)


Measured memory_bytes: 94244
public class Main {

	private static void solve() {
		int n = ni();
		int[][] p = ntable(n - 1, 3);
		
		for (int i = 0; i < n - 1; i ++) {
			int now = 0;
			for (int j = i; j < n - 1; j ++) {
				now = f(j, now, p);
			}
			out.println(now);
		}
		out.println(0);
	}
	
	private static int f(int i, int t, int[][] p) {
		if (p[i][1] <= t) {
			return (t + p[i][2] - 1) / p[i][2] * p[i][2] + p[i][0];
		} else {
			return p[i][1] + p[i][0];
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


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

int main(){
  int n, a, b, c, d;
  cin >> n;
  a = n/1000 ;
  b = n%1000/100 ;
  c = n%1000%100/10 ;
  d = n%1000%100%10 ;
  
  if (a == b && b == c && c == d){
    cout << "Yes" << endl;
  }
  else if (a == b && b == c){
    cout << "Yes" << endl;
  }
  else if (b == c && c == d){
    cout << "Yes" << endl;
  }
  else {
    cout <<"No" << endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>){
    
    val n = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map{ it.toInt() }
    val B = readLine()!!.split(" ").map{ it.toInt() }
    
    val A_d = A.drop(1)
    val B_d = B.take(B.size-1)
    val ans = mutableListOf<Int>()

    var sum = B_d.sum()
    ans += sum
    for (i in 0..A_d.size-1){
        sum += A_d[i]-B_d[i]
        ans += sum
    }

    val tmp: Int = ans.max()!!
    println(tmp + A[0] + B[B.size-1])

}

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

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NW = Sarray();
            var N = NW[0];
            var W = NW[1];
            var wi = new long[N];
            var vi = new long[N];
            for (var i = 0; i < N; ++i)
            {
                var wv = Sarray();
                wi[i] = wv[0];
                vi[i] = wv[1];
            }
            var GETA = wi[0] - 1;
            for (var i = 0; i < N; ++i)
                wi[i] -= GETA;
            var lst = 4 * N;
            var dp = new long[N + 1, N + 1, lst + 1];
            for (var i = 1; i <= N; ++i)
            {
                for (var n = 1; n <= N; ++n)
                {
                    for (var j = 0; j <= lst; ++j)
                    {
                        if (wi[i - 1] <= j)
                        {
                            var t = dp[i - 1, n - 1, j - wi[i - 1]];
                            if (n == 1 || t != 0)
                                dp[i, n, j] = t + vi[i - 1];
                        }
                        dp[i, n, j] = Max(dp[i, n, j], dp[i - 1, n, j]);
                    }
                }
            }
            var ans = 0L;
            for (var n = 1; n <= N; ++n)
            {
                var ho = GETA * n;
                for (var j = 0; j <= lst; ++j)
                {
                    if (ho + j <= W)
                        ans = Max(ans, dp[N, n, j]);
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 59828
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 2000000

void insert(int);
void heapIncreasekey(int *, int, int);
int heapextractMax(int *);
void maxheap(int *, int);

int heap[N+1], A[N+1], size=0;

int main(){

  int i, k, count=0;
  char command[8];

  while(1){
    scanf("%s",command);
    if(strlen(command)==3) break;
    else if(command[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(command[0]=='e'){
      A[count]=heapextractMax(heap);
      count++;
    }
  }
  for(i=0;i<count;i++){
    printf("%d\n",A[i]);
  }
  return 0;
}

void insert(int k){
  size++;
  heap[size]=-1;
  heapIncreasekey(heap, size, k);
}

void heapIncreasekey(int *heap, int i, int k){
  int t;

  if(k<heap[i]) return;
  heap[i]=k; 
  while(i>1 && heap[i/2]<heap[i]){
     t=heap[i];
     heap[i]=heap[i/2];
     heap[i/2]=t;
     i/=2;
  }
}

int heapextractMax(int *heap){
  int max;

  if(size<1) return 0;
  max=heap[1];
  heap[1]=heap[size];
  size--;
  maxheap(heap, 1);
  return max;
}
    
void maxheap(int *heap, int i){
  int l=2*i, r=2*i+1, largest, t;

  if(l<=size && heap[l]>heap[i]) largest=l;
  else largest=i;
  if(r<=size && heap[r]>heap[largest]) largest=r;
  if(largest!=i){
    t=heap[i];
    heap[i]=heap[largest];
    heap[largest]=t;
    maxheap(heap, largest);
  }
}

    




  
  
  
  


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

int main()
{
  int n,m,l;
  cin >> n >> m >> l;
  int A[100][100]={};
  int B[100][100]={};
  long int C[100][100]={};

  for(int i=0;i<n;i++)
    {
      for(int j=0;j<m;j++)
	{
	  cin >> A[i][j];
	}
    }

  for(int i=0;i<m;i++)
    {
      for(int j=0;j<l;j++)
	{
	  cin >> B[i][j];
	}
    }

  for(int i=0;i<n;i++)
    {
      for(int j=0;j<l;j++)
	{
	  for(int k=0;k<m;k++)
	    {
	      C[i][j]+=A[i][k]*B[k][j];
	    }
	  cout << C[i][j] ;
	  if(j==l-1)cout << endl;
	  else cout << " ";
	}
    }

  return 0;
}

Measured memory_bytes: 1324
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int D;
	cin >> D;
	cout << "Christmas";
	rep(i, 25 - D)cout << " Eve";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include  <set>
#include <cmath>
#include <cstdlib>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define dd(t,h) if(t!=0) h+=10;



int main() {
	ll  a = 10, b, c, d, e, f, g = 0, n, i, j, k, m = 0, h[150], sum = 3000, hh[150] = {};
	cin >> n ;
	h[0] = 0;
	rep(i, n) {
		cin >> h[i+1];
		if (h[i+1] > g)g = h[i+1];
	}
	for (i = 1; i < g + 1; i++) {
		for (j = 1; j < n + 1; j++) {
			if (h[j] >= i)hh[j]++;
			if (hh[j - 1] < hh[j] && hh[j] == i)m++;
		}
		//cout << i << m << "\n";
	}
	cout << m;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n,m;
	while(cin>>n>>m){
		if(n==0 && m==0){
			break;
		}
		int *taro,*hanako;
		int tSum=0,hSum=0;
		int min=100000;
		int minT=-1,minH=-1;

		taro = new int[n];
		hanako=new int[m];
		for(int i=0;i<n;i++){
			cin>>taro[i];
			tSum+=taro[i];
		}
		for(int i=0;i<m;i++){
			cin>>hanako[i];
			hSum+=hanako[i];
		}

		int flag=0;

		for(int i=0;i<n;i++){
			int tmpTSum=tSum;
			int tmpHSum=hSum;

			for(int j=0;j<m;j++){
				tmpTSum=tSum;
				tmpHSum=hSum;
				tmpTSum = tmpTSum-taro[i]+hanako[j];
				tmpHSum = tmpHSum-hanako[j]+taro[i];

				if(tmpTSum == tmpHSum){
					if(taro[i]+hanako[j]<=min){
						min=taro[i]+hanako[j];
						minT=taro[i];
						minH=hanako[j];
					}
					flag=1;
					break;
				}
			}
		}

		if(flag==0){
			cout<<-1<<endl;
		}
		else{
			cout<<minT<<" "<<minH<<endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = a; i < n; ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

// nPr の列挙
template <typename BidirectionalIterator>
inline bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last) {
    reverse(middle, last);
    return next_permutation(first, last);
}

bool Q(const string& s, int& i);
int E(const string& s, int& i, bool& ng);
int T(const string& s, int& i, bool& ng);
int F(const string& s, int& i, bool& ng);
int N(const string& s, int& i, bool& ng);

bool Q(const string& s, int& i) {
    bool ng = false;
    int val = E(s, i, ng);
    if (ng || s[i] != '=') return false;
    ++i; // '='
    ng = false;
    int val2 = E(s, i, ng);
    if (ng || i != s.size()) return false;
    return (val == val2);
}

int E(const string& s, int& i, bool& ng) {
    int val = T(s, i, ng);
    while (s[i] == '+' || s[i] == '-') {
        char op = s[i];
        ++i;
        int val2 = T(s, i, ng);
        if (op == '+') val += val2;
        else val -= val2;
    }
    return val;
}

int T(const string& s, int& i, bool& ng) {
    int val = F(s, i, ng);
    while (s[i] == '*') {
        ++i;
        int val2 = F(s, i, ng);
        val *= val2;
    }
    return val;
}

int F(const string& s, int& i, bool& ng) {
    if (isdigit(s[i])) return N(s, i, ng);
    if (s[i] == '-') {
        ++i;
        return -F(s, i, ng);
    }
    if (s[i] != '(') return (ng = true);
    ++i;
    int val = E(s, i, ng);
    if (s[i] != ')') return (ng = true);
    ++i;
    return val;
}

int N(const string& s, int& i, bool& ng) {
    if (s[i] == '0') {
        ++i;
        return 0;
    }
    if (s[i] == '1') {
        int val = 1;
        ++i;
        while (s[i] == '0' || s[i] == '1') {
            val = val * 2 + (s[i] - '0');
            ++i;
        }
        return val;
    }
    return (ng = true);
}

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

    string s;
    cin >> s;
    const int n = s.size();
    vector<char> alphabets;
    for (char c : s) if (isalpha(c)) alphabets.push_back(c);
    sort(alphabets.begin(), alphabets.end());
    alphabets.erase(unique(alphabets.begin(), alphabets.end()), alphabets.end());
    const int alphabets_size = alphabets.size();
    string symbols = "()*+-01=";  // ソート済み
    int ans = 0;
    do {
        map<char, char> mp;
        for (int i = 0; i < alphabets_size; ++i) {
            mp[alphabets[i]] = symbols[i];
        }
        int equal_cnt = 0;
        string t;
        t.reserve(100);
        t = s;
        for (int i = 0; i < n; ++i) {
            if (isalpha(s[i])) t[i] = mp[s[i]];
            if (t[i] == '=') ++equal_cnt;
        }
        if (equal_cnt != 1) continue;
        const int equal_pos = t.find('=');
        int i = 0;
        ans += Q(t, i);
    } while (next_partial_permutation(symbols.begin(), symbols.begin() + alphabets_size, symbols.end()));
    cout << ans << endl;
}


Measured memory_bytes: 3236
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AOneOutOfThree {
public:
	void solve(istream& in, ostream& out) {
        int a, b, c; in >> a >> b >> c;
        if(a == b) out << c << endl;
        else if(b == c) out << a << endl;
        else if(c == a) out << b << endl;
	}
};

int main() {
	AOneOutOfThree solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    string t = s;
    reverse(s.begin(), s.end());
    if(t == s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int cnt[5];
int main(){
	int n;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		if(s == "AC")cnt[1]++;
		else if(s == "WA")cnt[2]++;
		else if(s == "TLE")cnt[3]++;
		else if(s == "RE")cnt[4]++;
	}
	cout << "AC x " << cnt[1] << "\nWA x " << cnt[2];
	cout << "\nTLE x " << cnt[3] << "\nRE x " << cnt[4];
	return 0;
}


Measured memory_bytes: 3628
from collections import Counter
H, W = map( int, input().split())
S = ''
for _ in range(H):
    S += input()
CS = Counter(S)
ans = 'Yes'
two = 0
one = 1
if H%2 == 1:
    two += W//2
if W%2 == 1:
    two += H//2
if H%2 == 1 and W%2 == 1:
    one = 1

nowtwo = 0
nowone = 0
for x in CS:
    if CS[x]%4 == 0:
        continue
    else:
        if CS[x]%2 == 0:
            nowtwo += 1
            if nowtwo > two:
                ans = 'No'
                break
        else:
            nowone += 1
            if nowone > one:
                ans = 'No'
                break
print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    vector <ii> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i].f >> a[i].s;

    vector <ii> v;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            v.app(mp(a[j].f - a[i].f, a[j].s - a[i].s));
        }   
    }   

    if (n == 1) {
        cout << 1 << endl;
        exit(0);
    }   

    int ans = 1e9;
    for (auto e : v) {
        if (e.f == 0 && e.s == 0)
            continue;

        int cnt = 0;

        for (auto p : a) {
            auto w = mp(p.f + e.f, p.s + e.s);
            for (auto pp : a) {
                if (pp == w) {
                    ++cnt;
                    break;
                }   
            }   
        }   

        ans = min(ans, n - cnt);
    }
    cout << max(ans,1ll) << endl;

}

Measured memory_bytes: 508
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
struct Point { long double px, py; };
struct Segment { Point p1, p2; }; 
Segment x[55], y[55]; Point p[55], q[55]; int n, m;
Point Minus(const Point& a, const Point& b) { return Point{ a.px - b.px,a.py - b.py }; }
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
long double dst(const Segment& a, const Point& b) { return dot(Minus(a.p2, a.p1), Minus(b, a.p1)) < 0.0 ? abs(Minus(b, a.p1)) : (dot(Minus(a.p1, a.p2), Minus(b, a.p2)) < 0.0 ? abs(Minus(b, a.p2)) : abs(crs(Minus(a.p2, a.p1), Minus(b, a.p1)) / abs(Minus(a.p2, a.p1)))); }
long double dst(const Segment& a, const Segment& b) { 
	long double P1 = dst(a, b.p1), P2 = dst(a, b.p2), P3 = dst(b, a.p1), P4 = dst(b, a.p2);
	return min({ P1,P2,P3,P4 });
}
int main() {
	cin >> n; for (int i = 0; i < n; i++)cin >> p[i].px >> p[i].py;
	cin >> m; for (int i = 0; i < m; i++)cin >> q[i].px >> q[i].py;
	for (int i = 0; i <= n; i++) {
		int F = i - 1, G = i; Point D1, D2;
		if (F == -1)D1 = Point{ 0,0 }; else D1 = p[F];
		if (G == n)D2 = Point{ 1000,0 }; else D2 = p[G];
		x[i] = Segment{ D1,D2 };
	}
	for (int i = 0; i <= m; i++) {
		int F = i - 1, G = i; Point D1, D2;
		if (F == -1)D1 = Point{ 0,1000 }; else D1 = q[F];
		if (G == m)D2 = Point{ 1000,1000 }; else D2 = q[G];
		y[i] = Segment{ D1,D2 };
	}
	long double minx = 1e6;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			minx = min(minx, dst(x[i], y[j]));
		}
	}
	printf("%.24Lf\n", minx);
	return 0;
}

Measured memory_bytes: 3308
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    long long int N,H,W,i,j,k,ans,count,cost,tmp;
    long long int S[200010];
    long long int Ssum[200010];
    string T;
    bool flag;
    count=0;
    ans=std::pow(10,18);
    flag=false;
    cin >>T;
    
        if (T=="SUN"){
            
            cout <<7 <<endl;
        }
        else if(T=="MON"){
            cout <<6 <<endl;
        }
        else if(T=="TUE"){
            cout <<5 <<endl;
        }
        else if(T=="WED"){
            cout <<4 <<endl;
        }
        else if(T=="THU"){
            cout <<3 <<endl;
        }
        else if(T=="FRI"){
            cout <<2 <<endl;
        }
        else if(T=="SAT"){
            cout <<1 <<endl;
        }
    

    
    

    return 0;
    
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define Phuong ios_base::sync_with_stdio(0); cin.tie(0);

typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
vector<pii> a;

int main()
{
    Phuong;
    //freopen("input.inp", "r", stdin);
    int n;
    cin >> n;
    a = vector<pii> (n);
    for(int i=0; i<n; ++i) cin >> a[i].second >> a[i].first;
    sort(a.begin(), a.end());
    int sum=0;
    bool flag=true;
    for(int i=0; i<n; ++i)
    {
        if (sum+a[i].second>a[i].first)
        {
            flag=false;
            break;
        }
        sum+=a[i].second;
    }
    if (flag) cout << "Yes"; else cout << "No";

    return 0;
}


Measured memory_bytes: 1792
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <iostream>

int main() {
	using namespace std;
	namespace mp = boost::multiprecision;
	// 任意長整数型
	using Bint = mp::cpp_int;
	// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
	using Real = mp::number<mp::cpp_dec_float<1024>>;
	Bint a, b; cin >> a >> b;
	if (a > b) {
		cout << "GREATER" << endl;
	}
	else if (a == b) {
		cout << "EQUAL" << endl;
	}
	else {
		cout << "LESS"<< endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pa pair
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;




int main()
{
    
    
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    if(d==1) cout << 1 << endl;
    else out(0);
    
    
    
    return 0;
}



Measured memory_bytes: 256
import itertools
n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]

ans = -float("inf")
for i in itertools.product((0,1), repeat=10):
  if list(i) == [0] * 10:
    continue
  a = 0
  for j in range(n):
    c = 0
    for k in range(10):
      if i[k] == f[j][k] == 1:
        c += 1
    a += p[j][c]
  ans = max(ans, a)
  
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int h = sc.nextInt();
      int w = sc.nextInt();
      if(h == 0 && w == 0) {
        break;
      } else {
        for(int i = 0; i < h; i++) {
          for(int j = 0; j < w; j++) {
            if(i % 2 == 0) {
              if(j % 2 == 0) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            } else {
              if(j % 2 == 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
          }
          System.out.println();
        }
        System.out.println();
      }
    }
  }
}



Measured memory_bytes: 36956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n; cin >> n;
	cout<<n+n*n+n*n*n;
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3644
n = int(input())
ans = 0

def ryuka(a,b,count):
    global ans
    c = a + b
    if count == n:
        ans = c
    else:
        count = count + 1
        ryuka(b,c,count)
        
if n == 0 :
    print(2)
elif n == 1:
    print(1)
else:
    ryuka(2,1,2)        
    print(ans)


Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  int AC = 0, WA = 0, TLE = 0, RE = 0;

  cin >> N;

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;

    if (S == "AC") AC++;
    if (S == "WA") WA++;
    if (S == "TLE") TLE++;
    if (S == "RE") RE++;
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;

  vector<int> vec(m);
    for (int i = 0; i < m; i++)
    {
        cin >> vec.at(i);
    }
  int sum =0;
  for (int i = 0; i < m; i++)  {
    sum=sum+vec.at(i);
  }
  if(n-sum<0){
    cout<<-1<<endl;
  }
  else{
    cout<<n-sum<<endl;
  }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod = 1e9 + 7;
long long INF = 1e7;
double EPS = 1e-12;
typedef long long int lld;
long double tick(){static clock_t oldt; clock_t newt=clock();
    long double diff=1.0L*(newt-oldt)/CLOCKS_PER_SEC; oldt = newt; return diff; }
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
inline lld sc() { lld a; scanf("%lld", &a); return a; }
inline int scd() { int a; scanf("%d", &a); return a; }
inline double scf() { double a; scanf("%lf",&a); return a; }
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) (c).begin(), (c).end()
#define sz(a) ((int)a.size())
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }
#define errorpair(a) cout<<#a<<" = ( "<<((a).first)<<" , "<<((a).second)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld x, lld y) {
    lld ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}
 
bool bitSet(lld n, lld bit){
    if((n & (1LL << bit)) != 0) return true;
    else return false;
}
 
lld findGcd(lld a, lld b){
    while(a != 0) { lld temp = b % a; b = a; a = temp; }
    return b;
}

#define lim 1000010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
PA P[lim], N[lim];

int main(){
    lld n = sc();
    lld pos = 0, neg = 0;
    rep(i,0,n-1) {
        lld mn = 0, total = 0;
        string S;
        cin >> S;
        for(auto c : S) {
            total += (c == '(') ? 1 : -1;
            mn = min(mn, total);
        }
        if(total >= 0) P[pos++] = {-mn, total};
        else N[neg++] = {mn, total};
        // P[i] = {-mn, total};
    }
    sort(P, P + pos);
    sort(N, N + neg, [](const PA& a, const PA& b) {
        return a.first - a.second < b.first - b.second;
    });
    lld curr = 0;
    for(auto& pio : P) {
        if(curr - pio.first < 0) {
            printf("No\n");
            return 0;
        }
        curr += pio.second;
    }
    for(auto& pio : N) {
        if(curr + pio.first < 0) {
            printf("No\n");
            return 0;
        }
        curr += pio.second;
    }
    // Error(curr);
    if(curr == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 19296
import java.util.Scanner;

public class Main {

	private static final int MAX = 100000;
	private static final long[] fac = new long[MAX];
	private static final long[] finv = new long[MAX];
	private static final long[] inv = new long[MAX];
	private static final int MOD = 1_000_000_007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		COMinit();
		for(int i = 1;i <= K;i++) {
			System.out.println(COM(N-K+1,i)*COM(K-1,i-1)%MOD);
		}
	}

	//累乗・累乗の逆元の前計算
	private static void COMinit() {
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[0] = inv[1] = 1;
		for(int i = 2;i < MAX;i++) {
			fac[i] = fac[i-1] * i %MOD;
			inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
			finv[i] = finv[i-1] * inv[i] %MOD;
		}
	}
	//組み合わせ本計算
	private static long COM(int n,int k) {
		if(n < k) {
			return 0;
		}
		if(n < 0 || k < 0) {
			return 0;
		}
		return fac[n] * (finv[k] * finv[n-k] % MOD)%MOD;
	}
}

Measured memory_bytes: 24660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
const int N = 3*1e5, M = 7 + 1e9;
int n, m, a[N];
int main()
{
	ios_base::sync_with_stdio(0);
   	cin.tie(0);
	cin >> n >> m;
	f(i, 0, n)
		cin >> a[i];
	ll sum = 0;
	f(i, 0, n)
		sum += a[i];
	sort(a, a+n, greater<int>());
	if(a[m-1] >= 1.00/m/4*sum)
		cout << "Yes";
	else
		cout << "No";
	
}

Measured memory_bytes: 256