akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<ll> v(n+1);
  v[0] = 2;
  v[1] = 1;
  rep(i,n+1-2) {
    v[i + 2] = v[i] + v[i + 1];
  }
  cout << v[n] << endl;
}

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

Measured memory_bytes: 3604
#include <stdio.h>
#define N 36

typedef struct{
  char gara[N];
  int num[N];
}Trump;

Trump bubble(Trump, int);
Trump select(Trump,int);

int main(){
  int n = 0, flag = 0;
  int i = 0;
  Trump tru, tru2, tru3;

  scanf("%d",&n);

  for(i = 0; i < n; i++){/*scan*/
    scanf(" %c%d",&tru.gara[i],&tru.num[i]);
  }
  
  /*call def*/
  tru2 = bubble(tru, n);
  tru3 = select(tru, n);

  /*select stable check*/
  for(i = 0; i < n; i++){
    if(tru2.gara[i] != tru3.gara[i])flag = 1;
  }
  
  if(flag == 1)printf("Not stable\n");
  else printf("Stable\n");
  
  return 0;
}

Trump bubble(Trump tru, int n){
  int i = 0, j = 0, key = 0;
  char key2;

  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(tru.num[j] < tru.num[j-1]){
	key2 = tru.gara[j-1];
	key = tru.num[j-1];
	tru.gara[j-1] = tru.gara[j];
	tru.num[j-1] = tru.num[j];
	tru.gara[j] = key2;
	tru.num[j] = key;
      }
    }
  }
  for(i = 0; i < n; i++){/*print*/
    printf("%c%d",tru.gara[i],tru.num[i]);
    if(i == n-1)printf("\n");
    else printf(" ");
  }
  printf("Stable\n");

  return tru;
}

Trump select(Trump tru, int n){
  int i = 0, j = 0, key = 0, minj = 0;
  char key2;
  
  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(tru.num[j] < tru.num[minj]){
	minj = j;
      }
    }
    key2 = tru.gara[minj];
    key = tru.num[minj];
    tru.gara[minj] = tru.gara[i];
    tru.num[minj] = tru.num[i];
    tru.gara[i] = key2;
    tru.num[i] = key;
  }
  
  for(i = 0; i < n; i++){/*print*/
    printf("%c%d",tru.gara[i],tru.num[i]);
    if(i == n-1)printf("\n");
    else printf(" ");
  }

  return tru;
}




Measured memory_bytes: 2100
#include<cstdio>
#include<utility>
#include<cstring>
using namespace std;
#define lowbit(i) i&(-i) 
#define ll long long
inline int read(){
	int f=1,sum=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch==EOF){return -1;}if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=(sum<<1)+(sum<<3)+(ch^48);ch=getchar();}
	return sum*f;
}
int n,l,r;
ll val[200010],tree[2000010],sum[2000010];
inline int max(int i,int j){return i>j?i:j;} 
inline void updata(ll i,ll v){
    while(i<=200000){
        tree[i]+=v;
        i+=lowbit(i);
    }
    return;
}
inline ll getsum(ll i){
	ll ans=0;
	while(i>0){
		ans+=tree[i];
		i-=lowbit(i);
	}
	return ans;
}
inline bool check(int x){
	memset(tree,0,sizeof tree);
    sum[0]=0;
    for(int i=1;i<=n;i++){
    	if(val[i]>=x)sum[i]=sum[i-1]+1;
    	else sum[i]=sum[i-1]-1;
	}
    ll ans=0;
    for(int i=0;i<=n;i++){
        ans+=getsum(sum[i]+100010);
        updata(sum[i]+100010,1);
    }
    return ans<(long long)n*(n+1)/4;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)val[i]=read(),r=max(r,val[i]);
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid))r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",r);
	return 0;
}

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

#define FOR(i,N) for(int i=0;i<N;i++)
#define ROF(i,N) for(int i=N-1;i>=0;i--)
#define ROF1(i,a,b) for(int i=(b);i>=(a);i--)
#define FOR1(i,a,b) for(int i=(a);i<=(b);i++)
#define FORi(i,a,b,c) for(int i=(a);i<=(b);i+=(c))

#define read freopen("IN.txt","r",stdin)
#define write freopen("OT.txt","w",stdout)
#define fastread {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mem(a,b)          memset(a,b,sizeof(a))
#define EPS 1e-9
#define PI              acos(-1.0)
#define INF             2e16

#define ll              long long
#define ull             unsigned long long
#define ft              first
#define sd              second
#define bn              begin
#define en              end
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(x) x.begin(), x.end()


#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main()
{
#ifdef SunWalker
    //read;
   //write;
#endif

int a,b;
cin>>a>>b;
cout<<max(max(a-b,a+b),a*b)<<"\n";


return 0;
}



Measured memory_bytes: 256
#include <cstdio>
const int P = 998244353;
int n, m, a[3005], f[3005][3005], ans;
int main(){
	scanf("%d%d", &n, &m);
	for (register int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (register int i = 1; i <= n; ++i)
		for (register int j = 1; j <= m; ++j){
			if (j == a[i]) f[i][j] = (f[i][j] + i) % P;
			if (j >= a[i]) f[i][j] = (f[i][j] + f[i - 1][j - a[i]]) % P;
			if (j == m) ans = (ans + 1ll * f[i][j] * (n - i + 1)) % P;
			f[i][j] = (f[i][j] + f[i - 1][j]) % P;
		}
	printf("%d\n", ans);
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    vector<ll> arr;
    for (ll i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        arr.pb(temp);
    }
    ll ans = 0;
    sort(arr.begin(), arr.end());
    for (ll i = 0; i < n; i++)
    {
        for (ll j = i + 1; j < n; j++)
        {
            ll rem = arr[j] + arr[i];
            ll pos = lower_bound(arr.begin(), arr.end(), rem) - arr.begin();
            if (pos - 1 > j)
            {
                ans += (pos - j - 1);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1E5+7;
int arr[N];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>arr[i];
	int ans=0;
	int sum=0;
	for(int i=n-1;i>=1;i--){
		if(arr[i]>=arr[i+1]) ans++;
		else ans=0;
		sum=max(ans,sum);
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using ll = long long;
const ll INF = 100000000000000;

int main(){
    ll n;
    std::cin >> n;
    std::vector<ll> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a[i];
        a[i] -= i + 1;
    }

    std::sort(a.begin(), a.end());

    // 中央値でOK
    ll b = a[n / 2];
    ll out = 0;
    for(int i = 0; i < n; i++){
        out += std::abs(a[i] - b);
    }

    std::cout << out << std::endl;

    return 0;
}


Measured memory_bytes: 1792
///
// File:  c.cpp
// Author: ymiyamoto
//
// Created on Sat Nov  4 21:41:00 2017
//

#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;
static vector<uint32_t> As;
static vector<uint32_t> Bs;
static vector<uint32_t> Cs;

uint32_t lower_num(vector<uint32_t> &S, uint32_t val)
{
  uint32_t left = 0;
  uint32_t right = S.size();
  if (val < S[left]) return 0;
  if (val > S[right - 1]) return S.size();

  while (left + 1 < right) {
    uint32_t mid = (left + right) / 2;
    if (val == S[mid])
      return mid;
    else if (val < S[mid])
      right = mid;
    else
      left = mid;
  }

  return right;
}

uint32_t upper_num(vector<uint32_t> &S, uint32_t val)
{
  uint32_t left = 0;
  uint32_t right = S.size();
  if (val < S[left]) return S.size();
  if (val > S[right - 1]) return 0;

  while (left + 1 < right) {
    uint32_t mid = (left + right) / 2;
    if (val == S[mid])
      return S.size() - (mid + 1);
    else if (val < S[mid])
      right = mid;
    else
      left = mid;
  }

  return S.size() - right;
}

int32_t main()
{
  uint32_t N;
  cin >> N;
  for (uint32_t i = 0; i < N; i++) {
    uint32_t A;
    cin >> A;
    As.push_back(A);
  }

  for (uint32_t i = 0; i < N; i++) {
    uint32_t B;
    cin >> B;
    Bs.push_back(B);
  }

  for (uint32_t i = 0; i < N; i++) {
    uint32_t C;
    cin >> C;
    Cs.push_back(C);
  }

  sort(As.begin(), As.end());
  sort(Bs.begin(), Bs.end());
  sort(Cs.begin(), Cs.end());

  uint64_t total = 0;
  for (uint32_t i = 0; i < Bs.size(); i++) { // N
    uint64_t anum = lower_bound(As.begin(), As.end(), Bs[i]) - As.begin();
    uint64_t cnum = Cs.end() - upper_bound(Cs.begin(), Cs.end(), Bs[i]);
    total += anum * cnum;
  }

  cout << total << endl;

  return 0;
}


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

char Array[2000][2000];
int count;

void DFS(int h,int w,char c){

  if(Array[h][w] != c || Array[h][w] == '.'){
    return;
  }

  char tmp=Array[h][w];

  Array[h][w] = '.';

  DFS(h-1,w,tmp);
  DFS(h,w+1,tmp);
  DFS(h+1,w,tmp);
  DFS(h,w-1,tmp);

}

int main(){
    int H,W;

    while(1){
      cin >> H >> W;

      if(H == 0 && W == 0){
        break;
      }
      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          cin >> Array[i][j];
        }
      }

      for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
          if(Array[i][j] != '.'){
            count++;
            DFS(i,j,Array[i][j]);
          }
        }
      }
      cout << count << endl;

      
      count = 0;
  }
    return 0;
}

Measured memory_bytes: 3472
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)

P = [a for a in A if a >= 0]
Q = [a for a in A if a < 0]

if len(P) == 0:
    P = [A[0]]
    Q = A[1:]
if len(Q) == 0:
    P = A[:-1]
    Q = [A[-1]]

print(sum(P) - sum(Q))

for i in range(1, len(P)):
    print(Q[0], P[i])
    Q[0] -= P[i]

for i in range(1, len(Q)):
    print(P[0], Q[i])
    P[0] -= Q[i]

print(P[0], Q[0])

Measured memory_bytes: 14144
#include<stdio.h>
#include<stdlib.h>
int linearSearch(int *s,int key,int n){
  int left=0,right=n,mid;
  
  while(left<right){
    mid = (left+right)/2;
    if(s[mid]==key) return 1;
    else if(key<s[mid]) right = mid;
    else left = mid+1;
  }
  return 0;
}


int main(){
  int i;
  int n,q,s[100000],t[100000];
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&t[i]);
  for(i=0;i<q;i++) count+=linearSearch(s,t[i],n);
  printf("%d\n",count);
  
  return 0;
}




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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

int main(void){
       cin.tie(0);https://atcoder.jp/user/MATSUMAT/history#
    ios::sync_with_stdio(false);

       cin >> a >> b;
       Cout(a*a-b);
return 0;
}


Measured memory_bytes: 256
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 1000005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,ar[N],br[N];
string s,s1;
//Variables End

int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
    	ll ans=0;
    	ll last=1;
		cin>>n;  
		while(n!=0)
		{
			ans+=last;
			last*=2;
			n/=2;
		}      
		cout<<ans<<endl;
    }
    return 0;
        
}

Measured memory_bytes: 256
#include<stdio.h>
double ds[100];
int sp=100;
void push(double v) { if(sp>0) ds[--sp]=v; }
double pop(void) { return (sp<100?ds[sp++]:0.0); }
int isN(char c){return c>='0'&&c<='9';}
double RPN( const char * f ){
    double v,g;
    for(;*f;f+=2,g=1) {
        switch(*f){
        case '+':v=pop();push(pop()+v); break;
        case '*':v=pop();push(pop()*v); break;
        case '/':v=pop();push(pop()/v); break;
        case '-':
            if(!isN(f[1])){v=pop();push(pop()-v);break;}
            else{g=-1;f++;}
        default :
            for(v=0;isN(*f);v=v*10+(*f-'0'),f++);f--;
            push(v*g);
            break ;
        }
    }
    return pop();
}
int main(void){
    char s[82];
    while(fgets(s,sizeof(s),stdin)){
        printf("%f\n",RPN(s));
    }
    return 0;
}

Measured memory_bytes: 560
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	string s;
	cin>>s;
	if(s=="ARC")print("ABC");
	else print("ARC");



}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
vector< vector<int> > ri(200001);
vector<int> ans(200001,0);
void dfs(int x, int p){
    for(int i=0; i<ri.at(x).size(); i++){
        if(ri.at(x).at(i)==p) continue;
        ans[ri.at(x).at(i)] += ans[x];
        dfs(ri.at(x).at(i),x);
    }
    return;
}
int main(){
    int n, q;
    cin>>n>>q;
    for(int i=0; i<n-1; i++){
        int a,b;
        cin>>a>>b;
        ri.at(a).push_back(b);
        ri.at(b).push_back(a);
    }
    for(int i=0; i<q; i++){
        int tm, p;
        cin>>tm>>p;
        ans.at(tm)+=p;
    }
    dfs(1,0);
    for(int i=1; i<n+1; i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

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

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

const int INF = 1e9;
const int mod = 1e9+7;

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

    ll ans, x = n / k;
    ans = x * x * x;
    if(k % 2 == 0){
        if(n % k >= k / 2) x++;
        ans += x * x * x; 
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def insertion_sort(A,N):
    sorted_A = A.copy()
    print(*sorted_A)
    for i in range(1,N):
        v = sorted_A[i]
        j = i-1
        while (j>=0)&(sorted_A[j]>v):
            sorted_A[j+1] = sorted_A[j]
            j -= 1
        sorted_A[j+1] = v
        print(*sorted_A)
        

N = int(input())
A = list(map(int, input().split()))

insertion_sort(A,N)


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

using namespace std;

int main()
{
    long n;
    cin>>n;
    
    long height=0;
    
    long a[n];
    
    for(int i=0; i<n; i++)
    cin>>a[i];
    
    for(int i=1; i<n; i++)
    {
        if(a[i]<a[i-1])
        {
            height+=(a[i-1]-a[i]);
            a[i]=a[i-1];
        }
    }
    
    cout<<height<<endl;
    
    return 0;
}

Measured memory_bytes: 5176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

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

    ll N;
    unordered_set<char> S;
    cin >> N;
    for (ll i = 0; i < N; i++) {
        char c;
        cin >> c;
        S.insert(c);
    }

    if (S.size() == 3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
a,b,c,x,y = map(int,input().split())
ans = 0
if a > c*2:
    a = c*2
if b > c*2:
    b = c*2
if a + b >= c*2:
    ans += min(x,y)*c*2
    if x > y:
        ans += (x-y)*a
    else:
        ans += (y-x)*b
else:
    ans = a*x + b*y
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

void print(int A[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(i)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

void insertsort(int A[],int n)
{
   int i,j,tmp;
   for(i=0;i<n-1;i++)
   {
       j=i+1;
       tmp=A[j];
       while(j>0 && A[j-1]>tmp)
       {
           A[j]=A[j-1];
           j--;
       }
       A[j]=tmp;
       print(A,n);
   }

}

int main()
{
    int n;
    scanf("%d",&n);
    int A[n];
    for(int i=0;i<n;i++)scanf("%d",&A[i]);
    print(A,n);
    insertsort(A,n);

    return 0;
}



Measured memory_bytes: 2044
N=int(input())
plus=[]
minus=[]
for _ in range(N):
    S=input()
    tmp=0
    min_tmp=0 #)))の
    for i in range(len(S)):
        if S[i]=="(":
            tmp+=1
        else:
            tmp-=1
        if tmp<0:
            min_tmp=min(min_tmp,tmp)
    tmp=0
    max_tmp=0 #(((の
    for i in range(len(S)):
        i=len(S)-i-1
        if S[i]=="(":
            tmp+=1
        else:
            tmp-=1
        if tmp>0:
            max_tmp=max(max_tmp,tmp)
    if tmp>=0:
        plus.append((tmp,max_tmp,-min_tmp))
    else:
        minus.append((tmp,max_tmp,-min_tmp))

plus.sort(key=lambda x:x[2])
minus.sort(reverse=True,key=lambda x:x[1])
ans=0
for i,j,k in plus:
    if ans<k:
        print("No")
        exit()
    ans+=i
for i,j,k in minus:
    if ans<k:
        print("No")
        exit()
    ans+=i
if ans==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 231204
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#define N 100010
using namespace std;
long long num[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
	sort(num+1,num+n+1,greater<int>());
	for(int i=2;i<=n+1;i++)
	if(i-1<=num[i-1] && i>num[i])
	{
		int x=i-1;
		if((num[x]-x)%2==1){puts("First");return 0;}
		while(num[x+1]+1==i) x++;
		if((x-i+1)%2==0){puts("Second");return 0;}
		puts("First");
		return 0;
	}
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int rStns=0,wStns=0;
    REP(i,n){
        if(s[i]=='R')rStns++;
        else wStns++;
    }
    int red,white;
    int leftreds = 0,rightwhites = 0;
    REP(i,rStns){
        if(s[i]=='R')leftreds++;
    }
    red = rStns - leftreds;
    REP(i,wStns){
        if(s[n-i-1]=='W')rightwhites++;
    }
    white = wStns - rightwhites;
    cout << min(red,white) << endl;
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
using namespace std;
typedef pair<int, int> P;

int n, a, b, c, d;
int mod = 1e9 + 7;
int dp[1010][1010];

typedef long long ll;
ll mod_pow(ll x,ll n){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2);
	if(n&1) res=res*x%mod;
	return res;
}
ll fact[200010];
ll factr[200010];
ll inv[200010];
ll get_nCk(ll n,ll k){
    if(k < 0 || k > n) return 0;
    return fact[n]*factr[k]%mod*factr[n - k]%mod;
}

int f(int p, int s){
    // if(s == 0) return 1;    
    // if(dp[p][s] != -1) return dp[p][s];  
    // if(p > b || s < 0) return 0;
    
    
    int& res = dp[p][s];
    if(res >= 0) return res;
    res = 0;
    if(s == 0){
        res = 1;
    }else{
        if(p > b) return 0;
        res += f(p + 1, s);
        int v = 1;
        for(int i = 1; i <= d && p <= s; i++){
            (v *= get_nCk(s, p) * inv[i] % mod) %= mod;
            s -= p;
            if(c <= i && i <= d){
                res += v * f(p + 1, s) % mod;
                // cout << p << " " << s << " " << i << " " << v << " " << res << endl;
            }
        }
    }
    res %= mod;
    return res;

}

signed main(){
    cin >> n >> a >> b >> c >> d;
    rep(i, 0, 1010){
        rep(j, 0, 1010){
            dp[i][j] = -1;
        }
    }
    fact[0] = inv[1] = factr[0] = 1;
    for(int i = 2; i < 200010; i++) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
	for(int i=1;i<200010;i++){
        fact[i]=fact[i-1]*i%mod;
        factr[i] = factr[i - 1] * inv[i] % mod;
    }
    cout << f(a, n) << endl;
    // rep(i, a, b + 1){
    //     rep(j, 0, n + 1){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
}

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

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

    int a = -1;
    int z = -1;

    for(int i=0; i < s.size(); i++){
        if(s.at(i) == 'A' && a == -1) a = i;
        if(s.at(i) == 'Z' ) z = i;
    }

    cout << z - a + 1 << endl;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main(){
	int n,q;
	cin>>n;
	vector<pair<int,int> >A;
	for(int i=0;i<n;i++)
	{
		cin>>q;
		A.push_back(make_pair(q,i+1));
	}
	sort(A.begin(),A.end(),greater<pair<int,int>>());
	map<int,int>m;
	m[0]=0;
	m[n+1]=0;
	m[A[0].second]=A[0].first; 
	int ans=0;
	for(int i=1;i<n;i++)
	{
		auto it=m.upper_bound(A[i].second);
		int x=it->first;
		int y=(--it)->first;
		int a,b,c,l=0,k=0;
		if(x==n+1)a=0;
		else{
			a=(m.upper_bound(x))->first-x-1;
			l=1;
		}
		if(y==0)b=0;
		else{
			auto itt=m.lower_bound(y);
			b=y-(--itt)->first-1;
			k=1;
		}
		c=l*((a+1)*(A[i].second-y))+k*((b+1)*(x-A[i].second));
		ans=ans+A[i].first*c;
		m[A[i].second]=A[i].first;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8048
m,D=map(int,input().split())

ans=0
for mo in range(m):
    for d in range(D+1):
        if d>=22:
            d_10=int(str(d)[0])
            d_1=int(str(d)[1])
            if d_10*d_1==mo+1 and d_10>1 and d_1>1:
                ans +=1
                #print(mo+1,d)

print(ans)


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

int main() {
	int i, j, l,n;
	int m[10][3][4] = {0};
	int b, f, r, v;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> b;
		cin >> f;
		cin >> r;
		cin >> v;
		m[r-1][f-1][b-1] = m[r-1][f-1][b-1] + v;
	}
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 3; j++) {
			for (l = 0; l < 10; l++) {
				cout << " "<<m[l][j][i];
			}
			 cout << "\n";
		}
		if (i != 3)cout << "####################\n";
	}
}



Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
	string str[3];
	while(cin >> str[0]){
		if(str[0] == "0") break;
		int r=-1;
		cin >> str[1] >> str[2];
		for(int i=0;i<3;i++){
			if(str[i][0] == str[i][1] && str[i][1] == str[i][2]){
				if(str[i][0] != '+'){
					str[i][0] == 'b'?r=0:r=1;
					break;
				}
			}
			if(str[0][i] == str[1][i] && str[1][i] == str[2][i]){
				if(str[0][i] != '+'){
					str[0][i] == 'b'?r=0:r=1;
					break;
				}
			}
		}
		if((str[0][0] == str[1][1] && str[1][1] == str[2][2]) ||
		(str[2][0] == str[1][1] && str[1][1] == str[0][2])){
			if(str[1][1] != '+'){
				str[1][1] == 'b'?r=0:r=1;
			}
		}
		if(r == -1){
			cout << "NA" << endl;
		}else{
			r==0?cout<<"b"<<endl:cout<<"w"<<endl;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int n,ans=0x7fffffff;
struct Node{
    int id,tot;
}a[100005],b[100005];
inline bool cmp(Node a,Node b){
    return a.tot>b.tot;
}
inline int min(int x,int y){
    return x<y?x:y;
}
int main(){
    scanf("%d",&n);
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    for(int i=1;i<=100000;i++) a[i].id=b[i].id=i;
    for(int i=1;i<=n/2;i++){
        int t;
        scanf("%d",&t);
        a[t].tot++;
        scanf("%d",&t);
        b[t].tot++; 
    }
    sort(a+1,a+100000+1,cmp);
    sort(b+1,b+100000+1,cmp);
    if(a[1].id==b[1].id){
        ans=min(ans,n-a[1].tot-b[2].tot);
        ans=min(ans,n-a[2].tot-b[1].tot);
    }
    else ans=min(ans,n-a[1].tot-b[1].tot);
    printf("%d\n",ans);
    return 0;
} 

Measured memory_bytes: 1792
N, M = list(map(int, input().split()))
pen_tot = 0
corr_tot = 0
ac = [0 for _ in range(N)]
pen = [0 for _ in range(N)]

for _ in range(M):
  pi, ans = input().split()
  pi = int(pi) - 1
  if ac[pi] == 0:
    if ans == 'WA':
        pen[pi] += 1
    else:
      corr_tot += 1
      ac[pi] = 1
      pen_tot += pen[pi]
    
  
print('{} {}'.format(corr_tot, pen_tot))

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

typedef long long LL;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string S; cin >> S;

    char state = S[0];
    int cnt = 0;

    FOR(i, 1, S.length()) {
        char cur = S[i];
        if (state == cur) {
            ++cnt;
        }

        state ^= 1;
    }

    cout << cnt << endl;

}


Measured memory_bytes: 512
def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N, Q = read_values()
    S = input()
    
    num = [0]
    pre = None
    count = 0
    for s in S:
        if pre == "A" and s == "C":
            count += 1
        num.append(count)
        pre = s

    for _ in range(Q):
        l, r = read_values()
        print(num[r] - num[l])


if __name__ == "__main__":
    main()


Measured memory_bytes: 6148
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>
     
using namespace std;
typedef long long ll;
     
     
bool debug = false;
     

struct state
{
    ll a,b,c;

    state(ll a, ll b, ll c) : a(a), b(b), c(c)
    {

    }

  bool operator==(const state &other) const
  { return (a == other.a
            && b == other.b
            && c == other.c);
  }
};


struct KeyHasher
{
    size_t operator()(const state& k) const
  {
    //using std::size_t;
    //using std::hash;
    //using std::string;

    return ((hash<ll>()(k.a)
               ^ (hash<ll>()(k.b) << 1)) >> 1)
               ^ (hash<ll>()(k.c) << 1);
  }
};  

set<state> mySet;
unordered_map<state, ll, KeyHasher> getId;


vector<state> graph[100005];
string choice[100005];

bool possible = false;
stack<char> path;
vector<char> res; 
ll nn;

void dfs(ll a, ll b, ll c, ll i)
{
    if (possible) return;

    if (a < 0 || b < 0 || c < 0)
        return;

    if (i == nn) // possible
    {
        possible = true;

        while (!path.empty())
        {
            res.push_back(path.top());
            path.pop();
        }
    }

    string currChoice = choice[i];

    ll newA = a, newB = b, newC = c;

    if (currChoice == "AB")
    {
        path.push('A');
        dfs(a+1,b-1,c,i+1);
        if (!path.empty()) path.pop();
        path.push('B');
        dfs(a-1,b+1,c,i+1);
         if (!path.empty()) path.pop();
    }
    else if (currChoice == "AC")
    {
         path.push('A');
        dfs(a+1,b,c-1,i+1);
        if (!path.empty()) path.pop();
         path.push('C');
        dfs(a-1,b,c+1,i+1);
        if (!path.empty()) path.pop();
    }
    else
    {
         path.push('B');
        dfs(a,b+1,c-1,i+1);
        if (!path.empty()) path.pop();
        path.push('C');
        dfs(a,b-1,c+1,i+1);
         
         if (!path.empty()) path.pop();
    }
}

int main()
{
	std::ios::sync_with_stdio(false);
    
    ll n,a,b,c;
    ll id = 1;

    cin >> n >> a >> b >> c;
    nn = n;

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

    dfs(a, b, c, 0);

    if (possible)
    {
        cout << "Yes" << endl;

        

        for (int i = n-1; i >= 0; i--)
        {
            cout << res[i] << endl;
        }
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

string s1, s2;
int k;
int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> s1 >> k;
    s2 = s1;
    int c1 = 0, c2 = 0;
    for(int i = 1; i < s1.size(); i++){
        if(s1[i] == s1[i - 1]){
            s1[i] = ' ';
            c1++;
        }
    }
    c2 = 1, s2[0] = ' ';
    for(int i = 2; i < s2.size(); i++){
        if(s2[i] == s2[i - 1]){
            s2[i] = ' ';
            c2++;
        }
    }
    if(s1[0] != s1[s1.size() - 1]) cout << 1ll * k * c1 << '\n';
    else if(s1[0] != s2[s2.size() - 1])cout << (1ll * (k + 1) / 2 * c1 + 1ll * k / 2 * c2) << '\n';
    else cout << (c1 + 1ll * (k - 1) * c2) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll fast(ll x,ll n) {ll ans=1;for(;n;n>>=1,x=x*x%mod) if(n&1) ans=ans*x%mod; return ans;}
const int N=1e6+100;

int n;
char s[N];
int t[200][4005];
int cnt[N];
int main() {
    cin>>n;
    cin>>s+1;
    for(int i=1;i<=n;i++) {
        t[s[i]][++cnt[s[i]]]=i;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++) if(s[i]!=s[j]) {
        int k='R'+'G'+'B'-s[i]-s[j];
        int d=j-i;
        if(s[j+d]==k) ans--;
        int pos=lower_bound(t[k]+1,t[k]+cnt[k]+1,j+1)-t[k];
        //see(i);see(j);see(pos);see(cnt[k]);
        ans+=cnt[k]-pos+1;
        //see(ans);
    }
    cout<<ans;
}


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

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    vector<int> h(n);
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<double> temp(n);
    for (int i = 0; i < n; i++){
      temp[i] = t - h[i] * 0.006;
    }
    vector<double> diff(n);
    for (int i = 0; i < n; i++){
        diff[i] = a - temp[i];
        if (diff[i]<0) diff[i] = -diff[i];
    }

    int spot = -1;
    double res = 1000000;
    for (int i = 0; i <n; i++){
        if (res > diff[i]) {
            res = diff[i];
            spot = i;
        }
    }

    cout << spot + 1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i=0; i < n; i++) array[i] = sc.nextInt();
		sc.close();
		StringBuilder sb = new StringBuilder();
		for (int i=n-1; 0 < i; i--) sb.append(array[i] + " ");
		sb.append(array[0]);
		System.out.println(sb.toString());
	}
}

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


#define rep(i,n) for(int i = 0;i < (int)(n);i++)
#define Rep(i,n,m) for(int i = (int)(n); i < (int)(m);i++)
#define rrep(i,n) for(int i = (int)(n); i > -1;i--)

#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

template<typename T>
void swap(T*,T*);


int main()
{
    ll A,B,K;
    cin >> A >> B >> K;
    if(A >= K)
    {
        cout << A - K << " " << B << endl;
    }
    else
    {
        cout << 0 << " " << (A+B-K>=0 ? A + B - K : 0) << endl;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

ll a,b,c,x,y;

int main(){
  ll res=INF;
  cin>>a>>b>>c>>x>>y;
  rep(i,300001){
    ll resta=max(0LL,x-i);
    ll restb=max(0LL,y-i);
    minch(res,i*2*c+resta*a+restb*b);
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
def tets():
    n,y=map(int,input().split())
    a=10000
    b=5000
    c=1000
    for i in range(n+1):
        for j in range(n+1):
            k=n-i-j
            if a*i+b*j+c*k==y and 0<=k:
                return i,j,k
    return -1,-1,-1
d,e,f=tets()
print(d,e,f)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	while(cin >>s){
		int l=s.length();
		int f=0;
		for(int i=0;i<l;i++){
			if(i%2!=0){
				if(s[i]=='R'){
					f=1;
					cout << "No\n";
					break;
				}
			}
			else{
				if(s[i]=='L'){
					f=1;
					cout << "No\n";
					break;
				}
			}
		}
		if(!f) cout << "Yes\n";
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);

    vector<int> ans(n);
    int i;
    for(i=0; i<n; i++) {
        if(str[i]=='R') {
            int k=i;
            while(str[k]=='R') {
                k++;
            }
            int j;
            for(j=i; j<k; j++) {
                if((k-j)%2==0) ans[k]++;
                else           ans[k-1]++;
            }
            i=k-1;
        }
        else {
            int k=i;
            while(str[k]=='L') {
                k++;
            }
            int j;
            for(j=i; j<k; j++) {
                if((j-i)%2==0) ans[i]++;
                else           ans[i-1]++;
            }
            i=k-1;
        }
    }
    for(i=0; i<n; i++) {
        printf("%d ", ans[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 896
#include<iostream>

using namespace std;

int a[10010];
int main(void){
    int n,m;
    int sum =0;
    scanf("%d %d",&n,&m);
    for (int i=0;i<m;i++){
        scanf("%d",&a[i]);
    }
    for(int k=0;k<m;k++){
        sum = sum + a[k];
    }
    int ans = n - sum;
    if(ans>=0){
        printf("%d\n",ans);
    }else{
        printf("-1\n");
    }
    return 0;
}

Measured memory_bytes: 3808
n = int(input())
s = [input() for _ in range(n)]

start = 0
end = 0
same = 0
c = 0
for x in s:
    c = c + len(x.split('AB')) - 1
    if x.startswith('B'):
        start += 1
        if x.endswith('A'):
            same += 1
    if x.endswith('A'):
        end += 1

if start == end:
    c += start
    if same > 0 and same == start:
        c  -= 1
elif start > end:
    c += end
else:
    c += start
print(c)

Measured memory_bytes: 3700
import sys
input = sys.stdin.readline
mod = 10**9 + 7

s = input().rstrip()
n = len(s)
s = s[::-1]

dp = [[0]*13 for _ in range(n + 1)] # dp[i][j] : i桁目まで見て13で割ってj余る個数
dp[0][0] = 1
mul = 1
for i in range(n):
    if i > 0:
        mul *= 10
        mul %= 13
    if s[i] != '?':
        s_ = int(s[i]) * mul
        for j in range(13):
            dp[i + 1][(j + s_) % 13] += dp[i][j]
            dp[i + 1][(j + s_) % 13] %= mod
    else:
        for j in range(13):
            for k in range(10):
                k *= mul
                dp[i + 1][(j + k) % 13] += dp[i][j]
                dp[i + 1][(j + k) % 13] %= mod
print(dp[-1][5])



Measured memory_bytes: 61532
#include <iostream>
#include <vector>
#define int long long
using namespace std;

int k;
int n = 50;
vector<int> a;

signed main() {
	int i;
	
	cin >> k;
	
	for (i = 0; i < k % n; i++) a.push_back(n - (k % n));
	for (i = 0; i < n - (k % n); i++) a.push_back(-(k % n) - 1);
	for (i = 0; i < n; i++) a[i] += n;
	for (i = 0; i < n; i++) a[i] += k / n;
	
	cout << n << endl;
	for (i = 0; i < n; i++) {
		cout << a[i];
		if (i + 1 < n) cout << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=998244353;

int main(){
  int n; cin>>n;
  int a; cin>>a;
  if(a!=0){
    cout<<0<<endl;
    return 0;
  }
  vector<ll> num(n+1,0);
  ll maxnum=0;
  for(int i=0;i<n-1;i++){
    int x; cin>>x;
    num[x]++;
    maxnum=max(maxnum,ll(x));
  }
  if(num[0]>0){
    cout<<0<<endl;
    return 0;
  }
  
  for(int i=1;i<=maxnum;i++){
    if(num[i]==0){
      cout<<0<<endl;
      return 0;
    }
  }
  ll ans=1;
  for(int i=1;i<maxnum;i++){
    for(int j=0;j<num[i+1];j++){
      ans*=num[i];
      ans%=MOD;
    }
  }
  cout<<ans<<endl;
} 

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]", B: "List[int]", C: "List[int]"):
    last = -999
    satis = 0
    for now in A:
        if now-1 == last:
            satis += C[last-1]
        satis += B[now-1]
        last = now
    print(satis)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N - 1)]  # type: "List[int]"
    solve(N, A, B, C)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	ll n;
	ll small, large;
	ll vsmall, vlarge;
	string str;
	cin >> n;
	ll res[20]; //Male=0, Female=1
	ll check[20] = {};
	
	check[0] = 0;
	check[1] = n - 1;
	for (int i = 0; i < 2; i++) {
		cout << check[i] << endl;
		cout << flush;
		cin >> str;
		if (str =="Male") {
			res[i] = 0;
		}
		else if (str=="Female") {
			res[i] = 1;
		}
		if (str=="Vacant") {
			return 0;
		}
	}
	small = 0;
	vsmall = res[0];
	large = n - 1;
	vlarge = res[1];

	for (int i = 2; i < 20; i++) {
		ll temp, vtemp;
		temp = (small + large) / 2;
		cout << temp << endl;
		cout << flush;
		cin >> str;
		if (str == "Vacant") {
			return 0;
		}
		else if (str == "Male") {
			vtemp = 0;
		}
		else if (str == "Female") {
			vtemp = 1;
		}

		if ((temp - small) % 2 == 0) {
			if (vsmall == vtemp) {
				small = temp;
				vsmall = vtemp;
			}
			else {
				large = temp;
				vlarge = vtemp;
			}
		}
		else {
			if (vsmall != vtemp) {
				small = temp;
				vsmall = vtemp;
			}
			else {
				large = temp;
				vlarge = vtemp;
			}
		}


	}



	return 0;
}

Measured memory_bytes: 976
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int h,w,n;
    cin >> h >> w >> n;
    // cout << max(h,w) << endl;
    if(n%max(h,w)==0)
    {
        cout << (int)(n/max(h,w)) << endl;
    }
    else
    {
        cout << (int)(n/max(h,w)) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        final int H = in.i();
        final int W = in.i();
        final int K = in.i();
        char[][] c = new char[H][];
        int k = 0;
        for (int i = 0; i < c.length; i++) {
            c[i] = in.s(W);
        }
        int ans = 0;
        for (int i = 0; i < 1 << H; i++) {
            for (int j = 0; j < 1 << W; j++) {
                int black = 0;
                for (int h = 0; h < H; h++) {
                    char[] d = c[h];
                    boolean b = (i >> h & 1) == 0;
                    for (int w = 0; w < W; w++) {
                        if (b && (j >> w & 1) == 0 && d[w] == '#') {
                            black++;
                        }
                    }
                }
                if (black == K) {
                    ans++;
                }
            }
        }
        out.println(ans);
    }

    static class MyReader extends BufferedReader {
        char[] cbuf = new char[1024];
        int head = 0;
        int tail = 0;

        MyReader() {
            super(new InputStreamReader(System.in));
        }

        char next() {
            if (head == tail) {
                try {
                    tail = read(cbuf, 0, cbuf.length);
                } catch (IOException e) {}
                head = 0;
            }
            return cbuf[head++];
        }

        void back() {
            head--;
        }

        boolean minus() {
            boolean minus;
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    if (!(minus = c == '-')) back();
                    return minus;
                }
            }
        }

        void skip() {
            while (true) {
                char c = next();
                if (c != ' ' && c != '\n' && c != '\r') {
                    back();
                    break;
                }
            }
        }

        char[] s(final int N) {
            skip();
            char[] s = new char[N];
            for (int i = 0; i < s.length; i++) {
                s[i] = next();
            }
            return s;
        }

        int i() {
            boolean minus = minus();
            int n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }

        int[] ii(final int N) {
            int[] a = new int[N];
            for (int j = 0; j < a.length; j++) a[j] = i();
            return a;
        }

        long l() {
            boolean minus = minus();
            long n = 0;
            while (true) {
                int k = next() - '0';
                if (k < 0 || 9 < k) break;
                n = 10 * n + k;
            }
            return minus ? -n : n;
        }
    }
}


Measured memory_bytes: 32688