akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  vector<double>a(n),sa(n+1);
  rep(i,n){
    cin>>a[i];
    a[i]=(a[i]+1)/2;
  }
  rep(i,n)sa[i+1]=sa[i]+a[i];
  double res=0;
  rep(i,n-k+1){
    chmax(res,sa[i+k]-sa[i]);
  }
  cout<<setprecision(12)<<res<<endl;

  return 0;

}


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

int main(){
	while(1){
		int W, H; cin >> W >> H;
		if(W == 0 && H == 0) return 0;

		vector<vector<int>> dp(H, vector<int> (W,0));
		vector<vector<bool>> g(H, vector<bool> (W,true));
		
		int n; cin >> n;
		rep(_,n){
			int wi, hi; cin >> wi >> hi; wi--; hi--;
			g[hi][wi] = false;
		}

		dp[0][0] = 1;
		rep(h,H){
			rep(w,W-1){
				if(w == 0 && h > 0){
					if(g[h][w]) dp[h][w] = dp[h-1][w];
					if(g[h][w+1]) dp[h][w+1] += dp[h][w] + dp[h-1][w+1];
					continue;
				}

				if(g[h][w+1]){
					if(h == 0) dp[h][w+1] += dp[h][w];
					else dp[h][w+1] += dp[h][w] + dp[h-1][w+1];
				}
			}
		}

		cout << dp[H-1][W-1] << endl;
		
	}
}


Measured memory_bytes: 3148
// https://atcoder.jp/contests/arc060/tasks/arc060_a
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int N, A;
int x[50];
ll dp[51][51][3010];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A;
    REP(i, N) cin >> x[i];

    dp[0][0][0] = 1;
    REP(i, N) REP(j, N) REP(k, 2500) {
        if (dp[i][j][k]) {
            // カードを選ばない
            dp[i + 1][j][k] += dp[i][j][k];
            // カードを選ぶ
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        }
    }

    ll ans = 0;
    FOR(i, 1, N + 1) ans += dp[N][i][i * A];
    cout << ans << endl;
    return 0;
}


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

int main(void){
  int k,x;
  
  cin >> k >> x;
  for (int i=x-(k-1); i<=x+(k-1); i++){
    cout << i;
    if (i==x+(k-1)) cout << endl;
    else cout << " ";
  }
  return 0;
}

Measured memory_bytes: 256
num = int(input())
org_list = list(map(int, input().split()))

new_list = sorted(org_list, reverse=True)

alice_sum = sum(new_list[::2])
bob_sub = sum(new_list[1::2])

# print(new_list)
# print(str(alice_sum) + ":" +str(bob_sub))
print(str(alice_sum-bob_sub))

Measured memory_bytes: 9068
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <map>
#include <string>
#include <sstream>
#include <queue>
#include <iomanip>
#include <set>


using namespace std;

#define ll long long int
#define MOD 1000000007

ll T(ll n){
    return n*(n+1)/2;
}


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, K;
    cin>>N>>K;
    
    ll S = 0;
    
    for(int k = K; k<=N+1; k++){
        ll mini, maxi;
        mini = T(k-1);
        maxi = T(N) - T(N-k);
        //cout<<k<<" "<<maxi - mini + 1<<endl;
        S = (S + maxi - mini + 1)%MOD;
    }
    
    cout<<S<<endl;
    
    return 0;
    
    
    
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,a,n) for(int _tmp=n,i=a;i<=_tmp;++i)
#define dep(i,a,n) for(int _tmp=n,i=a;i>=_tmp;--i)
#define re(i,a,n) for(int _tmp=n,i=a;i<_tmp;++i)
#define fec(i,a) for(__typeof a.begin() i=a.begin();i!=a.end();++i)
#define For(i,v,u) for(int i=H[u],v=to[i];i;i=nxt[i],v=to[i])
#define si(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define X first
#define Y second
#define inf 1000000000
using namespace std;
template<class T> inline void read(T&x){char c;bool fu=0;for(c=getchar();c<=32;c=getchar());if(c=='-')fu=1,c=getchar();for(x=0;c>32;c=getchar())x=x*10+c-'0';if(fu)x*=-1;}
template<class T> inline void read(T&x,T&y){read(x);read(y);}
template<class T> inline void read(T&x,T&y,T&z) {read(x,y);read(z);}
template<class T> inline void MAX(T&x,T y){if(x<y)x=y;}
template<class T> inline void MIN(T&x,T y){if(x>y)x=y;}
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
const int N=111111;
//head
int cnt;
char s[N];
int main() {
	scanf("%s",s+1);int len=strlen(s+1);
	rep(i,1,len)if(s[i]!=s[i-1])++cnt;
	printf("%d\n",cnt-1);
	return 0;
}

Measured memory_bytes: 384
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
s=input()
res=[0]*26
n=len(s)
if n!=26:
    for c in s:
        res[ord(c)-ord('a')]=1
    for i in range(26):
        if res[i]==0:
            ans=i
            break
    print(s+chr(ans+ord('a')))
else:
    s=list(s)
    res=[]
    for i in range(n-1):
        if ord(s[n-1-i])-ord(s[n-2-i])>0:
            idx=ord(s[n-2-i])
            res.sort()
            if not res:
              s[n-1-i],s[n-2-i]=s[n-2-i],s[n-1-i]
              print("".join(s[:n-1-i]))
              exit()
            ch=bisect.bisect_right(res,idx)
            if ch==len(res):
                res=[chr(i) for i in res]
                res.append(s[n-2-i])
                ans=[]
                for j in range(n):
                    if j!=n-2-i:
                        ans.append(s[j])
                    else:
                        ans.append(s[n-1-i])
                        break
                print(''.join(ans))
            else:
                minc=chr(res[ch])
                ans=[]
                for j in range(n):
                    if j!=n-2-i:
                        ans.append(s[j])
                    else:
                        ans.append(minc)
                        break
                print(''.join(ans))
            break
        else:
            res.append(ord(s[n-1-i]))
    else:
        print(-1)

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

UL N;
pair<int,int> P[524288];

struct RT{
 UL N;
 UL D;
 tuple<int,int,UL> V[20][524288];
 void init(UL n){
  N=1; D=0; while(N<n){ D++; N<<=1; }
  rep(i,n) V[0][i] = make_tuple(P[i].first,P[i].second,i);
  for(UL i=n; i<N; i++) V[0][i] = make_tuple(INT_MAX,INT_MAX,0);
  sort(V[0],V[0]+N);
  for(UL d=0; d<D; d++){
   UL L=(1<<d);
   for(UL l=0; l<N; l+=(L+L)){
    UL p=0, q=0;
    while(p+q<L+L){
     bool choose_p = false;
     if(q==L) choose_p=true;
     else if(p<L) if(get<1>(V[d][l+p]) <= get<1>(V[d][l+L+q])) choose_p=true;
     if(choose_p) { V[d+1][l+p+q]=V[d][l+p]; p++; }
     else { V[d+1][l+p+q]=V[d][l+L+q]; q++; }
    }
   }
  }
 }
 const vector<UL>& query(int xl,int xr,int yl,int yr,UL a=~0u,UL b=~0u,UL d=~0u){
  static vector<UL> ans;
  if(!~d){ a=0; b=N; d=D; ans.clear(); }
  if(xr<=get<0>(V[0][a]) || get<0>(V[0][b-1])<xl) return ans;
  if(xl<=get<0>(V[0][a]) && get<0>(V[0][b-1])<xr) {
   UL pl,pr;
   UL l,r;
   l=a; r=b+1;
   while(l+1<r){ UL m=(l+r)>>1;
    if(get<1>(V[d][m-1])<yl) l=m; else r=m;
   } pl=l;
   l=a; r=b+1;
   while(l+1<r){ UL m=(l+r)>>1;
    if(get<1>(V[d][m-1])<yr) l=m; else r=m;
   } pr=l;
   for(UL p=pl; p<pr; p++) ans.push_back(get<2>(V[d][p]));
   return ans;
  }
  query(xl,xr,yl,yr,a,(a+b)>>1,d-1);
  query(xl,xr,yl,yr,(a+b)>>1,b,d-1);
  return ans;
 }
} G;

int main() {
 scanf("%u",&N);
 rep(i,N) scanf("%d%d",&P[i].first,&P[i].second);
 G.init(N);
 UL Q; scanf("%u",&Q);
 rep(q,Q){
  int xl,xr,yl,yr; scanf("%d%d%d%d",&xl,&xr,&yl,&yr);
  auto ans=G.query(xl,xr+1,yl,yr+1);
  sort(ans.begin(),ans.end());
  for(UL a:ans) printf("%u\n",a);
  printf("\n");
 }
 return 0;
}



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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

bool valid(ll a, ll b, ll c) {
	if (a + b > c && a + c > b && b + c > a) {
		return true;
	}
	return false;
}

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vi l(n);
	f(i, 0, n - 1) {
		cin >> l[i];
	}
	ll ans = 0;
	f(i, 0, n - 1) {
		f(j, i + 1, n - 1) {
			f(k, j + 1, n - 1) {
				if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k] && valid(l[i], l[j], l[k])) {
					//cout << l[i] << " " << l[j] << " " << l[k] << endl;
					ans++;
				}
			}
		}
	}
	cout << ans << endl;

	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
*/





























Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
main(){
	int n;
	cin>>n;
	int l=0,r=n;
	cout<<0<<endl;
	string pre,now;
	cin>>pre;
	int P=l;
	r(i,30){
		int mid=(l+r)/2;
		cout<<mid<<endl;
		cin>>now;
		if(now=="Vacant")break;
		if(P<mid&&(abs(P-mid)%2==0&&now==pre||abs(P-mid)%2==1&&now!=pre)||
		   P>mid&&(abs(P-mid)%2==1&&now==pre||abs(P-mid)%2==0&&now!=pre)
			){
			l=mid+1;
		}
		else{
			r=mid;
		}
		pre=now;
		P=mid;
	}
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll t[105];
set<ll>s;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        cin>>t[i];
    ll ans=t[0];
    for(int i=1;i<n;i++)
    {
        ll k=__gcd(ans,t[i]);
        ans=ans/k*t[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import copy
import itertools

N=input()

L=[ [ None for j in range(N)] for i in range(N)]

for i in range(N):  #i番目の人の意見
    A=input()
    for _ in range(A):
        x,y=map(int, raw_input().split())
        L[i][x-1]=y

CC=list(itertools.product((0,1),repeat=N))

ans=0


for C in CC:
    flag=True
    for i,c in enumerate(C):
        if flag==False: break
        if c==1:
            for x,y in zip(C,L[i]):
                if (x==1 and y==0) or (x==0 and y==1):
                    flag=False
                    break
    else:
        if flag==True:
            ans=max(ans,sum(C))
print ans

Measured memory_bytes: 39836
#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 <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=K; i<N; i++){
    if(A[i-K] < A[i]){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }
  
  return 0;
}

Measured memory_bytes: 3984
#include <iostream>
#include <cmath>
#include <cstring>
#include <string>

using namespace std;

#define MAXW 100005
#define MAXN 105

typedef long long ll;

ll dp[MAXN][MAXW];
int weights[MAXN];
ll values[MAXN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, w, wi, vi;
	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		cin >> weights[i] >> values[i];
	}
	for(int i = 0; i <= w; i++) {
		dp[1][i] = (weights[1] <= i) ? values[1] : 0L;
	}
	for(int i = 2; i <= n; i++) {
		for(int j = 0; j <= w; j++) {
			dp[i][j] = dp[i - 1][j];
			if(weights[i] <= j) dp[i][j] = max(dp[i][j], dp[i - 1][j - weights[i]] + values[i]);
		}
	}
	cout << dp[n][w] << '\n';
	
	return 0;
}

Measured memory_bytes: 81712
function Main(input){
  var inputs = input.split("\n");
  var s = inputs[1];
  var a = new Number(inputs[0]);
  if(a >= 3200){
    console.log(s)
  }else{
    console.log("red");
  }
  }
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

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

int main(){
    int k;
    string s;
    cin >>k>>s;
    if(k>=(int)s.size()){
        cout << s << endl;
    }else{
        rep(i,k)cout << s[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define loop(i,a,b) for(int i=a; i<b; i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
void solve()
{
     string s;cin>>s;
     cout<<s[0]<<s[1]<<s[2]<<"\n";
	return;
}
int32_t main() 
{ 
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0; 
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[2][n];
for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
        cin >> a[i][j];
    }
}
long long sumone[n+1];
long long sumtwo[n+1];
sumone[0]=0;
sumtwo[0]=0;
for(int i=0;i<n;i++){
    sumone[i+1]=sumone[i]+a[0][i];
    sumtwo[i+1]=sumtwo[i]+a[1][i];
}
long long maximum=0;
long long ans[n];
for(int i=0;i<n;i++){
    ans[i]=sumone[i+1]+sumtwo[n]-sumtwo[i];
}
for(int i=0;i<n;i++){
    maximum=max(maximum,ans[i]);
}
cout << maximum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b,d,r;
    double f;

    scanf("%d %d",&a,&b);

    d = a / b;
    r = a % b;
    f = (double)a / b;

    printf("%d %d %f\n",d,r,f);


    return 0;
}


Measured memory_bytes: 2708
def maxheapify(A, i):
    l = 2 * i
    r = 2 * i + 1
    largest = -1

    if l <= len(A) - 1 and A[l] > A[i]:
        largest = l
    else:
        largest = i

    if r <= len(A) - 1 and A[r] > A[largest]:
        largest = r

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        maxheapify(A, largest)

def buildmaxheap(A):
    for i in reversed( range(1, int(  ( len(A) - 1 ) / 2.0 ) + 1 ) ):
        maxheapify(A, i)

def Main():
    n = int(input())
    A = [-1] + [ int(a) for a in input().split()]
    buildmaxheap(A)
    res = [" " + str(a) for a in A]
    print("".join(res[1:]))
    
Main()


Measured memory_bytes: 67816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 998244353
ll powmod(ll a,ll b ,ll mod){
    ll p=1;
    a%=mod;
    while(b){
        if(b&1)p=(p*(a%mod))%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return p;
}
const int SIZE = 1e5+5;
int cnt[SIZE];
int arr[SIZE];
int main(){
    int n;scanf("%d",&n);
    int maxx=-1;
    int f=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&arr[i]);
        cnt[arr[i]]++;
        maxx = max(maxx,arr[i]);
    }
    if(arr[1]!=0||cnt[0]!=1)
    {
        printf("0\n");
        return 0;
    }
    ll res = 1;
    for(int i=1;i<=maxx;i++){

        res =res * powmod(cnt[i-1],cnt[i],MOD)%MOD;
      // cout<<res<<endl;
    }
    printf("%lld",res);
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, x, l;
  cin >> n >> x;
  int ans = 0, now = 0;
  for (int i = 0; i < n; i++) {
    if (now <= x) ans++;
    cin >> l;
    now += l;
  }
  if (now <= x) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

int main(){
	int n;

	cin >> n;
	
	int ret = 0;

	if (n < 10) {
		ret = n;
	} else if (9 < n && n < 100) {
		ret = 9;
	} else if (99 < n && n < 1000) {
		ret = 9 + (n - 99);
	} else if (999 < n && n < 10000) {
		ret = 909;
	} else if (9999 < n && n < 100000) {
		ret = 909 + (n - 9999);  
	} else {
		ret = 90909;
	}
	cout << ret << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    while (1) {
        int n, m, p;

        cin >> n >> m >> p;
        if (n == 0) break;

        int gold = 0;
        int winner = 0;
        for (int i = 0; i < n; ++i) {
            int a;
            cin >> a;
            if (i + 1 == m) winner = a;
            gold += a;
        }
        cout << (winner == 0 ? 0 : gold * (100 - p) / winner) << endl;
    }
}

Measured memory_bytes: 3076
n = gets.to_i
array = gets.split(' ')

return puts 0 if array.include?('0')

sum = array[0].to_i * array[1].to_i
for i in 2..(n-1) do
  sum *= array[i].to_i
  break if sum > 1000000000000000000
end

if sum > 1000000000000000000
  puts '-1'
else
  puts sum
end

Measured memory_bytes: 20824
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long double ld;
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int n,k1,k2;int i;
	ld a,x,m;ld ans=0.;
	scanf("%d%d%d",&n,&k1,&k2);k1-=k2; 
	a=k1;x=k2;m=2.*n;
	rep(i,1,n){
		ans+=a+(m+1)/2.*x;
		a+=(2.*a+3.*x)/m;
		//a=((m+2.)*a+3.*x)/(ld)m;
		x+=4.*x/m;
		//x=x*(m+4)/(ld)m;
		m-=2.;
	}
	printf("%.15f",(double)ans);
}
		
	
	

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


int main() {
  
  long N, N_root;
  
  cin >> N;
  
  N_root = sqrt(N) ;
  //cout << N<<"  " << N_root << endl;
  
  long i = N_root;
  while(true){
    if(N % i == 0) break; 
    
    i--;
  }
  
  long a = N / i ;
  long ans = i+a -2;
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;cin>>n;
	ll c[10010]={};
	for(int x=1; x*x<=n; x++){
		for(int y=1; y*y<=n; y++){
			for(int z=1; z*z<=n; z++){
				int v=x*x+y*y+z*z+x*y+y*z+z*x;
				if(v<=n) c[v]++;
			}
		}
	}
	for(int i=1; i<=n; i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>

int main(void){
  int i,j,a[105],key,len,k;
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<=len;i++){
    for(k=0;k<len;k++){
      printf("%d",a[k]);
      if(k!=len-1){
	printf(" ");
      }
    }
    printf("\n");
    key=a[i];
    j=i-1;
    while(j>=0 && a[j]>key){
      a[j+1]=a[j];
      j--;
      a[j+1]=key;
    }
  }
  
  return 0;
}

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

import sys

def main():
    n = int(input())
    MOD = 10**9+7
    if n <= 1:
        print(0)
        exit()
    A = 10**n-8
    ans = pow(10, n, MOD) - pow(9, n, MOD) - pow(9, n, MOD) + pow(8, n, MOD)
    print(ans % MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 10580
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		int[] ans = new int[n];
		int num = 1;
		for(int i = 0;i < n-1;i++){
			num = saori.saori_hayami();
			ans[num-1]++;
		}
		for(int i = 0;i < n;i++){
			System.out.println(ans[i]);
		}
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 56856
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<vector<Int>> a(N, vector<Int>(N));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}

	vector<vector<bool>> huyou(N, vector<bool>(N,false));//trueなら不要な道

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < N; j++) {
			if (i == j)continue;
			for (Int k = 0; k < N; k++) {
				if (i == k)continue;
				if (j == k)continue;

				if (a[i][j] > a[i][k] + a[k][j]) {
					cout << "-1" << "\n";
					return 0;
				}


				if (a[i][j] == a[i][k] + a[k][j])huyou[i][j] = true;

			}
		}
	}

	Int ans = 0;
	for (Int i = 0; i < N; i++) {
		for (Int j = i; j <N; j++) {
			if (!huyou[i][j])ans += a[i][j];
		}
	}

	cout << ans << "\n";
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;

int32_t main() {
IOS;
int n,m;
cin>>n>>m;
vector<int> v(n+4);
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
       v[a]++,v[b]++;
    }
    for (int i = 1; i <=n  ; ++i) {
        cout<<v[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
ll dp[110005];
const ll INF = 10010010010;
               
int main()
{
    int n;
    ll W;
    cin >> n >> W;
    rep(i,110000)dp[i] = INF;
    dp[0] = 0;
    rep(i,n){
        int w,v;
        cin >> w >> v;
        for(int j = 110000;j >= 0;--j){
            if(j-v>=0)dp[j] = min(dp[j-v] + w,dp[j]);
        }
    }
    int ans = 0;
    rep(i,110000){
        if(dp[i] <= W){
            ans = i;
        }
    }
    cout << ans << endl;


    return 0;
}

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

int main(){
    int N;
    cin >> N;
    string s[N];
    rep(i, N){
        cin >> s[i];
    }

    int cnt = 0;
    rep(i, N){
        rep(j, s[i].size()-1){
            if(s[i].substr(j, 2)=="AB"){
                cnt++;
            }
        }
    }
    
    vector <int> a, b, c;
    rep(i, N){
        if(s[i][s[i].size()-1]=='A'){
            a.emplace_back(i);
        }
        if(s[i][0]=='B'){
            b.emplace_back(i);
        }
    }
    rep(i, a.size()){
        rep(j, b.size()){
            if(a[i]==b[j]){
                c.emplace_back(a[i]);
            }
        }
    }
    int comb;
    int a_ = a.size(), b_ = b.size(), c_ = c.size();
    a_ -=c_;
    b_ -=c_;

    if(c_>=1){
        comb = c_-1;
        if(a_>=1){
            comb++;
            a_--;
        }
        if(b_>=1){
            comb++;
            b_--;
        }
        comb += min(a_, b_);
    }else{
        comb = min(a_, b_);
    }
    cout << cnt+comb << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main()
{
  string x;

  cin >> x;

  
  while ( x != "0")
    {

      int sum = 0;
  
      for ( int i = 0; i < (int)x.size(); i++)
        {
          sum += x[i] - '0';
        }
      cout << sum << endl;
      cin >> x;
    }
  
  return 0;
}

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

unordered_map<uint64_t, uint64_t> cache;
uint64_t n, a, b, c, d;

uint64_t dfs(uint64_t k) {
    if (k == 0) return 0;
    if (k == 1) return d;
    if (cache.count(k) > 0) return cache[k];
    uint64_t ans = d * k;
    ans = min(ans, dfs(k / 5) + c + d * (k % 5));
    if (k % 5 != 0) ans = min(ans, dfs(k / 5 + 1) + c + d * (5 - k % 5));
    ans = min(ans, dfs(k / 3) + b + d * (k % 3));
    if (k % 3 != 0) ans = min(ans, dfs(k / 3 + 1) + b + d * (3 - k % 3));
    ans = min(ans, dfs(k / 2) + a + d * (k % 2));
    if (k % 2 != 0) ans = min(ans, dfs(k / 2 + 1) + a + d * (2 - k % 2));
    cache[k] = ans;
    return ans;
}

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        cache.clear();
        cin >> n >> a >> b >> c >> d;
        uint64_t ans = dfs(n);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 4152
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int solve(vector<int> v){
    sort(v.begin(),v.end(),greater<int>());
    
    int ma = 0;
    int mi = 0;
    int L = v.size();
    
    for(int i=0; i<L; i++){
        ma+= v[i]*pow(10,L-1-i);
        mi+= v[L-1-i]*pow(10,L-1-i);
    }
    
    return ma-mi;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    
    /////////
    //write//
    /////////
    
    while(1){
        
        int a,L; cin >> a >> L;
        if(a==0 && L==0)break;
        vector<int> v;
        vector<int> ans;
        ans.push_back(a);
        
        int foo = 10;
        while(1){
            int tmp = a/(foo/10)%10;
            if(a/(foo/10)==0)break;
            v.push_back(tmp);
            foo*=10;
        }
        
        for(int i=0; v.size()<L; i++){
            v.push_back(0);
        }
        
        bool end = false;
        while(1){
            ans.push_back(solve(v));
            for(int i=0; i<ans.size()-1; i++){
                if(ans.back() == ans[i]){
                    cout << i << " " << ans.back() << " " << ans.size()-1-i << endl;
                    end = true;
                    break;
                }
            }
            if(end)break;
            v.clear();
            
            a = ans.back();
            foo = 10;
            while(1){
                int tmp = a/(foo/10)%10;
                if(a/(foo/10)==0)break;
                v.push_back(tmp);
                foo*=10;
            }
            
            for(int i=0; v.size()<L; i++){
                v.push_back(0);
            }
        }
        
    }
    
    
    
    
    return 0;
}




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


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

    if(a+b == 3) cout<<3<<endl;
    else if(a+b == 5) cout<<1<<endl;
    else cout<<2<<endl;

    return 0;
}


Measured memory_bytes: 256
/*  .　　∧_∧
   　（ ´・ω・)
   　//＼￣￣旦＼
   ／/ ※ ＼＿＿＿＼
   ＼＼ 　※ 　※ 　※ ヽ
   　 ＼ヽ-＿_＿--＿__ヽ*/

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//-------------------------------------------------------------------------------------------------------------------------------------------//

int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=800;
		if(i%15==0){
			ans-=200;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
from math import gcd
from functools import reduce
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))

if reduce(gcd,a)!=1:
  print("not coprime")
  exit()

def primes(x):
  ret=[]
  for i in range(1,int(x**0.5)+1):
    if x%i==0:
      ret.append(i)
      if x//i!=i:
        ret.append(x//i)
  ret.sort()
  return ret[1:]
      
s=set()
for q in a:
  p=primes(q)
  for j in p:
    if j in s:
      print("setwise coprime")
      exit()
    s.add(j)
print("pairwise coprime")


Measured memory_bytes: 181080
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 n;
    cin>>n;
    vector<int64> p(n);
    for(int64 i=0;i<n;i++){
        cin>>p[i];
    }

    int64 ans=0;

    for(int64 i=0;i+2<n;i++){
        if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2])){
            ans++;
        }
    }

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

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

int main()
{
  ll n, y;cin>>n>>y;
  rep(i, n+1) {
    for(int j=0; i+j < n+1; j++) {
      int k = n-i-j;
      if(i*10000 + j*5000 + k * 1000 == y) {
        cout << i << " " << j << " " <<  k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

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

int main() {
	string s;
	int k;
	cin >> s >> k;
	for (auto &c : s) {
		if (c == 'a') {
			continue;
		}
		int x = 'z' - c + 1;
		if (x <= k) {
			k -= x;
			c = 'a';
		}
	}
	if (k) {
		k %= 26;
		s[s.size() - 1] = 'a' + ((s[s.size() - 1] - 'a' + k) % 26);
	}
	cout << s << endl;
	return 0;
}

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

int main (){
    int a,b;
    char op;
    
    while(1){
        cin >>a>>op>>b;
        if(op == '?')
break;

        if (op== '+') cout<<a+b<<endl;
        else if (op == '-') cout << a-b<<endl;
        else if (op =='*') cout <<a*b<<endl;
        else if(op =='/') cout<<a/b<<endl;
        
    }
    return 0;
}


Measured memory_bytes: 3080
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int n,g,k,x,mx;
int main(){
	scanf("%d%d",&n,&k);
	fp(i,1,n)scanf("%d",&x),g=__gcd(g,x),cmax(mx,x);
	puts(k%g==0&&k<=mx?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
dp = [i for i in range(N+1)]

for i in range(1, 7):
    for j in range(9**i, N+1):
        dp[j] = min(dp[j], dp[j-9**i]+1)
for i in range(1, 7):
    for j in range(6**i, N+1):
        dp[j] = min(dp[j], dp[j-6**i]+1)
print(dp[N])

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

ll bin_pow(ll x, ll n, ll mod=MD){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}
ll nCk_mod(ll n, ll k, int mod=MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret = 1, rt2 = 1;
	for(ll i=n-k+1; i<n+1; i++) ret = ( ret * i) % mod;
	for(ll i=1; i<k+1; i++) rt2 = ( rt2 * i) % mod;
	return ( ret * bin_pow( rt2, mod-2, mod)) % mod;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, k;
	cin >>n >>m >>k;
	
	ll cnd = 0;
	rep(i, n) (cnd += (ll)i*(i+1)/2 * m %MD * m) %=MD;
	rep(i, m) (cnd += (ll)i*(i+1)/2 * n %MD * n) %=MD;
	ll ans = nCk_mod(n*m-2, k-2) * cnd % MD;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt(), h = readInt(), w = readInt();
        System.out.print((n - h + 1) * (n - w + 1));
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32368
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String c1 = sc.next();
    String c2 = sc.next();
    String c3 = sc.next();
    StringBuilder sb = new StringBuilder();
    sb.append(c1.charAt(0)).append(c2.charAt(1)).append(c3.charAt(2));
    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 21844
s1 = input()
s = s1 + '111111111111'
index = 0
while index < len(s):
    word = s[index:index + 5]
    # print(word)
    if word == '11111':
        break
    if '1' in word:
        print("NO")
        exit()

    if word == 'dream':
        index += 5

        if s[index:index + 2] == 'er':
            if s[index:index + 5] == 'erase':
                pass
            else:
                index += 2

    elif word == 'erase':
        index += 5
        if s[index] == 'r':
            index += 1

    else:
        print('NO')
        exit()

print("YES")


Measured memory_bytes: 3188
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	csf := make([][]int, n)
	for i := 0; i < n-1; i++ {
		var c, s, f int
		fmt.Scan(&c, &s, &f)
		csf[i] = []int{c, s, f}
	}
	for i := 0; i < n; i++ {
		t := 0
		for j := i; j < n-1; j++ {
			c, s, f := csf[j][0], csf[j][1], csf[j][2]
			d := t / f * f
			if t%f > 0 {
				d += f
			}
			t = c + max(s, d)
		}
		fmt.Println(t)
	}
}
func max(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}


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


int main() {
  int t, x;
  cin >> t >>x;
  double ans =  double(t)/x;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;


int main(){
  int N, K; cin >> N >> K;
  if (N % K == 0) cout << 0 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[21],n,m,q;
ll ans=0;
struct NODE{
    ll a,b,c,d;
}node[55];
void check(){
    ll tem=0;
    for(int i=1;i<=q;i++){
        if(a[node[i].b]-a[node[i].a]==node[i].c) tem+=node[i].d;
    }
    ans=max(ans,tem);
}
void dfs(int pos){
    if(pos==n+1) {check();return;}
    for(int i=0;i<=m-a[pos-1];i++){
        a[pos]=a[pos-1]+i;
        dfs(pos+1);
    }
}
int main() {
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++){cin>>node[i].a>>node[i].b>>node[i].c>>node[i].d   ;}
    a[0]=1;dfs(1);cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
N=int(input())
ans=[0,0,0,0]
judge=['AC','WA','TLE','RE']
for i in range(N):
  S=input()
  for j in range(4):
    if S==judge[j]:
      ans[j]+=1
      break

for i in range(4):
  print('{} x {}'.format(judge[i],ans[i]))

Measured memory_bytes: 75804
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N, -1);
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        --s;
        if (A[s] != -1 && A[s] != c) {
            cout << -1 << endl;
            return 0;
        }
        A[s] = c;
    }
    int base = 0;
    int end = 9;
    if (N == 2) {
        base = 10;
        end = 99;
    }
    if (N == 3) {
        base = 100;
        end = 999;
    }
    for (int i = base; i <= end; i++) {
        auto temp = to_string(i);
        bool check = true;
        for (int j = 0; j < N; j++) {
            if (A[j] == -1) continue;
            int num = temp[j] - '0';
            if (A[j] != num) {
                check = false;
            }
        }
        if (check) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
sum = 0

for i in range(N):
  if i == 0:
    sum += B[i]
  else:
    if A[i-1]+1 == A[i]:
      sum += B[i]
      sum += C[A[i-1]-1]
    else:
      sum += B[i]

print(sum)

Measured memory_bytes: 3064
/// {{{
#include "bits/stdc++.h"
#define   ALL(x)  x.begin(), x.end()
#define   iostreamBooster()  do{cin.tie(nullptr);ios::sync_with_stdio(false);}while(0)
#define   rep(i, s, t)       for(int i = int(s); i < int(t); ++i)
using namespace std;
typedef long long i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


signed main()
{
  int a, b;
  scanf("%2d%2d", &a, &b);

  auto yy = [](int n) {
    return 0 <= n;
  };

  auto mm = [](int n) {
    return 1 <= n && n <= 12;
  };

  bool yymm = yy(a) && mm(b);
  bool mmyy = mm(a) && yy(b);

  if (yymm && mmyy)
    puts("AMBIGUOUS");
  else if (!yymm && !mmyy)
    puts("NA");
  else if (yymm)
    puts("YYMM");
  else
    puts("MMYY");

  return 0;
}



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

int main() {

    int N;
    cin >> N;

    int A;
    double sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A;
        sum += 1.0 / A;
    }

    cout << 1.0 / sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>

#define INF_LL 1e18
#define INF 1e9

typedef long long ll;

using namespace std;

int main()
{
  int n, x;
  cin >> n;
  int min = INF;
  int max = 0;

  for (int i = 0; i < n; i++)
  {
    cin >> x;
    if (x >= max)
    {
      max = x;
    }

    if (x <= min)
    {
      min = x;
    }
  }

  cout << abs(max - min) << endl;

  return 0;
}


Measured memory_bytes: 256