akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    int RGB[3],N;
    REP(i,3){
        cin >> RGB[i];
    }
    cin >> N;
    vector<int> line(N+1,0);
    line[0] = 1;
    REP(i,3){
        REP(j,N+1-RGB[i]){
            line[j+RGB[i]]+=line[j];
        }
    }
    cout << line.back() << endl;
    return 0;
}


Measured memory_bytes: 256
/*
___ is a raging sadist.
*/

//Destroy all WA at test 2

#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define PI 3.14159265
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MOD1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

    ll n;
    cin>>n;

    string s;

    while(n>0)
    {
        ll rem=n%26;
        if (rem==0)
        {
            s.pb('z');
            n-=26;

        } else {
            s.pb('a'+rem-1);
            n-=rem;
        }
        n/=26;
    }

    reverse(all(s));
    cout<<s;

return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll p , q , r;
    cin >> p >> q >> r;
    cout << min( p + q , min( q + r , p + r ) ) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

signed main(){
    int n;
    ll L;
    cin>>n>>L;
    V<ll> a(n);
    cinf(n,a);
    bool ok=0;
    int last;
    rep(i,n-1){
        if(a[i]+a[i+1]>=L){
            ok=1;
            last=i+1;
            break;
        }
    }
    if(ok){
        cout<<"Possible"<<'\n';
        int m=1;
        while(m<last){
            cout<<m++<<'\n';
        }
        m=n-1;
        while(m>last){
            cout<<m--<<'\n';
        }
        cout<<last<<'\n';
    }else cout<<"Impossible"<<'\n';
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <array>
#include <map>
#include <math.h>

using namespace std;

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

    long int max_value = 0;
    max_value = std::floor(a * n / b) - a * std::floor(n / b);

    if(n >= b)
    {

        long int i = b - 1;
        long int value = std::floor(a * i / b) - a * std::floor(i / b);
        max_value = max(max_value, value);
    }

    cout << max_value << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    while(s!="0"){
        int x=0;
        for(int i=0;i<s.size();i++){
            x+=s.at(i)-'0';
        }
        cout<<x<<endl;
        cin>>s;
    }
   
}


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    char c;
    cin >> c;
    if(c=='a'|c=='i'|c=='u'|c=='e'|c=='o')cout<<"vowel";else cout <<"consonant";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl v(n);
  rep(i, n) cin >> v[i];
  sort(all(v));
  double ans = 0;
  rep(i, n) {
    double now = double(v[i]) * pow(0.5, n - i);
    if(i == 0) now *= 2;
    ans += now;
  };
  printf("%.10f\n", ans);
}

Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
struct segment_tree {
  public:
    int n, ht, N;
    vector<int> dat;
    segment_tree(int sz) {
      n = sz;
      ht = 1;
      N = 1;
      while (N < n) {
        ht++;
        N <<= 1;
      }
      dat.resize(2 * N, 0);
    }
    segment_tree(vector<int> v) {
      n = v.size();
      ht = 1;
      N = 1;
      while (N < n) {
        ht++;
        N <<= 1;
      }
      dat.resize(2 * N);
      for (int i = 0; i < n; i++) {
        dat[N + i] = v[i];
      }
      for (int i = N - 1; i >= 1; i--) {
        dat[i] = dat[2 * i] + dat[2 * i + 1];
      }
    }
    void add (int i, int x) {
      i += N;
      dat[i] += x;
      i >>= 1;
      for (; i; i >>= 1) {
        dat[i] = dat[2 * i] + dat[2 * i + 1];
      }
    }
    int getSum (int l, int r, int k = 1, int L = 0, int R = -1) {
      if (R == -1) R = N;
      if (R <= l || r <= L) {
        return 0;
      } else if (l <= L && R <= r) {
        return dat[k];
      } else {
        int C = (L + R) >> 1;
        return getSum(l, r, 2 * k, L, C) + getSum(l, r, 2 * k + 1, C, R);
      }
    }
};
int main() {
  int n, q;
  cin >> n >> q;
  segment_tree sgt(n + 1);
  while (q--) {
    int c;
    cin >> c;
    if (c == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      sgt.add(--s, x);
      sgt.add(t, -x);
    } else {
      int i;
      cin >> i;
      cout << sgt.getSum(0, i) << '\n';
    }
  }
  return 0;
}


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

int w,h;
int c[60][60];
int dx[]={1,1,0,-1,-1,-1,0,1};
int dy[]={0,1,1,1,0,-1,-1,-1};
bool seen[60][60];

void func(int i,int j){
    seen[i][j]=true;

    for(int n=0;n<8;++n){
        int ii=i+dy[n];
        int jj=j+dx[n];

        if(ii<0||jj<0||ii>=h||jj>=w)continue;
        if(c[ii][jj]==0)continue;
        if(seen[ii][jj])continue;
        func(ii,jj);
    }
}

int main(){
    while(cin>>w>>h && w!=0){
    int num=0;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin>>c[i][j];
            seen[i][j]=false;
        }    
    }

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(c[i][j]==1&&!seen[i][j]){
                func(i,j);
                num++;
            }
        }    
    }
    cout<<num<<endl;}
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
using namespace std;
int main(){
	unsigned long long n,k,i;
	cin>>n>>k;
	unsigned long long ma,mi,ans=0,mod=1e9+7;
	for(i=k;i<=n+1;++i){
		mi=((i-1)*i)/2;
		ma=(n*(n+1))/2-((n-i)*(n-i+1))/2;
		ans=(ans+ma-mi+1)%mod;
		
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int a, b; cin >> a >> b;
    int res = 0;
    for(int i=1; i<=a; i++){
        for(int j=1; j<=(i<a?12:b); j++){
            if(i==j) res++;
        }
    }
    cout << res << ln;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] ns = new int[n];
        for (int i = 0; i < q; i++) {
            ns[sc.nextInt() - 1]++;
        }

        for (int i : ns) {
            if ((k - (q - i)) > 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
        sc.close();
    }
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/

int main(){
	int N,X;
	cin >> N >> X;
	int ans = 1;
	int pos = 0;
	REP(i,N){
		int L;
	    cin >> L;
	    pos = L+pos;
	    if (pos <= X) ans++;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println((1..n).map {
        var a = sc.nextInt()
        var res = 0
        while (a % 2 == 0) {
            a /= 2
            res++
        }
        res
    }.min())
}

Measured memory_bytes: 29712
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    const int L = A + B;
    const int R = C + D;
    cout << (L > R ? "Left" : L == R ? "Balanced" : "Right") << endl;
}


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


int main() {
    const long long INF = 1LL << 60;
    const int MAX_N = 1e2 + 10;
    const int MAX_V = 1e5 + 10;
    int N, W;
    long long d[MAX_N][MAX_V];
    for (int j = 0; j < MAX_V; ++j) d[0][j] = INF;
    d[0][0] = 0;
    cin >> N >> W;
    for (int i = 1; i <= N; ++i){
        int w,v;
        cin >> w >> v;
        for (int j = 0; j < MAX_V; ++j){
            if (j-v>=0) d[i][j] = min(d[i-1][j], d[i-1][j-v]+w);
            else d[i][j] = d[i-1][j];
        }
    }

    long long ans = 0; 
    for (int j = 0; j < MAX_V; ++j){
        if (d[N][j] <= W) ans = j;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81152
NN = 202020
MOD = 10**9+7
INF = float("inf")


class UnionFind2:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        if self.same(x, y):
            return
        else:
            parx, pary = self.find(x), self.find(y)
            self.size[pary] += self.size[parx]
            self.size[parx] = 0
            self.par[parx] = pary

    def size(self, x):
        return self.size[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
A = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(m)]

T = UnionFind2(n)

for i in range(m):
    T.unite(S[i][0]-1, S[i][1]-1)

print(sum([T.same(i, A[i]-1) for i in range(n)]))


Measured memory_bytes: 133540
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

class Word {
public:
	char w[33];
	int length;
	int freq;
public:	
	Word() {
		strcpy(w, "");
		length = 0;
		freq = 0;
	}
};

int main()
{
	char str[1001];
	char buf[32];
	char *p, *q;
	fgets(str, 1001, stdin);
	
	Word wl[32];
	
	for ( p = str; (q = strstr(p, " ")) != NULL; ) {
		*q = '\0'; strcpy(buf, p); 
		for (int i=0; i<32; i++) {
			if ( strcmp(wl[i].w, "") == 0 ) {
				strcpy(wl[i].w, buf);
				wl[i].length = strlen(buf);
				wl[i].freq = 1;
				break;
			}
			else if ( strcmp(wl[i].w, buf) == 0 ) {
				wl[i].freq++;
				break;
			}
		}
		p = q + 1;
	}
	
	strcpy(buf, p); 
	for (int i=0; i<32; i++) {
		if ( strcmp(wl[i].w, "") == 0 ) {
			strcpy(wl[i].w, buf);
			wl[i].length = strlen(buf);
			wl[i].freq = 1;
			break;
		}
		else if ( strcmp(wl[i].w, buf) == 0 ) {
			wl[i].freq++;
			break;
		}
	}

	
	int max_freq = 0;
	int max_length = 0;
	char max_freq_w[32];
	char max_length_w[32];
	
	for (int i=0; i<32; i++) {
		if (max_freq < wl[i].freq) {
			max_freq = wl[i].freq;
			strcpy(max_freq_w, wl[i].w);
		}
		if (max_length < wl[i].length) {
			max_length = wl[i].length;
			strcpy(max_length_w, wl[i].w);
		}
	}
	
	cout << max_freq_w << " " << max_length_w << endl;
	
	return 0;
}

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

long long modpow(long long a, long long n, long long mod) {
    if (n == 0) return 1;
    
    if (n == 1) return a % mod;
    
    if (n % 2 == 0) {
        long long half = modpow(a, n / 2, mod) % mod;
        return half * half % mod;
    }
    else return modpow(a, 1, mod) * modpow(a, n - 1, mod) % mod;
}

int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }

    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        sum += a.at(i);
    }
    const long long mod = 998244353;
    vector<vector<long long>> dp(n + 1, vector<long long>(sum + 1));
    dp.at(0).at(0) = 1;
    for(int t = 1; t <= n; t++)
    {
        for(long long r = 0; r <= sum; r++)
        {
            dp.at(t).at(r) += dp.at(t - 1).at(r) * 2;
            dp.at(t).at(r) %= mod;

            if (r - a.at(t - 1) >= 0) dp.at(t).at(r) += dp.at(t - 1).at(r - a.at(t - 1));
            dp.at(t).at(r) %= mod;
        }
        
    }

    long long ans = modpow(3, n, mod);
    
    for(int r = ceil((double)sum / 2); r <= sum; r++)
    {
        ans -= dp.at(n).at(r) * 3 % mod;
        if (ans < 0) ans += mod;
    }

    if (sum % 2 == 0) {
        vector<vector<long long>> dp2(n + 1, vector<long long>(sum / 2 + 1, 0));
        dp2.at(0).at(0) = 1;
        for(int t = 1; t <= n; t++)
        {
            for(long long r = 0; r <= sum / 2; r++)
            {
                dp2.at(t).at(r) += dp2.at(t - 1).at(r);
                dp2.at(t).at(r) %= mod;

                if (r - a.at(t - 1) >= 0) dp2.at(t).at(r) += dp2.at(t - 1).at(r - a.at(t - 1));
                dp2.at(t).at(r) %= mod;
            }
        
        }   

        ans += dp2.at(n).at(sum / 2) * 3 % mod;  
    }
    
    ans %= mod;
    
    cout << ans << endl;
}   

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	int n=s.size();
	for (int i=0; i<n; i++) {
		for (int j=i+1; j<n; j++) {
			if(s[i]=='C'&&s[j]=='F') {
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

int main()
{
    ll A, B, X;
    cin >> A >> B >> X;

    if (A <= X && X < (A+B)){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

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

#define pb push_back
#define pa pair<long long,long long>
#define Mod 1000000007

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

    long long n,i,j,k,gap;
    cin>>n;
    long long A[n],sum=0,B[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
        sum+=A[i];
        B[i]=sum;
    }

    long long dp[n][n];
    for(i=0;i<n;i++)
        dp[i][i]=0;

    for(i=0;i<n-1;i++)
        dp[i][i+1]=A[i]+A[i+1];

    for(gap=3;gap<=n;gap++)
    {
        for(i=0;i<n-gap+1;i++)
        {
            j=i+gap-1;
            dp[i][j]=1e18;
            for(k=i;k<j;k++)
            {
                dp[i][j]=min(dp[i][k]+dp[k+1][j]+B[j]-B[i]+A[i],dp[i][j]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}


Measured memory_bytes: 1536
#include<stdio.h>

int main(){

  int data[5], i, j, stock;


  scanf("%d %d %d %d %d",&data[0],&data[1],&data[2],&data[3],&data[4]);


  for(i = 0; i < 4; i++){
    for(j = i; j < 5; j++){
      if(data[i] < data[j]){
	stock = data[i];
	data[i] = data[j];
	data[j] = stock;
      }
    }
  }

  printf("%d %d %d %d %d\n",data[0], data[1], data[2], data[3], data[4]);

  return 0;
}

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

using namespace std;


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    int ans1 = min(a, b);
    int ans2;
    if(a + b <= n) {
        ans2 = 0;
    } else {
        ans2 = a + b - n;
    }
    cout << ans1 << " " << ans2 << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include<stdlib.h>



#define N 100000
#define INF 1000000

typedef struct{
  int go;
  int back;
  int cost;
}Date;

int n, d[N];
Date a[500000];
void root(int);

int main(){
  int i, j, l, k, count = 0;
  scanf("%d", &n);
  for( i = 0 ; i < n ; i++) {
    scanf("%d%d", &l, &k);
    for( j = 0 ; j < k ; j++){
      a[count].back=l;
      scanf("%d%d", &a[count].go, &a[count].cost);
      count++;
    }
  }






  root(count);
  for( i = 0 ; i < n ; i++) printf("%d %d\n", i, d[i]);
  return 0;
}






void root(int b){
  int j, f = 1;

  for( j = 0 ; j < n ; j++) d[j] = INF;
  d[0] = 0;

  while(f != 0){
    f = 0;
    for( j = 0 ; j < b ; j++){
      if(a[j].cost + d[a[j].back] < d[a[j].go]){
        d[a[j].go] = a[j].cost + d[a[j].back];
        f = 1;
      }
    }
  }
}



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

int main() {
    static const double pi = 3.141592653589793;
    int l, s, h, m;
    cin >> l >> s >> h >> m;
    printf("%2.9lf\n",sqrt(((double)l * (double)l) + ((double)s * (double)s) - (2 * (double)l * (double)s * cos(fabs((((double)m / 60.0) * 2 * pi) - (((double)m + 60 * (double)h) / 720.0) * 2 * pi)))));
    return 0;
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;
#define rep(i, n)  for (int i = 0; i <  (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    ll A,B,C;
    cin >> A >> B >> C;

    vector<ll> count(10,0);
    count[A]++;
    count[B]++;
    count[C]++;

    string result = "No";
    rep(i,10){
        if(count[i] == 2){
            result = "Yes";
        }
    }

    cout << result;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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 int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    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;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ll num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int H,W;
    cin >> H >> W;

    auto c = make_vec<int>(10,10);
    REP(i,10) REP(j,10) cin >> c[i][j];

    REP(k,10) REP(i,10) REP(j,10) chmin(c[i][j],c[i][k]+c[k][j]);


    ll ans = 0;
    REP(i,H) REP(j,W) {
        int a;
        cin >> a;
        if(a!=-1) ans += c[a][1];
    }

    pl(ans)
    
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN 100001
#define X first
#define Y second
#define MOD 1000000007
#define fr(a,b,c) for(ll a=b;a<c;++a)
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

ll t,n,i,j;
int main()
{
    fastio;
    ll k;
    cin>>n;
    ll dp[MAXN][3]={0};
    ll a,b,c;
    cin>>a>>b>>c;
    dp[1][0]=a;
    dp[1][1]=b;
    dp[1][2]=c;
    fr(i,2,n+1){
        cin>>a>>b>>c;
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
        dp[i][1]=max(dp[i-1][2],dp[i-1][0])+b;
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
    }
    cout<<max(max(dp[n][0],dp[n][1]),dp[n][2])<<endl;
}


Measured memory_bytes: 2560
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()


n = ni()
s = ns()

level = 0
left = 0

for i in range(0, n):
    if s[i] == '(':
        level += 1
    else:
        level -= 1
    
    if level + left < 0:
        left += 1
    
level += left

print('(' * left + s[0:n] + ')' * level)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
//#include <cstring>

using namespace std;

typedef pair<int, int> pii;

int main() {
    int n, k;
    cin >> n >> k;
    pii td[n];
    for (int i = 0; i < n; i++) {
        int t, d;
        cin >> t >> d;
        t--;
        td[i] = pii(d, t);
    }
    sort(td, td+n);
    reverse(td, td+n);

    long long ans = 0;
    int c[n];
    fill(c, c+n, 0);
    for (int i = 0; i < k; i++) {
        ans += td[i].first;
        c[td[i].second]++;
    }
    int nt = 0;
    for (int i = 0; i < n; i++) {
        nt += c[i] > 0;
    }
    ans += 1ll * nt * nt;

    int i = k - 1, j = k;
    long long curr = ans;
    while (i >= 0 && j < n) {
        while (j < n && c[td[j].second] > 0) {
            j++;
        }
        if (j == n) {
            break;
        }

        while (i >= 0 && c[td[i].second] == 1) {
            i--;
        }
        if (i == -1) {
            break;
        }

        curr -= td[i].first;
        curr += td[j].first;
        c[td[i].second]--;
        c[td[j].second]++;
        curr += nt + nt + 1;
        nt++;
        ans = max(ans, curr);
        i--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int field[8][8],f = 0;
	for(;;){
		for(int i=0; i<8; i++){
			for(int l=0; l<8; l++){
				if(scanf("%1d",&field[l][i]) == EOF){f = 1;break;}
			}
			if(f == 1){break;}
		}
		if(f == 1){break;}
		for(int i=0; i<8; i++){
			for(int l=0; l<8; l++){
				if(field[l][i]){
					if(field[l][i+1] == 1 && field[l+1][i] == 1 && field[l+1][i+1] == 1){cout<<"A"<<endl;break;}
					else if(field[l][i+1] == 1 && field[l][i+2] == 1 && field[l][i+3] == 1){cout<<"B"<<endl;break;}
					else if(field[l+1][i] == 1 && field[l+2][i] == 1 && field[l+3][i] == 1){cout<<"C"<<endl;break;}
					else if(field[l][i+1] == 1 && field[l-1][i+1] == 1 && field[l-1][i+2] == 1){cout<<"D"<<endl;break;}
					else if(field[l+1][i] == 1 && field[l+1][i+1] == 1 && field[l+2][i+1] == 1){cout<<"E"<<endl;break;}
					else if(field[l][i+1] == 1 && field[l+1][i+1] == 1 && field[l+1][i+2] == 1){cout<<"F"<<endl;break;}
					else if(field[l+1][i] == 1 && field[l][i+1] == 1 && field[l-1][i+1] == 1){cout<<"G"<<endl;break;}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = N;
    for (int i = 1; i < N; ++i) {
        if (S[i] == S[i-1]) {
            --ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    long h, w;
    long ans = 0;
    Scanner scan = new Scanner(System.in);
    
    h = scan.nextInt();
    w = scan.nextInt();
    
    if(h == 1 || w == 1) {
      System.out.println(1);
    } else {
      ans = (long)((w*h + 1)/2);
      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 21844
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const n = Number(input.trim())
  if (n % 2 === 0) {
    console.log(0.5)
  } else {
    const x = Math.floor(n / 2)
    console.log((x + 1) / n)
  }

}
main()

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;

namespace E_ABC131
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            if (s[1] > ((s[0] - 1) * (s[0] - 2) / 2))
            {
                Console.WriteLine(-1);
                return;
            }
            var v = new List<int[]>();
            for (int i = 1; i < s[0]; i++)
            {
                int[] uv = new int[2] { i, s[0] };
                v.Add(uv);
            }
            int cnt = (s[0] - 1) * (s[0] - 2) / 2 - s[1];
            if (cnt == 0)
            {
                Console.WriteLine(v.Count);
                for (int k = 0; k < v.Count; k++)
                {
                    Console.WriteLine("{0} {1}", v[k][0], v[k][1]);
                }
                return;
            }
            for (int i = 1; i < s[0]; i++)
            {
                for (int j = s[0] - 1; j > i; j--)
                {
                    int[] uv = new int[2] { i, j };
                    v.Add(uv);
                    cnt--;
                    if (cnt == 0)
                    {
                        Console.WriteLine(v.Count);
                        for (int k = 0; k < v.Count; k++)
                        {
                            Console.WriteLine("{0} {1}", v[k][0], v[k][1]);
                        }
                        return;
                    }

                }


            }
            Console.WriteLine(v.Count);
            for (int k = 0; k < v.Count; k++)
            {
                Console.WriteLine("{0} {1}", v[k][0], v[k][1]);
            }
            return;

        }
    }
}


Measured memory_bytes: 13268
H,W,K=[int(i) for i in input().split()]
Fn=[1,1,2,3,5,8,13,21,0]
ans=[]
ans0=[0 for i in range(W+2)]
ans0[1]=1
ans.append(ans0)
for i in range(1,H+1):
    ansi=[0 for i in range(W+2)]
    for j in range(1,W+1):
        ansi[j-1]+=ans[i-1][j]*Fn[j-2]*Fn[W-j]
        ansi[j]+=ans[i-1][j]*Fn[j-1]*Fn[W-j]
        ansi[j+1]+=ans[i-1][j]*Fn[j-1]*Fn[W-j-1]
    for j in range(W+2):
        ansi[j]%=1000000007
    ans.append(ansi)
print(ans[H][K])

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

h = int(input())
w = int(input())
n = int(input())

num = 0
count = 0
w1 = w
w2 = w
h1 = h
h2 = h

while n > num:
    if w2 >= h2:
        num += w2
        w1 -= 1
        h2 -=1
    else:
        num += h2
        h1 -= 1
        w2 -=1
    
    count += 1

print(count)
        

Measured memory_bytes: 3064
#include<stdio.h>
int Y[]={-1,0,1,0};
int X[]={0,1,0,-1};
int h,w,i,j,m=1,ny,nx,r=0,t,y[1000010],x[1000010],u[1010][1010]={};
int main(){
  char c=0;
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf(" %c",&c);
      if(c=='#'){
	u[y[r]=i][x[r]=j]=1;
	r++;
      }
    }
  }
  for(t=0;r-t;t++){
    for(i=0;i<4;i++){
      ny=y[t]+Y[i];
      nx=x[t]+X[i];
      if(ny<0||h<=ny||nx<0||w<=nx)continue;
      if(u[ny][nx])continue;
      u[y[r]=ny][x[r]=nx]=u[y[t]][x[t]]+1;
      r++;
      if(m<u[ny][nx])m=u[ny][nx];
    }
  }
  printf("%d\n",m-1);
  return 0;
}


Measured memory_bytes: 11904
#include<queue>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define N 55
#define M 2005
int k,x;
int main()
{
    scanf("%d %d",&k,&x);
    for(int i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);i++)
    	printf("%d ",i);
    return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
X=list(map(int, input().split()))
X=sorted(X)
distance=[]
for i in range(M-1):
    distance.append(X[i+1]-X[i])


distance=sorted(distance, reverse=True)
#print(distance)
answer=sum(distance[(N-1):])
print(answer)

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using namespace std;
#define vec(type) vector<type>

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

	int q1 = 0, q2 = 0, q3 = 0;
	for (int i = 0; i < n; i++) {
		cin >> p;
		if (p <= a) q1++;
		else if (a < p && p <= b) q2++;
		else q3++;
	}

	cout << min({q1, q2, q3}) << endl;
}

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

int main(int argc, char const *argv[]) {
  string s, p;
  cin >> s >> p;

  int i, j;
  for (i = 0; i < s.length(); i++) {
    // cout << "-----------" << endl;
    for (j = 0; j < p.length(); j++) {
      // cout << s[(i + j) % s.length()] << " : " << p[j] << endl;
      if (s[(i + j) % s.length()] != p[j]) break;
      if (j == p.length() - 1 && p[j] == s[(i + j) % s.length()]) {
        cout << "Yes" << endl;
        return 0;
      }
      // cout << s[i + j] << " : " << p[j] << endl;
    }
    // cout << s[i] << endl;
  }
  cout << "No" << endl;

  return 0;
}



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

// 切り上げ除算
ll roundUp(ll a, ll b) { return (a + (b - 1)) / b; }

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

  vector<ll> tp(5);
  ll minTp = 1e15 + 1;
  int idx = 0;
  rep(i, 5) {
    cin >> tp[i];
    if (tp[i] < minTp) {
      minTp = tp[i];
      idx = i;
    }
  }

  ll ans = roundUp(n, minTp) + 4;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if (A > B) swap(A, B);

    if (A + V*T >= B + W*T) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

}

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

int main() {
	int a,b,c, i;
	i = 0;
	cin >> a >> b >> c;
	for (int x = a; x <= b; x++) {
		if (c%x == 0) {
			i++;
		}
	}
	cout << i << endl;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int ans=0;

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] nums = new Integer[n];
        for(int i = 0;i<n;i++){
            nums[i] = sc.nextInt();
        }

        loop: while (true) {
            for (int i = 0; i < n; i++) {
                int num=nums[i];
                if(num%2==0){
                    nums[i] = num/2;
                }else{
                    break loop;
                }
            }
            ans++;
        }
        System.out.println(ans);
    }
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);		

		int n = scan.nextInt();
		int a[] = new int[n];
		long sum = 0L;
		
		for (int i = 0; i < a.length; i++) {
			a[i] = scan.nextInt();
			sum += a[i];
		}

		Arrays.sort(a);

		System.out.println(a[0] + " " + a[n-1] + " " + sum);
		
		scan.close();
	}
}

Measured memory_bytes: 33640
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int ans=0;
		double d=Math.Abs(s[1]-(s[0]-a[0]*0.006));
		for(int i=1;i<n;i++){
			if(d>Math.Abs(s[1]-(s[0]-a[i]*0.006))){
				ans=i;
				d=Math.Abs(s[1]-(s[0]-a[i]*0.006));
			}
		}
		Console.WriteLine("{0}",ans+1);
	}
}

Measured memory_bytes: 13204
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<int,int>;
using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////

void solve(){
  ini(N);
  vi B(N-1); in(B);
  vi a(N);
  rep(i,N) {
    if(i==0) a[0] = B[0];
    else if(i==N-1) a[N-1] = B[N-2];
    else a[i] = min(B[i],B[i-1]);
  }
  int ans = 0;
  each(x,a) ans += x;
  out(ans);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

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

  vector <bool> A(N + 1);
  for (int i = 0; i < M; i++){
    int O; cin >> O; A[O] = true;
  }

  vector <ll> DP(N + 1);
  DP[0] = 1;
  for (int i = 1; i < N + 1; i++){
    if (i > 1) DP[i] = DP[i - 1] + DP[i - 2];
    else DP[i] = DP[i - 1];
    if (A[i] == true) DP[i] = 0;
    DP[i] %= nmax;
  }
  cout << DP[N] << endl;
  
  return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define for_each(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = __INT_MAX__;               // 2^31 - 1
const long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

void chmax(int &a, int b) {
    if (b > a) a = b;
}

void dfs(int n, int i, string s) {
    if (i == n) {
        cout << s << endl;
        return;
    }

    int nx = -1;
    for_each(c, s) chmax(nx, c - 'a');
    nx++;
    rep(j, nx + 1) {
        char c = char(j + 'a');
        dfs(n, i + 1, s + c);
    }
}

int main() {
    int n;
    cin >> n;
    dfs(n, 0, "");
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
	using namespace std;
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define ps push
	#define pll pair<long,long>
	typedef long long ll;
	#define PI 3.14159265
	
	
	const ll INF=(ll)1e16;
	
	
	int main()
	{
		ios::sync_with_stdio(0); 
		cin.tie(0); 
		cout.tie(0);
		
		string s;
		cin>>s;
		if(s[3]==s[2] && s[5]==s[4])
			cout<<"Yes";
		else
			cout<<"No";
	}		


Measured memory_bytes: 256
import sys
import collections
S = input()
count_dict = collections.Counter(S)
Num_A = count_dict["a"]
Num_B = count_dict["b"]
Num_C = count_dict["c"]

judge = sorted([Num_A, Num_B, Num_C])
if judge[2]-judge[0]>1:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 3444
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,m[MAX][MAX];

void dijkstra(){
  int minv;
  int d[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
   while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&m[u][v]!=INFTY){
        if(d[v]>d[u]+m[u][v]){
          d[v]=d[u]+m[u][v];
          color[v]=GRAY;
        }
      }
    }
  }

   for(int i=0;i<n;i++){
     cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
   }
}

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

  int k,c,u,v;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      m[u][v]=c;
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18 
 
using namespace std;

signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n;
    cin>>n;
    int x=n%1000;
    x=1000-x;
    if(x==1000) x=0;
    cout<<x;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll s; cin >> s;
  ll x1 = 1e9, x2 = 1;
  ll y2 = (s+x1-1)/x1;
  ll y1 = x1*y2-s;
  cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main(void){

  int a,b,c;
  int cards[11];
  int mycards;

  while( cin >> a >> b >> c ){

    for( int i = 1 ; i <= 10 ; i++ ){
      cards[i] = 1;
    }
    mycards = a + b;
    cards[a] = cards[b] = cards[c] = 0;

    double cnt = 0;
    for( int i = 1 ; i <= 10 ; i++ ){
      if( cards[i] && mycards + i <= 20 ){
	cnt++;
      }
    }
    if( cnt / 7 * 100 >= 50 ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    var ans = 0
    repeat(n) {
        if ((it+1) % 2 == 1 && a[it] % 2 == 1) {
             ans++
        }
    }
    println(ans)
}


Measured memory_bytes: 36380