akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		caseL:
		while(true){
			int N = Integer.parseInt(br.readLine());
			if(N==0)
				break;
			String[] l = br.readLine().split(" ");
			HashMap<String, Integer> map = new HashMap<>();
			for(String s:l){
				if(map.containsKey(s))
					map.put(s, map.get(s)+1);
				else
					map.put(s, 1);
			}
			int max = Integer.MIN_VALUE;
			for(String s:l){
				max = Math.max(max, map.get(s));
				if(max>l.length/2){
					System.out.println(s);
					continue caseL;
				}
			}
			System.out.println("NO COLOR");
		}
	}
}

Measured memory_bytes: 247316
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

int colors[200005];
int c[200005];

const int mod = 1000000007;

void add(int& a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}

int main() {

    memset(colors, 0, sizeof(colors));
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) cin >> c[i];

    int dp = 1;
    for (int i = 0; i < n; i++) {
        int x = c[i];
        if (i > 0 && c[i] == c[i - 1]) continue;

        add(colors[x], dp);
        dp = colors[x];
    }

    cout << dp;


}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    
    
    int n,q,a,b,c;
    cin >> n >> q;
    
    vector<stack<int> > vec(n);
    
    rep(i,0,q){
        cin >> a;
        
        if(a == 0){
            cin >> b >> c;
            vec[b].push(c);
        }
        else if(a == 1){
            cin >> b;
            if(!vec[b].empty()) cout << vec[b].top() << endl;
        }
        else{
            cin >> b;
            if(!vec[b].empty()) vec[b].pop();
        }
    }
    return 0;
}


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

namespace agc019_a
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long n = long.Parse(Console.ReadLine());
            long ret = 0;
            if (n % 2 == 1)
            {
                int a = 4;
                long amin = long.MaxValue;
                for (int i = 0; i < 3; i++)
                {
                    amin = Math.Min(amin, x[i] * a);
                    a /= 2;
                }
                ret += amin;
            }
            long b = 8;
            long bmin = long.MaxValue;
            for (int i = 0; i < 4; i++)
            {
                bmin = Math.Min(bmin, x[i] * b);
                b /= 2;
            }
            ret += n / 2 * bmin;
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13268
n=int(input())
info=[]
time=0
ok=0
for i in range(n):
    a,b=map(int,input().split())
    info.append([a,b])
info2=sorted(info,key=lambda x:x[1])
for i in range(n):
    time+=info2[i][0]
    if time>info2[i][1]:
        ok=1
        break
print("Yes" if ok==0 else "No")

Measured memory_bytes: 39700
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
ll c[200001]={};
ll cb[200001]={};
ll calc(ll p1,ll q1){
	ll r=(c[p1]*cb[q1])%1000000007;
	r=(r*cb[p1-q1])%1000000007;
	return r;
}
int main() {
	int n;
	cin>>n;
	int a[100]={};
	for(int i=0;i<n;++i){
		cin>>a[i];
	}
	sort(a,a+n);
	int r=1000000007;
	for(int i=a[0];i<=a[n-1];++i){
		int t=0;
		for(int j=0;j<n;++j){
			t+=(a[j]-i)*(a[j]-i);
		}
		r=min(r,t);
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int A,B;
    int s, d, c;

    scanf("%d %d", &A, &B);


    s = A+B;
    d = A-B;
    c = A*B;
    
    if(s >= d){
        if(s>=c){
            printf("%d",s);
        }else{
            printf("%d",c);
        }
    }else if(d >= c){
        if(d >= s){
            printf("%d",d);
        }else{
            printf("%d",s);
        }
    }else{
        if(c >= d){
            printf("%d",c);
        }else{
            printf("%d",d);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define int ll
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define db double
#define ld long db
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline int read(){
	ri x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}

signed main()
{
	ri x=read(),y=read(),k=read();
	if(x<=k)k-=x,x=0;
	else x-=k,k=0;
	if(y<=k)y=0;
	else y-=k;
	cout<<x<<' '<<y;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
ll INF=1000000000000000;
ll mod=1000000007;
ll i,j,k,l;

int main(){
    ll n,m;cin>>n>>m;//m個は壊れている
    vector<ll> a(m),step(n+1),dp(n+1,0);
    //a:崩壊　step:階段の状態 　dp:i段目に到達するまでの行き方
    for(i=0;i<m;i++){cin>>a[i];}

    for(i=1;i<m;i++){//連続で崩壊していたら渡れない
        if(a[i]==a[i-1]+1){
            cout<<0<<endl;
            return 0;
        }
    }

    for(i=0;i<m;i++){
        step[a[i]]=1;//崩壊なら1 渡れるなら0
    }

    dp[0]=1;dp[1]=1;
    for(i=2;i<=n;i++){//崩壊しているところを通らないようなfibo
        if(!step[i-1]){
            dp[i]+=dp[i-1];
            dp[i]%=mod;
        }
        if(!step[i-2]){
            dp[i]+=dp[i-2];
            dp[i]%=mod;
        }
    }

    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){
  int a, b, Ia, Ib=1, ans;
  cin >> a >> b;
  for(int i=2;i<499500;i++){
    Ib+=i;
    Ia=Ib-i;
    if(Ia-a==Ib-b){
      ans=Ia-a;
      if(ans<0)ans*=-1;
      cout << ans << endl;
      return 0;
    }
  }
}


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

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

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> m;
    int size = 0;

    REP(i, N) {
        int n;
        cin >> n;
        if (m.find(n) == m.end()) {
            m[n] = 1;
            size++;
        }
    }

    cout << size << endl;

    return 0;
}


Measured memory_bytes: 256
K = int(input())
from queue import Queue
q = Queue()
for i in range(9):
    q.put(i+1)
num = 0
for i in range(K):
    num = q.get()
    if num%10 != 0:
        q.put(num*10+num%10-1)
    q.put(num*10+num%10)
    if num%10 != 9:
        q.put(num*10+num%10+1)
print(num)

Measured memory_bytes: 57428
using System;

namespace Ubiquity
{
    class Program
    {
        const long mod = 1000000007;
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            // 桁が大きいので、毎回modで割る必要がある
            // Math.Powで求めると桁が多すぎる

            long ans = Pow(10, N) - Pow(9, N) - Pow(9, N) + Pow(8, N);
            ans %= mod;
            Console.WriteLine((ans + mod) % mod);
        }

        public static long Pow(long x, long y)
        {
            long result = 1;
            if (y > 1)
            {
                for (int i = 0; i < y; i++)
                {
                    result = result * x % mod;
                }
            }
            return result;
        }
    }
}


Measured memory_bytes: 27492
#include<bits/stdc++.h>
#define ll long long
using namespace std;

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

    string s;
    cin>>s;
    string s_reverse = s;
    reverse(s_reverse.begin(),s_reverse.end());

    if(s == s_reverse){

    int N = s.size();
    int sub_1 = (N-2)/2;
    int sub_2 = (N+4)/2;
    string str2 = s.substr(0,sub_1+1);
    string str3 = s.substr (sub_2-1,N-1);
    string revers_s2 = str2;reverse(str2.begin(),str2.end());
    string revers_s3 = str3;reverse(str3.begin(),str3.end());
    

    if(str2 == revers_s2){
        if(str3 == revers_s3 )
            cout<<"Yes";
            return 0;
    }
}

    cout<<"No";

    return 0;

    
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 24 14:37:00 2020

@author: matsui
"""

N,M=map(int,input().split())

g=dict()
h=[0]*(N+1)
for i in range(1,N+1):
    g[i]=[]
  
for i in range(M):
    x,y=map(int,input().split())
    g[x].append(y)
    h[y]+=1
     
st=[]

for i in range(1,N+1):
    if h[i]==0: 
        st.append(i)
    
ans=[]
dp=[0]*(N+1)

while(len(st)):
    i=st[0]
    st.remove(st[0])
    
    ans.append(i)
    
    for j in g[i]:
        h[j]-=1
        if h[j]==0: 
            st.append(j)
            if dp[i]+1>dp[j]: 
                dp[j]=dp[i]+1
        
#print(ans)
print(max(dp))

Measured memory_bytes: 32692
/**
 *    author:  FromDihPout
 *    created: 2020-06-24
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long x;
    cin >> x;
    
    long long ans = x / 11;
    long long curr = ans * 11;
    if (x == 0) {
        cout << 1 << endl;
    }
    else if (x - curr == 0) {
        cout << ans * 2 << endl;
    }
    else if (x - curr <= 6) {
        cout << ans * 2 + 1 << endl;
    }
    else {
        cout << ans * 2 + 2 << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, k;
// string s;

int main() {
    cin >> n >> k;
    Vi a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));

    int mini = 1e9;
    REP(i, n) {
        if (i+k-1 == n) break;
        mini = min(mini, a[i+k-1] - a[i]);
    }
    cout << mini << '\n';

    return 0;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = []
    p = 0
    for e in a:
        if p != e:
            b.append(e)
        p = e
    a = b
    n = len(b)

    ans = 0
    i = 0
    while i < n:
        ans += 1
        if i + 1 == n: break
        else:
            if a[i] < a[i+1]:
                while i + 1 < n and a[i] < a[i+1]:
                    i += 1
                i += 1
            else:
                while i + 1 < n and a[i] > a[i+1]:
                    i += 1
                i += 1
    print(ans)



    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


Measured memory_bytes: 20568
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())
from collections import Counter

n = ii()
a = li()
c0 = Counter(a[::2])
c1 = Counter(a[1::2])
x0, y0 = c0.most_common(1)[0]
x1, y1 = c1.most_common(1)[0]
if x0 != x1:
    ans = n - y0 - y1
else:
    y00 = c0.most_common(2)[1][1] if len(c0) > 1 else 0
    y11 = c1.most_common(2)[1][1] if len(c1) > 1 else 0
    ans = min(n - y0 - y11, n - y00 - y1)
print(ans)


Measured memory_bytes: 18648
L, R = map(int, input().split())
LAW = 2019
l = L % LAW
r = R % LAW
if R - L >= LAW:
  ans = 0
elif l >= r:
  ans = 0
else:
  candidates = list(range(l, r+1))
  mods = []
  for i in range(len(candidates)):
    for j in range(i+1, len(candidates)):
      mods.append((candidates[i] * candidates[j]) % LAW)
  ans = min(mods)
print(ans)

Measured memory_bytes: 75436
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int st[10000],b,c,n,o;
int maxx,minn=10000,i,ans,now,t;
char ch[10000];
int main()
{
	st[0]=-1;
	scanf("%d",&n);
	scanf("%s",ch);
	int len=strlen(ch);
	for (i=0;i<len;i++)
	{
		if (ch[i]=='(') now=0;
		else now=1;
		if (now==1)
		{
			if (st[t]==0) t--;else st[++t]=1;
		}
		else st[++t]=0;
	}
	for (i=1;i<=t;i++)
	{
		if (st[i]==0) break;
	}
	ans=i-1;
	for (i=1;i<=ans;i++) cout<<'(';
	cout<<ch;
	for (i=1;i<=t-ans;i++)cout<<')';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#define N (100000+1000)
using namespace std;

struct Edge{int to,next,len;}edge[N<<1];
int head[N],num_edge;
long long n,m,cnt[4],flag,col[N];
long long ans,sum,u,v;

void add(int u,int v,int l)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	edge[num_edge].len=l;
	head[u]=num_edge;
}

void Dfs(int x)
{
	cnt[col[x]]++;
	for (int i=head[x]; i; i=edge[i].next)
	{
		if (edge[i].len==1) sum++;
		if (col[edge[i].to]==-1)
		{
			col[edge[i].to]=(col[x]+edge[i].len)%3;
			Dfs(edge[i].to);
		}
		else if (col[edge[i].to]!=(col[x]+edge[i].len)%3)
			flag=1;
	}
	
}

int main()
{
	scanf("%lld%lld",&n,&m);
	for (int i=1; i<=m; ++i)
	{
		scanf("%lld%lld",&u,&v);
		add(u,v,1); add(v,u,2);
	}
	memset(col,-1,sizeof(col));
	for (int i=1; i<=n; ++i)
		if (col[i]==-1)
		{
			sum=cnt[0]=cnt[1]=cnt[2]=flag=0;
			col[i]=0; Dfs(i);
			if (flag)
			{
				long long t=cnt[0]+cnt[1]+cnt[2];
				ans+=t*t; continue;
			}
			if ((!cnt[0]) || (!cnt[1]) || (!cnt[2]))
			{
				ans+=sum;
				continue;
			}
			ans+=cnt[0]*cnt[1]+cnt[1]*cnt[2]+cnt[2]*cnt[0];
		}
	printf("%lld\n",ans);
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    int H = 0;
    rep(i, n){
        cin >> h[i];
        H = max(h[i], H);
    }
    int cnt = 0;
    rep(i,H){
        int tmp = 0;
        rep(j,n){
            if(h[j]==0){
                if(tmp !=0){
                    cnt++;
                }
                tmp = 0;
            }else{
                tmp = h[j];
                h[j]--;
            }
        }
        if(tmp!=0)
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<0<<endl;
        return 0;
    }
    if(n==1){
        if(a!=b)cout<<0<<endl;
        else cout<<1<<endl;
    }
    else cout<<((n-2)*(b-a))+1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int r = sc.nextInt();
        int D = sc.nextInt();
        int x_2000 = sc.nextInt();

        for (int i = 2001; i <= 2010; i++) {
            System.out.println(amount(r, i, D, x_2000));
        }

        sc.close();

    }

    public static int amount(int r, int i, int D, int x_2000) {
        if (i == 2000) {
            return x_2000;
        }
        return r * amount(r, i - 1, D, x_2000) - D;
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool check(int target, const vector<int> v){
	int dp[2][20000];
	fill(dp[0], dp[0]+20000, 0);
	dp[0][10000] = 1;
	for(int i=0;i<v.size();i++){
		int cur = i%2, next = 1-cur;
		fill(dp[next], dp[next]+20000, 0);
		for(int j=0;j<20000;j++){
			if(!dp[cur][j]) continue;
			dp[next][j-v[i]] = 1;
			dp[next][j+v[i]] = 1;
		}
	}
	return dp[v.size()%2][10000 + target];
}

int main(){
	string S;
	while(cin >> S){
		int x, y; cin >> x >> y;
		int idx = 0, turn = 0, first = 1;
		vector<int> seg[2];
		while(idx < S.size()){
			int p = 0;
			while(idx < S.size() && S[idx] == 'F'){ ++p; ++idx; }
			if(first){
				x -= p;
				first = 0;
			} else {
				seg[turn].push_back(p);
			}
			++idx;
			turn = 1 - turn;
		}
		cout << ((check(x, seg[0]) && check(y, seg[1])) ? "Yes" : "No") << endl;
	}
}


Measured memory_bytes: 512
#横にn個入力
n, m = map(int, input().split())
c = []
for i in range(n):#h:高さ
    c.append([int(m) for m in input().split()])

numset = set()
for i in range(1, 31):
    numset.add(i)

for i in range(n):
    numset= set(c[i][1:]) & numset
print(len(numset))

Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int cnt[2019];

int main(void){
    string s;
    int ic;
    int nds;
    int temp;
    int ans=0;
    cin>>s;
    reverse(s.begin(),s.end());
    for(int i=0;i<2019;i++){
        cnt[i]=0;
    }
    cnt[0]=1;
    temp=0;
    nds=1;
    for(char c:s){
        ic=(int)(c-'0');
        temp += ic*nds;
        nds *= 10;
        temp %= 2019;
        nds %= 2019;
        cnt[temp]++;
    }
    for(int x:cnt){
        ans+=x * (x-1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3696
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())

n,r = [int(i) for i in readline().split()]


if n >= 10:
    print(r)
else:
    print(r+100*(10-n))










Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(string x)
{
  ll l=x.length();
  ll f=0;
  for(ll i=0;i<l;i++)
  {
    f+=(x[i]-'0');
  }
  if(f%3)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}
int main()
{
  string s;
  cin>>s;
  solve(s);
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define N 200005
#define oo (1<<30)
using namespace std;
vector<int> G[N],V[N];
int n,f[20][N],d[N],X,Y,ans,tag[N];
struct edge{ int x,y;}E[N];
void dfs(int t,int fa)
{
	int i; f[0][t]=fa;
	d[t]=d[fa]+1;
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa) dfs(G[t][i],t);
}
int lca(int x,int y)
{
	int i; if(x==y) return x;
	if(d[x]<d[y]) swap(x,y);
	for(i=19;i>=0;i--)
		if(d[f[i][x]]>=d[y])
			x=f[i][x];
	if(x==y) return x;
	for(i=19;i>=0;i--)
		if(f[i][x]!=f[i][y])
			x=f[i][x],y=f[i][y];
	return f[0][x];
}
int dis(int x,int y){ return d[x]+d[y]-2*d[lca(x,y)];}
void DFS(int t,int fa,int ds)
{
	int i; ans=max(ans,d[t]-1);
	if(tag[t]){ ans=oo; return ;}
	for(i=0;i<V[t].size();i++)
		if(V[t][i]!=fa&&d[V[t][i]]-1>ds)
			DFS(V[t][i],t,ds+1);
}
int main()
{
	int i,x,y;
	scanf("%d %d %d",&n,&X,&Y);
	for(i=1;i<n;i++)
		scanf("%d %d",&E[i].x,&E[i].y);
	for(i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	  }
	dfs(Y,0);
	for(i=1;i<20;i++)
		for(x=1;x<=n;x++)
			f[i][x]=f[i-1][f[i-1][x]];
	for(i=1;i<n;i++){
		x=dis(E[i].x,E[i].y);
		if(x>=3) tag[E[i].x]=tag[E[i].y]=1;
		V[E[i].x].push_back(E[i].y);
		V[E[i].y].push_back(E[i].x);
	  }
	DFS(X,0,1);
	printf("%d",ans==oo ? -1 : ans*2);
	return 0;
}


Measured memory_bytes: 50304
def main():
    n,d = map(int,input().split(' '))
    x=[]
    for i in range(n):
        x.append(list(map(int,input().split(' '))))
    res = 0
    dis = 0
    for i in range(n):
        for j in range(i,n):
            if i !=j:
                for k in range(d):
                    dis += (x[i][k]-x[j][k])**2
                if dis**0.5%1 ==0:
                    res += 1
                dis = 0
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
n = int(input())
max_ = 10 ** 6 + 10
ans = [2 for _ in range(max_)]
ans[0] = 0
ans[1] = 1
for i in range(2, max_):
    for j in range(i * i, max_, i):
        ans[j] += 2
        if j == i * i:
            ans[j] -= 1

ans_ = 0
for i in range(1, n):
    ans_ += ans[i]
print(ans_)


Measured memory_bytes: 17036
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

#include <cmath>
#include <climits>

using namespace std;

bool cmp(const pair<int, pair<string, int> > &a, const pair<int, pair<string, int> > &b)
{
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }
    else {
        return a.second.second > b.second.second;
    }
}

int main() {
    int n; cin >> n;
    vector< pair<int, pair<string, int> > >vec(n);
    for(int i =0; i < n; ++i){
        string s; cin >> s;
        int p; cin >> p;
        vec[i] = make_pair(i+1, make_pair(s, p) );
    }

    sort(vec.begin(), vec.end(), cmp);

    for(int i =0; i < n; ++i){
        cout << vec[i].first << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n=1,b[10000]={0},c[10000]={0},i,e=0,f=0;
	while(n!=0){
		scanf("%d",&n);
		if(n==0){continue;}
		for(i=0;i<n;i++)
		{
			scanf("%d %d",&b[i],&c[i]);
		}
		for(i=0;i<n;i++)
		{
			if(b[i]>c[i]){e+=(b[i]+c[i]);}
			else if(b[i]<c[i]){f+=(b[i]+c[i]);}
			else{e+=b[i];f+=c[i];}
		}
		printf("%d %d\n",e,f);
		e=0;f=0;
	}
	return 0;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll h,w;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>h>>w;
  vector <string> a(h);
  ll tmp;
  REP(i,h){
    cin >>a[i];
  }
  REP(i,w+2) cout <<'#';
  cout <<endl;
  REP(i,h){
    cout <<'#'<<a[i] <<'#'<<endl;
  };
  REP(i,w+2) cout <<'#';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, debt = 100000;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    debt = debt * 105 / 100;
    if (debt % 1000) {
      debt = (debt / 1000 + 1) * 1000;
    } 
  }
  printf("%d\n", debt);
  return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる
//時間を意識しろ
//コードテストちゃんとして
//画面とにらめっこするな書け
//WA出すたびにABCは五億円払え
//わからない問題はとばせ
//躊躇なくぐぐれ

//ここから
int main(){
    ll H,W;
    cin>>H>>W;
    vector<bool> h(H,false);
    vector<bool> w(W,false);
    vector<vector<char>> grid(W,vector<char>(H));
    rep(i,H){
        rep(j,W){
            cin>>grid.at(j).at(i);
        }
    }
    rep(i,W){
        rep(j,H){
            if(grid.at(i).at(j)=='#'){
                h.at(j)=true;
                w.at(i)=true;
            }
        }
    }
    rep(i,H){
        bool check=false;
        rep(j,W){
            if(w.at(j)&&h.at(i)){
                cout<<grid.at(j).at(i);
                check=true;
            }
            if(j==W-1&&check){
                cout<<endl;
            }
            }
        }
    }



Measured memory_bytes: 256
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    N, K = [int(x) for x in input().split()]
    if K >= N:
        return 0
    H = [int(x) for x in input().split()]
    ret = 0
    H.sort()
    for i in range(N - K):
        ret += H[i]
    return ret


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 43980
def f(N):
  output=[]
  temp=int(pow(N, 1/2))+1
  for i in range(1, temp):
    if N%i==0:
      j=N//i
      output.append([i, j])
      
  return output
    

N=int(input())
nums=f(N)

temp=len(nums)
cand=[]
for temp in nums:
  cand.append(temp[0]+temp[1]-2)
  
print(min(cand))

Measured memory_bytes: 39152
//
//  main.cpp
//  test130
//
//  Created by  on 2019/06/16.
//  Copyright © 2 All rights reserved.
//
//
//  main.cpp
//  new
//
//  Created on 2019/06/09.
//  Copyright  All rights reserved.
//

// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define int long long
using namespace std;

int n;

signed main(){
    cin>>n;
    cout<<1110-n<<endl;
    
}






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

using namespace std;
typedef long long int ll;

#define INF (1e9)

int K, S;

int main() {
    cin >> K >> S;

    int ans = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            if (0 <= S - i - j and S - i - j <= K)
                ans++;
        }
    }

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


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

#define ff first
#define ss second

const int N = 20 + 10, inf = 1e9;
string s[N];
int height[N][N], ans, n, m, dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};

bool isVal(int x, int y) {
	return x >= 0 && y >= 0 && x < n && y < m && s[x][y] == '.';
}

void bfs(int x, int y) {
  	for (int i = 0; i < N; i++)
      	for (int j = 0; j < N; j++)
          	height[i][j] = inf;
 	height[x][y] = 0;
  	queue<pair<int, int>> q;
  	q.push({x, y});
  	while (q.size()) {
		pair<int, int> v = q.front();
      	q.pop();
      	for (int i = 0; i < 4; i++)
          	if (isVal(v.ff + dx[i], v.ss + dy[i]) && height[v.ff + dx[i]][v.ss + dy[i]] == inf) {
				height[v.ff + dx[i]][v.ss + dy[i]] = height[v.ff][v.ss] + 1;
              	q.push({v.ff + dx[i], v.ss + dy[i]});
            }
    }
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  	cin >> n >> m;
  	for (int i = 0; i < n; i++)
      	cin >> s[i];
	for (int i = 0; i < n; i++)
      	for (int j = 0; j < m; j++) {
        	if (s[i][j] == '#')
            	continue;
          	bfs(i, j);
          	for (int g = 0; g < n; g++)
              	for (int h = 0; h < m; h++)
                  	if (height[g][h] != inf)
                      	ans = max(height[g][h], ans);
        }
 	cout << ans << "\n";
}

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

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) 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;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

vector<ll> yakusu(ll x){
    vector<ll> y;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            if(i*i==x) y.push_back(i);
            else{
                y.push_back(i);
                y.push_back(x/i);
            }
        }
    }
    sort(y.begin(),y.end());
    return y;
}

mint f(ll n,ll k) {
  if (n == 0) return 1;
  mint x = f(n/2,k);
  x *= x;
  if (n%2 == 1) x *= k;
  return x;
}

int main(){
    ll n,k;
    cin >> n >> k;
    vector<mint> a(k+1);
    for(ll i=k;i>0;i--){
        a[i]=f(n,k/i);
        for(ll j=2*i;j<=k;j+=i){
            a[i]-=a[j];
        }
    }
    
    mint ans=0;
    
    for(ll i=1;i<=k;i++){
        ans+=a[i]*i;
    }
    
    cout << ans << endl;
    
    return 0;
}











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

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

  
}


Measured memory_bytes: 256
n, a, cost = int(input()), list(map(int, input().split())), 0
b = sorted(a)
b0 = b[0]
for i in range(n - 1):
    bi, tmp_cost, count = b[i], 0, 0
    si = a.index(bi)
    while si != i:
        bsi = b[si]
        sj = a.index(bsi)
        a[si], a[sj] = bsi, bi
        tmp_cost += bi + bsi
        count += 1
        si = sj
    if count:
        cost += min(tmp_cost, (bi + b0) * 2 + tmp_cost - (bi - b0) * count)
print(cost)

Measured memory_bytes: 7764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
    int n;
    char tmp[100];
    int tmp_n;

    int cnt=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        sprintf(tmp,"%d",i);
        tmp_n=strlen(tmp);
        if(tmp_n%2){
            cnt++;
        }
    }

    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var r, g, b, k int
	fmt.Scanf("%d %d %d", &r, &g, &b)
	fmt.Scanf("%d", &k)

	for i := 1; i <= k; i++ {
		if r >= g {
			g = 2 * g
			continue
		}
		if g >= b {
			b = 2 * b
			continue
		}
	}

	if r < g && g < b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")

	}

}


Measured memory_bytes: 1832
a=[list(map(int,input().split()))for i in range(3)]
cnt=[0,0,0,0]
for i in range(3):
    cnt[a[i][0]-1]+=1
    cnt[a[i][1]-1]+=1
flag=False
for i in range(4):
    if cnt[i]==3:
        flag=True
print("NO") if flag else print("YES")

Measured memory_bytes: 3064
import numpy as np
n, targw = map(int,input().split())
w = [0 for _ in range(n)]
v = [0 for _ in range(n)]
for i in range(n):
	w[i], v[i] = map(int,input().split())
"""
定義
dp[i] := v == i のときのwが最小なるもの.
"""
dp = np.full(100001, targw+1, dtype=np.int64)
dp[0] = 0
for i in range(n):
	dp[v[i]:] = np.minimum(dp[:-v[i]]+w[i], dp[v[i]:])
print(np.where(dp <= targw)[0][-1])

Measured memory_bytes: 29104
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a=0,b=0,c=0,d,n,sa[1];
string s[11000];
signed main()
{
	cin>>n;
	rep(i,n){
		cin>>s[i];
		rep(j,s[i].size()-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B'){
				a++;
			}
		}
		if(s[i][s[i].size()-1]=='A'){
			b++;
		}
		if(s[i][0]=='B'){
			c++;
		}
	}
	if((b==0&&c==0)||b!=c){
		cout<<a+min(b,c);
		return 0;
	}else{
		rep(i,n){
			if(s[i][0]=='B'&&s[i][s[i].size()-1]!='A'){
				cout<<a+min(b,c);
				return 0;
			}
		}
		cout<<a-1+min(b,c);
	}
}

Measured memory_bytes: 896
//Meri hr baat bs yaad hai tumhari , mera apna koi kissa nhi!!
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define md 1000000007
double PI=3.1415926535;
const int N =  (int)(1 * 1e6 + 10);

using namespace std;


int main()


{
    ll n , rem;
    cin>>n;
    string s;

    char a[26]={'z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y'};
    while(n)
    {
        rem=n%26;
        s+=a[rem];
        if(n>1)n--;
        n=n/26;
        
        
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string S, T;
    std::cin >> S >> T;

    std::vector<int> s(26, -1);
    std::vector<int> t(26, -1);

    bool flag = true;
    for (int i = 0; i < S.size(); i++) {
        int s_char = S[i] - 'a';
        int t_char = T[i] - 'a';
        
        if (s[s_char] != -1 && s[s_char] != t_char) {
            flag = false;
            break;
        }

        s[s_char] = t_char;
        if (t[t_char] != -1 && t[t_char] != s_char) {
            flag = false;
            break;
        }

        t[t_char] = s_char;
    }

    if (flag) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 200111

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

ll n, x;
ll l[maxn], u[maxn], b[maxn];
vector<pll> value;

bool check(ll mid){
	ll num = mid / x;
	ll r = mid % x;
	ll aoki = 0;
	ll ans = 0;

	for(int i = 0; i < num; i++){
		int cur = value[i].se;
		ans += value[i].fi;
	}

	for(int i = 0; i < n; i++){
		int cur = value[i].se;
		aoki += b[cur] * l[cur];
	}

	if(ans >= aoki)
		return 1;


	for(int i = 0; i < n; i++){
		int cur = value[i].se;
		ll aoki_cur = aoki;
		ll ans_cur = ans;

		if(i < num){
			if(num < n){
				ans_cur -= value[i].fi;
				ans_cur += value[num].fi;

				if(r > b[cur]){
					ans_cur += b[cur] * l[cur];
					ans_cur += (r - b[cur]) * u[cur];
				}
				else
					ans_cur += r * l[cur];
			}
		}
		else{
			if(r > b[cur]){
				ans_cur += b[cur] * l[cur];
				ans_cur += (r - b[cur]) * u[cur];
			}
			else
				ans_cur += r * l[cur];
		}

		if(ans_cur >= aoki_cur)
			return 1;
	}

	return 0;
}


int main(){
	scanf("%lld%lld", &n, &x);
	for(int i = 0; i < n; i++){
		scanf("%lld%lld%lld", b + i, l + i, u + i);
		ll cur = b[i] * l[i] + (x - b[i]) * u[i];
		value.pb(mp(cur, i));
	}

	sort(value.begin(), value.end());
	reverse(value.begin(), value.end());

	ll left = 0, right = n * x, ans = -1;
	while(left <= right){
		ll mid = (left + right) / 2;
		if(check(mid)){
			ans = mid;
			right = mid - 1;
		}
		else
			left = mid + 1;
	} 

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

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

int main() {
	string S;
	cin >> S;
	
	//先頭に限らず3つ連続する場合もYes
	
	//真ん中2文字をそれぞれ基準にして
	//その左右が同じならYes
	
	int chck=0;
	for(int i=1; i<3; i++){
		bool left = S[i-1] == S[i];
		bool right = S[i] == S[i+1];
		if(left && right) {
          chck =1;
          break;
        }
		else chck=0;
	}
	
	if(chck==1)cout << "Yes";
	else cout << "No";
	
	cout << endl;

	return 0;
}

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

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	long double win=0, roll=(long double)1/(long double)n;
	for (int i=1; i<=n; i++) {
		if (i>=k) {
			win+=roll;
			continue;
		}
		long double hds=roll;
		int c=i;
		while (c<k) {
			hds/=2;
			c*=2;
		}
		win+=hds;
	}
	printf("%.10LF\n", win);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;

int main(void){
  int H1,M1,H2,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int hour = (H2 - H1 - 1)*60;
  int minute;
  if (H2 == H1) {
    minute = M2 - M1;
    hour = 0;
  } else {
    minute = (60 - M1) + M2;
  }
  int answer = hour + minute -K;
  printf("%d\n",answer);
  return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N;
    cin >> N;
    string s;
    map<string,int> m;
    for ( int i = 0; i < N; i++ ) {
        cin >> s;
        m[s]++;
    }
    cout << "AC x " << m["AC"] << "\n";
    cout << "WA x " << m["WA"] << "\n";
    cout << "TLE x " << m["TLE"] << "\n";
    cout << "RE x " << m["RE"] << "\n";
    return 0;
}

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

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	int i, j, k, N, F[101][6][3];
	long long P[101][11];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		for (j = 1; j <= 5; j++) scanf("%d %d", &(F[i][j][1]), &(F[i][j][2]));
	}
	for (i = 1; i <= N; i++) {
		for (j = 0; j <= 10; j++) scanf("%lld", &(P[i][j]));
	}
	
	int flag[11] = {1}, count;
	long long max = -1000000000, tmp;
	while (flag[10] == 0) {
		tmp = 0;
		for (i = 1; i <= N; i++) {
			count = 0;
			for (j = 0; j < 10; j++) if (flag[j] == 1 && F[i][j/2+1][j%2+1] == 1) count++;
			tmp += P[i][count];
		}
		if (tmp > max) max = tmp;
		
		for (i = 0; flag[i] == 1; i++);
		for (flag[i--] = 1; i >= 0; flag[i--] = 0);
	}
	
	printf("%lld\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> count(n);
  ll allb = 0;
  for(int i = 0;i <= n - 1;i++){
    ll a = 0;
    ll b = 0;
    cin >> a >> b;
    count[i] = a + b;
    allb += b;
  }
  sort(count.begin(),count.end());
  ll res = 0;
  /*ll akaisuu = 0;
  akaisuu = n / 2;
  if(n % 2 == 1)akaisuu++;
  cout << akaisuu << endl;*/
  for(int i = n - 1;i >= 0;i--){
    if((n - 1 - i) % 2 == 0)res += count[i];
  }
  //cout << res << endl;
  res -= allb;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>        P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// メイン
int main()
{
	string S;
	cin >> S;
	int maxSize = S.size();
	REP(i, maxSize - 1) {
		if (S[i] == S[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}

		if (i + 2 < maxSize) {
			if (S[i] == S[i + 2]) {
				cout << i + 1<< " " << i + 3 << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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

int main() {
	ll n;
	cin >> n;
	vector<ll> v(5);
	rep(i, 5)
		cin >> v[i];
	ll piv = n;
	ll res = 5;
	rep(i, 5)
		piv = min(piv, v[i]);

	cout << 4 + ll(ceil(n/(double)piv)) << endl;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7
import math
from collections import defaultdict
dic = defaultdict(int)


def factoring(k): #kを因数分解し、素因数とその個数を辞書に入れて返す。
    n = int(math.sqrt(k))+2
    for i in range(2, n):
        count = 0
        while k%i == 0:
            count += 1
            k = k//i
        if count != 0:
            dic[i] += count
    if k != 1: #sqrt(k)までチェックしてもkが1になっていない --> kが素因数
        dic[k] += 1

N = int(input())

for i in range(1, N + 1):
    factoring(i)

ans = 1
for i in dic:
    ans *= (dic[i] + 1)
    ans %= MOD

print (ans)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

//素数判定
template <class T>
bool is_prime(T x){
	for(T i=2;i*i<=x;i++){
		if(x%i==0){
			return false;
		}
	}
	return x!=1;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n=200000;
	vector<ll> sum(n+10,0);
	rep(i,n){
		sum[i+1]=sum[i];
		if((i+1)%2 && is_prime(i+1) && is_prime((i+2)/2)) sum[i+1]++;
	}
	int q;
	cin>>q;
	while(q--){
		int l,r;
		cin>>l>>r;
		cout<<sum[r]-sum[l-1]<<endl;
	}
}

Measured memory_bytes: 4716