akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
int a[20];
int b[20];
int ans=0;
int vis[25];
void dfs(int sum,int deep)
{
    if(deep==2)
    {
                b[++ans]=sum;
                return;

    }
    for(int i=1;i<=3;i++)
    {
        if(vis[i]==0)
        {
            vis[i]=1;
        dfs(sum+a[i],deep+1);
        vis[i]=0;
        }

    }
}
int main()
{
    ans=0;
    memset(vis,0,sizeof(vis));
    for(int i=1;i<=3;i++)
        scanf("%d",&a[i]);
        dfs(0,0);
    sort(b+1,b+1+ans);
        printf("%d\n",b[1]);
    return 0;
}


Measured memory_bytes: 128
//NAME-ADITYYA OJHA
                                               /*
                                                      GURU(MENTOR)-AARADHYA
                                               */
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define forin for(int i=0;i<n;i++)
#define forjn for(int j=0;j<n;j++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  f   first
#define  s   second
#define mod 1000000007
 const int N=2e5+ 5;
 const ll N1=1e15 + 5;

using namespace std;

//check for corner cases(for n==1)
// check for int overflow
// run on some sample cases before submitting



int main()
{
  fast;
ll x,n;
cin>>x>>n;
set<ll>s;
forin
{
    ll a;
    cin>>a;
    s.insert(a);
}


 ll ans1=-1;
 ll mi=INT_MAX;
 for(int i=0;i<=x;i++)
 {   if(!s.count(i)){
     ll z=abs(x-i);
     if(z<mi)
     {
         mi=z;
         ans1=i;
     }
 }

 }
 ll ans2=-1;
 ll mi1=INT_MAX;
 for(int i=x+1;i<=1000;i++)
 {   if(!s.count(i)){
     ll z=abs(x-i);
     if(z<mi1)
     {
         mi1=z;
         ans2=i;
     }
 }

 }

 if(mi<=mi1)
 {
     cout<<ans1<<endl;
 }else
 {
     cout<<ans2<<endl;
 }


}





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

int main(){
    int N;
    std::string S;
    std::cin >> N >> S;
    
    int cnt = 0;
    for(int i=0; i<1000; i++){
        std::vector< int > digit_num(3);
        digit_num[0] = i / 100;
        digit_num[1] = (i % 100) / 10;
        digit_num[2] = (i % 10) / 1;
        
        int index = 0;
        int digit = 0;
        while(digit != 3 && index != N){
            if(digit_num[digit] == S[index] - '0'){
                digit++;
            }
            index++;
        }
        if(digit == 3){
            cnt++;
        }
    }
    
    std::cout << cnt << std::endl;
    
    
    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;
using vi = vector<int>;

int main(){
    int n,m;cin>>n>>m;
    vector<set<int>> vs(n);
    int s,c;
    rep(i,m){
        cin>>s>>c;
        s--;
        vs[s].insert(c);
    }
    
    if(n>1 && vs[0].count(0)){
        cout << -1 << endl;
        return 0;
    }
    
    rep(i,n){
        if(vs[i].size()>1){
            cout << -1 << endl;
            return 0;
        }
    }
    
    if(n==1){
        if(vs[0].size()){
            for(auto p: vs[0])
                cout << p << endl;
            return 0;
        }
        else{
            cout << 0 << endl;
            return 0;
        }
    }
    
    if(vs[0].size()){
        for(auto p: vs[0])
            cout << p;
    }else{
        cout << 1;
    }
    for(int i=1; i<n; i++){
        if(vs[i].size()){
            for(auto p: vs[i])
                cout << p;
        }else{
            cout << 0;
        }
    }
    
    cout << endl;
    
    return 0;
}

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

using ll=long long;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int div1(ll x){
  return x%1000000007;
}

main(){
    int n=in(),p[n][3],t[n][3];
    for (int i=0;i<n;i++){
        for (int i2=0;i2<3;i2++){
            cin >> p[i][i2];
            t[i][i2]=0;
        }
    }
    t[0][0]=p[0][0];
    t[0][1]=p[0][1];
    t[0][2]=p[0][2];
    for (int i=1;i<n;i++){
        for (int i2=0;i2<3;i2++) t[i][i2]=max(t[i-1][(i2+1)%3],t[i-1][(i2+2)%3])+p[i][i2];
    }
    cout << max({t[n-1][0],t[n-1][1],t[n-1][2]}) << endl;
}


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

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL>  VL;

typedef pair<int,int> PII;
typedef pair<LL,LL>   PLL;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
bool operator<(const PII& p1, const PII& p2){
    return p1.first < p2.first;
    //return p1.second < p2.second;
}
bool operator<(const PLL& p1, const PLL& p2){
    return p1.first < p2.first;
    //return p1.second < p2.second;
}

#define r0(i,n) for(int i=0; i<n; i++)
#define R0(i,n) for(int i=0; i<=n; i++)
#define r1(i,n) for(int i=1; i<n; i++)
#define R1(i,n) for(int i=1; i<=n; i++)

string alphabet="abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    VI si(26);
    fill(si.begin(),si.end(),0);
    r0(i,s.length()){
        si[(int)s[i]-'a']++;
    }
    if(s.length()!=26){
        r0(i,26){
            if(si[i]==0){
                s += (char)((int)'a'+i);
                cout << s << endl;
                return 0;
            }
        }
    }else if("zyxwvutsrqponmlkjihgfedcba"==s){
        cout << "-1\n";
        return 0;
    }else{
        string t;
        t = s;
        next_permutation(s.begin(),s.end());
        r0(i,t.length()){
            if(s[i]!=t[i]){
                cout << s.substr(0,i+1) << endl;
                return 0;
            }
        }
    }
}


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();
		long X = sc.nextLong();
		long burger = 1;
		for(int i = 0; i < N; i++) {
			burger = 3 + 2 * burger;
		}
		long ans = calc(burger, X);
		System.out.println(ans);
	}

	static long calc(long burger, long x) {
		long ans = 0;
		if(burger == 1) {
			ans = 1;
		} else {
			long tmp = (burger - 3) / 2;
			if(x < 2) {
				ans = 0;
			} else if(2 <= x && x < tmp + 2) {
				ans = calc(tmp, x - 1);
			} else if(tmp + 2 == x) {
				ans = calc(tmp, tmp);
				ans++;
			} else if(tmp + 2 < x && x < tmp * 2 + 3) {
				ans = calc(tmp, x - tmp - 2);
				ans += calc(tmp, tmp);
				ans++;
			} else if(tmp * 2 + 3 <= x) {
				ans = 2 * calc(tmp, tmp);
				ans++;
			}
		}
		return ans;
	}
}


Measured memory_bytes: 22224
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,T;
    cin>> N>>T;
    int c[N], t[N];
    rep(i,0,N)   cin>> c[i]>>t[i];
    int  res=100000;
    bool s=false;
    rep(i,0,N){
        if(t[i]<=T){
            res=min(res,c[i]);
            s=true;
        }
    }
    if(s) cout << res<<"\n";
    else cout << "TLE"<<"\n";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    A, B = map(int, input().split())
    if A >= 13:
        print(B)
    elif A >= 6:
        print(int(B / 2))
    else:
        print(0)


if __name__ == "__main__":
    main()


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

 int main() {
   int N;
   cin >> N;
   vector<int> h(N);
   rep(i, 0, N) cin >> h.at(i);
   vector<int> f(N);
   f.at(0) = 0;
   f.at(1) = abs(h.at(1) - h.at(0));
   rep(i, 2, N) {
     f.at(i) = min(f.at(i - 1) + abs(h.at(i) - h.at(i - 1)), f.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
   }
   cout << f.at(N - 1) << endl;
 }


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
const int Maxn = 100000 + 100;
int Begin[Maxn * 2], Next[Maxn * 2], To[Maxn * 2];
int A[Maxn], Cnt;
using namespace std;
int N;
int F[Maxn];
inline void add_edge(int x, int y)
{
	To[++Cnt] = y;
	Next[Cnt] = Begin[x];
	Begin[x] = Cnt;
}
inline void dfs(int x)
{
	if (!Begin[x]) return ;
	for (int i = Begin[x]; i; i = Next[i])
		dfs(To[i]);
	int Sum = 0;
	for (int i = Begin[x]; i; i = Next[i])
		A[++Sum] = F[To[i]];
	sort(A + 1, A + Sum + 1);
	for (int i = 2; i <= Sum; ++i)
		if (A[i] <= A[i - 1])
			A[i] = A[i - 1] + 1;
	F[x] = A[Sum] + 1;
}
int main()
{
	scanf("%d", &N);
	for (int i = 2; i <= N; ++i)
	{
		int x;
		scanf("%d", &x);
		add_edge(x, i);
	}
	dfs(1);
	cout<<F[1]<<endl;
	return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

vector<int> a;
using Graph=vector<vector<int>>;
Graph g;
vector<int> ans;
vector<int> dp;
const int INF= 1e9+2;

void dfs(int v,int pre){
    auto it = lower_bound(dp.begin(),dp.end(),a[v]);
    int tmp = *it;
    *it = a[v];
    ans[v] = (lower_bound(dp.begin(),dp.end(),INF)-dp.begin())-1;
    for(auto to:g[v]){
        if(to!=pre) dfs(to,v);
    }
    *it = tmp;
}

int main(){
    int n;
    cin>>n;
    a.resize(n);
    for(int i=0;i<n;i++) cin>>a[i];
    g.resize(n);
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        u--,v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    ans.resize(n,-1);
    dp.resize(n+1,INF);
    dp[0] = 0;
    
    dfs(0,-1);

    for(int i=0;i<n;i++) cout<<ans[i]<<endl;

    
    
    return 0;
}


Measured memory_bytes: 28064
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){
    
    double N,K,A[100010],o,ans,k,a;
    cin >> N >>K;
    k=K-1;

    ans=1;
    N=N-K;

    ans+= ceil(N/k);

    cout << ans <<endl;

    return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  for(int i=0;i<1200;++i){
    bool c8=0,c10=0;
    if(floor(i*8/100)==a){
      c8=1;
    }
    if(floor(i/10)==b){
      c10=1;
    }
    if(c8 && c10){
      return cout << i << endl,0;
    }
    if(i==1199){
      return cout << -1 << endl,0;
    }
  }
  return 0;
}


Measured memory_bytes: 3624
n, x=map(int, input().split())
l=list(map(int, input().split()))
if len(l)==1:
  print(abs(l[0]-x))
  exit()
import math
ans=x-l[0]
for i in range(n-1):
  ans=math.gcd(ans, l[i+1]-l[i])
print(ans)


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    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;
    }
}
ll 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;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A;ll B;ll K;
    cin>>A>>B>>K;
    if(A>=K){
        A-=K;
    }else{
        B=B-(K-A);
        if(B<0){
            B=0;
        }
        
        A=0;
    }
    cout<<A<<" "<<B<<endl;
    return 0;
}


Measured memory_bytes: 3584
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }
#define INF (ll)998244353
long long mul_modp(long long a, long long b, long long p){
    // a*b mod p
    return ((a % p) * (b % p)) % p;
}

long long pow_modp(long long a, long long n, long long p){
    // a^n mod p
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = mul_modp(res, a, p);
        a = mul_modp(a, a, p);
        n >>= 1;
    }
    return res;
}

int main(void){
    ll N;
    cin >> N;
    vector<ll> D(N);
    REP(i,N) cin >> D[i];

    if(D[0] != 0){cout << 0 << endl; return 0;}
    SORT(D);
    if(D[1] != 1){cout << 0 << endl; return 0;}

    ll ans = 1, prev = 1, n = 0;
    auto itr = D.begin();
    while(itr!=D.end()){
        ll num = 0;
        while(itr!=D.end() && *itr == n){itr++; num++;}
        if(num == 0){ans = 0; break;}
        ans = mul_modp(ans, pow_modp(prev, num, INF), INF);
        prev = num; n++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------
intl n,k;
vector<intl> d;
vector<intl> ok;
intl e;
intl mi = INF;
void input_var(){
    cin >> n >> k;
    d.resize(k);
    rep(i,k)cin >> d[i];
}
//-------------------------------------------------------------------------------


void dfs(intl v) {
    //debug(v);
    if(v >= n){
        mi = min(v,mi);
        return;
    }
    for (auto i : ok) {
        if(!(v) && !(i))continue;
        dfs(v * 10 + i);
    }
}

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    rep(i,10){
        if(find(all(d),i) != d.end())continue;
        ok.pb(i);
    }
    //for(auto i :ok)cout << i << endl;
    dfs(0);
    cout << mi << endl;
    return 0;
}

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

#define repd(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
typedef long long ll;

const long long INF = 1LL << 60;
const int MOD = 1000000007;
const int MAX_N = 1000;

ll dp[MAX_N][5][5][5];

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

    dp[0][0][0][0] = 1;

    rep(n, N) {
        rep(i, 5) {
            rep(j, 5) {
                rep(k, 5) {
                    repd(l, 1, 5) {
                        if (j == 1 && k == 2 && l == 3) continue;
                        if (j == 1 && k == 3 && l == 2) continue;
                        if (j == 2 && k == 1 && l == 3) continue;
                        if (i == 1 && k == 2 && l == 3) continue;
                        if (i == 1 && j == 2 && l == 3) continue;
                        dp[n + 1][j][k][l] += dp[n][i][j][k];
                        dp[n + 1][j][k][l] %= MOD;
                    }
                }
            }
        }
    }

    ll ans = 0;

    rep(i, 5) {
        rep(j, 5) {
            rep(k, 5) {
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }

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


Measured memory_bytes: 384
#136_C
n=int(input())
h=list(map(int,input().split()))[::-1]

flg=True
for i in range(1,n):
    if h[i-1]<h[i]:
        h[i]-=1
        if h[i-1]<h[i]:
            flg=False
            break
print('Yes' if flg else 'No')

Measured memory_bytes: 14396
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))


k = load()
q = deque()

li = list()

for i in range(1, 10):
    li.append(str(i))
    q.append(str(i))
    if len(li) >= k:
        print(li[-1])
        exit()

while True:
    e = q.popleft()
    for i in range(-1, 2, 1):
        next = int(e[-1]) + i
        if next >= 0 and next < 10:
            li.append(e + str(next))
            q.append(e + str(next))
        if len(li) >= k:
            print(li[-1])
            exit()





Measured memory_bytes: 60828
import sys
def input():
    return sys.stdin.readline().strip()
n, a, b, c = map(int, input().split())
s = []
for _ in range(n):
    s.append(input())

# 0 <= i < n-1
ans = []
for i in range(n-1):
    if s[i] == 'BC':
        if b > c:
            ans.append('C')
            b -= 1
            c += 1
        elif b < c:
            ans.append('B')
            b += 1
            c -= 1
        elif s[i+1] == 'AB':
            ans.append('B')
            b += 1
            c -= 1
        else:
            ans.append('C')
            b -= 1
            c += 1

    elif s[i] == 'AC':
        if a > c:
            ans.append('C')
            a -= 1
            c += 1
        elif a < c:
            ans.append('A')
            a += 1
            c -= 1
        elif s[i+1] == 'BC':
            ans.append('C')
            a -= 1
            c += 1
        else:
            ans.append('A')
            a += 1
            c -= 1

    else:
        if a > b:
            ans.append('B')
            a -= 1
            b += 1
        elif a < b:
            ans.append('A')
            a += 1
            b -= 1
        elif s[i+1] == 'AC':
            ans.append('A')
            a += 1
            b -= 1
        else:
            ans.append('B')
            a -= 1
            b += 1

    if a < 0 or b < 0 or c < 0:
        print('No')
        exit()

# i = n-1
if s[n-1] == 'BC':
    if b > c:
        ans.append('C')
        b -= 1
        c += 1
    else:
        ans.append('B')
        b += 1
        c -= 1

elif s[n-1] == 'AC':
    if a > c:
        ans.append('C')
        a -= 1
        c += 1
    else:
        ans.append('A')
        a += 1
        c -= 1

else:
    if a > b:
        ans.append('B')
        a -= 1
        b += 1
    else:
        ans.append('A')
        a += 1
        b -= 1

if a < 0 or b < 0 or c < 0:
    print('No')
    exit()

print('Yes')
for i in ans:
    print(i)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
typedef pair<string,int> psi;

/*** chmax, chmin ***/
// a < b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
// a > b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
/*** chmax, chmin ここまで ***/

void Main()
{
    int n;
    cin >> n;
  	vector<string> s(n);
  	rep(i,n) cin >> s[i];
    
  	sort(all(s));
  	vector<psi>data;
  	int count = 1;
  
    rep(i,n-1){
      	if(s[i] == s[i+1]) {
          	count++;
        }
		else{
        	data.emplace_back(s[i], count);
          	count = 1;
        }
    }
	if(s[0] != s[n-1]) data.emplace_back(s[n-1],count);
  	else{
    	cout << s[0] << endl;
      	return;
    }
  	int mx = 0;
  	rep(i,data.size()){
    	chmax(mx, data[i].second);
    }
  	
	rep(i,data.size()){
    	if(data[i].second == mx) {
			cout << data[i].first << endl;
        }
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 17392
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int a[3][3];
int d[3][3];
int main() {
    int count = 0;
    rep(i, 3){
        rep(j, 3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    rep(k, n) {
        int x;
        cin >> x;
        rep(i, 3){
            rep(j, 3){
                if(a[i][j] == x){
                    d[i][j] = 1;
                }
            }
        }
    }
    bool ans = false;
    rep(i, 3) {
        int count = 0;
        rep(j, 3){
            count += d[i][j];
        }
        if(count == 3){
            ans = true;
        }
    }
    rep(i, 3) {
        count = 0;
        rep(j,3){
            count += d[j][i];
        }
        if(count == 3){
            ans = true;
        }
        count = 0;
        rep(j ,3) {
            count += d[j][j];
        }
        if(count == 3){
            ans = true;
        }
        count = 0;
        rep(j, 3){
            count += d[j][2 - j];
        }
        if(count == 3){
            ans = true;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,a,b;
  	cin>>n>>a>>b;
  	int ans=0;
  	if(n>(a+b)){
      ans=0;
    }else{
    	ans=(a+b)-n;
    }
  	cout<<min(a,b)<<" "<<ans<<endl;
}
     

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
vector<int> pr;
int main(){

    int n;
    scanf("%d", &n);
    pr.clear();
    mp.clear();
    while (n--) {
        int t;
        scanf("%d", &t);
        if (mp.count(t) == 0) {
            mp[t] = 1;
            pr.push_back(t);
        } else {
            mp[t]++;
        }
    }
    long long ans = 0ll;
    for (int i=0; i<pr.size(); i++){
        if (mp[pr[i]] == pr[i])
            continue;
        if (mp[pr[i]] < pr[i]) {
            ans += (long long)mp[pr[i]];
        } else {
            ans += (long long) (mp[pr[i]] - pr[i]);
        }
    }
    cout << ans << endl;

}


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

#define ll long long
#define fore(i, n) for(i=0;i<n;i++)

int main() {
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll x, i; cin>>x;
	ll n=100;
	fore(i, 4000)
	{
		ll p=1.01*n;
		if(p>=x)
			break;
		else
			n=p;
	}
	cout<<i+1<<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=100005;

int ar[mxN];



int main(){
    fast;
    int n;
    cin>>n;
    fo(i, n)cin>>ar[i];
    int dp[n+1];
    dp[0]=0;
    dp[1]=abs(ar[1]-ar[0]);
    fok(i, 2,n){
        dp[i]=min((dp[i-1]+abs(ar[i-1]-ar[i])),(dp[i-2]+ abs(ar[i-2]-ar[i])));
    }
    //fo(i, n)cout<<dp[i]<<" ";cout<<endl;
    int ans=dp[n-1];
    cout<<ans;
}


Measured memory_bytes: 1024
K=int(input())
ans=set()
for i in range(1,10):
    ans.add(i)
def saiki(A):
    genzai_saigo=int(A[-1])
    ketasu=len(A)
    if ketasu>0:
        B="".join(A)
        ans.add(eval(B))
    if ketasu==10:
        return
    for i in [genzai_saigo-1,genzai_saigo,genzai_saigo+1]:
        if i < 0 or i>9:
            continue
        A.append(str(i))
        saiki(A)
        A.pop()
for i in range(1,10):
    saiki([str(i)])
kotae=list(ans)
kotae.sort()
print(kotae[K-1])

Measured memory_bytes: 26236
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
a = [0] * n;b = [0]*n;c = [0] * m;d = [0]*m;
for i in range(n):
    a_,b_ = readInts()
    a[i] = a_;b[i]=b_;
for i in range(m):
    c_,d_ = readInts()
    c[i] = c_;d[i] = d_;
for A,B in zip(a,b):
    MIN = float('inf')
    i = 1
    for C,D in zip(c,d):
        man = abs(C-A) + abs(D-B)
        if man < MIN:
            idx = i
            MIN = man
        i += 1
    print(idx)


Measured memory_bytes: 3316
package main

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

func main() {
	_ = nextInt()
	K := nextInt()
	S := nextString()
	for i, s := range S {
		ss := string(s)
		if i+1 == K {
			fmt.Print(strings.ToLower(ss))
			continue
		}
		fmt.Printf(ss)
	}

	fmt.Println()
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N;
  cin >> N;
  vector<int> A(N + 1);
  vector<long long> node_mx(N + 1);
  node_mx[0] = 1;
  cin >> A[0];
  if (N > 0 && A[0] > 0)
  {
    cout << -1 << endl;
    return 0;
  }
  if (N == 0 && A[0] != 1)
  {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i <= N; i++)
  {
    cin >> A[i];
    node_mx[i] = std::min((node_mx[i - 1] * 2), (long long)100000000 * 100001) - A[i];
  }
  node_mx[N] = 0;

  long long sum = 0;
  long long layer; // node + leaf at each depth
  long long node = 0;
  rep(i, N + 1)
  {
    if ((node + 1) / 2 > node_mx[N - i])
    {
      cout << -1 << endl;
      return 0;
    }
    node = std::min(node_mx[N - i], node);
    layer = A[N - i] + node;
    sum += layer;
    node = layer;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4568
#include<bits/stdc++.h>
using namespace std;
namespace whatever{
	int readu(){
		char ch=getchar();
		while(!isdigit(ch))
			ch=getchar();
		int value=ch-'0';
		ch=getchar();
		while(isdigit(ch)){
			value=value*10+ch-'0';
			ch=getchar();
		}
		return value;
	}
	void writeu(int n){
		if(n<10)
			putchar(n+'0');
		else{
			writeu(n/10);
			putchar(n%10+'0');
		}
	}
	void run(){
		int n=readu();
		string prev;
		cin>>prev;
		set<string> s;
		s.insert(prev);
		while(--n){
			string cur;
			cin>>cur;
			if(prev.back()!=cur.front()||s.count(cur)){
				puts("No");
				return;
			}
			s.insert(cur);
			prev=cur;
		}
		puts("Yes");
	}
}
int main(){
	whatever::run();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)x)<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,a,b) for(int i=a;i<=b;i++)
#define erep(i,n) EREP(i,0,n)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

int h,w,q;
int rn[50002],cn[50002];
bool rflg[50002],cflg[50002];

int main(void){
  while(scanf("%d%d%d",&h,&w,&q),h||w||q){
    memset(rn,0,sizeof(rn));
    memset(cn,0,sizeof(cn));
    memset(rflg,0,sizeof(rflg));
    memset(cflg,0,sizeof(cflg));

    rep(i,q){
      int A,B,order;
      scanf("%d%d%d",&A,&B,&order);

      if(A){
        cn[B] = i+1;
        cflg[B] = order;
      }
      else{
        rn[B] = i+1;
        rflg[B] = order;
      }
    }

    vector<int> sit;
    vector<int> stand;
    rep(i,w){
      if(cflg[i])
        stand.push_back(cn[i]);
      else
        sit.push_back(cn[i]);
    }
    sort(sit.begin(),sit.end());
    sort(stand.begin(),stand.end());

    int res = 0;
    rep(i,h){
      if(rflg[i]){
        res += stand.size();
        res += upper_bound(sit.begin(),sit.end(),rn[i]) - sit.begin();
      }
      else{
        res += stand.end() - upper_bound(stand.begin(),stand.end(),rn[i]);
      }
    }

    cout<<res<<endl;
  }
}

Measured memory_bytes: 1848
// In The Name Of Allah
// Mehrkish Makuei

#include <bits/stdc++.h>

#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y ) cerr << #x << " : " << x << "  " << #y << " : " << y << endl;

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector <ll> vll;
typedef set <char> sch;
typedef set <ll> sll;

const ll MOD = 1e9 + 7;
const ll MAXN = 1e3 + 19;

ll a, b, c;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;int c=0;
    for(int i=0;i<s.size();i++)
    if(s[i]=='+')
    c++;
    else
    c--;
    cout<<c;
}
 

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


int main(){
    int n,i;
    string ch;
    i=0;
    cin >> n;
    cin >> ch;
    if (n%2!=0){
        cout << "No";
    }
    else{
        while(i<(n/2)){
            if(ch[i]!=ch[n/2+i]){
                cout<<"No";
                return 0;
            }
            i++;
        }
        cout<<"Yes";
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> dp(N + 100, INF);
    vector<ll> h(N);
    rep(i, N) { cin >> h[i]; }

    dp[0] = 0;
    rep(i, N) {
        for (int j = 0; j <= K; j++) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }

    cout << dp[N - 1] << endl;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int[] p = new int[n];
		for(int i=0;i<n;i++) {
			p[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		Arrays.sort(p);
		int[] cnt = new int[3];
		for(int i=0;i<n;i++) {
			if(p[i]<=a) {
				cnt[0]++;
			}else if(p[i]<=b) {
				cnt[1]++;
			}else if(b<p[i]){
				cnt[2]++;
			}
		}
		Arrays.sort(cnt);
		System.out.println(cnt[0]);
	}

}


Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>

using namespace std;
int D[10000];
int H[10000];


void printResult(int i, int n){
    printf("node %d: key = %d, ",i,H[i]);
    if(i!=1) printf("parent key = %d, ",H[i/2]);
    if(2*i<=n) printf("left key = %d, ",H[2*i]);
    if(2*i+1<=n) printf("right key = %d, ",H[2*i+1]);
    printf("\n");

}

int main()
{
    int n,i,x;
    string com;

    cin>>n;
    for(i=1;i<=n;i++){
        cin>>H[i];
    }
    for(i=1;i<=n;i++){
        printResult(i,n);
    }


    return 0;
}


Measured memory_bytes: 3120
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var ss = new List<String>();
            for (int i = 0; i < 3; i++)
            {
                ss.Add(cin.next());
            }           

            Console.WriteLine(ss[0].ToCharArray()[0].ToString() + 
                ss[1].ToCharArray()[1].ToString() +
                ss[2].ToCharArray()[2].ToString());
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
n, q = map(int, input().split())
 
ki = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b = map(int, input().split())
    ki[a].append(b)
    ki[b].append(a)
# print(ki)
 
cnt = [0] * (n + 1)
for i in range(q):
    p, x = map(int, input().split())
    cnt[p] += x
 
 
# print(cnt)
 
 
def d(y, parent):
    for i in ki[y]:
        if i == parent:
            continue
        cnt[i] += cnt[y]
        d(i, y)
 
 
d(1, -1)
print(*cnt[1:])

Measured memory_bytes: 230932
n, m = map(int, input().split())

count_ac = count_wa = 0
check_ac = [0] * n
wa_p_i = [0] * n

for i in range(m):
    p, s = input().split()
    now = int(p) - 1

    if s == "AC":
        if check_ac[now] == 0:
            count_ac += 1
            check_ac[now] = 1
            count_wa += wa_p_i[now]
    elif s == "WA":
        wa_p_i[now] += 1

print(count_ac, count_wa)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;
 
 
int main(){
    int n,m; cin >> n >> m;
    vector<vector<int> > ki(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }

    vector<int> visited(n,0);
    vector<int> ans(n);
    queue<P> q;
    q.push(P(0,0));
    while(!q.empty()){
        int now=q.front().first;
        int p=q.front().second;
        q.pop();
        if(visited[now]) continue;
        visited[now]++;
        //cout << now << endl;
        ans[now]=p;
        rep(i,ki[now].size()){
            q.push(P(ki[now][i],now));
        }
    }
    rep(i,n){
        if(!visited[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rep(i,n-1) cout << ans[i+1]+1 << endl;
return 0;
}

Measured memory_bytes: 15056
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int n;
ll ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)
        if(i%3!=0&&i%5!=0) ans+=i;
    cout<<ans;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  char c[h][w];
  rep(i, h)
  {
    rep(s, w)
    {
      cin >> c[i][s];
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << h); ++i)
  {
    for (int s = 0; s < (1 << w); ++s)
    {
      int black = 0;
      rep(t, h)
      {
        if (i & (1 << t))
          continue;
        rep(u, w)
        {
          if (s & (1 << u))
            continue;
          if (c[t][u] == '#')
            ++black;
        }
      }
      if (black == k)
        ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut h = vec![0; n];

    for i in 0..n {
        h[i] = read::<i64>();
    }

    let mut cnt = 0;
    for i in 0..n-1 {
        if h[i] > h[i+1] {
            if h[i] > h[i+1] + 1 {
                println!("No");
                return;
            } else {
                cnt += 1;
                if cnt > 1 {
                    println!("No");
                    return;
                }
            }
        } else {
            if h[i] < h[i+1] {
                cnt = 0;
            }
        }
    }

    println!("Yes");
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {
    int n,m; cin >> n >> m;
    vector<vector<pair<ll, int>>> py(n+1, vector<pair<ll,int>>());

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        py[a].push_back(make_pair(b, i));
    }


    vector<string> ans(m);

    FOR(i, 1, n+1) {
        if(py[i].size() <= 0) continue;
        sort(py[i].begin(), py[i].end());

        std::ostringstream ss;
        ss << setw(6) << setfill('0') << i;
        string ps(ss.str());
        rep(j, py[i].size()) {
            std::ostringstream ss2;
            ss2 << setw(6) << setfill('0') << j+1;
            string ps2(ss2.str());
            ans[py[i][j].second] = ps+ps2;
        }
    }

    rep(i, m) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
int main() {
	double num;
	while(cin>>num,num>0){
	    string str;
		for(double i=128,a;i>0.03125;i/=2){
			str+=int(a=num/i)+'0';
			if(a>=1)num-=i;
			if(i==1)str+='.';
		}
		if(num>0)cout<<"NA"<<endl;
		else cout<<str<<endl;
	}
}

Measured memory_bytes: 1220