akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<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 int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  REP(i,s.size()){
    if(s[i] == '1' && i%2==0) x++;
    if(s[i] == '0' && i%2==1) x++; 
    if(s[i] == '0' && i%2==0) y++;
    if(s[i] == '1' && i%2==1) y++; 
  }
  OUT(min(x,y));
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>

using namespace std;

void Main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  const int dx=tx-sx,dy=ty-sy;
  cout<<string(dy,'U')<<string(dx,'R');
  cout<<string(dy,'D')<<string(dx,'L');
  cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
  cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
  cout<<endl;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int judge(char *,int ,int );
int judge(char *s,int A,int B)
{
    int i;
    for(i=0;i<A+B+1;i++)
    {
        if(i!=A)
        {
            if(!(s[i]>='0'&&s[i]<='9'))
            {
                return 0;
            }
        }
        if(i==A)
        {
            if(s[i]!='-')
            {
                return 0;
            }
        }
    }
    return 1;
}
int main()
{
    char a[10001];
    int A,B;
    scanf("%d%d%s",&A,&B,a);
    printf((judge(a,A,B)==1)?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int m = h[0];
    int c = 1;
    for(int i = 1; i < n; i++){
        if(h[i] >= m){
            c++;
            m = h[i];
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 888
n = int(input())
xs = list(map(int, input().split()))

def cost(p):
    res = 0
    for x in xs:
        res += (p - x) ** 2
    return res

ans = 1 << 60
for i in range(0,101):
    ans = min(ans, cost(i))

print(ans)
         

Measured memory_bytes: 3060
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))

    A, count = bubbleSort(A, N)

    print(' '.join([str(a) for a in A]))
    print(count)

def bubbleSort(A, N):
    flag = True
    count = 0

    while flag:
        flag = False

        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                count += 1
                flag = True

    return A, count

if __name__ == '__main__':
    main()

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

using namespace std;

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

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

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

ll calc(ll x){
	ll t = 1;
	while((t + 1) * (t + 2) / 2 <= x) t++;
	return t;
}

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

	ll n;
	cin >> n;

	if(n == 1){
		cout << 0 << endl;
		return 0;
	}

	vector<pll> v = prime_factorize(n);
	ll ans = 0;
	for(auto p : v){
		ans += calc(p.second);
	}

	cout << ans << endl;
}


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

int main()
{    
    int a,b;
    cin >> a >> b;
    if((a+b)%2==1)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << (a+b)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
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 modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<=n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=false,right=false;
			
			for(int j=0;j<i;j++){
				if(s[j]==c)left=true;
			}
			for(int j=i;j<=n;j++){
				if(s[j]==c)right=true;
			}
			
			if(left&&right)cnt++;
		}
		if(ans<cnt)ans=cnt;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
n,k = map(int,input().split())
li = list(map(int,input().split()))
ruisekiwa = list(np.cumsum(li))
ruisekiwa.insert(0,0)
ans = []
for i in range(n-k+1):
  num = ruisekiwa[i+k]-ruisekiwa[i]
  ans.append(num)
print(0.5*max(ans) + 0.5*k)

Measured memory_bytes: 34604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split(' ');
            var n = int.Parse(nk[0]);
            var k = int.Parse(nk[1]);
            List<int> h = new List<int>();
            for(int i = 0; i < n; i++)
            {
                h.Add(int.Parse(Console.ReadLine()));
            }
            var hs = h.OrderBy(x => x).ToArray();
            var diff = 1000000000;
            for(int i = 0; i < n - k + 1; i++)
            {
                diff = Math.Min(diff, hs[i + k - 1] - hs[i]);
            }
            Console.WriteLine(diff);
        }
        

    }
}


Measured memory_bytes: 20956
#include <algorithm>
#include <cstdio>

const int mo=1000000007;

int f[2005];

int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	m--;k--;f[0]=1;
	int ans=0;
	for (int i=0;i<n+m;i+=k)
		for (int j=std::min(i,n);j>=0 && i-j<=m;j--){
			for (int x=1;x<=k;x++)
				if (j+x<=n && i-j+k-x<=m){
					(f[j+x]+=f[j])%=mo;
					if ((n-j-x)%k==0) (ans+=f[j])%=mo;
				}
			if (i-j+k>m) f[j]=0;
		}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int X,Y,Z,ans=0;
    cin>>X>>Y>>Z;

    X-=2*Z;

    while(X>=Y){
        ans++;
        X-=Y;
        X-=Z;
    }

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

Measured memory_bytes: 256
import collections as col

n = int(input())
a = [0] + list(map(int,input().split()))

wa = [i + a[i] for i in range(1,n+1)]
sa = [i - a[i] for i in range(1,n+1)]
cnt = col.Counter(sa)

ans = 0
for num in wa: ans += cnt[num]
print(ans)


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

ll nCrModp(ll n, ll r, ll p)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

int main()
{
    ll A,B,C;
    cin >> A >> B >> C;
    if (A+B+C >= 22) {
        print("bust");
    } else {
        print("win");
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[200005],fir=-1000000,sec=-1000000,fx;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) fir=max(fir,a[i]);
	for(int i=0;i<n;i++){
		if(a[i]==fir){
			fx=i;
			break;
		}
	}
	for(int i=0;i<n;i++){
		if(i!=fx) sec=max(sec,a[i]);
	}
	for(int i=0;i<n;i++){
		if(a[i]==fir) cout<<sec<<endl;
		else cout<<fir<<endl;
	}
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<ll,ll> P;
const int mod = 1e9+7;

struct mint{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a){
        (x+=a.x)%=mod;
        return *this;
    }
    mint& operator-=(const mint a){
        (x-=mod-a.x)%=mod;
        return *this;
    }
    mint& operator*=(const mint a){
        (x *= a.x)%= mod;
        return *this;
    }
    mint operator+(const mint a)const{
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a)const{
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a)const{
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
      if(!t)return 1;
      mint a = pow(t>>1);
      a*=a;
      if(t%1)a*=*this;
      return a;
    }

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

struct combination{
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1){
    fact[0] = 1;
    for(int i = 1; i<n;++i)fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i>=1;--i) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k){
    if(k<0 || k>n)return 0;
    return fact[n] * ifact[k] + ifact[n-k]; 
  }
};

struct Edge{
    int to,id;
};
vector<vector<Edge>> g;
// vector<int> ans(1e5+20,-1);
vector<int> ans;

void dfs(int v, int c =-1, int p=-1){
    int k = 1;
    rep(i,g[v].size()){
        int u = g[v][i].to, ei = g[v][i].id;
        if(u==p)continue;
        if(c==k)++k;
        ans[ei] = k++;
        dfs(u,ans[ei],v);
    }
}

// void dfs(int v, int p=0){
//     int k = 1;
//     rep(i,g[v].size()){
//         if(g[v][i].to==p)continue;
//         int e = g[v][i].to, t = g[v][i].id;
//         if(ans[v]==k)++k;
//         ans[t] = k++;
//         dfs(e,v);
//     }
// }


int main(){
    int n;
    cin >> n;
    g.resize(n);
    ans.resize(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    dfs(0);
    int maxi = -1;
    rep(i,n-1){
        int t = g[i].size();
        maxi = max(maxi,t);
    }
    cout << maxi<< endl;
    rep(i,n-1){
        cout << ans[i] << endl;
    }
    return 0;
    
}

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


int main(){
    string s;
    cin>>s;
    if((s[0]==s[1]&&s[2]==s[3])||(s[1]==s[3]&&s[2]==s[0])||(s[0]==s[3]&&s[1]==s[2]))
    {
        if(s[0]==s[1]&&s[0]==s[2]){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
import math
import numpy as np
n = int(input())

s = math.sqrt(n)
i = 2
f = {}
while i <= s:
    while n % i == 0:
        f[i] = f.get(i,0)+1
        n = n // i
    i += 1

ans = 0
for x in f.values():
    e = 0
    cumsum = 0
    while e + cumsum + 1 <= x:
        e += 1
        cumsum += e
    ans += e
print(ans+(n>1))

Measured memory_bytes: 27168
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n; cin>>n;
    vector<int> h(n);
    loop(n) cin>>h[i];

    vector<ll> dp(n, 9999999999);
    dp[0] = 0;
    for(int i = 0; i<n; i++){
        for(int j = 1; i+j<n && j<=2; j++){
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1408
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  int n;
  cin>>n;
  VI d(n); rep(i,n) cin>>d[i];

  int sum=0;
  for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
          sum+=d[i]*d[j];
      }
  }
  cout<<sum<<endl;
 }



Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    char ch = sc.next().charAt(0);
    if(ch >=65 && ch<=90) {
      System.out.println("A");
    } else {
      System.out.println("a");
    }
  }
}

Measured memory_bytes: 35672
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a >= b && a >= c)
    cout << 10 * a + b+ c << endl;
  else if(b >= a && b >= c)
    cout << 10 * b + a + c;
  else
    cout << 10 * c + a + b;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(n):
    s = input()
    if s == 'AC':
        AC += 1
    elif s == 'WA':
        WA += 1
    elif s == 'TLE':
        TLE += 1
    else:
        RE += 1
print("AC","x",AC)
print("WA","x",WA)
print("TLE","x",TLE)
print("RE","x",RE)

Measured memory_bytes: 69868
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y>>z;
if(x+y>=z)std::cout << "Yes" << '\n';
else std::cout << "No" << '\n';
}


Measured memory_bytes: 256
#include<iostream>//<bits/stdc++.h>
using namespace std;
 
int main(){
  int a[100001],n,count=0;
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
 
  for(int i=0;i<n;i++)
    if(a[i]>a[n-1])count++;
    else swap(a[i],a[i-count]);
 
  for(int i=0;i<n-count-1;i++) cout<<a[i]<<' ';
  cout<<'['<<a[n-count-1]<<']'<<' ';
  for(int i=n-count;i<n-1;i++) cout<<a[i]<<' ';
  cout<<a[n-1]<<endl;
 
  return 0;
}



Measured memory_bytes: 3500
#include <stdio.h>

int main(void)
{
	int n,h[100],i,max,cnt=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	max = h[0];
	for(i=0;i<n;i++){
		if(h[i] >= max){
			max = h[i];
			cnt++;
		}
	}
	printf("%d\n",cnt);
	
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  string s;
  cin >> s;
  cout << "2018/01/" + s.substr(8, 9);
}

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

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

    if(n>=m){
        cout<<0<<endl;
        return 0;
    }
    else{
    int a[m];rep(i,m)cin>>a[i];
    sort(a,a+m);
    
    int b[m-1];
    rep(i,m-1)b[i]=a[i+1]-a[i];
    
    sort(b,b+m-1,greater<int>());
    int ans_sub = 0;
    rep(i,n-1)ans_sub+=b[i];
    
    cout<<a[m-1]-a[0]-ans_sub<<endl;
    }
	return 0;
}

Measured memory_bytes: 4340
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;

long long da[100000], db[100000], dc[100000];

int main() {

	memset(da, 0, 100000);
	memset(db, 0, 100000);
	memset(dc, 0, 100000);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++){
		int a, b, c;
		cin >> a >> b >> c;

		if(i == 0){
			da[0] = a;
			db[0] = b;
			dc[0] = c;
		}
		else{
			da[i] = a + max(db[i - 1], dc[i - 1]);
			db[i] = b + max(dc[i - 1], da[i - 1]);
			dc[i] = c + max(da[i - 1], db[i - 1]);
		}
	}

	cout << max({da[n - 1], db[n - 1], dc[n - 1]}) << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  int a = n / 100000;
  int b = (n - a * 100000) / 10000;
  int c = (n - a * 100000 - b * 10000) / 1000;
  int d = (n - a * 100000 - b * 10000 - c * 1000) / 100;
  int e = (n - a * 100000 - b * 10000 - c * 1000 - d * 100)  / 10;
  int f = (n - a * 100000 - b * 10000 - c * 1000 - d * 100 - e * 10) ;
  if (a == 1){cout << 90909;}
  else if(b>0) {cout << 909 + n - 9999;}
  else if(c>0){cout << 909;}
  else if(d>0){cout << 9 + n - 99;}
  else if(e>0){cout << 9;}
  else if(f>0){cout << n;}
  return 0;
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    ans = [0] * (N+1)
    for i, a in enumerate(A):
        j = i+1
        ans[a] += 1
    for a in ans[1:]:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91716
import sys
import math
import itertools
input = sys.stdin.readline
##

while True:
    n, m = input().rstrip().split()
    n, m = int(n), int(m)
    if n + m == 0:
        sys.exit()
    
    taro = []
    hanako = []
    for _ in range(n):
        taro.append(int(input().rstrip()))
    for _ in range(m):
        hanako.append(int(input().rstrip()))

    card_diff = sum(taro) - sum(hanako)
    if card_diff % 2 == 1:
        print("-1")
        continue
    else:
        card_diff = card_diff // 2

    found_flag = False
    for piv_taro, piv_hanako in itertools.product(range(0, n), range(0, m)):
        if (taro[piv_taro] - hanako[piv_hanako]) == card_diff:
            found_flag = True
            break
    if found_flag == True:
        print("{} {}".format(taro[piv_taro], hanako[piv_hanako]))
    else:
        print("-1")



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

typedef long long ll;
#define pii pair<ll , ll>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 200005

ll n , k;

int main()
{
    _FastIO;
    cin >> n >> k;
    ll s = 0;
    ll sum = 0;
    ll x = 0;
    ll y = n;

    for(ll i = 1; i < k; i++){
        s += i;
        x = i;
    }
    for(ll i = n; i > n - k; i--){
        sum += i;
        y = i;
    }
    ll ans = 0;
    for(ll i = k; i < n + 2; i++){
        x++;
        y--;
        ans += (sum - s + 1);
        ans %= 1000000007;
        s += x;
        sum += y;

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


Measured memory_bytes: 3648
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[500005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=500005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }

// bool sorter(lld a, lld b)
// {
//     vector<lld> v2;
//     vector<lld> w;
//     // cout<<"A == " <<a<<"  B== "<<b;
//     while(a>=1)
//     {
//         v2.pb(a%10);
//         a/=10;
//     }
//     while(b>=1)
//     {
//         w.pb(b%10);
//         b/=10;
//     }   
       
//     reverse(all(v2));
//     reverse(all(w));
//     lld l1 = v2.size();
//     lld l2 = w.size();
//     lld  l = (l1*l2)/__gcd(l1,l2);
//     // cout<<l1<< " "<<l2<< " "<<l<< " ";
//     for(int i=0;i<l;i++)
//     {
//         if(v2[i%l1]!=w[i%l2])
//         {
//             // cout<< "   "<< (v2[i%l1] > w[i%l2])<<"\n";
//             return v2[i%l1] > w[i%l2];
//         }
//     }
//     // printf("false\n");
//     return false;
// }


lld p1=1e8 + 7,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;
lld ss=1;

void solve()
{

    cin >> n;
    string s;
    cin >>s ;
    ans =0 ;
    x=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='W') x+=1; 
    }
    ans= x;
    for(i=n-1;i>=n-x;i--)
    {
        if(s[i]=='W') ans-=1;
    }
    cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    // cin>>t;
    // cout<<t;
     // getfac(p1);
    //check the value by which modulo is to be taken
    // lld ans=0;
    // precompute();
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3780
#include<queue>
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
#include<stack>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

template<class T>
struct Fenwick : vector<T> {
    typedef vector<T> S;
    int N;
    Fenwick(int N_=0): S(N_), N(N_) {}
    void add(int i, T x) {
	for (; i<N; i|=i+1) S::operator[](i) += x;
    }
    inline T sum(int r) {
	T s = 0;
	for (; r; r&=r-1) s += S::operator[](r-1);
	return s;
    }
    T sum(int l, int r) {
	return sum(r) - sum(l);
    }
    int lower_bound(T x) { // argmin_i x <= sum(0,i)
	int i = 1, j = 0;
	T s = T();
	while (i<N) i<<=1;
	for (; i; i>>=1) {
	    if (i+j <= N && s + S::operator[](i+j-1) < x) {
		s += S::operator[](i+j-1);
		j += i;
	    }
	}
	return j;
    }
};

int N, Q;
LL A[100111];

vector<LL> all_indexes() {
    priority_queue<LL> X;
    vector<LL> ret;
    ret.push_back(0);
    REP (i, Q) {
	X.push(A[i]);
	ret.push_back(A[i]);
    }
    
    LL pr = -1;
    for (int i=Q; i--; ) {
	while (!X.empty() && X.top() > A[i]) {
	    LL x = X.top(); X.pop();
	    if (x != pr) {
		pr = x;
		LL k = (x - 1) % A[i] + 1;
		X.push(k);
		ret.push_back(k);
	    }
	}
    }
    sort(ret.begin(), ret.end());
    ret.erase(unique(ret.begin(), ret.end()), ret.end());
    return ret;
}

int main() {

    scanf("%d%d", &N, &Q);
    REP (i, Q) scanf("%lld", A+i);
    stack<LL> S;
    S.push(N);
    REP (i, Q) {
	while (!S.empty() && S.top() >= A[i]) S.pop();
	S.push(A[i]);
    }

    Q = S.size();
    for (int i=Q; i--; ) {
	A[i] = S.top();
	S.pop();
    }


    vector<LL> idx = all_indexes();
    Fenwick<LL> F(idx.size() + 1);
    F.add(0, 1); 
    F.add(idx.size()-1, -1);
    
    for (int i=idx.size(); --i;) {
	if (idx[i] <= A[0]) break;
	int k = lower_bound(A, A+Q, idx[i]) - A;
	LL m = A[k-1];

	LL a = idx[i], b = idx[i-1];
	int ai = i, bi = i-1, mi = lower_bound(idx.begin(), idx.end(), m) - idx.begin();
	LL d = F.sum(ai);
	F.add(0, -d); F.add(ai, d);
	if (a / m) {
	    F.add(0, a / m * d); F.add(mi, - (a / m * d));
	}
	if (a % m) {
	    int zi = lower_bound(idx.begin(), idx.end(), a % m) - idx.begin();
	    F.add(0, d); F.add(zi, -d);
	}

	F.add(0, d); F.add(bi, -d);
	if (b / m) {
	    F.add(0, -(b / m * d)); F.add(mi, b / m * d); 
	}
	if (b % m) {
	    int zi = lower_bound(idx.begin(), idx.end(), b % m) - idx.begin();
	    F.add(0, -d); F.add(zi, d); 
	}
    }


    int cur = 0;
    REP (i, N) {
	while (cur < (int)idx.size() && idx[cur] < i+1) cur++;
	printf("%lld\n", F.sum(cur));
    }



    return 0;
}



Measured memory_bytes: 8824
#include<bits/stdc++.h>
const int MIN=-1e9;
const int INF=1e9;
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
bool visited[100005];
const int max_N=1e5+10;
int N;
ll a[20005],b[20005];
int main(void)
{
  cin >> N;
  for(int i=1;i<=N;i++)
    {
      ll p;
      cin >> p;
      a[p]=30000*p;
      b[p]=30000*(N-p)+i;
    }
  for (int i = 1; i <= N; ++i)
    {
      if(i!=N) cout << a[i] << ' ';
      else cout << a[i] << endl;
    }
  for (int i = 1; i <= N; ++i)
    {
      if(i!=N) cout << b[i] << ' ';
      else cout << b[i] << endl;
    }
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int digits(ll a){
  int res=0;
  while(a>0){
    a = a/10;
    res++;
  }
  return res;
}

int F(ll a, ll b){
  return max(digits(a), digits(b));
}

int main()
{
  ll N;
  int res=INF;
  cin >> N;

  for(ll i=1; i*i<=N; i++){
    if(N%i==0)
      res = min(res, F(i, N/i));
  }

  cout << res << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

int main(){

    int n; std::cin >> n;
    std::vector<int> a(n+1),b(n+1);

    for(int i = 1; i <= n;i++){
        std::cin >> a[i];
    }

    for(int i = n; i > 0;i--){

        int sumBall = 0;
        for(int k = i*2; k <= n; k += i){
            if(b[k] == 1){
                sumBall ++;
            }
        }

        if(sumBall % 2 != a[i]){
            b[i] = 1;
        }
    }

    std::vector<int> ans;
    for(int i = 1; i <= n;i++){
        if(b[i]) ans.emplace_back(i);
    }

    std::cout << ans.size() << std::endl;
    for(int i = 0; i < ans.size(); i ++){
        printf("%d%c", ans[i],ans.size()==i+1?'\n':' ' );
    }
    return 0;
}


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    cout<<(n-1)/2;
    return 0;
}



Measured memory_bytes: 256
def b_card_game_for_three():
    next_turn = {ch: list(input())[::-1] for ch in 'abc'}
    current_turn = 'a'
    while next_turn[current_turn]:
        current_turn = next_turn[current_turn].pop()
    return current_turn.upper()

print(b_card_game_for_three())

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >> n;
  if(n<1200){cout << "ABC" << endl;}
  else if(1200<=n && n<2800){cout << "ARC" << endl;}else{cout << "AGC" << endl;}
}


Measured memory_bytes: 3592
import collections,itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
while 1:
    w,h = LI()
    if w==h==0:
        break
    ans = 0
    c = [LI() for _ in range(h)]
    seen = [[0]*w for _ in range(h)]
    stack = []
    dhdw = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
    def dfs(H,W):
        seen[H][W] = 1
        stack.append([H,W])
        while stack:
            sh,sw = stack.pop()
            for dh,dw in dhdw:
                nh,nw = sh+dh,sw+dw
                if not(0<=nh<=h-1) or not(0<=nw<=w-1) or seen[nh][nw] or c[nh][nw]==0:
                    continue
                seen[nh][nw] = 1
                stack.append([nh,nw])
    for H,W in itertools.product(range(h),range(w)):
        if seen[H][W] or c[H][W]==0:
            continue
        ans += 1
        dfs(H,W)
    print(ans)


Measured memory_bytes: 6036
def btc2yen(value):
    return 380000 * float(value)
total = 0
N = int(input())
for i in range(N):
    tmp = input()
    if tmp[-3:] == "BTC":
        total += btc2yen(tmp[:-4])
    else:
        total += int(tmp[:-4])
print(total)

Measured memory_bytes: 2940
n,a,b,c,d=map(int,input().split())
s=input()
if (c<d):
	if not '##' in s[a-1:d-1]: print('Yes')
	else: print('No')
elif (d<c):
	if (not '##' in s[a-1:c-1])&('...' in s[b-2:d+1]): print('Yes')
	else: print('No')

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x.begin(),x.end())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define endl "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define sz(a) (int)a.size()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define Q(x) for(int i=0;i<x;i++)
#define show(x) for(auto i:x)cout<<i<<" ";cout<<endl;

using namespace std;
const ll mod = 1e9 + 7;
void solve() {



}
int main() {

	double d, t, s;
	cin >> d >> t >> s;
	if (d / s <= t) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}
	

Measured memory_bytes: 3720
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main() {
  int A[3][3], i, j;
  // make a bingo
  for(i = 0; i < 3; i++) {
    for(j = 0; j < 3; j++) {
   	  scanf("%d", &A[i][j]);
    }
  }
  int N;
  scanf("%d", &N);
  int b[N], k;
  // select numbers
  for(k = 0; k < N; k++) {
   	scanf("%d", &b[k]); 
  }
  int ans = 0;
  // check
  for(i = 0; i < 3; i++) {
    int tmp = 0;
    for(j = 0; j < 3; j++) {
      int checkNum = A[i][j];
      for(k = 0; k < N; k++) {
       	if(checkNum == b[k]) {
          tmp++;
          break;
        }
      }
    }
    if(tmp == 3) {
      ans = 1;
      break;
    }
  }
  for(j = 0; j < 3; j++) {
    int tmp = 0;
    for(i = 0; i < 3; i++) {
      int checkNum = A[i][j];
      for(k = 0; k < N; k++) {
       	if(checkNum == b[k]) {
          tmp++;
          break;
        }
      }
    }
    if(tmp == 3) {
      ans = 1;
      break;
    }
  }
  int tmp = 0;
  for(i = 0; i < 3; i++) {
    int checkNum = A[i][i];
    for(k = 0; k < N; k++) {
      if(checkNum == b[k]) {
        tmp++;
        break;
      }
    }
  }
  if(tmp == 3) {
    ans = 1;
  }
  tmp = 0;
  for(i = 0; i < 3; i++) {
    int checkNum = A[i][2-i];
    for(k = 0; k < N; k++) {
      if(checkNum == b[k]) {
        tmp++;
        break;
      }
    }
  }
  if(tmp == 3) {
      ans = 1;
  }
  if(ans == 1) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

long ruijo(long a,int b){
	int i;
	long r=1;
	for(i=0;i<b;i++)r=r*a;
	return r;
}

int main(){
	long n,p,ans=1;scanf("%ld%ld",&n,&p);
	long i;
	if(n==1){
		printf("%ld\n",p);
		return 0;
	}
	if(n>=50){
		puts("1");
		return 0;
	}
	if(ruijo(2,n)>p){
		puts("1");
		return 0;
	}
	for(i=2;ruijo(i,n)<=p;i++){
		if(p%ruijo(i,n)==0){
			ans=i;
		//	p=p/(ruijo(i,n));
		}
	}
	printf("%ld\n",ans);
	return 0;
}

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

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

  vector<int> t(100000), x(100000), y(100000);

  t[0] = 0; x[0] = 0; y[0] = 0;

  rep(i,n) cin >> t[i] >> x[i] >> y[i];

  string ans="Yes";

  rep(i,n){
    int step = abs(x[i] - x[i-1]) + abs(y[i]-y[i-1]);

    int time = abs(t[i] - t[i-1]);

    if ((time - step < 0) || (time - step)%2 != 0){
      ans = "No";
      break;
    }

  }


  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var a = NextInt();
            var b = NextInt();
            

            if(Regex.IsMatch(Line(), "[0-9]{" + a + ",}-[0-9]{" + b + ",}")) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 16076
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	string s;
	cin>>s;
	if(s=="ABC"){
		cout << "ARC";
	}
	else{
		cout << "ABC";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3628
--{-# LANGUAGE StandaloneDeriving #-}
--{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
import Control.Monad
import Data.List
--import Data.Char
--import qualified Data.Set.Strict as Set
--import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  getLine
  c <- lines <$> getContents
  --a `traceShow`
  let m = solve c
  forM_ ["AC", "WA", "TLE", "RE"] $ \s -> do
    let i = case lookup s m of Just j -> j
                               Nothing -> 0
    putStrLn (s ++ " x " ++ show i)

solve :: [String] -> [(String, Int)]
solve c = map (\s -> (head s, length s)) . group . sort $ c


Measured memory_bytes: 32300
X, N = map(int, input().split())
P = list(map(int, input().split()))
l, r = 0, 0
for i in range(0, X+1):
    if not i in P:
        l = i
for i in range(101, X, -1):
    if not i in P:
        r = i
if abs(X-l) <= abs(X-r):
    print(l)
else:
    print(r)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const ll MAX = 1100000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	repl(i, 2, MAX) {
		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(int n, int k) {
	if (n < k) return 0;
	if (n < 0 or k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	COMinit();

	int n, k;
	cin >> n >> k;
	repl(i, 1, k + 1) cout << COM(k - 1, i - 1) * COM(n - k + 1, i) % MOD << endl;
	return 0;
}

Measured memory_bytes: 25984
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    N, A, B = map(int, input().split())
    r = N // (A + B)
    l = N - r * (A + B)
    cnt = r * A
    if l < A:
        cnt += l
    else:
        cnt += A
    print(cnt)


if __name__ == "__main__":
    main()


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

template< class T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) (ret += data[k]) %= mod;
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) (data[k] += x) %= mod;
  }
};

int main() {
  int N, M, X[100000], Y[100000];
  cin >> N >> M;
  for(int i = 0; i < N; i++) cin >> X[i];
  for(int i = 0; i < M; i++) cin >> Y[i];

  int L[100000], R[100000];
  memset(L, -1, sizeof(L));
  memset(R, -1, sizeof(R));
  for(int i = 0; i < N; i++) {
    auto it = lower_bound(Y, Y + M, X[i]) - Y;
    if(it > 0) L[i] = X[i] - Y[it - 1];
    if(it != M) R[i] = Y[it] - X[i];
  }

  map< int, vector< int > > query;
  vector< int > rs{-1};
  for(int i = 0; i < N; i++) {
    if(~L[i] && ~R[i]) rs.emplace_back(R[i]);
  }
  sort(begin(rs), end(rs));
  rs.erase(unique(begin(rs), end(rs)), end(rs));
  for(int i = 0; i < N; i++) {
    if(~L[i] && ~R[i]) query[L[i]].emplace_back(lower_bound(begin(rs), end(rs), R[i]) - begin(rs));
  }
  BinaryIndexedTree< int > bit(rs.size() + 1);
  bit.add(0, 1);
  for(auto &beet : query) {
    auto &v = beet.second;
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
    reverse(begin(v), end(v));
    for(auto &height : v) bit.add(height, bit.sum(height - 1));
  }
  cout << bit.sum(rs.size()) << endl;
}


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

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000000;

string s;
int n;

int main() {
	cin >> n;
	cin >> s;
	string ss = s;
	int cnt = 0;
	REP(i, n) { 
		if (s[i] == ')'&&cnt <= 0) { ss.insert(0,"("); }
		else if (s[i] == ')'&&cnt > 0)cnt--;
		else if (s[i] == '(')cnt++;
	}
	if (cnt > 0) {REP(i, cnt)ss.push_back(')');}
	print(ss);
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func f(s string) string {
	var b [26]bool
	var r string
	for i := 0; i < len(s); i++ {
		b[s[i]-'a'] = true
	}
	for i := 0; i < len(b); i++ {
		if !b[i] {
			r = s + string('a'+i)
			break
		}
	}
	return r
}

func main() {
	var S, ans string
	fmt.Scan(&S)
	n := len(S)
	if n < 26 {
		ans = f(S)
	} else {
		var i int
		for i = n - 1; i > 0; i-- {
			if S[i] > S[i-1] {
				break
			}
		}
		if i == 0 {
			ans = "-1"
		} else {
			var b [26]bool
			ans = S[:i-1] // S[0]...S[i-2]までの文字列と、S[i-1]の文字の辞書順の次に大きい文字になる
			// S[i-1]より辞書順で大きく、かつansで使われていない文字を探す
			for i := 0; i < len(ans); i++ {
				b[ans[i]-'a'] = true
			}
			for j := 0; j < len(b); j++ {
				if !b[j] && (S[i-1] < ('a' + byte(j))) {
					ans += string('a' + j)
					break
				}
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#define REP(i,a,n) for(int i = a;i < n;i++)
#define ll long long 
#define MAX 100000
using namespace std;

int main(void) {
    ll x, y;
    scanf("%lld %lld", &x, &y);
    ll ans = 1;

    while (y >= 2*x) {
        ans ++;
        x = 2*x;
    }

    printf("%lld\n", ans);
}



Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    LL n;
    LL k;
    LL ans=0;

    cin >> n >> k;

    vector<LL> start_comb(n+2-k);
    vector<LL> end_comb(n+2-k);

    start_comb[0]=0;
    end_comb[0]=0;
    for(int i=0; i<k; i++){
        start_comb[0]+=i;
        end_comb[0]+=n-i;
    }
    for(int j=1; j<n+2-k; j++){
        start_comb[j]=start_comb[j-1]+k-1+j;
        end_comb[j]=end_comb[j-1]+n-k+1-j;
    }
    //cout << "test" << endl;
    for(int i=0; i<n+2-k; i++){
        ans += end_comb[i]-start_comb[i]+1;
        ans %= MOD;
        //cout << start_comb[i] << " " << end_comb[i] << endl;
    }

    //cout << n+2-k << endl;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>

using namespace std;
using P = pair<int, int>;

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<P> LR(M);
	vector<P> pq(Q);
	for (int i = 0; i < M; ++i) {
		P p;
		cin >> p.first >> p.second;
		LR[i] = p;
	}
	for (int i = 0; i < Q; ++i) {
		P p;
		cin >> p.first >> p.second;
		pq[i] = p;
	}

	vector<vector<int>> sum;
	sum.assign(N+1,vector<int>(N+1 , 0));
	for (int i = 0; i < M;++i) {
		sum[LR[i].first][LR[i].second]++;
	}
	for (int i = 1; i <= N;++i) {
		for (int j = 1; j <= N; ++j) {
			sum[i][j] += sum[i - 1][j];
			sum[i][j] += sum[i][j-1];
			sum[i][j] -= sum[i - 1][j-1];
		}
	}

	for (P p : pq) {
		int ans = 0;
		ans = sum[p.second][p.second] 
			- sum[p.second][p.first - 1] - sum[p.first - 1][p.second] 
			+ sum[p.first - 1][p.first - 1];
		cout << ans << endl;
	}
}


Measured memory_bytes: 4352