akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+18
#define MOD 1000000007
using namespace std;



int main(){
    ll ans=0;
    
    ll N,K;
    cin >> N >> K;
    ll A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    

    ll num[41][2]={};
    ll x=1;
    for(ll i=0; i<=40; i++){
        for(int k=0; k<N; k++){
            
            if(A[k]%2==0){
                num[i][1] += x;
            }else{
                num[i][0] += x;
            }
            A[k]/=2;
        }
        
        x*=2;
    }
    
    ll keta_K[41]={};
    ll saijoi=-1;
    for(int i=0; i<41; i++){
        keta_K[i]+=K%2;
        if(keta_K[i]==1){
            saijoi=i;
        }
        K/=2;
    }


    for(int i=0; i<=saijoi; i++){
        ans+=num[i][keta_K[i]];
    }
    
    for(int i=saijoi; i>=0; i--){
        ll temp=0;
        if(keta_K[i]==0){
            continue;
        }
        
        for(int j=0; j<=saijoi; j++){
            if(j<i){
                temp+=max(num[j][0],num[j][1]);
            }else if(j>i){
                temp+=num[j][keta_K[j]];
            }else{
                temp+=num[j][0];
            }
        }
        
        ans=max(ans,temp);
    }
    
    
    
    for(int i=saijoi+1; i<41; i++){
        ans+=num[i][0];
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			int n = Integer.parseInt( kb.readLine() );
			String[] cards = new String[ 2 ];
			int hanakoScore = 0, taroScore = 0;
			int i,j,hlen,tlen;
			i=0;			
	        while( i<n ) {
				cards = kb.readLine().split( " " );
				if( cards[0].equals( cards[1] ) ) {
					hanakoScore += 1;
					taroScore += 1;
				} else {
					j=0;
					hlen = cards[0].length();
					tlen = cards[1].length();
					while( true ) {
						if( cards[0].charAt( j ) < cards[1].charAt( j ) ) {
							taroScore += 3;
							break;
						} else if( cards[0].charAt( j ) > cards[1].charAt( j ) ) {
							hanakoScore += 3;
							break;						
						}
						j++;
						if( j == hlen || j == tlen ) {
							if( hlen < tlen ) {
								taroScore += 3;
								break;
							} else if( hlen > tlen ) {
								hanakoScore += 3;
								break;
							}
						}			
					}
				}
				i++;
	        }
	        
        	System.out.println( hanakoScore+" "+taroScore );				
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 20200
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		int n;
		long a, b, c, d;
		Set<Long> set = new HashSet<>();

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			n = in.nextInt();
			a = in.nextLong();
			b = in.nextLong();
			c = in.nextLong();
			d = in.nextLong();

			long sa = Math.abs(b-a);
			for (int k = 0; k < n-1; k++) {
				if (k*c-(n-1-k)*d <= sa && sa <= k*d-(n-1-k)*c) {
					out.println("YES");
					return;
				}
			}

			out.println("NO");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

const int MX = 1e5 + 5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define F0R(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ps(x) cout << x << "\n";
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
		ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
		// cin.exceptions(cin.failbit); 
		// throws exception when do smth illegal
		// ex. try to read letter into int
		if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int a, b;

int main() {
	cin >> a >> b;
	if (a == 0 || b == 0) {
		ps("Zero");
		return 0;
	}
	else if (a > 0 && b > 0) {
		ps("Positive");
		return 0;
	}
	if (b > a) swap(a, b);
	//cout << a << " " << b << "\n";
	if (a > 0 && b < 0) {
		ps("Zero");
		return 0;
	}
	else {
		int dist = b - a + 1;
		if (dist & 1) {
			ps("Negative");
			return 0;
		}
		else {
			ps("Positive");
			return 0;
		}
	}
}







Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

void solve(int N, int K) {
  if (N % K == 0) {
    cout << "0" << endl;
  } else {
    cout << "1" << endl;
  }
}

int main() {
  int N, K;
  cin >> N >> K;
  solve(N, K);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

signed main()
{
    int2(n, w);

    vi a[4];

    int2(c, b);
    a[0].pb(-b);

    Rep(i, n) {
        int2(d, e);
        a[d-c].pb(-e);
    }
    rep(i, 4) sort(all(a[i]));
    int ans = 0;
    int dp[a[0].size()+2][a[1].size()+2][a[2].size()+2][a[3].size()+2];
    memset(dp, 0, sizeof(dp));

    rep(i, a[0].size()+1) {
        rep(j, a[1].size()+1) {
            rep(k, a[2].size()+1) {
                rep(l, a[3].size()+1) {
                    if (a[0].size() != i) 
                        dp[i+1][j][k][l] = dp[i][j][k][l] - a[0][i];
                    if (a[1].size() != j) 
                        dp[i][j+1][k][l] = dp[i][j][k][l] - a[1][j];
                    if (a[2].size() != k) 
                        dp[i][j][k+1][l] = dp[i][j][k][l] - a[2][k];
                    if (a[3].size() != l) 
                        dp[i][j][k][l+1] = dp[i][j][k][l] - a[3][l];
                    if ( (i * c) + (j * (c+1)) + (k * (c+2)) + 
                            (l * (c+3)) <= w) {
                        ans = max(ans, dp[i][j][k][l]);
                    }
                }
            }
        }
    }

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



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

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int k,t;
    cin>>k>>t;
    int a[t];
    int ma=0;
    for(int i=0;i<t;i++){
        cin>>a[i];
        ma=max(ma,a[i]);
    }
    int maki=k-ma;
    if(ma+1<=maki){
        cout << 0<<endl;
    }else{
        ma-=maki;
        cout << ma-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    vi v;
    rep(i,n){
        int hoge; cin>>hoge;
        v.push_back(hoge);
    }
    sort(all(v),greater<int>());
    rep(i,n)rep(j,n){
        if(i==j)continue;
        string hoge=to_string(v[i]*v[j]);
        bool foo=true;
        rep(k,hoge.size()){
            if(k==hoge.size()-1)continue;
            if(hoge[k]>=hoge[k+1]||hoge[k+1]-hoge[k]!=1)foo=false;
        }
        if(foo){cout<<hoge<<endl; return 0;}
    }
    cout<<-1<<endl;
}

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

int main() {
    string S;
    cin >> S;
    
    sort(S.begin(), S.end());
    
    if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) cout << "Yes";
    else cout << "No";
    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;

    if(n%2){
        cout << 0 << endl;
        return 0;
    }

    ll res = 0;
    ll N = n/2;

    for (ll i = 1; i < 28; ++i){
        ll bottom = pow(5, i);
        res += N / bottom;
    }
    cout << res << endl;
}

Measured memory_bytes: 512
// 2020-07-24 01:34:17
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  using P = pair<int, int>;
  int n;
  cin >> n;
  vector<vector<int> > a(n, vector<int>(n, -1));
  rep(i, n) {
    rep(j, n-1) {
      cin >> a[i][j];
      a[i][j]--;
    }
    a[i][n-1] = i;
  }
  set<P> st;
  auto add = [&](int i, int j) {
    st.insert(make_pair(min(i, j), max(i, j)));
  };
  rep(i, n) {
    int j = a[i][0];
    if(a[j][0] == i) add(i, j);
  }
  vector<int> c(n, 0);
  int ans = 0, done = 0;
  while(done < n) {
    ans++;
    set<P> p;
    swap(p, st);
    if(p.empty()) {
      cout << -1 << '\n';
      return;
    }
    for(const auto& el : p) {
      int u, v;
      tie(u, v) = el;
      c[u]++;
      c[v]++;
      for(int i : {u, v}) {
        if(a[i][c[i]] == i) done++;
        else {
          int j = a[i][c[i]];
          if(a[j][c[j]] == i) add(i, j);
        }
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 7536
#include<iostream>
#include<vector>
#include<stack>
#define MAX 100000
#define NIL -1

// 隣接リスト
std::vector<int> G[MAX];

// 隣接する頂点に同じ色を付けて記録するデータ
int color[MAX];

// 頂点数
int n;

// 深さ探索
// 探索した頂点には隣接頂点の印としてcの色を付ける
void dfs(int r, int c)
{
	std::stack<int> S;
	S.push(r);
	color[r] = c;

	while (!S.empty())
	{
		int u = S.top();
		S.pop();
		for (int i = 0; i < G[u].size(); i++)
		{
			int v = G[u][i];
			if (color[v] == NIL)
			{
				color[v] = c;
				S.push(v);
			}
		}
	}
}

// 色を付けて隣接頂点同士に分類する
void assignColor()
{
	int id = 1;
	for (int i = 0; i < n; i++)color[i] = NIL;
	for (int u = 0; u < n; u++)
	{
		if (color[u] == NIL)dfs(u, id++);
	}
}

int main()
{
	int m;
	std::cin >> n >> m;

	int s, t;
	for (int i = 0; i < m; i++)
	{
		std::cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}

	assignColor();

	int q;
	std::cin >> q;
	for (int i = 0; i < q; i++)
	{
		std::cin >> s >> t;
		if (color[s] == color[t])
		{
			std::cout << "yes" << std::endl;
		}
		else
		{
			std::cout << "no" << std::endl;
		}
	}

	return 0;
}

// 参考
// ALDS1_11_B_DepthFirstSearchと同じロジックで深さ探索を実装
void dfs_2(int r, int c)
{
	std::stack<int> S;
	S.push(r);
	color[r] = c;
	while (!S.empty())
	{
		int u = S.top();
		int v = -1;
		for (int i = 0; i < G[u].size(); i++)
		{
			if (color[G[u][i]] == NIL)
			{
				v = G[u][i];
			}
		}
		if (v != -1)
		{
			S.push(v);
			color[v] = c;
		}
		else
		{
			S.pop();
		}
	}
}



Measured memory_bytes: 9040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
#define loop(i,a,n) for (int i = (a); (i) < (n); ++ (i))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    int N;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<int> p(N);
    rep(i,N) 
    {
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int sum =0;
    rep(i,N-1) 
    {
        sum += p[i];
    }   
    sum += p[N-1]/2;
    cout << sum << endl;
    return 0; 
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

ll N, K, L;

vector<ll>A[202020];
ll a_cnt = 0;
ll a_flg[202020];
vector<ll>A2[202020];

vector<ll>B[202020];
ll b_cnt = 0;
ll b_flg[202020];
vector<ll>B2[202020];

ll ans[202020];

int main(){

    cin >> N >> K >> L;
    rep(i, K){
        ll a, b;
        cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    rep(i, L){
        ll a, b;
        cin >> a >> b;
        B[a].push_back(b);
        B[b].push_back(a);
    }
    
    rep1(i, N){
        if(a_flg[i])continue;
        a_cnt++;
        a_flg[i] = a_cnt;
        stack<ll>S;
        S.push(i);
        while(!S.empty()){
            ll idx = S.top();
            S.pop();
            rep(j, A[idx].size()){
                ll to = A[idx][j];
                if(a_flg[to])continue;
                a_flg[to] = a_cnt;
                S.push(to);
            }
        }
    }
    rep1(i, N)A2[a_flg[i]].push_back(i);
    rep1(i, N){
        if(b_flg[i])continue;
        b_cnt++;
        b_flg[i] = b_cnt;
        stack<ll>S;
        S.push(i);
        while(!S.empty()){
            ll idx = S.top();
            S.pop();
            rep(j, B[idx].size()){
                ll to = B[idx][j];
                if(b_flg[to])continue;
                b_flg[to] = b_cnt;
                S.push(to);
            }
        }
    }
    rep1(i, N)B2[b_flg[i]].push_back(i);

    rep1(i, a_cnt){
        map<ll, ll>cnt;
        rep(j, A2[i].size()){
            ll idx = A2[i][j];
            cnt[b_flg[idx]]++;
        }
        rep(j, A2[i].size()){
            ll idx = A2[i][j];
            ans[idx] = cnt[b_flg[idx]];
        }
    }

    rep1(i, N){
        cout << ans[i];
        if(i < N)cout << " ";
        else cout << endl;
    }

    return 0;
}

Measured memory_bytes: 42868
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

vector<ll > divisor(ll n) {
  vector< ll > div;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      div.push_back(i);
      //重複許すマジ
      if(i * i != n) div.push_back(n / i);
    }
  }
  sort(div.begin(), div.end());
  return (div);
}

//商とあまりをM 割る数をYとすると
//MY+M = N -> M(Y+1) = N つまり約数から1引いた数が制約と一致するか確認するとよさそう

int main() {

    ll N;
    cin >> N;

    vector<ll > div = divisor(N);

    ll ans = 0;

    for(ll i = 0 ; i < div.size(); i++){
        if(div[i]-1 == 0) continue;
        if(N / (div[i]-1) == N % (div[i]-1)){
            ans += div[i]-1;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#define NIL -1
#define MAX 25

int Max( int, int );
int Depth( int );
int Height( int );
void Print( int );

struct Node{
    int p;
    int l;
    int r;
    int s; //s means another sibling
    int degree;
};
struct Node A[26];

//------------------------------------------------
int main(){
    int n, id, r, l, cnt, i;

    //initialize
    for(i = 0; i<MAX; i++){
	A[i].p = NIL;
	A[i].l = NIL;
	A[i].r = NIL;
	A[i].s = NIL;
    }
    //input
    scanf("%d",&n);
    for(i = 0; i<n; i++){
	cnt = 0;
	scanf("%d%d%d", &id, &l, &r);
	A[id].l = l; //parent operations
	A[id].r = r;
	if(l != NIL){ //left child
	    A[l].p = id;
	    A[l].s = r;
	    cnt++;
	}
	if(r != NIL){ //right child
	    A[r].p = id;
	    A[r].s = l;
	    cnt++;
	}
	A[id].degree = cnt; //degree
    }
    //display
    for(i = 0; i<n; i++) Print( i );
    
    return 0;
}

//--------------------------------------------------
void Print( int x ){
    int depth, height, i;

    depth = Depth( x );
    height = Height( x );
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", x, A[x].p, A[x].s, A[x].degree, depth, height);
    //the type of the node
    if( A[x].p == NIL ) printf("root\n");
    else if( A[x].degree == 0 ) printf("leaf\n");
    else printf("internal node\n");
    
    return ;
}

//---------------------------------------------------
int Depth( int x ){
    int cnt = 0;

    while( A[x].p != NIL ){
	cnt++;
	x = A[x].p;
    }
    return cnt;
}

//---------------------------------------------------
int Height( int x ){
    if(A[x].degree == 0) return 0;
    else                 return 1+Max( Height(A[x].l), Height(A[x].r) );
}

//---------------------------------------------------
int Max( int x, int y ){
    if (x > y) return x;
    else       return y;
}
    














Measured memory_bytes: 2112
#include<stdio.h>
int main(void){
	int n;
	int counta=0,countw=0,countt=0,countr=0;
	scanf("%d",&n);
	char s[n][3];
	for(int i=0;i<n;i++)
		scanf("%s",s[i]);
	for(int i=0;i<n;i++){
		if(s[i][0]=='A')	
	counta++;
	else if(s[i][0]=='W')	
	countw++;
	else if(s[i][0]=='T')	
	countt++;
	else if(s[i][0]=='R')	
	countr++;
	}
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",counta,countw,countt,countr);
return 0;
}

Measured memory_bytes: 2024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int c,m,n;
	cin >> c;
	while(c--){
		cin >> m >> n;
		if(m*m + n*n <= 1){
			cout << 'C' << endl;
			continue;
		}
		int ct = 0;
		int size = m*m + n*n + 1;
		for(int x = -sqrt(size) ;x*x <= size;++x){
			for(int y = -sqrt(size) ;y*y <= size;++y){
				if(x==y && x==0)continue;
				int sqsum = x*x + y*y;
				int a = x*m + y*n, b = x*n - y*m;
				if((a == 0 || a % sqsum == 0) && (b == 0 || b % sqsum == 0)){
					ct++;
					//					cout << "x:" << x << " y:" << y << endl;
				}
			}
		}
		if(ct == 8)cout << 'P' << endl;
		else cout << 'C' << endl;
	}
  return 0;
}

Measured memory_bytes: 2976
#include <iostream>

using namespace std;

int main(){
  
  int H , W;

  while(1){
    
  cin >> H >> W;
    
    if(H==0&&W==0){
      
      break;
    }
    
    for(int i=0;i<H;i++){
      
      for(int j=0;j<W;j++){
        
        
    if(i%2==1 && j%2==1 || i%2==0 && j%2==0){
        
        cout << '#';
      }
    
    else
      
      cout << '.';
      }
      cout << endl;
    }
    
      cout << endl;
  }
}


Measured memory_bytes: 3084
/* Sriram S. Nair */
/* MNNIT Allahabad */

#include<iostream>
#include<vector>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	vector<int> a(n);
	vector<bool> dp(k+1);

	//dp[i] = true, if i coins remains and first player wins;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int stones=0; stones<=k; stones++){
		for(int i=0;i<n;i++){
			if(stones>=a[i] && !dp[stones-a[i]]){
				dp[stones] = true;
			}	
		}
	}
	if(dp[k]){
		cout<<"First";
	}
	else{
		cout<<"Second";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;


int main(void){

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

    sort(a.begin(), a.end());
    int flag = 0;

    for(int i = 0;i < n-1;i++){
        if(a[i] == a[i+1]) {
            flag = 1;
            break;
        }
    }

    cout << (flag == 1 ? "NO" : "YES") << endl;

    return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


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> PII;
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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#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)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int cnt = 0;
	int ans = -1;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;

		if (x == 1) {
			cnt++;
			ans = max(ans, cnt);
		}
		else {
			cnt = 0;
		}
	}

	if (ans != -1) {
		cout << ans+1 << endl;
	}
	else {
		cout << 1 << endl;
	}
	

	return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int l[n];
  for(int i=0; i<n; i++) {
    cin >> l[i];
  }
  sort(l,l+n);
  reverse(l,l+n);
  int ans=0;
  for(int i=0; i<k; i++) {
    ans+=l[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod = 1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 5011;
int n, a[maxn], pos[maxn];
ll dp[maxn], ndp[maxn];
int ia[maxn];
int main()
{
	int A, B;
	geti(n);
	getii(A, B);
	for (int i=1; i<=n; i++) geti(a[i]), ia[a[i]] = i;
	memset(dp, 20, sizeof(dp));
	dp[0] = 0;
	for (int i=1; i<=n; i++)
	{
		memset(ndp, 20, sizeof(ndp));
		ll mn = ndp[0];
		for (int j=0; j<=n; j++)
		{
			if (j==ia[i]) ndp[j] = mn;
			mn = min(mn, dp[j]);
			ndp[j] = min(ndp[j], mn+(j<ia[i]?B:A));
		}
		swap(dp, ndp);
	}
	ll ans = 1e18;
	for (int i=0; i<=n; i++) ans = min(ans, dp[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	count := readInt()
	list := make([]int, count)

	loop(0, count, func(i int) {
		list[i] = readInt()
	})

	sort.Ints(list)

	previous := list[0]
	loop(1, count, func(i int) {
		if previous == list[i] {
			fmt.Println("NO")
			os.Exit(0)
		}
		previous = list[i]
	})

	fmt.Println("YES")
}

func loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readInt() int {
	var v int
	fmt.Scan(&v)
	return v
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define int long long
#define N 1000005
using namespace std;
struct point
{
    int X,Y,id;
}p[N];
int n,ans=0,par[N],cnt=0;
bool cmp(point a,point b)
{
    if(a.X==b.X)return a.Y<b.Y;
    return a.X<b.X;
}
bool cmp2(point a,point b)
{
    if(a.Y==b.Y)return a.X<b.X;
    return a.Y<b.Y;
}
struct edge
{
    int l,r,x;
}e[N];
int root(int x)
{
    while(par[x]>-1)x=par[x];
    return x;
}
void merger(int x,int y)
{
    if((x=root(x))==(y=root(y)))
    {
        return;
    }
    if(par[y]<par[x])swap(x,y);
    par[x]+=par[y];
    par[y]=x;
}
bool cmp3(edge a,edge b)
{
    return a.x<b.x;
}
void kruskal()
{
    sort(e+1,e+cnt+1,cmp3);
    for(int i=1;i<=cnt;i++)
    {
        int ru=root(e[i].l);
        int rv=root(e[i].r);
        if(ru!=rv)
        {
            ans+=e[i].x;
            merger(ru,rv);
        }
    }
}
main()
{
    memset(par,-1,sizeof(par));
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].X>>p[i].Y;
        p[i].id=i;
    }
    sort(p+1,p+n+1,cmp);
    for(int i=1;i<n;i++)
    {
        cnt++;
        e[cnt].l=p[i].id;
        e[cnt].r=p[i+1].id;
        e[cnt].x=p[i+1].X-p[i].X;
    }
    sort(p+1,p+n+1,cmp2);
    for(int i=1;i<n;i++)
    {
        cnt++;
        e[cnt].l=p[i].id;
        e[cnt].r=p[i+1].id;
        e[cnt].x=p[i+1].Y-p[i].Y;
    }
    kruskal();
    cout<<ans;
}


Measured memory_bytes: 18688
#include <cstdio>
#include <iostream>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include<string>
#include <numeric>
using namespace std;
int a[810];
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n;
	cin >> n;
	int x = 0;
	rep(i, n) { cin >> a[i]; x+=a[i]; }
	sort(a, a + n);
	if (x % 2 != 0) { rep(i, n) { if (a[i] % 2 != 0) { cout << (x - a[i])/2 << endl; return 0; } } }
	else { cout << x /2<< endl; }
}






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

int main()
{
	int n,k;
    cin>>n>>k;
    int ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+n);
    long sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=ar[i];
    }
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3556
/*
created on 20/4/2020
*/
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
int const MOD = 1000000007;
lli findans(lli K, lli N){
  return (((2*N - K +1)*K)/2) - (K*(K-1)/2) +1;
}
void solve(){
  lli N, K;
  cin>>N>>K;
  lli sum = 0;
  for(int i = K;i<=N+1;i++){
    sum = (sum%MOD + findans(i, N)%MOD)%MOD;
  }
  cout<<sum%MOD<<Endl;
}


Measured memory_bytes: 3648
# L 以上 R 以下の整数のうち、d の倍数であるようなものはいくつありますか？
l, r, d = map(int, input().split())
# d の倍数
ans = 0
for i in range(l, r+1):
    # L 以上 R 以下の整数が割り切れるかどうか
    if i % d == 0:
        ans += 1
print(ans)


Measured memory_bytes: 9072
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{input, marker::Usize1};

const M: u64 = 1000_000_007;

fn main() {
    input! {
        n: usize,
        xy: [(Usize1, Usize1); n - 1],
    }

    println!("{}", DP::new(n, &xy).calc(0, 0));
}

struct DP {
    dp: Vec<Option<(u64,u64)>>,
    t: Vec<Vec<usize>>,
}

impl DP {
    fn new(n: usize, xy: &Vec<(usize, usize)>) -> DP {
        let mut t = vec![vec![]; n];
        for &(x, y) in xy {
            t[x].push(y);
            t[y].push(x);
        }

        DP {
            dp: vec![None; n],
            t: t,
        }
    }

    fn calc(&mut self, i: usize, p: usize) -> u64 {
        if let Some(v) = self.dp[i] {
            (v.0 + v.1) % M
        } else {
            let mut v = (1, 1);
            for j in self.t[i].clone() {
                if j != p {
                    v.0 = v.0 * self.calc(j, i) % M;
                    v.1 = v.1 * self.dp[j].unwrap().0 % M;
                }
            }
            self.dp[i] = Some(v);
            (v.0 + v.1) % M
        }
    }
}



Measured memory_bytes: 27784
let rec fold_n n f v = if n <= 0 then v else fold_n (n-1) f (f v)
let inf = 10101010101010

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init m (fun _ -> Scanf.scanf " %d %d %d" (fun a b c -> a-1,b-1,c)) in

  let reach = begin
    let g = Array.init n (fun _ -> []) in
    a |> Array.iter (fun (u,v,_) -> g.(v) <- u :: g.(v));
    let vis = Array.make n false in
    let rec f u =
      vis.(u) <- true;
      List.iter (fun v -> if not vis.(v) then f v) g.(u)
    in f (n-1);
    vis
  end in

  let sc = Array.make n (-inf) in sc.(0) <- 0;
  let mem = Array.make n false in
  let has_loop = true |> fold_n (2*n) (fun upd ->
    if not upd then false else begin
      Array.fill mem 0 n false;
      Array.fold_left (fun b (u,v,c) ->
        let b' = sc.(u) + c > sc.(v) in
        if b' then (mem.(v) <- true; sc.(v) <- sc.(u) + c);
        b || b'
        ) false a
    end)
  in
  let inf_loop = has_loop && begin
    Array.init n (fun i -> reach.(i) && mem.(i)) |> Array.fold_left (||) false
  end in

  if inf_loop then
    print_endline "inf"
  else
    Printf.printf "%d\n" sc.(n-1)


Measured memory_bytes: 2688
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a-lin bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

vector<int> multiple(1000005);

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
 
    int N;cin >> N;
    int maxi = 0;
    vector<int> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
        maxi = max(maxi,retu.at(i));
        multiple.at(retu.at(i))++;
    }
    int MaxMultipleCount = 0;
    for(int i = 2;i<=maxi;i++){
        int multipleCount = 0;
        int now = i;
        while(true){
            if(now > 1000000) break;
            multipleCount += multiple.at(now);
            now += i;
        }
        MaxMultipleCount = max(MaxMultipleCount,multipleCount);
    }
    if(MaxMultipleCount == N){
        cout << "not coprime" << endl;
        return 0;
    }
    if(MaxMultipleCount > 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    cout << "pairwise coprime" << endl;
}

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

int main(){
  int k,s;
  cin>>k>>s;
  int cou=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j>=0&&s-i-j<=k){
        cou++;
      }
    }
  }
  cout<<cou<<endl;
}
        



Measured memory_bytes: 256
#include<iostream>

using namespace std;
typedef long long ll;

const int MAX = 45;

ll f[MAX];

ll fibonacci(long n) {

	if (f[n] != -1) return f[n];
	if (n < 2) return 1;

	ll fb = fibonacci(n - 1) + fibonacci(n - 2);
	f[n] = fb;

	return fb;
}


int main() {

	for (int i = 0;i < MAX;i++) f[i] = -1;

	int num;
	cin >> num;

	cout << fibonacci(num) << endl;

	return 0;
}





Measured memory_bytes: 3108
using System;

namespace ABC054B
{
    static class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            double power = 1;
            double mod = Math.Pow(10, 9) + 7;
            
            for(int i = 1; i < n + 1; i++)
                power = (power * i) % mod;

            Console.WriteLine(power);
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		boolean  bool = true; 
		for(int i = 0; i < n; i++) {
			int num =a[i];
			if(num % 2 == 0) {
				if(num % 3 != 0 && num % 5 != 0) {
					bool = false;
					break;
				}
			}
		}
		
		if(bool) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
		
		sc.close();
	}
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep (i, n) {
    cin >> a[i];
  }
  vll dp(n + 1, vl(k + 1));
  dp[0][0] = 1;
  rep (i, n) {
    rep (j, k + 1) {
      if (j == 0) {
        dp[i + 1][0] = dp[i][0];
      }
      else if (j - a[i] <= 0) {
        dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
      }
      else {
        dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - a[i]] + MOD) % MOD;
      }
    }
  }
  cout << dp[n][k] << endl;
}


Measured memory_bytes: 80256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX 100010
int dc=100000;
int dist(int a,int b){
  return (a<b)?b-a:a-b;
}

int main(){
  if(df)printf("*** debug mode ***\n");
  char s[MAX],d[MAX];
  int idx[MAX],i;
  scanf(" %s",s);
  int len=strlen(s);
  if(df)printf("%s:%d\n",s,len) ;
  int j=0;
  idx[0]=-1;
  for(i=0;i<len;i++){
    if(s[i]!='x'){
      d[j]=s[i];
      idx[j+1]=i;
      j++;
    }
  }
  if(df)printf("\n");
  idx[j+1]=len;
  int d_len=j,flag=1,m=(1+d_len)/2;
  if(df){
    for(i=0;i<d_len;i++){
      printf("%c",d[i]);
    }
    printf("\n");
    for(i=0;i<d_len+2;i++){
      printf("%d",idx[i]);
    }
    printf("\n");
  }
  for(i=0;i<d_len;i++){
    if(d[i]!=d[d_len-i-1])flag=0;
  }
  if(flag==0){
    printf("-1");
    return 0;
  }
  int sum=0;
  for(i=0;i<m;i++){
    sum+=dist(idx[i+1]-idx[i],idx[d_len-i+1]-idx[d_len-i]);
  }
  

  printf("%d",sum);
  return 0;
}


/// confirm df==0 ///


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


int main() {
    int N,M;
    cin>>N>>M;
    vector<int> s(M),c(M);
    rep(i,M){
        cin>>s.at(i)>>c.at(i);
        s.at(i)--;
    }
    bool ju=false;
    int a,b,ans;
    if(N==1){a=0;b=9;}
    if(N==2){a=10;b=99;}
    if(N==3){a=100;b=999;}
    for(int i=a;i<=b;i++){



        vector<int> x(N);
        int j=i;
        bool judge=true;
        if(N==1){x.at(0)=i;}
        if(N==2){x.at(0)=i/10;x.at(1)=i%10;}
        if(N==3){x.at(0)=i/100;j-=x.at(0)*100;x.at(1)=j/10;x.at(2)=j%10;}
        rep(j,M){
            if(x.at(s.at(j))!=c.at(j)){judge=false;}
        }
        if(judge){ans=i;ju=true;break;}
    }
    if(ju){cout<<ans<<endl;}
    else{cout<<-1<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll k;
  cin >>k;
  ll e[k];
  for(ll i=0;i<k;i++) cin >>e[i];
  sort(e,e+k);
  vector <pair<ll,ll>> ee;
  ll c=1;
  for(ll i=0;i<k;i++){//配列の中身がそれぞれ何個あるかのカウント
   if(e[i]==e[i+1]){
     c++;
     if(i==k-2){//122333みたいなときは3のところがansに入らないので
       ee.push_back(make_pair(c,e[i]));
       break;
     }
   }
   else{
     ee.push_back(make_pair(c,e[i]));
     if(i==k-2) {
         ee.push_back(make_pair(1,e[i+1]));//112223とかのときにansに3の分を足すため
         break;
     }
     c=1;
   }
  }
  ll es=ee.size();
  ll ans=0;
  for(ll i=0;i<es;i++){
    if(ee[i].first<ee[i].second) ans+=ee[i].first;
    else if(ee[i].first>ee[i].second) ans+=(ee[i].first-ee[i].second);
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int d;
ll g;
vector<int> p;
vector<int> c;
vector<bool> seen;
int ans;

void dfs(ll sum, int n, int i){
    ll rowmax = 100*(i+1)*p[i] + c[i];
    // printf("%lld, %d, %d, %lld\n", sum, n, i, rowmax);
    if(sum + rowmax >= g){
        int div, mod;
        div = (g - sum) / (100*(i+1));
        mod = (g - sum) % (100*(i+1));
        if(mod>0) div++;
        if(div >= p[i]) n += p[i];
        else n += div;
        // pr(n);
        chmin(ans, n);
        // return;
    }else{
        sum += rowmax;
        n += p[i];
        seen[i] = true;
        rep(j, d){
            if(seen[j]) continue;
            dfs(sum, n, j);
            seen[j] = false;
        }
    }
}

int main()
{
    cin >> d >> g;
    p.resize(d); c.resize(d);
    rep(i, d) cin >> p[i] >> c[i];
    ans = INF;
    rep(i, d){
        seen.assign(d, false);
        dfs(0, 0, i);
    }
    pr(ans);
    return 0;}

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

int main(){
  double r;
  cin >> r;
  printf("%.9lf\n",r*2.0*3.141592653589793238);
  return 0;
}

Measured memory_bytes: 3784
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
ll ans,K,A,B;
int main()
{
	K=read();A=read();B=read();
	if(A+2>=B){cout<<K+1<<endl;return 0;}
	K+=1;ans=A;K-=A;
	ans=ans+(B-A)*(K/2);
	if(K%2==1)++ans;
	cout<<ans<<endl;
	return 0;
}


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

const int MAXN = 100005;
int N;
int a[MAXN], b[MAXN];

int main() {
  while (cin >> N) {
    map<int, int> m;
    for (int i = 0; i < N; ++i) {
      cin >> a[i] >> b[i];
      m[a[i]]++;
      m[b[i]+1]--;
    }
    // 1 3   3 4
    // 1 +1
    // 3 +1
    // 4 -1
    // 5 -1
    int res = 1, num = 1, prev = 0;
    for (map<int, int>::iterator it = m.begin();
         it != m.end(); ++it) {
      if (num >= prev) {
        res = max(res, min(num, it->first - 1));
      }
      prev = it->first;
      num += it->second;
    }
    cout << res - 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 6004
package main

import (
	"fmt"
)

func main() {
	var a1, a2, a3 int
	fmt.Scan(&a1, &a2, &a3)
	
	sum := a1 + a2 + a3

	if sum >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}

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

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

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0){
        c -= b;
        if(c > 0)
        a -= d;
    }
    if(a>0)cout<<"Yes\n";
    else cout<<"No\n";
    
    return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
struct st
{
	int p,b,c;
};
bool operator<(st a,st b)
{
	return a.c>b.c;
}
vector<int>G[100000];
unordered_map<int,int>d[100000];
unordered_map<int,vector<int>>E[100000];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int p,q,c;
		scanf("%d%d%d",&p,&q,&c);
		p--;
		q--;
		E[p][c].push_back(q);
		E[q][c].push_back(p);
		G[p].push_back(c);
		G[q].push_back(c);
	}
	priority_queue<st>que;
	d[0][0]=0;
	que.push({0,0,0});
	while(!que.empty())
	{
		st p=que.top();
		que.pop();
		if(d[p.p][p.b]!=p.c)
			continue;
		if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c)
		{
			d[p.p][0]=p.c;
			que.push({p.p,0,p.c});
		}
		if(p.b==0)
		{
			for(int v:G[p.p])
			{
				if(d[p.p].find(v)==d[p.p].end()||d[p.p][v]>p.c+1)
				{
					d[p.p][v]=p.c+1;
					que.push({p.p,v,p.c+1});
				}
			}
			continue;
		}
		for(int v:E[p.p][p.b])
		{
			if(d[v].find(p.b)==d[v].end()||d[v][p.b]>p.c)
			{
				d[v][p.b]=p.c;
				que.push({v,p.b,p.c});
			}
		}
	}
	int Min=INT_MAX;
	for(auto p:d[n-1])
		Min=min(Min,p.second);
	if(Min==INT_MAX)
		puts("-1");
	else
		printf("%d\n",Min);
	return 0;
}

Measured memory_bytes: 79636