akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
ll fac[510000], finv[510000], inv[510000];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




int main(){
  int N;
  cin>>N;
  int p = N%3;
  int q = N/3;
  COMinit();
  ll ans = 0;
  for(int i = 1;i<=q;i++){
    ans+=COM((i-1+(N-3*i)),N-3*i);
    ans=ans%MOD;
  }
  cout << ans << endl;
  return 0;
}
  

Measured memory_bytes: 15584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 Scanner s = new Scanner(System.in);
		 long point = s.nextLong();
		 long divisorBy11 = point/11*2;
		 long remainder = point%11;
		 if(remainder ==0){
			 System.out.println(divisorBy11);
		 }else if(remainder <=6){
			 System.out.println(divisorBy11+1);
		 }else{
			 System.out.println(divisorBy11+2);
		 }
	}

}

Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v) cerr << #v << ":"; rep(i, v.size()) cerr << " " << v[i]; cerr<<endl
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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


Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
    char c1[3];char t1[3];int i,c=0;
    gets(c1); gets(t1);
    
    for(i=0;i!='\n';i++)
    {
     if(c1[i]==t1[i])
     {
         c++;
     }
    }
    c=c-3;
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a_list=list(map(int,input().split()))
INF=10**9+7
def modinv(a,m):
    b=m
    (x,lastx)=(0,1)
    (y,lasty)=(1,0)
    while not b==0:
        q=a//b
        (a,b)=(b,a%b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx%m
def modcomb(n,k,m):
    fac=[0]*(n+1)
    finv=[0]*(n+1)
    inv=[0]*(n+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,n+1):
        fac[i]=fac[i-1]*i%m
        inv[i]=m-inv[m%i]*(m//i)%m
        finv[i]=finv[i-1]*inv[i]%m
    return fac[n]*(finv[k]*finv[n-k]%m)%m
a_list.sort()
m=0
M=0
x=modcomb(n-1,k-1,INF)
for i in range(n-k+1):
    m=(m+x*a_list[i])%INF
    x=x*(n-k-i)
    d=modinv(n-1-i,INF)
    x=(x*d)%INF
a_list.sort(reverse=True)
x=modcomb(n-1,k-1,INF)
for i in range(n-k+1):
    M=(M+x*a_list[i])%INF
    x=x*(n-k-i)
    d=modinv(n-1-i,INF)
    x=(x*d)%INF
ans=(M-m)%INF
print(ans)


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

int n, M=1e9+7, d[105][5][5][5];

int f(int p, int a, int b, int c) {
	int re=0;
	if(p==n) return 1;
	if(d[p][a][b][c]) return d[p][a][b][c];
  	for(int d=0; d<4; d++){
		if(b==0 && c==1 && d==2) continue;
		if(b==0 && c==2 && d==1) continue;
		if(b==1 && c==0 && d==2) continue;
		if(a==0 && c==1 && d==2) continue;
		if(a==0 && b==1 && d==2) continue;
		re += f(p+1, b, c, d);
		re %= M;
    }
	return d[p][a][b][c] = re;
}

int main() {
	cin >> n;
 	cout << f(0, 4, 4, 4);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int h,w;
scanf("%d%d",&h,&w);
char s[h][w+1];int i;
for(i=0;i<h;i++)scanf("%s",s[i]);
for(i=0;i<h;i++){
printf("%s\n",s[i]);
printf("%s\n",s[i]);
}
return 0;
}

Measured memory_bytes: 128
from itertools import product

n = int(input())
data = {}
for p in range(1, n+1):
    a = int(input())
    # 人p=1～の証言
    data[p] = [list(map(int, input().split())) for _ in range(a)]
    
# パターン生成
ans = 0
for honest in product(range(2), repeat=n):
    for p,hk in enumerate(honest, 1):
        if hk == 1:
            # 証言の矛盾をチェック
            if not all([honest[x-1] == y for x,y in data[p]]):
                break
    else:
        ans = max(ans, sum(honest))

print(ans)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
vector<long long> mf = {1};
vector<long long> mfi = {1};
long long modfact(int n){
	if (mf.size() > n){
		return mf[n];
	} else {
		for (int i = mf.size(); i <= n; i++){
			long long next = mf.back() * i % MOD;
			mf.push_back(next);
			mfi.push_back(modinv(next));
		}
		return mf[n];
	}
}
long long modfactinv(int n){
	if (mfi.size() > n){
		return mfi[n];
	} else {
		return modinv(modfact(n));
	}
}
long long modbinom(int n, int k){
	if (n < 0 || k < 0 || k > n){
		return 0;
	} else {
		return modfact(n) * modfactinv(k) % MOD * modfactinv(n - k) % MOD;
	}
}
int main(){
  int S;
  cin >> S;
  long long ans = 0;
  for (int i = 0; i <= S; i++){
    ans += modbinom(S - i * 2 - 1, i - 1);
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
constexpr int IINF = INT_MAX;

int n, m, s[100005];

int solve(int x){
    int lv = 1, cnt = 0;
    while(lv + x <= s[n-1]){
        int i = upper_bound(s, s+n+1, lv) - s;
        int up = 0;
        if(i>0 && s[i-1] < lv+x) up = max(1, x-abs(lv-s[i-1]));
        if(s[i] < lv+x) up = max(up, max(1,x-abs(lv-s[i])));
        if(up == 0) return IINF;
        lv += up;
        cnt++;
    }
    return cnt+1;
}

int main() {
    while(cin >> n >> m, n){
        for(int i=0;i<n;i++) cin >> s[i];
        s[n] = IINF;
        int ok = 0, ng = 1e6+5;
        while(abs(ok-ng) > 1){
            int mid = (ok+ng)/2;
            if(solve(mid) >= m){
                ok = mid;
            }
            else{
                ng = mid;
            }
        }
        int t = solve(ok);
        if(t<IINF && t >= m){
            cout << ok << endl;
        }
        else{
            cout << -1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3484
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  int ans = 0;
  if(a + b > c * 2){
    if(x > y){
      x -= y;
      ans += c * 2 * y;
      if(a > c * 2) ans += c * 2 * x;
      else ans += a * x;
    }
    else{
      y -= x;
      ans += c * 2 * x;
      if(b > c * 2) ans += c * 2 * y;
      else ans += b * y;
    }
  }
  else{
    ans += a * x + b * y;
  }
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1333>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int W,N;
bool C(int m,vector<int>& sum){
    vector<int> dp(N+1);
    int lim = N,r = N;
    int cnt = 0;
    for(int i = N-1; i>= 0;i--){
        while(W - (sum[lim] - sum[i]) - (lim - i - 1) < 0){
            cnt -= dp[lim--];
        }
        while((r > lim || r - i - 1> 0) && (W - (sum[r] - sum[i]) + r - i - 2)/(r - i - 1) <= m){
            cnt += dp[r--];
        }
        dp[i] = lim == N || cnt > 0;
    }
    return dp[0] == 1;
}
int solve(){
    int res = INF;
    vector<int> x(N),sum(N+1);
    for(int i = 0; i < N;i++) cin >> x[i];
    for(int i = 0; i < N;i++) sum[i+1] = sum[i] + x[i];
    int l = 0, r = W;
    while(r - l > 1){
        int m = (l+r)/2;
        if(C(m,sum)){
            r = m;
        }else{
            l = m;
        }
    }
    res = r;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> W >> N, W|N){
        cout << solve() << endl;
    }
    return 0;
}



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

int main() {
    int H, W;
    cin >> H >> W;
    vector <string> A(H);
    for (int i=0; i<H; i++){
        cin >> A[i];
    }
    int dx[8]={0,0,-1,-1,-1,1,1,1};
    int dy[8]={-1,1,-1,0,1,-1,0,1};
    for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
            int count=0, x, y;
            if (A[i][j]=='#') continue;
            for (int k=0; k<8; k++){
                x=j+dx[k];
                y=i+dy[k];
                if (x<0 || x>=W) continue;
                if (y<0 || y>=H) continue;
                if (A[y][x]=='#') count++;
            }
            A[i][j]=char(count+'0');
        }
    }
    for (int i=0; i<H; i++){
        cout << A[i]<< endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll x,y;
 
int main() {
ll ans=0;
cin>>x>>y;
while(x<=y)x*=2,ans++;
cout<<ans<<endl;
	return 0;
           } 

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

int main(void){
    char C[100][100];
    int H, W; cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> C[i][j];
        }
    }
    for(int i = 0; i < 2*H; i++){
        for(int j = 0; j < W; j++){
            cout << C[i/2][j];
        }
        cout << endl;
    }
    return 0;
}


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

struct UnionFind {
    vector<int> par; 
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); //どちらも負の数なのでsizeで行ったらyのほうが大きい場合という意味 
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


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

  vector<int> a(m),b(m);
  for (int i = 0; i<m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  UnionFind uf(n);
  vector<long long> ans;
  long long tmp = n*(n-1)/2;
  for (int i = 0; i<m; i++){
    ans.push_back(tmp);
    if (uf.issame(a[m-1-i],b[m-1-i])) continue;

    tmp -= uf.size(a[m-1-i]) * uf.size(b[m-1-i]);
    uf.merge(a[m-1-i],b[m-1-i]);
  }
  for (int i = ans.size()-1;i>=0; i--){
    cout << ans[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;


ll fastpow(ll a, ll pw) {
	ll res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

int main() {
    cin>>N;
    vec num(N, 0);
    rep(i,N) {
        cin>>A;
        ++num[A];
    }
    bool ok = true;
    if(N&1) {
        for(int i = 0; i < N; i += 2) if(num[i] != 2 - (i == 0)) ok = false;
    }
    else {
        for(int i = 1; i < N; i += 2) if(num[i] != 2) ok = false;
    }
    cout<<(ok ? fastpow(2, N / 2) : 0)<<endl;
}

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

typedef long long ll;

const int MAXN=500005;

ll ans,a[MAXN],s[MAXN],c[MAXN],ss[MAXN],n,k;

map <ll,ll> to;

ll lowbit(ll x){
	return x & -x;
}

void change(ll x,ll y){
	while (x<=n){
//		printf("%d ",x);
		c[x]+=y;
		x+=lowbit(x);
	}
	return;
}

ll sum(ll x){
	ll s=0;
	while (x>=1){
		s+=c[x];
		x-=lowbit(x);
	}
	return s;
}

int main(){
	int i;
	scanf("%lld%lld",&n,&k);
	for (i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		a[i]-=k;
		s[i]=s[i-1]+a[i];
		ss[i]=ss[i-1]+a[i];
		if (s[i]>=0) ans++;
	}
	/*
	for (i=1;i<=n;i++){
		ss[i]=s[i];
		printf("%d,%lld,%lld\n",a[i],s[i],ss[i]);
	}
	*/
	sort(ss+1,ss+n+1);
	/*
	for (i=1;i<=n;i++){
		printf("%d,%lld,%lld\n",a[i],s[i],ss[i]);
	}
	*/
	ll kk=1ll;
	to[ss[1]]=1ll;
	for (i=2;i<=n;i++){
		if (ss[i]>ss[i-1]){
			kk++;
			to[ss[i]]=kk;
		}
	}
	for (i=1;i<=n;i++){
		s[i]=to[s[i]]; 
	}
//	printf("??");
	/*
	for (i=1;i<=n+1;i++){
		printf("%lld\n",s[i]);
	}
	*/
	change(s[1],1ll);
	for (i=2;i<=n;i++){
		ans+=sum(s[i]);
		change(s[i],1ll); 
//		printf("%lld ",ans);
	} 
//	printf("\n");
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 26624
#include<iostream>

using namespace std;
int main()
{
    int x,x1,x2,x3,x4,x5,x6,x7,x8,a[3][3];
    for(int i=0;i<3;i+=1){
        for(int j=0;j<3;j+=1){
            cin>>a[i][j];
            if(i==0 && j==0){
                x = a[i][j];
            }
            if(i==0 && j==1){
                x1 = a[i][j];
            }
            if(i==0 && j==2){
                x2 = a[i][j];
            }
            if(i==1 && j==0){
                x3 = a[i][j];
            }
            if(i==1 && j==1){
                x4 = a[i][j];
            }
            if(i==1 && j==2){
                x5 = a[i][j];
            }
            if(i==2 && j==0){
                x6 = a[i][j];
            }
            if(i==2 && j==1){
                x7 = a[i][j];
            }
            if(i==2 && j==2){
                x8 = a[i][j];
            }
        }
    }
    int n,s=0,s1=0,s2=0,s3=0,s4=0,s5=0,s6=0,s7=0,b[10];cin>>n;
    for(int j=0;j<n;j+=1){
        cin>>b[j];
        if(b[j]==x){
           s++;s3++;s6++;
        }
        if(b[j]==x1){
           s++;s4++;
        }
        if(b[j]==x2){
           s++;s5++;s7++;
        }
        if(b[j]==x3){
           s1++;s3++;
        }
        if(b[j]==x4){
           s1++;s4++;s6++;s7++;
        }
        if(b[j]==x5){
           s1++;s5++;
        }
        if(b[j]==x6){
           s2++;s3++;s7++;
        }
        if(b[j]==x7){
           s2++;s4++;
        }
        if(b[j]==x8){
           s2++;s5++;s6++;
        }
    }
    if(s==3 || s1==3 || s2==3 || s3==3 || s4==3 || s5==3 || s6==3 || s7==3){
       cout<<"Yes"<<endl;
    }
    else{
       cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict as dd
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
d = dd(int)
d2=dd(int)
for i in range(n):
  d[a[i]]+=1
for i in range(m):
  d2[b[i]]+=1
for k in sorted(d2.keys()):
  if d2[k] > d[k]:
    print("NO")
    exit()
print("YES")

Measured memory_bytes: 57056
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;
 
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(a+b, max(a-b, a*b));
}

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

int main(){
    string cha;
    cin >> cha;
    int an = 0;
    int bn = 0;
    int cn = 0;
    string ans = "No";
    for(int i = 0; i < 3; i++) {
        if(cha[i] == 'a') an++;
        else if(cha[i] == 'b') bn++;
        else if(cha[i] == 'c') cn++;
    }

    if(an == 1 && bn == 1 && cn == 1) ans = "Yes";

    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))
result = sum(w)
for i in range(n):
    if abs(sum(w[0:i])-sum(w[i:n+1])) < result:    result = abs(sum(w[0:i])-sum(w[i:n+1]))    
print(result)

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

int main(void){
    int n,d;
    cin >> n >> d;
    double x[n][d];
    double sum=0;
    int ans=0;
    rep(i,n){
        rep(j,d){
            int a;
            cin >> a;
            x[i][j] = a;
        }
    }
    rep(i,n){
        for(int j=i+1;j<n;j++){
            sum = 0;
            rep(z,d){
                sum += (x[i][z]-x[j][z])*(x[i][z]-x[j][z]);
            }
          	int num = sum;
            num = sqrt(num);
            if((num*num)==sum){
                ans += 1;
            }
        }
    }
    cout << ans <<endl;
    
    return 0;
}













Measured memory_bytes: 384
import sys
import heapq as h

inf = sys.maxsize

# おまじない
class heapq:
    def __init__(self):
        self.q = []

    def push(self,v):
        h.heappush(self.q, v)
    
    def pop(self):
        return h.heappop(self.q)

    def is_empty(self):
        return len(self.q) == 0


V,e,r=(int (i)for i in input().split())
#print(v)
G=[[] for i in range(V)]#iごとに[]（式）を評価(実行)する。
for j in range(e):
    f,t,cost=(int (i)for i in input().split())
    G[f].append((t,cost))
dist=[inf]*100000
visited=[False]*100000
a=heapq()
a.push((0,r))
def end(visited):
    for i in visited:
        if i==False:
            return False
    return True
while(not a.is_empty()):
    (cur_dist,u)=a.pop()#uはid,cur_distはいまの道の長さ
    if not visited[u]:
        
        dist[u]=cur_dist
        #print(cur_dist,u)
        visited[u]=[True]
        for (v,cost) in G[u]:
            if not visited[v] and dist[u]+cost<dist[v]:
                a.push((dist[u]+cost,v))
#print(v)
for i in range(V):
    if dist[i]==inf:
        print('INF')
    else:
        print(dist[i])
    


Measured memory_bytes: 114164
pub struct Scanner{
     line : Vec<String> ,
     idx : usize
}

impl  Scanner{
    #[allow(dead_code)]
    fn new() -> Scanner{
        return Scanner{ line: vec![], idx : 0}
    }
    #[allow(dead_code)]
    fn next<T: std::str::FromStr> (&mut self) -> T{
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();

            let a : Vec<&str>  = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    #[allow(dead_code)]
    fn read_vec<T: std::str::FromStr>  (&mut self, n: usize) -> Vec<T>{
        let mut v : Vec<T>= Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}


fn main() {
    let mut scan = Scanner::new();
    let a:i32  = scan.next();
    let b:i32  = scan.next();

    let ans = std::cmp::max(a + b,  std::cmp::max(a - b, a * b));

    println!("{}", ans);
}

Measured memory_bytes: 4352
module Main (main) where
import System.IO
import Control.Monad

parseInput input = map read $ words input :: [Int]

main :: IO ()
main = do
    input <- getLine
    let [n, t] = parseInput input
    line <- sequence $ replicate n $ (\[cost, time] -> (read cost, read time)) . words <$> getLine :: IO [(Int, Int)]
    let res = solve line t    
    if minimum res == 10000
        then putStrLn "TLE"
    else putStrLn(show (minimum res))

solve :: [(Int, Int)] -> Int -> [Int]
solve [] t = []
solve ((cost, time) : xs) t
    | time <= t = [cost] ++ solve xs t
    | otherwise = [10000] ++ solve xs t


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


/*
int N;
Graph G;

int main() {
  cin >>N;
  rep(i, N-1){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b); G[b].push_back(a);
  }
}
*/

int main() {
  string s; cin >>s;
  int n = s.size();
  rep(i, n-8) cout <<s[i];
  cout <<endl;
}

Measured memory_bytes: 256
from itertools import permutations
N = int(input())
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
ans = 0
cnt = 0
for p in permutations(range(N)):
    path = 0
    for i in range(1,N):
        path += ((X[p[i]]-X[p[i-1]])**2+(Y[p[i]]-Y[p[i-1]])**2)**0.5
    ans += path
    cnt += 1
print(ans / cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }

    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; }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    string S; cin >> S;
    string str = "coffee";

    bool ok = S[2] == S[3];
    ok = ok && S[4] == S[5];

    yesno(ok);
    
    
    return 0;
}


Measured memory_bytes: 256
// 17min

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];

    sort(h.begin(), h.end());
    // vector<ll> ruisekiwa;
    // ruisekiwa.push_back(0);

    // rep(i,n) ruisekiwa.push_back(ruisekiwa[i] + h[i]);

    // rep(i,n+1) {
    //     cout << ruisekiwa[i] << endl;
    // }
    ll ans = INF;
    for (int i = 0; i+k-1<n ; i++) {
        // ll tmp = ruisekiwa[i+k] - ruisekiwa[i];
        ll tmp = h[i+k-1] - h[i];
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


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

using namespace std;

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

template<int MOD>
struct ModInt {
   using Mint = ModInt;
   int val;
   ModInt(ll __val = 0) { fix(__val % MOD + MOD); }
   Mint& fix(int __val) { val = __val; if (val >= MOD) val -= MOD; return *this; }
   explicit operator int() { return val; }
   Mint operator + (const Mint &mt) const { return Mint().fix(val + mt.val); }
   Mint operator - (const Mint &mt) const { return Mint().fix(val - mt.val + MOD); }
   Mint operator * (const Mint &mt) const { return Mint().fix(ll(val) * mt.val % MOD + MOD); }
   Mint& operator += (const Mint &mt) { return *this = *this + mt; }
   Mint& operator -= (const Mint &mt) { return *this = *this - mt; }
   Mint& operator *= (const Mint &mt) { return *this = *this * mt; }
   Mint pow(int y) const {
      Mint x = *this;
      Mint ans(1);
      for (; y > 0; y >>= 1, x *= x) {
         if (y & 1) ans *= x;
      }
      return ans;
   }
   Mint operator -() const { return Mint().fix(MOD - val); }
   Mint inv() const { return pow(MOD - 2); }
   Mint operator / (const Mint &mt) const { return *this * mt.inv(); }
   Mint& operator /= (const Mint &mt) const { return *this / mt; }
   friend ostream& operator<<(ostream& os, const Mint& mt) { return os << mt.val; }
};

using Mint = ModInt<998244353>;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   string S; cin >> S;
   int K; cin >> K;
   K = min(K, 400);
   vector<vector<Mint>> dp(K + 1, vector<Mint>(K + 1));
   vector<int> segs;
   int l = 0;
   int N = S.size();
   while (l < N) {
      int len = 0;
      while (l < N && S[l] == '1') l++, len++;
      segs.emplace_back(len);
      if (l < N) l++;
   }
   reverse(segs.begin(), segs.end());
   dp[0][0] = 1;
   for (int v : segs) {
      vector<vector<Mint>> inc(K + 1, vector<Mint>(K + 1));
      vector<vector<Mint>> dec(K + 1, vector<Mint>(K + 1));
      for (int deg = 0; deg <= K; ++deg) {
         for (int tot = 0; tot <= K; ++tot) {
            if (deg) inc[deg - 1][tot] += dp[deg][tot];
            if (deg < K && tot < K) dec[deg + 1][tot + 1] += dp[deg][tot];
            if (deg + v + 1 <= K && tot + v + 1 <= K) dec[deg + v + 1][tot + v + 1] -= dp[deg][tot];
         }
      }
      for (int deg = K - 1; deg >= 0; --deg) {
         for (int tot = 0; tot <= K; ++tot) {
            inc[deg][tot] += inc[deg + 1][tot];
         }
      }
      for (int deg = 1; deg <= K; ++deg) {
         for (int tot = 1; tot <= K; ++tot) {
            dec[deg][tot] += dec[deg - 1][tot - 1];
         }
      }
      for (int deg = 0; deg <= K; ++deg) {
         for (int tot = 0; tot <= K; ++tot) {
            dp[deg][tot] += inc[deg][tot] + dec[deg][tot];
         }
      }
   }
   Mint ans = 0;
   for (int z = 0; z <= K; ++z) ans += dp[0][z];
   cout << ans << "\n";
}


Measured memory_bytes: 5188
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

L, R, d = input_int()

count=0
for i in range(L,R+1):
    if i%d==0:
        count+=1

print(count)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec A(N);
    REP(i,0,N) cin >> A[i];
    ASC(A); REV(A);

    ll sum = A[0];
    REP(i,2,N) {
        sum += A[i/2];
    }
    PR(sum);

    return 0;
}

/*



*/

Measured memory_bytes: 4836
import heapq
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
N, M = tuple(li())
A = list(li())
heapq.heapify(A)
def update(pq, k, val):
    # update pq in place
    for _ in range(k):
        cur = heapq.heappop(pq)
        if cur < val:
            heapq.heappush(pq, val)
        else:
            heapq.heappush(pq, cur)
            break

ops = []
# val, k_sum
keep = dict()
for i in range(M):
    k, val = tuple(li())
    k_sum = keep.get(val, 0)
    keep[val] = k_sum + k

for val, k in keep.items():
    update(A, k, val)

print(sum(A))


Measured memory_bytes: 23592
void main()
{
    dchar[] s = rdDchar;

    s.sort!"a < b";

    writeln(s.uniq.array.length == 2 ? "Yes" : "No");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)	
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	b    := 2
	x    := a * b
	
	r := a % b
	for r != 0 {
		a = b
		b = r
		r = a % b
	}

	fmt.Println(x / b)
}

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

int main()
{
  int n;
  string s;
  
  cin>>n;
  cin>>s;
  
  if(n>=(int)s.length())
    cout<<s;
  else
  {
    for(int i=0;i<n;i++)
      cout<<s[i];
    cout<<"...";
  }
}


Measured memory_bytes: 3540
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

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

	int n, m;
	int sum = 0;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));
	vector<int> b(m);
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		cin >> b[i];
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			sum += a[i][j] * b[j];
		}
		cout << sum << '\n';
		sum = 0;
	}

	return 0;
}


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

void call(int n){
	int i=1,x;
	do{
		x=i;
		if(x%3==0){
			cout<<" "<<i;
		}else{
			do{
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
				x/=10;
			}while(x);
		}
	}while(++i<=n);
	cout<<endl;
}
int main(){
	int n;
	cin>>n;
	call(n);
	return 0;
}

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

using namespace std;


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

  int a, b;
  cin >> a >> b;

  int ans = max(a+b, max(a-b, a*b));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int i,j;
	char str[108];
	while(scanf("%s",str) != EOF){
		for(i=0;;i++){
			if(str[i]=='\0'){
				puts("");
				break;
			}
			else if(str[i]=='@'){
				for(j=0;j<str[i+1]-49;j++){
					printf("%c",str[i+2]);
				}
				i++;
			}
			else{
				printf("%c",str[i]);
			}
			
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
  
class Main{
  public static void main(String[] arg){

    int count = 0;
    
    Scanner in = new Scanner(System.in);

    String w = in.nextLine();
    w = w.toLowerCase();

    while(true){
        String t = in.nextLine();

        if(t.equals("END_OF_TEXT")) break;

        t = t.toLowerCase();
        String [] words = t.split(" ",0);

        for(int i=0; i<words.length; i++)
            if(w.equals(words[i]))
                count++;
    }

    System.out.println(count);

  }
}

Measured memory_bytes: 26220
package main

import (
        "fmt"
        "math"
)

func main() {
        var N int
        fmt.Scan(&N)
        var S string
        fmt.Scan(&S)

        m := map[byte]uint64{}
        for i := 0; i < N; i++ {
                index := S[i]
                _, e := m[index]
                if e {
                        m[index]++
                } else {
                        m[index] = uint64(1)
                }
        }

        var res uint64 = 1
        M := uint64(math.Pow10(9) + 7)

        for _, v := range m {
                res *= (uint64(1) + v)
                res = res % M
        }
        fmt.Print(res - uint64(1))

}


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

#define SIZE 300005
#define MOD 1000000007LL
#define INF INT_MAX / 3
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i];if(i==a.size()-1)cout<<endl;else cout<<" ";}}
int gcd(int a,int b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
int lcm(int a,int b){return a==0||b==0?0:a*b/gcd(a,b);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int w;
  while (~scanf("%d",&w))
  {
    string str = "";
    FOR(i,0,9) if(w>>i & 1)
    {
      char tmp[256];
      sprintf(tmp,"%d ",1<<i);
      str += tmp;
    }
    str[str.size()-1] = '\n';
    printf("%s",str.c_str());
  }
  return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int main(){
  int N;  cin >> N;
  vector<int> a;
  for(int i = 0;i < N;i++){
    int b;  cin >> b;
    a.push_back(b);
  }

  sort(a.begin(),a.end(),greater<int>());

  int Alice = 0;
  int Bob = 0;

  for(int i = 0;i < N;i++){
    if(i % 2 == 0)Alice += a[i];
    else Bob += a[i];
  }

  cout << Alice - Bob << endl;


}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N, M, X;
vector<int> C(12);
vector<vector<int>> A(12, vector<int>(12, 0));

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

    cin >> N >> M >> X;

    for (int i = 0; i < N; i++) {
        cin >> C.at(i);
        for (int j = 0; j < M; j++) {
            cin >> A.at(i).at(j);
        }
    }

    ll mincost = INF;

    for (int i = 0; i < (1 << 12); i++) {
        bitset<12> bs(i);

        ll cost = 0;
        vector<ll> us(M, 0);

        for (int j = 0; j < 12; j++) {
            if (bs.test(j)) {
                cost += C.at(j);
                for (int k = 0; k < M; k++) {
                    us.at(k) += A.at(j).at(k);
                }
            }
        }

        bool flag = true;

        for (int j = 0; j < M; j++) {
            if (us.at(j) < X) {
                flag = false;
                break;
            }
        }

        if (flag) {
            chmin(mincost, cost);
        }

    }

    if (mincost == INF) {
        cout << -1 << endl;
    } else {
        cout << mincost << endl;
    }

    
    return 0;
}

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

void sum_three(int K, int S) {
	int ans = 0;
	for (int i = 0; i <= K; i++) {
		if (S - i >= 0) {
			for (int j = 0; j <= K; j++) {
				if (S - i - j >= 0) {
					if (S - i - j <= K) ans += 1;
					
				}
				else break;
			}
		}
		else break;
	}
	cout << ans << endl;
}
int main() {
	int K, S;
	cin >> K >> S;
	sum_three(K, S);
}

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

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

	vector<int> array(N, 0);
	for (int i = 0; i < N; ++i)
	{
		cin >> array[i];
	}

	int preMaxValue = -1;
	int resultValue = 0;
	for (int i = 0; i < N; ++i)
	{
		if (preMaxValue <= array[i])
		{
			preMaxValue = array[i];
			++resultValue;
		}

	}
	cout << resultValue << endl;

	return 0;
}


Measured memory_bytes: 256
program C049
    implicit none
    character(100000) :: S
    integer(8) :: i, j, N


    read(5,*) S
    N = len_trim(S)

    i = 0
    j = 0

    do while(i < N)
        if (S(i+1:i+7) == "dreamer") then
            if (S(i+8:i+8) /= "a")then
                i = i + 7
            else
                i = i + 5
            end if
        else if (S(i+1:i+5) == "dream") then
            i = i + 5
        else if (S(i+1:i+6) == "eraser") then
            i = i + 6
        else if (S(i+1:i+5) == "erase") then
            i = i + 5
        else 
            i = N
            j = 1
        end if
    end do

    if (j == 0) then
        write(6,*) "YES"
    else
        write(6,*) "NO"
    end if




    
end program C049


Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	lli n,w;
	cin >> n >> w;
	vector<vector<lli> > v(4, vector<lli>(1, 0));
	int base = 0;
	for(int i=0; i<n; i++){
		lli cost,value;
		cin >> cost >> value;
		if(i == 0) base = cost;
		v[cost-base].push_back(value);
	}
	vector<int> s(4);
	for(int i=0; i<4; i++){
		sort(v[i].begin()+1, v[i].end(), greater<lli>());
		for(int j=0; j<(int)v[i].size()-1; j++){
			v[i][j+1] += v[i][j];
		}
		s[i] = v[i].size();
	}
	lli ans = 0;
	for(lli i=0; i<s[0]; i++){
		for(lli j=0; j<s[1]; j++){
			for(lli k=0; k<s[2]; k++){
				for(lli l=0; l<s[3]; l++){
					if(i*base +j*(base+1) +k*(base+2) +l*(base+3) <= w){
						ans = max(ans, v[0][i] +v[1][j] +v[2][k] +v[3][l]);
					}
				}
			}
		}
	}
	cout << ans << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    ll index = 0;
    REP(_, Q) {
        ll q;
        cin >> q;
        if (q == 0) {
            ll x;
            cin >> x;
            A[index++] = x;
        }
        else if (q == 1) {
            ll x;
            cin >> x;
            cout << A[x] << endl;

        }
        else {
            index--;
        }
    }
    return 0;
}


Measured memory_bytes: 4688
#include<stdio.h>
#include<math.h>

void initialize(int array[], int n);
void diagonal(int array[]);
void process(int size, int hole[], int n);

main()
{
	int i = 0, n = 0, size[3];
	initialize(size, 3);
	while(scanf("%d %d %d", &size[0], &size[1], &size[2]), ((size[0] != 0) && (size[1] != 0) && (size[2] != 0)))
	{
		scanf("%d", &n);
		int hole[n];
		initialize(hole, n);
		for(i = 0; i < n; i++)
		{
			scanf("%d", &hole[i]);
		}
		diagonal(size);
		process(size[0], hole, n);
		initialize(size, 3);
	}
	
	return 0;
}
void initialize(int array[], int n)
{
	int i = 0;
	for(i = 0; i < n; i++)
	{
		array[i] = 0;
	}
}
void diagonal(int array[])
{
	int temp[3];
	initialize(temp, 3);
	int i = 0, j = 0;
	for(i = 0; i < 3; i++) //配列arrayを配列tempにコピー
	{
		temp[i] = array[i];
	}
	for(i = 0; i < 3; i++) //三平方の定理を使って対角線の長さを計算
	{
		j = i + 1;
		if(j == 3)
		{
			j = 0;
		}
		array[i] = sqrt(pow(temp[i], 2) + pow(temp[j], 2));
	}
	for(i = 0; i < 3; i++)
	{
		for(j = i + 1; j < 3; j++)
		{
			if(array[i] > array[j])
			{
				temp[0] = array[i];
				array[i] = array[j];
				array[j] = temp[0];
			}
		}
	}
}
void process(int size, int hole[], int n)
{
	int i = 0;
	for(i = 0; i < n; i++)
	{
		if(size < (hole[i] * 2))
		{
			printf("OK\n");
		}
		else
		{
			printf("NA\n");
		}
	}
}

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

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

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main() {
    int N, M;
    cin >> N >> M;
    int countAns = 0;
    int countMiss = 0;

    int WA[100010];
    int AC[100010];
    rep(i, N, 1) {
        WA[i] = 0;
        AC[i] = 0;
    }

    while (M--) {
        int p;
        string S;
        cin >> p >> S;
        if (AC[p] == 1) continue;
        if (S == "AC") {
            AC[p] = 1;
            countAns++;
            countMiss += WA[p];
        } else if (S == "WA") {
            WA[p]++;
        }
    }

    cout << countAns << endl;
    cout << countMiss << endl;

    return 0;
}

Measured memory_bytes: 1024
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::collections::HashMap;

fn main() {
    let n: usize;
    let mut ans: usize = 0;
    input!(n);
    let mut v = HashMap::new();
    for _ in 0..n {
        let mut s = str2vec(&input_line_str());
        s.sort();
        let po = v.entry(s).or_insert(0_usize);
        *po += 1;
    }

    for (i, x) in v.iter() {
        ans += x * (x - 1) / 2;
    }

    println!("{}", ans);
}


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

int main(){
    int N,M;
    cin >> N >> M;
    string S;
    vector<int> pAC(N);
    vector<int> pWA(N);
    rep(i,M){
        int tmp_p;
        cin >> tmp_p >> S;
        if(S=="AC"){
            pAC[tmp_p-1]=1;
        }else{
            if(pAC[tmp_p-1]!=1){
                pWA[tmp_p-1]++;
            }
        }
    }
    int ans_AC=0;
    int ans_P=0;
    rep(i,N){
        if(pAC[i]==1){
            ans_AC++;
            ans_P+=pWA[i];
        }
    }
    cout << ans_AC << " " << ans_P << endl;
    return 0;
}

Measured memory_bytes: 1024