akhauriyash/Code-Regression huggingface dataset:
N = (int)(input())
stex = input().split()
suu = []
for i in stex:
    suu.append((int)(i))
count = 0
for c in suu:
    unti = True
    while(unti):
        if(c%2 == 0):
            c = c/2
            count = count + 1
        else:
            unti = False
print(count)

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

// 各桁の和を計算する関数
int FindSum(int n) {
    int sum = 0;
    while (n>0) {
        sum += n%10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    for (int i=1; i<=N; i++) {
        int sum = FindSum(i); // 総和を計算する関数
        if (A <= sum && sum <= B) total += i;
    }
    cout << total << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split(" "))

def main():
	if k % 2 == 1:
		if k > n:
			print(0)
			return
		else:
			div = n // k
			print(div * div * div)
			return
	else:
		kk = k / 2
		div1 = n // k
		j = 0
		for i in range(1, n + 1):
			if i % k == kk:
				j += 1
		print(div1 * div1 * div1 + j * j * j)
		return
			
main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(void){
	int n,c=1;
  	string str;
  	cin >> n;
  	cin >> str;
  	for(int i=0;i<n-1;i++){
    	if(str[i]!=str[i+1]){
        	c++;
        }
    }
  	cout << c << endl;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    empty = A - B
    C -= empty
    if C < 0:
        C = 0
    print(C)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


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

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;
	int n = (int)S.length();
	if (n == 3){
		reverse(ALL(S));
	} // end if

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using ll = long long;
using namespace std;
int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
        ans+=a[i-1]-a[i];
        a[i]=a[i-1];
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4776
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int count = 0;
        for (int i = 0; i <= a; i++) {
            for (int j = 0; j <= b; j++) {
                for (int k = 0; k <= c; k++) {
                    int sum = i * 500 + j * 100 + k * 50;
                    if (sum == x) {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string> field;
    rep(i,h){
        string s;
        cin>>s;
        field.push_back(s);
    }
    
    vector<string> field2;
    int ans=0;
    for(int bit1=0; bit1<(1<<h); bit1++){
        for (int bit2=0; bit2<(1<<w); bit2++){
            field2=field;
            rep(i,h){
                if(bit1&(1<<i)) {
                    rep(j,w){
                        field2[i][j]='.';
                    }
                }
            }
            rep(i,w){
                if(bit2&(1<<i)) {
                    rep(j,h){
                        field2[j][i]='.';
                    }
                }
            }
            //check
            int count=0;
            rep(i,h){
                rep(j,w){
                    if(field2[i][j]=='#') count++;
                }
            }
            if(count==k) ans++;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3604
import numpy as np

parameter = list(map(int,input().split()))
b = list(map(int,input().split()))
B = np.array(b)
X=[]
for i in range(1,parameter[0]+1):
    a = list(map(int,input().split()))
    A = np.array(a)
    D = np.dot(A,B)+parameter[2]
    if D>0:
        X.append(1)
print(len(X))


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

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;

vector<pair<ll,ll>> primeFactorial(ll n){
    vector<pair<ll,ll>> res;
    for (ll i = 2;i*i<=n;i++){
        ll r = 0;
        while (n%i == 0){
            r++;
            n /= i;
        }
        res.emplace_back(i,r);
    }
    if (n > 1) {
        res.emplace_back(n,1);
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<pair<ll,ll>> res = primeFactorial(N);
    ll ans = 0;
    auto calc = [&] (ll x){
        return x*(x+1)/2;
    };
    for (int i=0;i<res.size();i++){
        ll large = 1e6;
        ll small = 0;
        while (large-small>1){
            ll mid = (large+small)/2;
            if (calc(mid) > res[i].second) large = mid;
            else small = mid;
        }
        ans += small;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 19680
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os") 

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define mp make_pair

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, lg=23, mod=1e9+7, inf=1e18;

ll n,m,t,a[maxn],dp[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n>>m>>t;
	for(int i=1;i<=n;i++) cin>>a[i];
	ll mmm=inf;
	for(int i=1,j=0;i<=n;i++){
		while(2*(a[i]-a[j+1])>t){
			mmm=min(mmm,dp[j]-2*a[j+1]);
			j++;
		}
		dp[i]=min(mmm+2*a[i],dp[j]+t);
	}
	cout<<dp[n]+m<<endl;

	return 0;
}








 







Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX]; 
void COMinit() {  //MOD combの計算を行う．COMinitを宣言してから以下のCOMルーチンを実行すればよい
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int 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(){
    COMinit();
    ll n,k;
    std::cin >> n>>k;
    ll ans=0ll;
    rrep(i,k,n+2){
        ans+=(2*n-i+1)*i/2-(i-1)*i/2+1;
        ans%=MOD;
        //std::cout << ans << std::endl;
    }
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 15580
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
ne = sum(a[::2])
no = sum(a[1::2])
p0 = (ne>no)
mn = BIG
for p0 in [True,False]:
 cnt = 0
 acc = 0
 #ddprint("ne {} no {} p0 {} a {}".format(ne,no,p0,a))
 for i in range(n):
    if (p0 if i%2==0 else not p0):
        x = max(0, 1-a[i]-acc)
        cnt += x
        acc += a[i]+x
    else:
        x = max(0, a[i]+acc+1)
        cnt += x
        acc += a[i]-x
    #ddprint("cnt {} acc {}".format(cnt,acc))
 mn = min(mn,cnt)
print(mn)


Measured memory_bytes: 63216
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
 
int main() {
    string s;
    while(getline(cin,s)) {
        string t;
        rep(j,0,26) {
            t.clear();
            rep(i,0,s.length()) {
                if('a' <= s[i] && s[i] <= 'z') {
                    int val = (s[i] - 'a' + j) % 26;
                    t += ('a' + val);
                }
                else t += s[i];
            }
            if(t.find("this") != string::npos) break;
            else if(t.find("the") != string::npos) break;
            else if(t.find("that") != string::npos) break;
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 3184
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <cmath>
using namespace std;

#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647

map<int, int> mp2;

int dfs(int count, vector<int> A, int sum, int targetValue, int minCount) {
	if (mp2[targetValue - sum] != 0) {
		return min(minCount, count + mp2[targetValue - sum]);
	}

	if (sum == targetValue) {
		return min(minCount, count);
	}
	else if (targetValue < sum) {
		return minCount;
	}

	for (size_t i = 0; i < A.size(); ++i) {
		int buf = dfs(count + 1, A, sum + A[i], targetValue, minCount);
		if (buf < minCount) {
			minCount = min(minCount, buf);
		}
	}

	return minCount;
}

int main() {
	int N;
	cin >> N;
	vector<int> A;
	map<int, bool> mp;

	A.push_back(1);
	for (int i = 1;; ++i) {
		if (mp[pow(9, i)] == 0 && pow(9, i) <= N) {
			A.push_back(pow(9, i));
			mp[pow(9, i)] = 1;
		}
		else {
			break;
		}
	}

	for (int i = 1;; ++i) {
		if (mp[pow(6, i)] == 0 && pow(6, i) <= N) {
			A.push_back(pow(6, i));
			mp[pow(6, i)] = 1;
		}
		else {
			break;
		}
	}

	sort(A.rbegin(), A.rend());


	for (int i = 1; i <= N; ++i) {
		int minCount = INT_MAX;
		int count = 0;
		count = dfs(0, A, 0, i, minCount);
		mp2[i] = count;
	}

	cout << mp2[N] << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<char, char> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n,m;
string w[20];
vector<string> s;
vector<int> ord;
int res=0;
set<P> role[2];
bool used[26];
int ccnt[100];

void dfs(int i){
  if(i==m){
    res++;
    if(res<2){
      role[res]=role[res-1];
    }
    return ;
  }
  int j=ord[i];
  rep(k,n){
    if(w[k].size()>s[j].size())break;
    if(s[j].size()!=w[k].size())continue;
    bool ok=true;
    vector<P> add;
    rep(l,s[j].size()){
      char c1=s[j][l],c2=w[k][l];
      if(used[c1-'A']!=used[c2-'A']){
        ok=false; break;
      }
      if(used[c1-'A']&&used[c2-'A']&&role[res].find(P(c1,c2))==role[res].end()){
        ok=false; break;
      }
      if(role[res].find(P(c1,c2))==role[res].end()){
        role[res].insert(P(c1,c2)); role[res].insert(P(c2,c1));
        used[c1-'A']=used[c2-'A']=true;
        add.push_back(P(c1,c2));
      }
    }
    if(!ok){
      rep(l,add.size()){
        role[res].erase(P(add[l].fi,add[l].se));
        role[res].erase(P(add[l].se,add[l].fi));
        used[add[l].fi-'A']=false; used[add[l].se-'A']=false;
      }
      continue;
    }
    dfs(i+1);
    if(res==2)return;
    rep(l,add.size()){
      role[res].erase(P(add[l].fi,add[l].se));
      role[res].erase(P(add[l].se,add[l].fi));
      used[add[l].fi-'A']=false; used[add[l].se-'A']=false;
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    s.clear();
    m=0; ord.clear();
    rep(i,n)cin>>w[i];
    sort(w,w+n,[](const string& a,const string& b){ return a.size() < b.size(); });
    while(1){
      ord.push_back(m++);
      string tmp;
      cin>>tmp;
      if(tmp[tmp.size()-1]=='.'){
        s.push_back(tmp.substr(0,tmp.size()-1));
        break;
      }
      s.push_back(tmp);
    }
    rep(i,m){
      set<char> st;
      rep(j,s[i].size())st.insert(s[i][j]);
      ccnt[i]=st.size();
    }
    sort(all(ord),[=](const int& a,const int& b){ return ccnt[a] > ccnt[b]; });
    res=0;
    rep(i,2)role[i].clear();
    memset(used,0,sizeof(used));
    dfs(0);
    if(res==2)cout<<"-."<<endl;
    else{
      string ans=s[0];
      repl(i,1,m)ans+=" "+s[i];
      ans+=".";
      rep(i,ans.size()){
        for(P p : role[0]){
          if(ans[i]==p.fi){
            ans[i]=p.se;
            break;
          }
        }
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3176
#include<bits/stdc++.h>
#define ljh ioi_aker
#define yxy tourist
#define wlj ugly_and_slow
#define pmh legendary_grandmaster
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define pb push_back
#define fr first 
#define se second
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
#define dbg cout << "---------------------------------\n"
cs int base = 233;
cs int ff = 2e6+1;
cs int mod = 998244353;
cs int inf = 1e17+1;
int fir[ff], nex[ff], to[ff], tot;
void add(int x, int y)
{
	if( x == y ) return;
	nex[++tot] = fir[x];
	fir[x] = tot;
	to[tot] = y;
}
int n, m, c, k, b[ff];
int dx[ff], kl, ds[ff], ld, qz[ff];
int cf[ff];
char s[ff];
void init()
{
	cin >> n >> k >> c;
	cin >> s+1;
	rep(i, 1, n)
	{
		if( s[i] == 'o' ) b[++m] = i, qz[i] = 1;
		qz[i] += qz[i-1];
	}
	dx[0] = 1 - c - 1; dx[++kl] = b[1];
	rep(i, 2, m)
	{
		if( b[i] - dx[kl] > c ) dx[++kl] = b[i];
		if( kl == k - 1 ) break;
	}
	ds[++ld] = b[m]; ds[0] = n+1+c;
	drep(i, m-1, 1)
	{
		if( ds[ld] - b[i] > c ) ds[++ld] = b[i];
		if( ld == k - 1 ) break;
	}
	int head = k - 1, tail = 0;
	rep(i, 1, k)
	{
		int sx = dx[head] + c + 1;
		int xx = ds[tail] - c - 1;
	//	cout << sx << " " << xx << endl;
		int gg = qz[xx] - qz[sx-1];
		if( sx <= xx ) cf[sx] += gg, cf[xx+1] -= gg;
		head--; tail++;
	}
	rep(i, 1, n)
		cf[i] = cf[i-1] + cf[i];
	rep(i, 1, n)
		if( cf[i] == 1 && s[i] == 'o' ) cout << i << endl;
}
signed main()
{
	int T = 1;
//	cin >> T;
	while(T--) 
		init();
} 

Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;

int n;
Graph G;
vector<int>res;

void dfs(int v,int p,int c){
  res[v] = c;
  for(auto e : G[v]){
    if(e.first == p) continue;
    if(e.second == 1) dfs(e.first,v,1-c);
    else dfs(e.first,v,c);
  }
}

int main() {
  cin >> n;
  G.assign(n,vector<Edge>());
  for(int i = 0;i < n-1;i++){
    int u,v,w;
    cin >> u >> v >> w;
    u--;v--;
    G[u].push_back(Edge(v,w%2));
    G[v].push_back(Edge(u,w%2));
  }
  res.assign(n,0);
  dfs(0,-1,0);
  for(auto v : res) cout << v << endl;
}


Measured memory_bytes: 8960
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = sr()
dp = [0, 1]  # ちょうど払う最小枚数、１円多くはらう最小枚数
for x in N:
    x = int(x)
    prev = dp[:]
    dp[0] = min(prev[0]+x, prev[1]+(10-x))
    dp[1] = min(prev[0]+x+1, prev[1]+(10-x-1))

answer = dp[0]
print(answer)
# 33

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

#define int long long

using namespace std;

const int MAXN = 2010;

const int MOD = 1e9 + 7;

int dp[MAXN];

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

    int S;
    cin >> S;

    dp[0] = 1;

    for(int i = 1 ; i <= S ; i++)
    {
    	for(int j = 3 ; j <= S ; j++)
    	{
    		if(i-j < 0)continue;
    		dp[i] = (dp[i] + dp[i-j])%MOD;
    	}
    }

    cout << dp[S] << '\n';

    return 0;
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    print(N*(N+1)//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring> 
using namespace std;
int main()
{
	char s;
	int x=0;
	while(scanf("%c",&s)!=EOF)
	{
		if(s=='1'||s=='0')
		{
			if(s=='1')x++;
		}
		else break;
	}
	printf("%d\n",x);	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    string s;
    int m, c;
    
    cin >> s;
    
    m = s.size();
    
    for(int i=1; i<=m-1; i++){
        
        if((m-i)%2==1){
            
            continue;
            
        }
        
        c = (m-i) / 2;
        
        for(int j=0; j<=c-1; j++){
            
            if(s.at(j)!=s.at(j+c)){
                
                break;
                
            } else if(j==c-1){
                
                cout << m-i << endl;
                return 0;
                
            }
            
        }
        
    }
    
    return 0;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String a[])
	{
		Scanner sc = new Scanner(System.in);

		long n = sc.nextInt(), p = 1;

		sc.close();

		for (int i = 1; i <= n; ++i)
		{
			p = p * i % 1000000007;
		}

		System.out.println(p);
	}
}


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

bool prime_number(int num) {
	if (num < 2) {
		return false;
	} else if (num == 2) {
		return true;
	} else if (num % 2 == 0) {
		return false;
	}

	double sqrt_num = sqrt(num);
	for (int i = 3; i <= sqrt_num; i += 2) {
		if (num % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	int x;
	cin >> x;
	int n = x;
	while (!prime_number(n)) {
			n++;
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 384
inputs = input()
a = int(inputs.split(" ")[0])
b = int(inputs.split(" ")[1])
c = int(inputs.split(" ")[2])
if a > b:
    if c > b and a > c:
        print("Yes")
    else:
        print("No")
else:
    if c > a and b > c:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
#define DEBUG 0

/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 4/6/2019, 9:03:49 PM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(10101010));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int A[5];
int B[5];

int main()
{
  for (auto i = 0; i < 5; i++)
  {
    cin >> A[i];
  }
  for (auto i = 0; i < 5; i++)
  {
    B[i] = A[i] % 10;
  }
  sort(B, B + 5);
  if (B[4] == 0)
  {
    int ans = 0;
    for (auto i = 0; i < 5; i++)
    {
      ans += A[i];
    }
    cout << ans << endl;
  }
  else
  {
    for (auto i = 0; i < 5; i++)
    {
      A[i] = (A[i] + 9) / 10 * 10;
    }
    int amari = 0;
    for (auto i = 0; i < 5; i++)
    {
      if (B[i] > 0)
      {
        amari = B[i];
        break;
      }
    }
    int ans = -10;
    for (auto i = 0; i < 5; i++)
    {
      ans += A[i];
    }
    cout << ans + amari << endl;
  }
}

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int n,ans;
    vector<int> nums;
    cin>>n;

    // それまでの最小値を記憶し、その最小値と比較
    for(int i = 0; i < n; i++){
        int tmp; cin>>tmp;
        nums.push_back(tmp);
    }

    ans = nums[1]-nums[0];
    int minnum = nums[0];

    for(int i = 1; i < n-1; i++){
        minnum = min(minnum, nums[i]);
        ans = max(ans, nums[i+1]-minnum);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3868
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    vector<ll>time;
    ll n;
    cin >> n;
    REP(i,5){
        ll a;
        cin >> a;
        time.push_back(a);
    }
    ll answer = 4;
    ll min = *min_element(time.begin(),time.end());
    answer += n/min;
    if(n%min!=0)answer++;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 string a;
  cin >> a;
 int b = a.size();
  int c = a.at(b-1);
    if(c=='3'){
      cout << "bon" << endl;
    }
      else if(c=='0'||c=='1'||c=='6'||c=='8'){
     cout << "pon" << endl;
      }
    else{
      cout << "hon" << endl;
    }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    int sum = 0, n;
    while (cin >> s)
    {
        rep(i, s.size())
        {
            if (s[i] < '0' || s[i] > '9')
                s[i] = ' ';
        }
        stringstream ss(s);
        while (ss >> n)
            sum += n;
    }

    OP(sum);

    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long int li;
#define mkp make_pair
#define sc(x) scanf("%lld",&x)
#define pf(x,y) printf("%lld %lld", x,y)
#define pfn printf("\n")
#define fr(i,a,n) for(i = a ; i < n ; i++)
map<long int , list<long int> > mp;
int vis[100001];
int dist[100001];
long int maxi = 0;
void dfs(long int src){
	vis[src] = 1;
//	cout << src << endl;
	for(auto i: mp[src]){
		if(!vis[i])dfs(i);
//		cout << i << " " << dist[i] << endl;
		dist[src] = max(dist[src],1+dist[i]);
	}
	if(maxi<dist[src])maxi=dist[src];
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long int n,m,x,y;
	cin >> n >> m;

	
	for(int i = 0 ; i < m ; i++){
		cin >> x >> y;
		mp[x].push_back(y);

	}

	for(long int i = 1 ; i <=n;i++){
		if(!vis[i])
			dfs(i);
	}
//	for(int i = 1 ; i<=n;i++){
////		cout << ind[i].first << " " << ind[i].second <<endl;
//		cout << dist[i] << " ";
//	}
	cout << maxi<< endl;
	return 0;
}


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

int main()
{
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a--;
    b--;
    c--;
    d--;
    if(c > d){
        bool f = false;
        for(int i = b - 1; i < d; i++){
            if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') f = true;
        }
        if(!f){
            cout << "No" << endl;
            return 0;
        }
    }
    while(a < n - 1){
        if(s[a + 1] == '#') a++;
        a++;
        if(s[a] == '#'){
            cout << "No" << endl;
            return 0;
        }
        if(a == c){
            break;
        }
    }
    while(b < n - 1){
        if(s[b + 1] == '#') b++;
        b++;
        if(s[b] == '#'){
            cout << "No" << endl;
            return 0;
        }
        if(b == d){
            break;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;

int main(void)
{
    int N, M;
    cin >> N >> M;
    const int NMAX = 1010;
    const int MMAX = 2010;
    int a[MMAX], b[MMAX];
    ll c[MMAX];

    for (int i = 1; i <= M; ++i)
    {
        cin >> a[i] >> b[i] >> c[i];
        c[i] = -c[i];
    }

    ll dist[NMAX];
    bool negative[NMAX];
    memset(dist, 0x3f, sizeof dist);
    memset(negative, 0, sizeof negative);
    dist[1] = 0;

    for (int loop = 0; loop < N - 1; ++ loop)
    {
        for (int i = 1; i <= M; ++i)
        {

            if (dist[a[i]] == INF) continue;

            if (dist[b[i]] > dist[a[i]] + c[i])
            {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }

    ll ans = dist[N];





    for (int loop = 0; loop < N ; ++ loop)
    {
        for (int i = 1; i <= M; ++i)
        {
            if (dist[a[i]] == INF) continue;

            if (dist[b[i]] > dist[a[i]] + c[i])
            {
                dist[b[i]] = dist[a[i]] + c[i];
                negative[b[i]] = true;
            }

            if (negative[a[i]] == true)
            {
                negative[b[i]] = true;
            }
        }
    }

    if (negative[N])
        cout << "inf" << endl;
    else
        cout << -ans << endl;

    return 0;
}


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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    long long ans = 0;

    unordered_map<string, int> dict;
    for (size_t i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if (dict[s] == 0) dict[s]++;
        else {
            ans += dict[s];
            dict[s]++;
        }
    }

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


Measured memory_bytes: 10372
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N, M;
    cin >> N >> M;
    int A;
    int sum = 0;
    rep(i,M) {
        cin >> A;
        sum += A;
    }

    if (N < sum) cout << -1 << endl;
    else cout << (N - sum) << endl;
    
    return 0;
}

Measured memory_bytes: 3636
import math
A, B, H, M = map(int, input().split())
D = [(30*H) + (0.5*M), 6*M]
N = max(D) - min(D)
C = math.cos(math.radians(N))
sans = (A**2 + B**2) - (2*A*B*C)
ans = math.sqrt(sans)
print(ans)

Measured memory_bytes: 9384
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long A[][] = new long[N][2];
		for(int i = 0; i < N; i++) {
			A[i][0] = sc.nextLong();
			A[i][1] = sc.nextLong();
		}
		
		Arrays.sort(A, Comparator.comparingLong(o -> o[0]));
		int cnt = 0;
		long ans = 0;
		int c = 0;
		while(cnt < M) {
			if(cnt + A[c][1] < M) {
				cnt += A[c][1];
				ans += A[c][0] * A[c][1];
				c++;
			} else {
				ans += A[c][0] * (M - cnt);
				break;
			}
			//System.out.println(ans);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 92932
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll r[105], c[105], DP[105][105];

ll Calc(int L, int R){
  if (DP[L][R] != 0) return DP[L][R];
  if (L == R) return DP[L][R] = 0;

  ll ans = INF;
  for (int k = L; k < R; k++){
    ll now = r[L] * c[k] * c[R];
    now += Calc(L, k) + Calc(k + 1, R);
    ans = min(now, ans);
  }
  
  return DP[L][R] = ans;
}

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> r[i] >> c[i]; 
  cout << Calc(0, N - 1) << endl;
  return 0;
}



Measured memory_bytes: 3152
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100005;

i64 n;

i64 a[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    for (i64 i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a, a + n);

    i64 R = 0;
    for (i64 i = 0; i < n; i++) {
        for (i64 j = i + 1; j < n; j++) {
            auto imin = upper_bound(a + j + 1, a + n, a[j] - a[i]);
            auto imax = lower_bound(a + j + 1, a + n, a[i] + a[j]);
            //cerr << imin << " " << imax << endl;
            R += max(0ll, (i64)(imax - imin));
        }
    }

    cout << R;
    return 0;
}

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

int main()
{
  string S;
  int K;
  cin >> S >> K;
  int non1_index = -1;
  int first_non1 = -1;
  int digit = S.size();
  rep(i, min(K, digit))
  {
    if (S[i] != '1')
    {
      cout << S[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}

Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
#
import sys


def solve(c):
  if c == 'A':
    return 'T'
  elif c == 'T':
    return 'A'
  elif c == 'G':
    return 'C'
  elif c == 'C':
    return 'G'

c = str(input())[0]
print(solve(c))


Measured memory_bytes: 38256
#include "stdio.h"


int main()
{
	int a = 0;
	int b = 0;
	int c = 0;
	scanf("%d%d%d", &a, &b, &c);
	if (a + b + c == 17)
	{
		printf("YES");
	}
	else
	{
		printf("NO");
	}

}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2e5+10;
int head[N],nxt[N<<1],n,a[N];
int vis[N],ex[N];
ll K;
int stk[N],top;
int main() {
	 rd(n),rd(K);
	 for(int i=0;i<n;++i) rd(a[i]);
	 for(int i=n-1;i>=0;--i) head[a[i]]=n+i;
	 for(int i=n-1;i>=0;--i) {
	 	nxt[i]=head[a[i]];
	 	head[a[i]]=i;
	}
	memset(vis,-1,sizeof(vis));
	int cnt=0,cur=0;
	vis[cur]=cnt;
	while(true) {
		cur=nxt[cur]+1;
		cnt+=cur/n,cur%=n;
		if(vis[cur]!=-1) {
			break;
		}
		vis[cur]=cnt;
	}
//	cout<<cur<<' '<<vis[cur]<<' '<<cnt<<endl;
	K-=vis[cur];
	K%=cnt-vis[cur];
	cnt=0;
//	cout<<K<<endl;
	while(true) {
		int v=nxt[cur]+1;
		int cnt1=cnt+v/n;
		if(cnt1>=K) break;
		cur=v%n,cnt=cnt1;
//		cout<<cur<<'-'<<cnt<<endl;
	}
//	cout<<cur<<' '<<cnt<<endl;
	for(int j=cnt+1;j<=K;++j) {
		for(int i=(j==cnt+1)?cur:0;i<n;++i) {
			if(ex[a[i]]) {
				do ex[stk[top]]=0;
				while(stk[top--]!=a[i]);
			}
			else ex[stk[++top]=a[i]]=1;
		}
	}
	for(int i=1;i<=top;++i) printf("%d ",stk[i]);
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int x;
	cin>>x;
	vector<int> a(n);
	long long sum=0;
	for(int i=0;i<n;i++){
		
		cin>>a[i];
		sum+=a[i];
	}
	long long ans;
	if(x-sum<0)
		ans=0;
	else{
		ans=n;
		sort(a.begin(),a.end());
		x-=sum;
		ans+=x/a[0];
			
		
	}
		cout<<ans<<endl;
		
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cerr<<v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll dp[100][202020];

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

    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
        A[i]--;
    }

    REP(i, N) dp[0][i] = A[i];

    REP(i, 80){
        REP(j, N){
            dp[i+1][j] = dp[i][dp[i][j]];
        }
    }

    ll now = 0;
    REP(i, 63){
        if(K>>i & 1) now = dp[i][now];
    }

    cout << now+1 << endl;

    return 0;
}

Measured memory_bytes: 131756
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;

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

  cout << 6 - a - b << endl;
  return 0;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var H = one[0];
  var N = one[1];
  var list = myconv(next(),4);
  var count = 0;
  for(var i = 0; i < N; i++){
    count = count + list[i];
  }
  if(count >= H){
     myout("Yes");
  }else{
     myout("No");
  }
  
}

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

#define rep(i, a) for (int i = 0; i < (int)a; ++i)
#define REP(i, a, b) for (int i = (a); i < (int)b; ++i)

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

void Main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> score(n, 0);
  rep(i, n-1) if (h[i+1] <= h[i]) score[i+1] = score[i] + 1;
  int ans = 0;
  rep(i, n) ans = max(ans, score[i]);
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

using namespace std;

int main()
{
	int n;

	while(cin >> n && n)
	{
		int name,m[4],s[4];
		int ans[3]={};
		int max1=0,max2=0,min1=1000000,min2=1000000;
		int list[100000]={};
		int namelist[100000]={};
		int count=0;

		while(n--)
		{
			cin >> name;

			for(int i=0;i<4;i++)
			{
				cin >>m[i]>>s[i];
				list[count]+=m[i]*60+s[i];
			}

			namelist[count]=name;

			if(min1>=list[count])
			{
				min1=min(list[count],min1);
				ans[0]=name;
			}
			max1=max(max1,list[count]);

			count++;
		}

		for(int i=0;i<count;i++)
		{
			if( list[i]>=max2  && max1!=list[i])
			{
				max2=list[i];
				ans[2]=namelist[i];
			}
			if( list[i]<=min2  && min1!=list[i])
			{
				min2=list[i];
				ans[1]=namelist[i];
			}
		}
		for(int i=0;i<3;i++)cout << ans[i] <<endl;
	}

    return 0;
}

Measured memory_bytes: 1944
<?php
$num=trim(fgets(STDIN));
$array=explode(" ",trim(fgets(STDIN)));
rsort($array);
$ans=$array[0];
$i=2;
$j=1;
while($i<$num){
  if($i%2==0){
    $ans+=$array[$i-$j];
  }else{
    $ans+=$array[$i-$j-1];
    ++$j;
  }
  ++$i;
}
echo $ans;
?>

Measured memory_bytes: 32064
using System;
using System.Linq;

namespace ConsoleApp25
{
    class Program
    {
        static void Main(string[] args)
        {
           int n = int.Parse(Console.ReadLine());
            string[] arr = new string[n];
            for (int i = 0; i < n; i++)
            {
                arr[i] = Console.ReadLine();
            }
            string [] disArr = arr.Distinct().ToArray();
            Console.WriteLine(disArr.Length);
        }
    }
}


Measured memory_bytes: 49272
def countStr(x,S):
    c = 0
    for i, s in enumerate(S):
        if i % 2 == x:
            if s == "0":
                c += 1
        else:
            if s == "1":
                c += 1
    return c

S = input()
print(min(countStr(0,S),countStr(1,S)))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int X{}; cin >> X;
  cout
    << (X == 5 || std::abs(X - 5) == 2 ? "YES" : "NO")
    << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
  double w, h, x, y;
  int ans=0;
  scanf("%lf %lf %lf %lf", &w, &h, &x, &y);
  if(w/2.0 == x && h/2.0 == y)
    ans = 1;
  printf("%lf %d\n", w*h/2.0, ans);
  return 0;
}


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


bool Check(int x, int y, int z) {
	if (x + y > z && x + z > y && z + y > x) {
		return true;
	}
	else {
		return false;
	}
}

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


	int cnt = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			for (int h = j + 1; h < N; h++) {

				if (data[i] == data[j] || data[i] == data[h] || data[j] == data[h]) {
					continue;
				}

				if (Check(data[i], data[j], data[h])) {
					cnt += 1;
				}
			}

		}
	}
	cout << cnt << endl;
	return 0;


}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
 int N, A, B;
 cin>>N>>A>>B;
 vec_int h(N);
 rep(i,N)cin>>h.at(i);

//一撃で終わる場合
int index=0;
int index2=0;
int flag = 1;
for(int i=0;i<N;i++){
    if(h.at(i)>B){
        if(h.at(i)>A){
            flag=0;
        }
        index2++;
    }else{
        index++;
    }
}
if(index==N || (index==N-1 && index2==1)){
    cout<<1<<endl;
    return 0;
}



int upper_num = 2*pow(10,9);
int lower_num = 1;

while(lower_num+1<upper_num){
    int med = (lower_num+upper_num)/2;
    
    int kaisuu = 0;
    for(int i=0;i<N;i++){
        if(h.at(i)-B*med>0){
            kaisuu += (h.at(i)-B*med)/(A-B);
            if((h.at(i)-B*med)%(A-B)!=0){
                kaisuu += 1;
            }
        }
    }
    if(kaisuu<=med){
        upper_num = med;
    }else{
        lower_num = med;
    }
}
cout<<upper_num<<endl;


    return 0;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  string s;
  cin >> s;
  string ss="hi";
  if(s.size()%2) {
    cout << "No" << endl;
    return 0;
  }
  for(ll i=0;i<s.size()-1;i+=2) {
    if(s.substr(i,2)!=ss) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
def getMedian(data):
    N = len(data)
    data.sort()
    if N % 2 == 0:
        median1 = N / 2
        median2 = N / 2 + 1
        median1 = int(median1) - 1
        median2 = int(median2) - 1
        return int((data[median1] + data[median2]) / 2)
    else:
        median = (N + 1) / 2
        median = int(median) - 1
        return int(data[median])


int(input())
A = list(map(int, input().split()))
B = []
for i in range(len(A)):
    B.append(A[i] - i - 1)

median = getMedian(B)

ans = 0

for b in B:
    ans += abs(b - median)

print(ans)


Measured memory_bytes: 25748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<int> H(N);
    rep(i,N)cin>>H.at(i);
    int ans=0;
    rep(i,N){
        if(!i)ans+=H.at(i);
        else{
            if(H.at(i)>H.at(i-1)){
                ans+=H.at(i)-H.at(i-1);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
from itertools import combinations

n = int(input())
S = [input() for _ in range(n)]

memo = {}
for i in 'MARCH':
    memo[i] = 0

for i in S:
    if i[0] in 'MARCH':
        memo[i[0]] += 1

ans = 0
for i, j, k in combinations('MARCH', 3):
    ans += memo[i] * memo[j] * memo[k]
print(ans)

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

int main() {
    string str;
    int num[26], x;
    char ch;

    for(int i=0; i<26; i++) {
	num[i] = 0;
    }

    while(cin >> str) {
	for(int i=0; i<str.length(); i++) {
	    str[i] = tolower(str[i]);
	    if(str[i] >= 'a' && str[i] <= 'z') {
		x = str[i] - 'a';
		num[x]++;
	    }
	}
    }

    for(int i=0; i<26; i++) {
	ch = 'a' + i;
	cout << ch << " : " << num[i] << endl;
    }
}

Measured memory_bytes: 1180