akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n,q; cin>>n>>q;
	string s; cin>>s;
	vi vec(n);
	int cnt=0;
	rep(i,1,n){
		if(s[i]=='C' && s[i-1]=='A') cnt++;
		vec[i]=cnt;
	}
	vi ans(n);
	rep(i,0,q){
		int l,r; cin>>l>>r;
		--l; --r;
		ans[i]=vec[r]-vec[l];
	}
	rep(i,0,q) cout<<ans[i]<<endl;
	return 0;
}

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

void dfs(string &s, string sub,
    vector<string> &result, map<char,bool> &changed){
    if(s.size() == sub.size()){
        result.push_back(sub);
    }
    char c = s[sub.size()];
    if(!changed[c] && c != 'z'){
        changed[c] = true;
        dfs(s,sub+char(c+1),result,changed);
        changed[c] = false;
    }
    if(changed[c-1] || c=='a'){
        dfs(s,sub+char(c),result,changed);
    }
}

int main(void){
    string s;
    while(cin>>s, s!="#"){
        vector<string> result;
        map<char,bool> changed;
        dfs(s,"",result,changed);
        sort(all(result));
        int m = result.size();
        cout<<m<<endl;
        rep(i,m){
            if(i<5 || m-5<=i) cout<<result[i]<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <queue>

using namespace std;

int bill[2][101];
int n;

const int d[]={0,1,2};

int search(pair<int,int> pos){

//	pair<int,int> cp=pos;
	bool passed[2][101];
	memset(passed,0,sizeof(passed));
	int cnt=1;

	queue<pair<int,int> > *prv = new queue<pair<int,int> >();
	queue<pair<int,int> > *nxt = new queue<pair<int,int> >();

	while(1){
		if(bill[pos.first][pos.second]==2)
			pos.second--;
		else if(bill[pos.first][pos.second]==1&&bill[pos.first][pos.second+1]==1)
			pos.second++;
		else
			break;
	}

	if(pos.second==n-1)
		return 0;
	prv->push(pos);
	while(prv->size()){
		while(prv->size()){
			pair<int,int> cp=prv->front();
			prv->pop();
			if(passed[cp.first][cp.second])
				continue;
			passed[cp.first][cp.second]=true;
			for(int i = 0; i < 3; i++){
				pair<int,int> np = cp;
				np.first^=1;
				np.second+=d[i];
				if(np.second>=0&&np.second<n&&!passed[np.first][np.second]){
					while(1){
						if(bill[np.first][np.second]==2)
							np.second--;
						else if(bill[np.first][np.second]==1&&bill[np.first][np.second+1]==1)
							np.second++;
						else
							break;
					}
					if(np.second==n-1){
						return cnt;
					}
					if(!passed[np.first][np.second])
						nxt->push(np);
				}
			}
		}
		cnt++;
		swap(prv,nxt);
	}
	return -1;
}

int main(){

	while(cin>>n&&n!=0){
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 101; j++)
				bill[i][j]=-1;
		}
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < n; j++)
				cin>>bill[i][j];
		}
		pair<int,int> pos;
		pos.first=0;
		pos.second=0;
		int minPath=1000000;
		int ret=search(pos);
		if(ret!=-1)
			minPath=min(minPath,ret);
		pos.first=1;
		int tmp=search(pos);
		if(tmp!=-1)
			minPath=min(minPath,tmp);
		if(minPath==1000000)
			cout<<"NA"<<endl;
		else
			cout<<minPath<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
typedef long long i64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 2e5+5;
int n, p[N], q[N], vis[N], ans;
int main()
{
    n = read(); for(int i = 1; i <= n; ++i) p[i] = read(), q[p[i]] = i;
    for(int i = 1, j; i <= n; i = j+1)
    {
        for(j = i; j < n&&q[j+1] > q[j]; ++j);
        ans = max(ans, j-i+1);
    }
    printf("%d\n", n-ans);
    return 0;
}

Measured memory_bytes: 1664
def dfs(A, use, cnt):
    if A > n:
        return cnt
    if use == 0b111:
        cnt.append(1)

    dfs(A*10+7, use|0b100, cnt)
    dfs(A*10+5, use|0b010, cnt)
    dfs(A*10+3, use|0b001, cnt)

n = int(input())
ans = []
dfs(0, 0, ans)
print(len(ans))

Measured memory_bytes: 3188
#include<stdio.h>
int data[10000];
void isprime(int n) {
    int i,k;
    for(i=2; i <=n; i++) {
        data[i] =1;
    }
    for(i=2; i*i <= n; i++) {
        if(data[i]){
            for(k=2*i;k <= n; k+=i) {
                data[k] =0;
            }
        }
    }
}
int main() {
    int i,x,Sprime=0,Lprime=0;
    while(1){
        scanf("%d",&x);
        if(x ==0)
            break;
        isprime(x);
        for(i=2; i<=x; i++){
            if(data[i] && data[i-2]){
                Sprime = i-2;
                Lprime = i;
            }
        }
        printf("%d %d\n",Sprime,Lprime);
    }
    return 0;
}
    

Measured memory_bytes: 632
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a=sorted(a)
for i in range(n):
    c[i]=-c[i]
c=sorted(c)

ans=0
for i in range(n):
    tmp1=bisect.bisect_left(a,b[i])
    tmp2=bisect.bisect_left(c,-b[i])
    ans+=tmp1*tmp2

print(ans)

Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, i;
  cin >> N >> M;
  vector<int> C(N);
  for (i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    C.at(a - 1)++;
    C.at(b - 1)++;
  }
  
  for (i = 0; i < N; i++) cout << C.at(i) << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

	int n;
	scanf("%d", &n);
	PII ar[n];
	for(int i=0; i<n; i++){
		scanf("%d %d", &ar[i].second, &ar[i].first);
	}
	sort(ar, ar+n);

	int time = 0;
	for(int i=0; i<n; i++){
		time += ar[i].second;
		if(time > ar[i].first){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var N = Input.NextInt();
            var K = Input.NextLong();
            var array = new long[200000];

            for (int i = 0; i < N; i++) {
                var a = Input.NextInt() - 1;
                var b = Input.NextInt();

                array[a] += b;
            }

            long count = 0;
            for (int i = 0; i < 200000; i++) {
                count += array[i];
                if(count >= K) {
                    Console.WriteLine(i + 1);
                    return;
                }
            }
        }
    }

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

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

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

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

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

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

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

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

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

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

int main() {
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;
  vector<int> ans(3, -1);
  for(int i=0;i<=N;i++) {
    for(int j=0;j<=N-i;j++) {
      if(i*9+j*4+N==Y) {
        ans[0]=i;
        ans[1]=j;
        ans[2]=N-i-j;
        break;
      }
    }
  }
  printf ("%d %d %d\n",ans[0],ans[1],ans[2]);
}

Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=200005;
const int maxm=30;
ll l,r;
int n,len=INF;
string s;
int cnt[maxn][maxm],z[maxn]; 
ll ans[maxm];

void Z_algorithm(){
	z[0]=0;
	int L=0,R=0;
	REP(i,n-1){
		if(R<=i){
			for(int j=0;j<n;j++)
			if(s[j]==s[i+j])z[i]++;
			else break;
			if(z[i])L=i,R=i+z[i]-1; 
		} 
		else{
			if(i>L&&i<R&&z[i-L]<=R-i)z[i]=z[i-L];
			else{
				z[i]=R-i;
				for(int j=R-i;j<n;j++)
				if(s[j]==s[i+j])z[i]++;
				else break;
				if(z[i])L=i,R=i+z[i]-1;
			}
		}
	}
}

inline vector<ll>add_vector(vector<ll>a,vector<ll>b){
	rep(i,26)b[i]+=a[i];
	return b;
}

ll solve(ll l_len,vector<ll>L,ll r_len,vector<ll>R,ll rest,vector<ll>&Ans){
	if(l_len+r_len<=rest){
		vector<ll>sum=add_vector(L,R);
		ll x=solve(l_len+r_len,sum,l_len,L,rest,Ans);
		rest=x;
	}
	if(l_len<=rest){
		Ans=add_vector(Ans,L);
		rest-=l_len;
	}
	return rest;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>s>>l>>r;
	l--;r--;
	s=s.substr(0,s.size()/2);
	n=s.size();
	
	rep(i,n){
		rep(j,26){
			if(s[i]-'a'==j)cnt[i][j]=!i?1:cnt[i-1][j]+1;
			else cnt[i][j]=!i?0:cnt[i-1][j];
		}
	}
	
	Z_algorithm();
	REP(i,n-1)if(z[i]+i==n)len=min(len,i);

	if(len==INF){
		rep(j,26){
			ans[j]+=(ll)cnt[n-1][j]*(r/(ll)n)+(ll)cnt[r%(ll)n][j];
			if(l-1>=0)ans[j]-=(ll)cnt[n-1][j]*((l-1)/(ll)n)+(ll)cnt[(l-1)%(ll)n][j];
		}
		rep(j,26)cout<<ans[j]<<' ';
		return 0;
	}
	
	else{
		vector<ll>L(maxm),R(maxm);
		rep(i,26)L[i]=cnt[len-1][i];
		rep(i,26)R[i]=cnt[n-1][i]-cnt[len-1][i];
		vector<ll>Ans1(maxm),Ans2(maxm);
		ll x1=solve(len,L,n-len,R,r+1,Ans1);
		ll x2=solve(len,L,n-len,R,l,Ans2);
		rep(i,26){
			ans[i]+=Ans1[i]-Ans2[i];
			if(x1>=1)ans[i]+=(ll)cnt[x1-1][i];
			if(x2>=1)ans[i]-=(ll)cnt[x2-1][i];
		}
		rep(i,26)cout<<ans[i]<<" ";
		return 0;
	} 
}

Measured memory_bytes: 14416
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	double n,sum=0,flag=0;
	scanf("%lf",&n);
	for(int i=1;i<=n;i++)
	{
		if(i%3==0||i%5==0||i%15==0)
		  flag=1;
		else
		  sum+=i;
	}
	printf("%.0lf\n",sum);
	return 0;	
}

Measured memory_bytes: 1752
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int x = 0;
    int Max = 0;
    
    
    for(int i=0; i<S.length(); i++) {
      String l = S.substring(i, i+1);
      if(l.equals("I")) {
        x++;
      } else {
        x--;
      }
      if(x>Max) {
        Max = x;
      }
    }
    System.out.println(Max);
  }
}

Measured memory_bytes: 21076
def LCS(array1, array2)
  array_i = array1.length
  array_j = array2.length
  array = Array.new(array_i+1).map{Array.new(array_j+1,0)}

  1.upto array_i do |i|
    1.upto array_j do |j|
      array[i][j] = (array1[i-1] == array2[j-1]) ? array[i][j] = array[i-1][j-1] + 1 : ((array[i][j-1] > array[i-1][j]) ? array[i][j-1] : array[i-1][j] )
    end
  end
  array.last.last
end

q = gets.to_i
q.times do
  array1 = gets.chomp.split("")
  array2 = gets.chomp.split("")
  puts LCS(array1, array2)
end



Measured memory_bytes: 52520
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y

def knapsack(limit, values, weights):
    """Returns the maximum value that can be reached using given weights"""
    n = len(weights)
    dp = [0]*(limit+1)
    for i in range(n):
        for j in range(limit, weights[i]-1, -1):
            dp[j] = max(dp[j], values[i] + dp[j - weights[i]])
    return dp[-1]

for _ in range(int(input()) if not True else 1):
    #n = int(input())
    n, w = map(int, input().split())
    #c, d = map(int, input().split())
    weights = []
    values = []
    for i in range(n):
        x, y = map(int, input().split())
        weights += [x]
        values += [y]

    print(knapsack(w, values, weights))

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

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;

#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)

int main(){
    ll N,K;
    vector<ll> H;
    cin >> N >> K;
    REP(i,0,N){
        ll h;
        cin >> h;
        H.push_back(h);
    }
    sort(H.rbegin(), H.rend());
    ll ret = 0;
    REP(i,0,N){
        if(K>0){
            K--;
        }else{
            ret+=H[i];
        }
    }
    cout << ret << endl;

    return 0;
}


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


    Scanner sc =new Scanner(System.in);
    String s=sc.next();
    String t=sc.next();
    String u=sc.next();
    String S=s.substring(0,1);
    String T=t.substring(1,2);
    String U=u.substring(2,3);
    System.out.println(S+T+U);

	}
}

Measured memory_bytes: 21844
import math
a, b, x = map(int, input().split())
if x * 2 >= a ** 2 * b:
    b2 = 2 * x / a ** 2 - b
    b -= b2
else:
    a2 = 2 * x / (a * b)
    a = a2
print(math.degrees(math.atan(b / a)))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
string week(int n){
	if(n==0){
		return "fri";
	}else if(n==1){
		return "sat";
	}else if(n==2){
		return "sun";
	}else if(n==3){
		return "mon";
	}else if(n==4){
		return "tue";
	}else if(n==5){
		return "wed";
	}else if(n==6){
		return "thu";
	}
}
int main(){
	//1=fri
	int n;cin>>n;n--;
	cout << week(n%7) << endl;
}


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

int digit(int a){
	int ans=0;
	while(a){
		a/=10;ans++;
		}
		return ans;
	}

signed main(){
	int n;cin>>n;
	int res=114514;
	for(long long i=1;i*i<=n;i++){
		int a=i,b=n/i;
		if(a*b==n){
			res=min(res,digit(max(a,b)));
			}
		}
	cout<<res<<endl;
	}


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

int x[10], y[10];

double dist(int i, int j) {
    double dist_x = x[i] - x[j];
    double dist_y = y[i] - y[j];
    return pow(pow(dist_x, 2) + pow(dist_y, 2), 0.5);
}

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

    double temp_dist=0;
    int count = 0;
    do
    {
        for (int i = 1; i < n; ++i) {
            temp_dist += dist(v[i-1], v[i]);
        }
        count++;
    } while (next_permutation(v.begin(), v.end()));
    double ans = temp_dist / count;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
int main()
{
	scanf("%lld",&n);
	ans=(1+n)*n/2;
	long long tmp=n/3ll;
	if(n>=3) ans-=(tmp*3ll+3ll)*tmp/2ll;
	tmp=n/5ll;
	if(n>=5) ans-=(tmp*5ll+5ll)*tmp/2ll;
	tmp=n/15ll;
	if(n>=15) ans+=(tmp*15ll+15ll)*tmp/2ll;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3760
# -*- coding: utf-8 -*-
import math
import sys

def get_diff(n):
  return abs(753 - n)


if __name__ == "__main__":
  s = str(sys.stdin.readline().rstrip())
  mn = 753
  for i in range(0, len(s)-2):
    mn = min(mn, get_diff(int(s[i:i+3])))
  print(mn)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int N,A,B,C;
vector<int> l(10);

int dfs(int n,int a,int b,int c,int m,bool q,bool w,bool e){
  if(n==N && q && w && e){return m+abs(A-a)+abs(B-b)+abs(C-c);}
  else if(n==N){return 1000000000;}
  int r,t,y;
  if(q){r=dfs(n+1,a+l[n],b,c,m+10,q,w,e);}
  else{r=dfs(n+1,a+l[n],b,c,m,1,w,e);}
  if(w){t=dfs(n+1,a,b+l[n],c,m+10,q,w,e);}
  else{t=dfs(n+1,a,b+l[n],c,m,q,1,e);}
  if(e){y=dfs(n+1,a,b,c+l[n],m+10,q,w,e);}
  else{y=dfs(n+1,a,b,c+l[n],m,q,w,1);}
  return min({r,t,y,dfs(n+1,a,b,c,m,q,w,e)});
}

int main(){
  cin >> N >> A >> B >> C;
  for(int i=0;i<N;i++)cin >> l[i];
  cout << dfs(0,0,0,0,0,0,0,0) << endl;
}

Measured memory_bytes: 256
N = list(input())
if N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
if N[-1] == '3':
    print('bon')
if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] =='7' or N[-1] == '9':
    print('hon')

Measured memory_bytes: 9128
#include <stdio.h>
#include <math.h>
int isPrime(int x){
    int i;
    if (x <= 1)
        return 0;
    else if(x==2)
        return 1;
        if(x%2==0)
        return 0;
    for(i=3;i*i<=x;i+=2){
    if(x%i==0)
        return 0;
    }
    return 1;
}
int main()
{
    int a,b,i;
    int c=0;
    scanf("%d",&a);
    for(int i = 0;i<a;i++){
        scanf("%d",&b);
        if(isPrime(b)==1){
            c++;
        }
        
    }
    printf("%d\n",c);
    
}


Measured memory_bytes: 2104
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
int a[10];
int main()
{
    scanf("%d%d%d",&a[0],&a[1],&a[2]);
    sort(a,a+3);
    int ans=0;
    if(a[0]%2!=a[1]%2) ans+=2;
    ans+=(a[1]-a[0])/2;
    ans+=(a[2]-a[1]);
    printf("%d\n",ans);
    return 0;
}


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

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

    int a, b, h, w;

    cin >> h >> w >> a >> b;

    for (int i = 0; i < h; i++){
        int t;
        i < b ? t = 1 : t = 0;
        for (int j = 0; j < w; j++)
            j < a ? cout << t : cout << 1 - t;
        cout << "\n";
    }
    return 0;
}

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

int main(){
  int N=0;
  string S;
  cin>>S;
  for(int i=0;i<4;i++){
    if(S.at(i)=='+'){
      N++;
      continue;
    }
    N--;
  }
  cout <<N<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

func main() {
        for {
                var n int
                _, err := fmt.Scanf("%d", &n)
                if err != nil || n == 0 {
                        break
                }

                var sum [5001]int

                for i := 1; i <= n; i++ {
                        fmt.Scanf("%d", &(sum[i]))
                        if i > 1 {
                                sum[i] += sum[i-1]
                        }
                }

                max_sum := sum[1]
                for i := 1; i <= n; i++ {
                        for j := 0; j < i; j++ {
                                if max_sum < sum[i] - sum[j] {
                                        max_sum = sum[i] - sum[j]
                                }
                        }
                }
                fmt.Printf("%d\n", max_sum)
        }
}



Measured memory_bytes: 1392
import scala.io.StdIn._
object Main {
  def main(args:Array[String]) {
    val S = readLine()
    if(S.contains("RRR")) println(3)
    else if(S.contains("RR")) println(2)
    else if(S.contains("R")) println(1)
    else println(0)
  }
}


Measured memory_bytes: 54524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,h;
  cin>>N>>h;
  int count=0;
  vector<int>A(N);
  vector<int>B(N);

  for(int i=0;i<N;i++){
    cin>>A.at(i)>>B.at(i);
  }
  sort(A.rbegin(),A.rend());
  sort(B.rbegin(),B.rend());
  
  for(int i=0;i<N;i++){
    if(A.at(0)<B.at(i)){
      count++;
      h-=B.at(i);
    }
    else{break;}
    if(h<=0){
      cout<<count<<endl;
      return 0;
    }
  }
  count+= h/A.at(0);
  if(h%A.at(0)!=0){
    count++;
  }
  cout <<count<<endl;
}

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

typedef long long LL;

const int N=400,mod=998244353;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
int Power(int a,int k,int p=mod){int res=1;for (;k;k>>=1,smul(a,a,p)) if (k&1) smul(res,a,p);return res;}

int n,a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i)
	scanf("%d",&a[i]);
}

int pw[N+9];

void Get_pw(){
  pw[0]=1;
  for (int i=1;i<=n;++i) pw[i]=mul(pw[i-1],2);
}

int len[N+9],cn;
int dp[N+9][N+9][2];

int Divide_dp(int l,int r,int last){
  if (l>r) return 0;
  int mid=l,k=++cn;
  for (int i=l+1;i<=r;++i)
	if (a[i]<a[mid]) mid=i;
  int ls=Divide_dp(l,mid-1,a[mid]),rs=Divide_dp(mid+1,r,a[mid]);
  for (int i=0;i<=len[ls];++i)
	for (int j=0;j<=len[rs];++j){
	  int c0=mul(dp[ls][i][0],dp[rs][j][0]);
	  int c1=add(mul(dp[ls][i][1],add(dp[rs][j][0],dp[rs][j][1])),mul(dp[ls][i][0],dp[rs][j][1]));
	  sadd(dp[k][i+j][0],c0);
	  sadd(dp[k][i+j][1],c1);
	  ssub(dp[k][i+j+1][0],c0);
	  sadd(dp[k][i+j+1][1],c0);
	}
  len[k]=len[ls]+len[rs]+1;
  for (int i=0;i<=len[k];++i){
	smul(dp[k][i][0],Power(pw[len[k]-i],a[mid]-last));
	smul(dp[k][i][1],Power(sub(pw[len[k]-i],1),a[mid]-last));
  }
  return k;
}

int ans;

void Get_dp(){
  dp[0][0][0]=1;
  int rot=Divide_dp(1,n,0);
  for (int i=0;i<=n;++i) sadd(ans,add(dp[rot][i][0],dp[rot][i][1]));
}

void work(){
  Get_pw();
  Get_dp();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

int main() {
 int A,B; cin >> A >> B;
 if(A>B){
   for(int i = 0; i<A; i++){
     cout << B;
   }
 }
 else{
   for(int i = 0; i<B; i++){
     cout << A;
   }
 }
  
  return 0;
}



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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define MOD 998244353 
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

ll ans;
int n,s;
int a[3005];
ll dp[3005];


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

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

    for(int i=0; i<n; i++) {
        dp[0]++;
        for(int j=s-a[i]; j>=0; j--)
            dp[j+a[i]]+=dp[j]%MOD;
        ans+=dp[s]%MOD;
    }

    ans%=MOD;
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())
T, A = map(int,input().split())
H = [int(i) for i in input().split()]
ans_i = 1; ans_diff = abs(A - (T - H[0] * 0.006))
# print(ans_diff)
for i in range(1,N):
    diff = abs(A - (T - H[i] * 0.006))
    if ans_diff > diff:
        ans_i = i+1
        ans_diff = diff

    # print(diff)
print(ans_i)


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

int main() {
    int A , B ;
    cin >> A >> B ; // 1 ≤ A,B ≤ 9
    if (A >= 1 && A <= 9 && B >= 1 && B <= 9) cout << A * B << endl ;
    else cout << "-1" << endl ;
	return 0;
}

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

#define DEBUG_ON 1  // 0 = off, 1 = on

namespace {
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define LEN(x) (int)((x).size())
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define OP minmax

#define FOR(i, begin, end)  \
  for (__typeof(end) i = (begin) - ((begin) > (end));  \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

/*
#ifndef ONLINE_JUDGE
#include "debug.h"
#endif  // ONLINE_JUDGE
*/
  
typedef long long int ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<ll> vll;
template<typename T> using min_pq = priority_queue<T, vector<T>, greater<T>>;

ll expmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
}

const int MAX_N = 200000;
const ll MODD = 1000000009LL;
const ld EPS = 1e-9;



ll a, b, c;
ll ba, bb, bc;

ll solve(ll N, ll X) {
	if (N % 2 == 0 && X == N / 2) return 3 * X;
	if (2*X > N) X = N - X;
	
	ll ans = 2 * X + N;
	
	ll rem = (N - 2*X);
	ll x = X;
	while (rem != 0) {
		if (rem % x == 0) {
			ans += 2 * rem - x;
			return ans;
		}
		ans += (rem / x) * 2*x;
		ll temp = x;
		x = rem % x;
		rem = temp;
	}
	return ans;
}

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

	ll N, X;
	cin >> N >> X;
	
	cout << solve(N, X) << endl;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int n;
  cin >> n;

  while(n != 0){
      vector<int> num;
      REP(i,n){
          int t;
          cin >> t;
          num.pb(t);
        }

        sort(num.begin(), num.end());

         int ans = 0, sum = 0;
        REP(i,n){
          sum += num[i];
          }
          sum /= n;

          REP(i, n){
              if(num[i] <= sum) ans++;
            }
            cout << ans << endl;

            cin >> n;
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[100000], t = -1;
ll s;

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	sort(a, a+n);
	rep(i,n-1) {
		s += a[i];
		if (s*2<a[i+1]) t = i;
	}
	cout << n-t-1 << ln;
}

Measured memory_bytes: 640
x1, y1, x2, y2 = map(int, input().split())

a, b = abs(x2 - x1), abs(y1 - y2)

if (x1 <= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b
elif (x1 >= x2)and(y1 <= y2):
    x3, y3 = x2 - b, y2 - a
    x4, y4 = x3 + a, y3 - b
elif (x1 >= x2)and(y1 >= y2):
    x3, y3 = x2 + b, y2 - a
    x4, y4 = x3 + a, y3 + b
elif (x1 <= x2)and(y1 >= y2):
    x3, y3 = x2 + b, y2 + a
    x4, y4 = x3 - a, y3 + b

print(x3, y3, x4, y4)

Measured memory_bytes: 9028
N = int(input())
list = [-1]
for _ in range(N):
    list.append(int(input()))

d = {}
on = 1
cnt = 0
while True:
    next = list[on]
    cnt += 1
    if next in d:
        print("-1")
        exit()
    else:
        d[next] = True
    if next == 2:
        print(cnt)
        exit()
    on = next


Measured memory_bytes: 16284
import java.math.BigInteger;

public class Main {
	final private static BigInteger modval = BigInteger.valueOf(1000000000L + 7);

	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var N = sc.nextInt();
		var A = new Long[N];
		long sumNow = 0;
		for (var i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			sumNow += A[i];
		}
		BigInteger res = BigInteger.ZERO;
		for (int i = 0; i < N; i++) {
			sumNow -= A[i];
			res = res.add(BigInteger.valueOf(sumNow).multiply(BigInteger.valueOf(A[i])));
			res = res.mod(modval);
		}
		System.out.println(res);

	}
}

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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli n;
  lli a[100];
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  for(int i=n-1;i>=0;i--){
    cout<<a[i];
    if(i!=0)cout<<" ";
  }

  cout<<endl;
  
  return 0;
}

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

using namespace std;
using ll = long long;

int main(void)
{
    ios::sync_with_stdio(0), cin.tie(NULL);
    int    n;
    string s;
    cin >> s;
    n = s.size() + 1;

    vector<ll> a(n, 0);

    for (int i = 0; i < n - 1; ++i)
        if (s[i] == '<')
            a[i + 1] = max(a[i + 1], a[i] + 1);

    for (int i = n - 2; i >= 0; --i)
        if (s[i] == '>')
            a[i] = max(a[i], a[i + 1] + 1);

    cout << accumulate(a.begin(), a.end(), (ll)0) << endl;

    return 0;
}


Measured memory_bytes: 7596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	ll a,b,n,x;
	cin >> a >> b >> n;
	if(n>=b) x=b-1;
	else if(n<b) x=n;
	cout << floor((a*x)/b)-a*floor(x/b) << endl;
	return 0;
}

Measured memory_bytes: 3740
import java.util.Scanner;
  
class Main{
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  
  int a = sc.nextInt();
  int b = sc.nextInt();
  
  if(a < b) System.out.println("a < b");
  else if(a == b) System.out.println("a == b");
  else System.out.println("a > b");
 }
}


Measured memory_bytes: 26184
import java.util.*;
/*being john malkovich*/
class Main
{
	public static void main(String[] args)
	{
		long max = (long)(Math.pow(10,18));
		// System.out.println(max);
		Scanner s = new Scanner(System.in);
		long x = s.nextLong();
		long y = s.nextLong();

		/*
		if((x*2)%y!=0)
		{
			System.out.println(x*2);
		}
		else if((x*3)%y!=0)
		{
			System.out.println(x*3);
		}
		else
		{
			System.out.println("-1");
		}
		*/

		/*
		
		// else
		{
			int flag = 0;
			for(long i =1;i*x <= max;i++)
			{
				if((i*x)%y!=0)
				{
					flag = 1;
					System.out.println(i*x);		
					break;
				}
			}
			if(flag == 0)
				System.out.println("-1");
		}
		// */
		/*

		if(x!=y && x%y!=0)
		System.out.println(x*y + x);
		else if(x!=y && (x+1)%y!=0)
			System.out.println((x+1)*(y + 1));
		else
		System.out.println("-1");

		*/
		/*

		if(x!=y)
			System.out.println(x);
		else
			System.out.println("-1");
			*/

			if((x*2)%y!=0)
		{
			System.out.println(x*2);
		}
		else if((x*3)%y!=0)
		{
			System.out.println(x*3);
		}
		else if((x*4)%y!=0)
		{
			System.out.println(x*4);
		}
		else
		{
			System.out.println("-1");
		}
		// else if((x*5)%y!=0)
		{
			// System.out.println(x*5);
		}
		// else if((x*6)%y!=0)
		{
			// System.out.println(x*6);
		}
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  string n; cin >> n;
  if (n[0]=='7'||n[1]=='7'||n[2]=='7') cout << yes << endl;
  else cout << no << endl;

  return 0;
}


Measured memory_bytes: 3604
s = input()
t = input()

mincount = 9999

for i in range(len(s)-len(t)+1):
    c=0
    ss = s[i:len(t)+i]
    for j in range(len(t)):
        if ss[j] != t[j]:
            c+=1
    
    if mincount > c:
        mincount = c

print(mincount)



Measured memory_bytes: 73340
import java.util.Scanner;

public class Main {

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


    if(N %2 ==0){
      System.out.println(0.5);
    }else{
      System.out.println((double)(N+1)/(2*N));
    }

  }


}


Measured memory_bytes: 22868
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val n = readInt()

    val a = readListOfLong()
    val lcm_ = a.fold(1L) { acc, v -> lcm(v, acc) }

    val x = a.fold(0L) { acc, v -> acc + lcm_ / v }
    val ans = lcm_.toDouble() / x.toDouble()
    println(ans.format(7))
    
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

using namespace std;

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

    vector<int> item(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> item.at(i);
    }

    int sum = 0;
    for (auto elem : item)
    {
        sum += elem;
    }
    float limit = sum / (4.0 * M);

    int cnt = 0;
    for (auto elem : item)
    {
        if (elem >= limit)
        {
            ++cnt;
        }
    }

    if (cnt >= M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

const int MAX = 200100;
const int MOD = 1000000007;
int fact[MAX], finv[MAX], inv[MAX];

void Cinit() {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i=2; i<MAX; i++) {
        fact[i] = fact[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

int C(int n, int k) {
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int N, M, K;

signed main() {
    Cinit();
    cin >> N >> M >> K;
    int ans = 0;
    for (int i=1; i<N; i++) {
        ans += i*(N-i)*M*M*C(N*M-2, K-2);
        ans %= MOD;
    }
    for (int i=1; i<M; i++) {
        ans += i*(M-i)*N*N*C(N*M-2, K-2);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int n; cin >> n;
	int mi;
	rep(i, n){
		int a; cin >> a;
		if(i == 0) mi = a;
		if(a <= mi) ans++;
		mi = min(mi, a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DRemainderReminder solver = new DRemainderReminder();
        solver.solve(1, in, out);
        out.close();
    }

    static class DRemainderReminder {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), k = in.ints();
            long ans = 0;
            for (int b = k + 1; b <= n; b++) {
                ans += (n / b) * (b - k);
                ans += Math.max(0, (n % b) + (k == 0 ? 0 : 1 - k));
            }
            out.println(ans);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

struct Edge {
  ll to, id;
};

vector<vector<Edge>> g;
vector<ll> ans;

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

signed main() {
  ll N;
  cin >> N;
  g.resize(N);
  ans = vll(N - 1);
  rep(i, N - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].pb({b, i});
    g[b].pb({a, i});
  }

  dfs(0);
  ll mx = 0;
  rep(i, N) {
    mx = max(mx, ll(g[i].size()));
  }
  COUT(mx);
  rep(i, N - 1) {
    COUT(ans[i]);
  }

  return 0;
}

Measured memory_bytes: 9728
import sys
S = input()
if S[0] != 'A' or S[2:-1].count('C') != 1:
    print('WA')
    sys.exit(0)

cnt = 0
for c in S:
    if('a' <= c <= 'z'):
        cnt+=1

if(cnt == len(S)-2):
    print('AC')
else:
    print('WA')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    int n;
    string s;
    cin>>s;
    n=s.length();
    map<char, int> mp;
    mp['N'];
    mp['E'];
    mp['W'];
    mp['S'];

    rep(i,n){
        if(s[i]=='N') mp['N']=1;
        else if(s[i]=='W') mp['W']=1;
        else if(s[i]=='E') mp['E']=1;
        else mp['S']=1;
    }
    if(mp['N']==mp['S'] && mp['E']==mp['W']){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 5e3;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    LL N;
    while (cin >> N) {
        int a,b,c; a = b = c = -1;
        FOR(i,1,maxn) FOR(j,1,maxn) {
            const LL m = N*i*j;
            const LL d = 4*i*j - N*(i+j);
            if (d > 0) {
                const LL k = m/d;
                if (k*d == m) {
                    a = i; b = j; c = k;
                }
            }
        }
        cout << a << ' ' << b << ' ' << c << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<stdio.h>

using namespace std;

int main(){
  int a[3];
  int rec=0,dia=0;
  while(scanf("%d,%d,%d",&a[0],&a[1],&a[2])!=EOF){
    if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]){
      rec++;
    }
    if(a[0]==a[1]){
      dia++;
    }
  }
  cout<<rec<<"\n"<<dia<<"\n";
  return 0;
}

Measured memory_bytes: 0