akhauriyash/Code-Regression huggingface dataset:
#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;
#define int ll
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
class edge{
public:
    int to;
    int cost;
    void Init(){to=0; cost=0;}
    edge(int t, int c):to(t), cost(c){};
    
};
vi d(100,INF);
vector<edge>Edge[100];
void dijkstra(){
    d[1]=0;
    priority_queue<pii,vector<pii>,greater<pii> >que;
    que.push(pii(0,1));
    while(!que.empty()){
        pii now=que.top(); que.pop();
        int to_v=now.second;
        if(d[to_v]<now.first)continue;
        rep(i,Edge[to_v].size()){
            edge e=Edge[to_v][i];
            if(d[e.to]>d[to_v]+e.cost){
                d[e.to]=d[to_v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}
signed main(){
    int n;
    while(cin>>n,n){
        vector<pair<pii,int>>data;
        rep(i,100)Edge[i].clear();
        rep(i,n-1){
            int from,to,cost;
            cin>>from>>to>>cost;
            Edge[from].push_back(edge(to,cost));
            Edge[to].push_back(edge(from,cost));
            data.push_back(make_pair(pii(from,to),cost));
        }
        int sum=0;
        rep(i,n+1)d[i]=INF;
        dijkstra();
        int maxi=0;
        for(int i=0; i<data.size();i++){
            if(data[i].first.first==1){
                if(Edge[data[i].first.second].size()==1)continue;
            }else if(data[i].first.second==1){
                if(Edge[data[i].first.first].size()==1)continue;
            }else if(Edge[data[i].first.first].size()==1 || Edge[data[i].first.second].size()==1)
                continue;
            sum+=data[i].second;
        }
        sum*=2;
        for(int i=1; i<=n;i++){
            if(i==1)continue;
            if(Edge[i].size()==1)continue;
            cmax(maxi, d[i]);
        }
        cout<<sum-maxi<<endl;
    }
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define int long long
#define P pair<int,int>

int n;

void dfs(string s, char mx){
    if(s.size() == n) cout << s << endl;
    else {
        for(char c = 'a'; c <= mx; c++){
            if(c == mx) dfs(s + c, mx + 1);
            else dfs(s + c, mx);
        }
    }
}

signed main() {
    cin >> n;

    dfs("",'a');
}



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

long long n;
vector<long long> a, res;

void solve();

int main() {
  cin >> n;
  a.resize(n);
  for (auto& p : a) cin >> p;
  solve();
  cout << res.size() << endl;
  for (auto p : res) cout << p << endl;
  return 0;
}

void solve() {
  {
    int id = 0;
    for (int i = 0; i < n; ++i)
      if (a[id] < a[i]) id = i;
    if (a[id] < 0) {
      cout << a[id] << endl;
      for (int i = 0; i < id; ++i) res.push_back(1), --n;
      while (n > 1) res.push_back(n--);
      return;
    }
  }
  {
    long long sum[2] = {};
    for (int i = 0; i < n; ++i)
      if (a[i] >= 0) sum[i & 1] += a[i];
    cout << max(sum[0], sum[1]) << endl;
    if (sum[(n - 1) & 1] < sum[n & 1]) {
      res.push_back(n);
      a.pop_back();
    }
  }
  n = a.size();
  bool ch = (n - 1) & 1;
  vector<long long> tmp;
  for (int i = 0; i < n; ++i) {
    if ((i ^ ch ^ 1) & 1) {
      if (a[i] >= 0)
        tmp.push_back(a[i]);
      else {
        res.push_back(tmp.size() + 1);
        if (tmp.size() && i < n - 1) {
          long long now = tmp.back() + a[i + 1];
          ++i;
          tmp.pop_back();
          tmp.push_back(now);
        }
      }
    } else {
      if (tmp.size())
        tmp.push_back(a[i]);
      else
        res.push_back(1);
    }
  }
  n = tmp.size();
  for (int i = 1; i < n; i += 2) res.push_back(2);
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define vec_all(vec) vec.begin(), vec.end()

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

    ll price_sum = 0;
    priority_queue<int> que;
    int tmp;
    rep(i, n)
    {
        cin >> tmp;
        price_sum += tmp;
        que.push(tmp);
    }

    ll sum = 0;
    int top;
    rep(i, m) {
        top = que.top();
        int half = top / 2;
        if (top % 2 == 0) {
            sum += half;
        } else {
            sum += (half + 1);
        }

        que.pop();
        que.push(half);
    }

    cout << price_sum - sum << endl;

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
//#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;



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

	int r, D, x;
	cin >> r >> D >> x;
	int res = x;
	REP(i, 10) {
		res = r * res - D;
		print(res);
	}
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20, D = 10 + 2;
int n, m, q;
int col[D][N];
int v[N], d[N], c[N];
vector <int> g[N];



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

	cin >> n >> m;

	for (int i = 0, u, v; i < m; i++)
	{
		cin >> u >> v;
		u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}

	cin >> q;

	for (int i = 0; i < q; i++)
	{
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}

	for (int i = q - 1; i >= 0; i--)
	{
		queue <pii> que;
		
		for (int j = d[i]; j >= 0; j--)
		{
			if (!col[j][v[i]])
			{
				col[j][v[i]] = c[i];
				que.push({j, v[i]});
			}
		}

		while (_sz(que))
		{
			int d = que.front().F, v = que.front().S;

			que.pop();

			if (!d) continue ;
			
			for (int u : g[v])
				if (!col[d - 1][u])
				{
					col[d - 1][u] = col[d][v];
					que.push({d - 1, u});
				}
		}
	}

	for (int i = 0; i < n; i ++) 
	{
		cout << col[0][i] << '\n'; 
	}
}


Measured memory_bytes: 17656
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        if(A < 10 && B < 10 && A > 0 && B > 0) {
            System.out.println(A*B);
        } else {
            System.out.println(-1);
        }

    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
int main(void){ 
  int n,m;
  int i,j;
  int ans=0;
  cin>>n>>m;
  vector<int> a(n,0);
  vector<int> c(m,0);
  vector<int> s(m,0);
  if(n!=1)a.at(0)=1;
  rep(i,m){
    cin>>s.at(i)>>c.at(i);
    a.at(s.at(i)-1)=c.at(i);
  }
  rep(i,m){
    if(a.at(s.at(i)-1)!=c.at(i)){ans=-1;}
    if(s.at(i)==1&&c.at(i)==0&&n!=1){ans=-1;}
  }  
  if(ans!=-1)
    rep(i,n)cout<<a.at(i);
  else{cout<<ans;}
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=b-1;i>=a;i--)
const ll maxb=21,mod=1e9+7;
ll n,ady[maxb][maxb],dp[1<<maxb];
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n;
    rep(i,0,n)
        rep(j,0,n)
            cin>>ady[i][j];
    dp[(1<<n)-1]=1;
    per(msk,0,(1<<n)-1) {
        ll i=__builtin_popcount(msk);
        rep(j,0,n) if(~msk&1<<j && ady[i][j])
            dp[msk]=(dp[msk]+dp[msk|1<<j])%mod;
    }
    cout<<dp[0]<<"\n";
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,m,q,t,x;
    cin>>n>>m;
    priority_queue <long long> a[n];
    for(long long i=0;i<m;i++){
        cin>>q>>t;
        if(q==0){
            cin>>x;
            a[t].push(x);
        }
        else if(q==1){
            if(!a[t].empty()){
                cout<<a[t].top()<<endl;
            }
        }
        else{
            if(!a[t].empty()){
                a[t].pop();
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int mex=2005;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++) 
int main()
{
   int n;
   cin>>n;
   int a[n],b[n];
   fo(i,0,n)
   cin>>a[i];
   fo(i,0,n)
   cin>>b[i];
   int arr[n];
   fo(i,0,n)
   {
       arr[i]=i+1;
       
   }
   int f=1;
   fo(i,1,n+1)
   f=f*i;
   int an,bn;
   fo(i,0,f)
   {
       int fg=0,fg1=0;
       fo(i,0,n)
       if(arr[i]!=a[i]) fg=1;
       fo(i,0,n)
       if(arr[i]!=b[i]) fg1=1;
       if(fg==0) an=i;
       if(fg1==0) bn=i;
       next_permutation(arr,arr+n);
   }
   cout<<abs(an-bn);
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)
 
#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif
 
using i64 = long long;
using iip = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;
 
template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }
 
template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }
 
template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
 
// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }
 
static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }
i64 gcd (i64 a, i64 b) {
	if (b == 0)
		return a;
	else
		return gcd (b, a % b);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  i64 a, b;
  cin >> a >> b;
  cout << a * b / gcd(a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
#define PII pair<int,int>
#define FF first
#define SS second
#define PB push_back
#define all(x) x.begin(), x.end()

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;	
#define vi vector<int> 
#define vl vector<ll> 
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};
	
const int MAXN = 3*1e5+10;
const int NINF = -1e5;
const int INF = 20000000;
const ll mod=1e9+7;
  
  
void solve()
{
	ll n;
	
		ll ans=2,ans1,ans2;
	cin>>n;
	if(n==1) {cout<<0<<endl;return;}
	if(n==2) {cout<<2<<endl;return;}
	else{
		ans=1,ans1=1,ans2=1;
		forn(i,0,n){
			ans=(ans*10)%mod;
			ans1=(ans1*9)%mod;
			ans2=(ans2*8)%mod;
			ans%=mod;
			ans1%=mod;
			ans2%=mod;
			//cout<<ans<<endl;
		}
		ans=((ans-2*ans1+ans2)+2*mod)%mod;
			cout<<ans<<endl;
	}

	return;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
main(){
  char egara;
  int n,i,j,maisuu;
  int a[4][13]={};
  scanf("%d",&maisuu);
  for(i=0;i<maisuu;i++){
    scanf("%s%d",&egara,&n);
    if(egara=='S') a[0][n-1]=1;
    if(egara=='H') a[1][n-1]=1;
    if(egara=='C') a[2][n-1]=1;
    if(egara=='D') a[3][n-1]=1;
  }
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if(a[i][j]==0){
        if(i==0) printf("S %d\n",j+1);
        if(i==1) printf("H %d\n",j+1);
        if(i==2) printf("C %d\n",j+1);
        if(i==3) printf("D %d\n",j+1);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
int main(){
    int n;cin >> n;
    vector<int> x(n);
    for(int i=0; i<n; i++) cin >> x[i];
    sort(x.begin(),x.end());
    int mn=x[0];
    sort(x.rbegin(),x.rend());
    int mx=x[0];
    int ans=INF;
    for(int i=mn; i<=mx; i++){
        int sum=0;
        for(int j=0; j<n; j++){
            sum+=pow(x[j]-i,2);
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = int(1e9) + 7


def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact = (fact * integer) % MOD
    return fact


if abs(N - M) >= 2:
    print(0)
else:
    if abs(N - M) == 1:
        print((factorial_cor(N) * factorial_cor(M))%MOD)
    else:
        print(((factorial_cor(N) * factorial_cor(M))*2)%MOD)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b=0;
  cin>>a>>b;
  int n[b];
  rep(i,0,b) cin>>n[i];
  int c;
  c=n[0]+a-n[b-1];
  rep(i,0,b-1) c=max(c,n[i+1]-n[i]);
  co(a-c);
  return 0;
}


Measured memory_bytes: 1024
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << "\n";
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
#define MOD 1000000007

int N;
int x[200000],v[200000];
int xid[200000];
int vid[200000];
int xloc[200000];
int l[200000],r[200000];
int dp[200001];
int sm[200001];

bool cmpx(int a,int b)
{
	return x[a]<x[b];
}
bool cmpv(int a,int b)
{
	return v[a]<v[b];
}

int main()
{
	cin >> N;
	for(int i=0;i<N;i++)
	{
		cin >> x[i] >> v[i];
		xid[i] = vid[i] = i;
	}
	sort(xid,xid+N,cmpx);
	sort(vid,vid+N,cmpv);
	for(int i=0;i<N;i++)
		xloc[xid[i]] = i;
	int mx = -1;
	for(int i=0;i<N;i++)
	{
		int cur = vid[i];
		if(xloc[cur] > mx) mx = xloc[cur];
		r[i] = mx;
	}
	int mn = N;
	for(int i=N-1;i>=0;i--)
	{
		int cur = vid[i];
		if(xloc[cur] < mn) mn = xloc[cur];
		l[i] = mn;
	}
	int high = -1;
	int j = 0;
	dp[0] = sm[0] = 1;
	for(int i=1;i<=N;i++)
	{
		while(j<N && r[j] < i)
		{
			if(l[j] > high) high = l[j];
			j++;
		}
		if(high==-1) dp[i] = (2*dp[i-1])%MOD;
		else if(high==0) dp[i] = sm[i-1];
		else dp[i] = (sm[i-1] + MOD - sm[high-1])%MOD;
		sm[i] = (sm[i-1] + dp[i])%MOD;
	}
	cout << dp[N] << '\n';
}

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

int main() {
    string t;
    cin >> t;
    rep(i, t.size()) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
}

Measured memory_bytes: 3752
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];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		int check=0;
		for(int i=0;i<n;i++) {
			if(a[i]%2==0) {
				if(a[i]%3!=0 && a[i]%5!=0) {
					check=1;
					break;
				}
			}
		}
		System.out.println((check==1)? "DENIED":"APPROVED");

	}
}

Measured memory_bytes: 23764
import math

def main():
    a, b = map(int, input().split())

    for i in range(1,1001):
        if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
            print(i)
            exit()

    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int N = 20161;					// 解の存在する盤面の個数
		int[] pList = new int[N];		// パネル
		int[] gList = new int[N];		// 最短手数
		int[] i0List = new int[N];		// 0の位置
		
		routine(pList, gList, i0List);		// 解の存在する盤面全てをシミュレートしておく
		
		Scanner in = new Scanner(System.in);
		int input, g;
		while(in.hasNext()){
			input = 0;	g = -1;
			for(int i=0; i<8; i++)	input = input*10 + in.nextInt();
			int p;
			for(int i=0; (p=pList[i]) != 0; i++)	if(input == p){	g = gList[i];	break;}
			System.out.println(g);
		}
		
		return;
	}
	
	private static void routine(int[] pList, int[] gList, int[] i0List){
		int tail = 0;
		pList[0] = 1234567;
		gList[0] = 0;
		i0List[0] = 0;
		
		int panel, i0, g;
		for(int n=0; pList[n] != 0; n++){
			panel = pList[n];
			g = gList[n];
			i0 = i0List[n];
			
			if(i0!=0 && i0!=4)
				tail += addNextPuzzle(i0, i0-1, panel, g, pList, gList, i0List, tail);
			if(i0!=3 && i0!=7)
				tail += addNextPuzzle(i0, i0+1, panel, g, pList, gList, i0List, tail);
			if(i0>3)
				tail += addNextPuzzle(i0, i0-4, panel, g, pList, gList, i0List, tail);		
			else
				tail += addNextPuzzle(i0, i0+4, panel, g, pList, gList, i0List, tail);
		}
	}
	
	private static int addNextPuzzle(int i, int j, int panel, int g, int[] pList, int[] gList, int[] i0List, int tail){
		int newPanel, num;
		int[] place = {10000000, 1000000, 100000, 10000, 1000, 100, 10, 1};
		num = (panel/place[j])%10;
		newPanel = panel - num*place[j] + num*place[i];
		
		for(int k=0; k<=tail; k++)	if(newPanel == pList[k])		return 0;
		
		pList[tail+1] = newPanel;
		gList[tail+1] = g+1;
		i0List[tail+1] = j;
		return 1;
	}
}

Measured memory_bytes: 13000
N, K = map(int, input().split())
S = list(input())

prev = S[0]
lst = []
cnt = 1
for s in S[1:]:
    if prev != s:
        lst.append(cnt)
        cnt = 0

    cnt += 1
    prev = s

lst.append(cnt)

right = 0
cnt = 0
l = len(lst)
sum_ = 0
max_ = 0
for i in range(l):
    if S[0] == '0':
        target_cnt = 2 * K + i % 2
    else:
        target_cnt = 2 * K + (i + 1) % 2

    while right < l and cnt < target_cnt:
        sum_ += lst[right]
        cnt += 1
        right += 1

    max_ = max(max_, sum_)
    sum_ -= lst[i]
    cnt -= 1


print(max_)


Measured memory_bytes: 11332
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

 int N=200005;

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    int x,y;
    cin>>x>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    sortA(a);
    pos=n;
    map<int,int> vis;
    rep(i,0,n)
    {
        vis[a[i]]++;
    }
    int mn=INF,ans;
    rep(i,-1000,1000)
    {
        if(abs(i-x)<mn&&!vis[i])
        {
            ans=i;
            mn=abs(i-x);
        }
    }
    cout<<ans;
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3700
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int N,K,X,Y;
	int i;
	int sum=0;
	cin >> N>>K>>X>>Y;
	if(N<=K)
	{
		for(i=0;i<N;i++)
		{
			sum+=X;
		}
	} 
	else
	{
		for(i=0;i<K;i++)
		{
			sum+=X;
		}
		for(i=0;i<N-K;i++)
		{
			sum+=Y;
		}
	}
	cout << sum<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
Original problem: 
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

namespace SOLVE {
	void main() {
	    ll n;
	    cin >> n;
	    VLL A(n);
	    REP(i, 0, n) {
	        cin >> A[i];
	    }

	    // dp[i][j] is X-Y when the array is from i to j, inclusive
	    vector < VLL > dp(n, VLL(n));

        // interesting for order - purely for bottom-up dp purposes
	    RREP(start, n - 1, 0) {
	        REP(length, 0, n - start) {
	            ll end = start + length;
	            if (start == end) {
	                dp[start][end] = A[start];
	            } else {
	                dp[start][end] = max(A[end] - dp[start][end - 1], A[start] - dp[start + 1][end]);
	            }
	        }
	    }
	    cout << dp[0][n - 1] << endl;

	}
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 70784
N = int(input())
B_list = list(map(int,input().split()))
A_list = [0 for i in range(N)]

A_list[0] = B_list[0]

for i in range(1,N-1):
    A_list[i] = min(B_list[i],B_list[i-1])

A_list[-1] = B_list[-1]
print(sum(A_list))

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

typedef pair < int , int > Pi;

int main()
{
	int N, K;
	int X[3005], Y[3005];
	
	
	cin >> N >> K;

	for ( int i = 0; i < N; i++ ) {
		cin >> X[i] >> Y[i];
	}

	for ( int i = 0; i < N; i++ ) {
		map < Pi, int > cnt;
		for ( int j = 0; j < N; j++ ) {
			if ( i == j ) continue;

			int a = Y[j] - Y[i];
			int b = X[j] - X[i];
			int div = __gcd(abs(a), abs(b));
			
			if ( ++cnt[Pi(a / div, b / div)] >= K - 1 ) {
				cout << 1 << endl;
				return ( 0 );
			}
		}
	}
	cout << 0 << endl;
	return ( 0 );
}



Measured memory_bytes: 3296
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n0, n) for (int i = n0; i < n; i++)
#define Com(i, j, n)              \
	for (int i = 0; i < n - 1; i++) \
		for (int j = i + 1; j < n; j++)
#define INF (1 << 29)

int main()
{
	int MOD = 1000000007;
	string hoge = "";
	cin >> hoge;
	int l = hoge.size();
	int dp[l+1][13] = {0};
	int dma[] = {1, 10, 9, 12, 3, 4};
	dp[0][0] = 1;
	char hatena = '?';
	int x = 0;
	int y = 0;
	int m = 13;
	rep(i, l) {
		x = dma[(l-1-i)%6];
		if(int(hoge[i]) == int(hatena)) {
			rep(k, 10) {
				rep(j, 13) {
					dp[i+1][j] = (dp[i+1][j] + dp[i][(j+k*x)%m])%MOD;
				}
			}
		} else {
			y = int(hoge[i] - '0');
			rep(j, 13){
				dp[i+1][j] = (dp[i+1][j] + dp[i][(j+y*x)%m])%MOD;
			}
		}
	}
	cout << dp[l][8] << endl;
	return 0;
}

Measured memory_bytes: 5504
#include<cmath>
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<vector>
#define int long long
using namespace std;
const int maxn=200010;
int n,m,cnt1,head1[maxn],cnt2,head2[maxn],vis[maxn],fa[maxn],a[maxn],b[maxn],c[maxn],sumb[maxn],rk[maxn],dp[maxn];
struct edge1
{
    int to,next;
}e1[maxn<<1];
struct edge2
{
    int to,next;
}e2[maxn<<1];
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
	if(ch=='-')
	    f=-1;
	ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
	x=(x<<1)+(x<<3)+(ch^48);
	ch=getchar();
    }
    return x*f;
}
inline void write(int a)
{
    if(a<0)
    {
	char a='-',b='1';
	putchar(a);
	putchar(b);
    }
    else
    {
	if(a>=10)
	    write(a/10);
	putchar(a%10+'0');
    }
}
void add1(int from,int to)
{
    e1[++cnt1]=(edge1){to,head1[from]};
    head1[from]=cnt1;
}
void add2(int from,int to)
{
    e2[++cnt2]=(edge2){to,head2[from]};
    head2[from]=cnt2;
}
int find(int x)
{
    return fa[x]==x?x:fa[x]=find(fa[x]);
}
bool cmp(const int &a,const int &b)
{
    return c[a]<c[b];
}
void dfs(int now)
{
    sumb[now]=b[now];
    for(int i=head2[now];i;i=e2[i].next)
    {
	int to=e2[i].to;
	dfs(to);
	sumb[now]+=sumb[to];
    }
    dp[now]=sumb[now]+c[now];
    for(int i=head2[now];i;i=e2[i].next)
    {
	int to=e2[i].to;
	dp[now]=min(dp[now],sumb[now]-sumb[to]+max(dp[to],c[now]));
    }
}
signed main()
{
    n=read(),m=read();
    for(int i=1;i<=n;i++)
    {
	a[i]=read(),b[i]=read();
	c[i]=max(a[i]-b[i],0LL);
	fa[i]=rk[i]=i;
    }
    for(int i=1;i<=m;i++)
    {
	int u=read(),v=read();
	add1(u,v),add1(v,u);
    }
    sort(rk+1,rk+n+1,cmp);
    for(int i=1;i<=n;i++)
    {
	int now=rk[i];
	vis[now]=1;
	for(int j=head1[now];j;j=e1[j].next)
	{
	    int to=e1[j].to;
	    if(vis[to])
	    {
		int f=find(to);
		if(f!=now)
		{
		    fa[f]=now;
		    add2(now,f);
		}
	    }
	}
    }
    dfs(rk[n]);
    write(dp[rk[n]]);
    return 0;
}


Measured memory_bytes: 23168
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
#define vvv vector<vector<vector<long long int>>>
#define vvvl(a, b, c, d) vector<vector<vector<long long int>>>(a, vector<vector<long long int>>(b, vector<long long int> (c, d)));
using namespace std;

int main(int argc, char const *argv[]) {
  ll INF=10000000000,n, ma, mb;std::cin >> n >> ma >> mb;
  vvl d = vv(n, 3, 0, ll);
  re(i, n) std::cin >> d[i][0] >> d[i][1] >> d[i][2];
  vvv dp = vvvl(n+1, n*10+1, n*10+1, INF);
  dp[0][0][0] = 0;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=n*10;j++){
      for(int k=0;k<=n*10;k++){
        dp[i][j][k] = dp[i-1][j][k];
        if(j<d[i-1][0]||k<d[i-1][1]) continue;
        dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-d[i-1][0]][k-d[i-1][1]] + d[i-1][2]);
      }
    }
  }
  ll ans = INF;
  for(int i=1;i<=n*10;i++){
    for(int j=1;j<=n*10;j++){
      if(i%ma==0&&j%mb==0&&i/ma==j/mb){
        ans = min(ans, dp[n][i][j]);
      }
    }
  }
  std::cout << (ans>10000?-1:ans) << '\n';
  return 0;
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)

int main()
{
    fast();

    using P = pair<int, int>;

    // d[0] : ひだり, d[1] : うえ, d[2] : みぎ, d[3] : した
    int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> grid(H);
    vector<vector<vector<P>>> d(H);

    int sx, sy, gx, gy;

    cin >> sx >> sy >> gx >> gy;
    sx--, sy--, gx--, gy--;

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

    for (int i = 0; i < H; i++) // init
    {
        d[i] = vector<vector<P>>(W, vector<P>(4, P(inf, inf)));
    }

    // (最短距離, その方向に進んだ回数), (x, y), dir
    priority_queue<pair<P, pair<P, int>>, vector<pair<P, pair<P, int>>>, greater<pair<P, pair<P, int>>>> pq;

    for (int i = 0; i < 4; i++)
    {
        d[sx][sy][i] = P(1, 0);
        pq.push({d[sx][sy][i], {{sx, sy}, i}});
    }

    while (!pq.empty())
    {
        auto v = pq.top();
        pq.pop();
        int vx = v.second.first.first, vy = v.second.first.second, dir = v.second.second;

        for (int i = 0; i < 4; i++) // 向きを変える
        {
            P ncost = make_pair(d[vx][vy][dir].first + 1, 0);
            if (d[vx][vy][i] <= ncost)
                continue;
            d[vx][vy][i] = ncost;
            pq.push({ncost, {{vx, vy}, i}});
        }

        // 直進する
        int nx = vx + dx[dir], ny = vy + dy[dir];
        if (nx < 0 || nx >= H || ny < 0 || ny >= W) // grid の外
            continue;
        if (grid[nx][ny] == '@') // 行き止まり
            continue;
        int df = d[vx][vy][dir].first, ds = d[vx][vy][dir].second;
        P ncost = make_pair(df + (ds + 1) / (K + 1), ds % K + 1);
        if (d[nx][ny][dir] <= ncost)
            continue;
        d[nx][ny][dir] = ncost;
        pq.push({ncost, {{nx, ny}, dir}});
    }

    int min_cost = (*min_element(d[gx][gy].begin(), d[gx][gy].end())).first;

    cout << (min_cost == inf ? -1 : min_cost) << "\n";
}


Measured memory_bytes: 85308
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a,b;
  cin >> a >>b;
  int count=0;
  int sum=1;
  
  if(b==1)cout<<"0"<<endl;
  else{
  for(;;){
    sum += a-1;          
    count ++;  
    if(b<=sum) break;
  }
  cout << count << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
S = input()


r = 1
ans = 0
for l in range(N):

    while True:
        #print(S.rfind(S[l:r+1]), S[l:r+1], l, r)

        if S.rfind(S[l:r+1]) >= r+1:
            r += 1
            ans = max(ans, r-l)
        else:
            break

print(ans)


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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;

int arr[maxr];

int32_t main()
{
	GO;
	int n;
	cin >> n;
	memset(arr, 0, sizeof(arr));
	for (int i = 1; i < 102; i++) {
		for (int j = 1; j < 102; j++) {
			for (int k = 1; k < 102; k++) {
				int value = (i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i);
				if (value <= n)
					arr[value]++;
			}
		}
	}
	for (int i = 1; i <= n; i++)
		cout << arr[i] << endl;
	return 0;
}

//!

Measured memory_bytes: 4308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);

		int dif = b - a;
		
		long result = (dif - 1)*dif/2 - a;
		
		System.out.println(result);
	}
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

ll N, M;
vector<ll> edges[1000];

signed main() {
  cin >> N >> M;
  rep(i, M) {
    ll s, t;
    cin >> s >> t;
    edges[s].push_back(t);
  }

  double ans = 10000000000;
  for (ll i=1; i<=N-1; i++) { // 頂点iから先の辺を（可能なら）切る
    double dp[1000]; // dp[j]: 頂点jから頂点Nまで距離の期待値
    rep(j,1000)
      dp[j] = 0.0;
    dp[N] = 0.0;
    for (ll j=N-1; j>=1; j--) {
      if (i == j && edges[j].size() >= 2) {
        // 頂点iから先で、一番距離が長くなりそうな経路を切る
        dp[j] = 0.0;
        ll max_v = edges[j][0];
        for (auto nxt: edges[j])
          if (dp[nxt] > dp[max_v])
            max_v = nxt;
        for (auto nxt: edges[j]) {
          if (nxt != max_v)
            dp[j] += (dp[nxt]+1);
        }
        dp[j] /= (edges[j].size()-1);
      } else {
        // ふつうにDP
        dp[j] = 0.0;
        for (auto nxt: edges[j]) {
          dp[j] += (dp[nxt]+1);
        }
        dp[j] /= edges[j].size();
      }
    }
    ans = min(ans, dp[1]);
  }
  printf("%.10f\n", ans);
}


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

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

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}
class G{
	long long node;
	long long w;
	
};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	long long K;
	cin>>K;
	for(int i=0;i<K;i++){
		if(s[i]!='1'){
			cout<<s[i]<<endl;
			return 0;
		}
	}
	cout<<s[K-1];
}

	


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		long MOD = 1000000007L;

		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);

		boolean[] statuses = new boolean[N + 1];
		Arrays.fill(statuses, true);

		for (int i = 0; i < M; ++i) {
			int index = Integer.parseInt(in.readLine());
			statuses[index] = false;
		}

		long[] counts = new long[N + 1];
		Arrays.fill(counts, 0);
		// initialize
		counts[0] = 1;
		if (statuses[1]) {
			counts[1] = 1;
		} else {
			counts[1] = 0;
		}

		for (int i = 2; i <= N; ++i) {
			if (statuses[i]) {
				// 登れる
				counts[i] = (counts[i - 2] + counts[i - 1]) % MOD;
			} else {
				// 登れない
				counts[i] = 0;
			}
		}
		System.out.println(counts[N]);
	}
}


Measured memory_bytes: 29492
// C - Strawberry Cakes
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> s(H);
	for (int i = 0; i < H; i++) cin >> s[i];
	vector<vector<int> > ans(H, vector<int>(W));
	int no = 1;
	for (int i = 0; i < H; i++) {
		int c = 0;
		for (int j = 0; j < W; j++)
			if (s[i][j] == '#') c++;
		if (c == 0) continue;
		for (int j = 0, k = 0; j < W; j++) {
			ans[i][j] = no + min(k, c - 1);
			if (s[i][j] == '#') k++;
		}
		no += c;
	}

	for (int i = 1; i < H; i++) {
		if (ans[i][0] != 0) continue;
		for (int j = 0; j < W; j++) ans[i][j] = ans[i - 1][j];
	}

	for (int i = H - 2; i >= 0; i--) {
		if (ans[i][0] != 0) continue;
		for (int j = 0; j < W; j++) ans[i][j] = ans[i + 1][j];
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cout << (j ? " " : "") << ans[i][j];
		cout << endl;
	}

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int f =0;
  int t = N;

  while (t>0) {
      f += t%10;
      t /= 10;
  }

  if (N%f == 0){
      cout << "Yes" << endl;
  }

  else {
      cout << "No" << endl;
  }
}

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

int n, er[302], fp = -1, ym, yd;
bool ata;
char aca;
vector<int> v[302];
queue<int> q;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			cin >> aca;
			if(aca == '1') v[i].push_back(j);
		}
	}
	for(int i = 1; i <= n; ++i) {
		ata = 1;
		for(int j = 1; j <= n; ++j) er[j] = 0;
		ym = yd = er[i] = n;
		q.push(i);
		while(q.size()) {
			ym = max(ym, er[q.front()]);
			yd = min(yd, er[q.front()]);
			for(int j = 0; j < v[q.front()].size(); ++j) {
				if(!er[v[q.front()][j]]) {
					if(er[q.front()] > n || (er[q.front()] == n && i > 0)) er[v[q.front()][j]] = er[q.front()] + 1;
					else er[v[q.front()][j]] = er[q.front()] - 1;
					q.push(v[q.front()][j]);
				} else {
					if(abs(er[v[q.front()][j]] - er[q.front()]) != 1) {
						ata = 0;
						break;
					}
				}
			}
			q.pop();
		}
		if(ata) {
			fp = max(fp, ym - yd + 1);
		}
	}
	cout << fp << endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    int candies[2][N];
    for (int i = 0; i < N; i++) cin >> candies[0][i];
    for (int i = 0; i < N; i++) cin >> candies[1][i];
    for (int i = 1; i < N; i++) candies[0][i] += candies[0][i - 1];
    for (int i = N - 2; i >= 0; i--) candies[1][i] += candies[1][i + 1];
    int ans = 0;
    for (int i = 0; i < N; i++) ans = max(ans, candies[0][i] + candies[1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B;
  cin >> A >> B;
  int ans_1=A+B;
  int ans_2=A+(A-1);
  int ans_3=B+(B-1);
  int max=ans_1;
  if(max<ans_2)
    max=ans_2;
  if(max<ans_3)
    max=ans_3;
  cout << max << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

char s[111];
int len;

int main() {
	scanf("%s", s);
	len = strlen(s);
	
	int ans = 753;
	for(int i=2;i<len;i++) {
		int x = (s[i-2]-'0')*100 + (s[i-1]-'0')*10 + (s[i]-'0');
		ans = min(ans, (int)labs(x-753));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip> // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main()
{
    int N;
    int K;
    int ans = 0;
    cin >> N >> K;

    int tmp;
    REP(i,N) {
        cin >> tmp;
        if(K <= tmp) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	ar := make([]int, n)
	i := 0
	for n > i {
		fmt.Scan(&ar[i])
		i++
	}

	no := 0
	j := 1
	for _, e := range ar {
		if e == j {
			j++
		} else {
			no++
		}
	}

	if no < n {
		fmt.Println(no)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int N; cin >> N;
  if (N == 1)
    cout << "Hello World" << endl;
  else{
    int A, B; cin >> A >> B;
    cout << A+B << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli n, m=0;

int main() {
	string s;
	cin >> s;
	lli dp[s.size()+1][13];
	
	rep0(i,13)dp[0][i]=0;
	if(s[0]!='?'){
		dp[0][(int)(s[0]-'0')]=1;
	}else rep0(i,10)dp[0][i]=1;
	
	for(int i=1;i<s.size();i++){
		rep0(j,13)dp[i][j]=0;
		if(s[i]!='?'){
			rep0(k,13){
				dp[i][((int)(s[i]-'0')+10*k)%13]+=dp[i-1][k]%MAX;
			}
		}else{
			rep0(j,10){
				rep0(k,13){
					dp[i][(10*k+j)%13]+=dp[i-1][k]%MAX;
				}
			}
		}
	}
	cout << dp[s.size()-1][5]%MAX;
}


Measured memory_bytes: 10624
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll N, ll K) {
  cout << N%K << endl;
}

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


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

int main()
{
    int a, b;
    cin >> a;
    cin >> b;
    if ((a * b) % 2 == 0)
    {
        std::cout << "Even" << std::endl;
    }
    else
    {
        std::cout << "Odd" << std::endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int INF = (int)1e9;
        int N;
        int M;
        N = sc.nextInt();
        M = sc.nextInt();

        int[][] ans = new int[M + 1][(int)Math.pow(2,N)];
        for (int[] hoge : ans) {
            Arrays.fill(hoge, INF);
        }
        for (int[] hoge : ans) {
            hoge[0] = 0;
        }

        int add;
        int p;
        for(int i = 1 ; i < M+1 ; i++){
            int cost = sc.nextInt();
            int num = sc.nextInt();

            add = 0;
            for(int j = 0 ; j < num ; j++){
                p = sc.nextInt();
                add += (int)Math.pow(2, p-1);
            }
            for(int j = 0; j < ans[i].length; j++) {
                if(ans[i-1][j] != INF) {
                    int idx = j | add;
                    ans[i][idx] = Math.min(ans[i][idx], ans[i-1][j] + cost); 
                    ans[i][j] = Math.min(ans[i][idx], ans[i-1][j]); 
                }
            }

        }
        if(ans[M][(int)Math.pow(2,N)-1] == INF) ans[M][(int)Math.pow(2,N)-1] = -1;
        System.out.println(ans[M][(int)Math.pow(2,N)-1]);
    }
}


Measured memory_bytes: 51064