akhauriyash/Code-Regression huggingface dataset:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())

    d = deque([3,5,7])
    res = 0
    while 1:
        a = d.popleft()
        for i in [3,5,7]:
            b = a*10 + i
            if b <= n:
                d.append(b)
                b = str(b)
                if '3' in b and '5' in b and '7' in b:
                    res += 1
            else:
                print(res)
                exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll a,b;

int main(){
	cin >> a >> b;
	
	int i=0; ll pos=a;
	while(pos<=b){
		pos*=2;
		i++;
	}
	
	cout << i << endl;
	return 0;
}



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

using namespace std;

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

    int otherdir = 0;
    int sol = n;

    for(int i = 0; i < n; i++){
        if(str[i] == 'W'){
            otherdir++;
        }
    }

    for(int i = n-1; i >= 0; i--){
        if(str[i] == 'W'){
            otherdir--;
        }
        sol = min(sol, otherdir);

        if(str[i] == 'E'){
            otherdir++;
        }
    }

    cout << sol << endl;

    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

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

    set<string> word;
    vector<string> w_list(n);

    rep(i, n){
        cin >> w_list[i];
        word.insert(w_list[i]);
    }
    if(word.size() != n){
        cout << "No" << endl;
        return 0;
    }

    string hoge = w_list[0];
    char s = hoge[hoge.size()-1];

    bool flg = true;
    repr(i, 1, n){
        string tmp = w_list[i];
        if(s != tmp[0]) flg = false;
        s = w_list[i][w_list[i].size()-1];
    }

    if(flg){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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

typedef struct Stack {
	int S[1000];
	int top;
	void init() {
		top = 0;
	}
	void push(int x) {
		//cout << "push:" << x << endl;
		S[top] = x;
		top += 1;
	}
	int pop() {
		top--;
		return S[top];
		
	}
	int calc(int x, char c, int y) {
		if (c == '+') {
			
			//cout << "a" << x << "b" << y << endl;
			//cout << "x+y:" << (int)(x + y) << endl;
			return (int)(x + y);
		}
		else if (c == '-') {
			return x - y;
		}
		else if (c == '*') {
			return x*y;
		}
	}
};
int main() {
	Stack st;
	st.init();
	int a, b;
	string s;
	for (; cin >> s;) {
		if (s[0] == '+' || s[0] == '-' || s[0] == '*') {
			a = st.pop();
			b = st.pop();
			st.push(st.calc(b, s[0], a));
		}
		else {
			int v = 0;
			for (int i = 0; i < s.size(); i++) {
				v *= 10;
				v += (int)(s[i] - '0');
			}
			st.push(v);
		}
	}
	cout << st.pop() << endl;
}


Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){

  int N;
  cin>>N;
  vector<int> D(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>D[i];
  }
  sort(D.begin(),D.end());
  cout<<D[N/2]-D[N/2-1];
  return 0;
}

Measured memory_bytes: 3788
import numpy as np

Q = int(input())
q = list()
n = 10 ** 5 + 1
for _ in range(Q):
    l, r = map(int, input().split())
    q.append((l, r))

# エラトステネスのふるい
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False

for i in range(2, int(n ** 0.5) + 1):
    if not is_prime[i]:
        continue
    for j in range(i * 2, n + 1, i):
        is_prime[j] = False

N = [0] * (n + 1)
for i in range(3, n + 1, 2):
    if is_prime[i] and is_prime[(i + 1) // 2]:
        N[i] = 1

ans = np.cumsum(N)
for l, r in q:
    print(ans[r] - ans[l - 1])


Measured memory_bytes: 28920
import sys
n = int(input())

xyhl = []
for _ in range(n):
    x,y,h = map(int,input().split())
    xyhl.append((x,y,h))
    
for x in range(101):
    for y in range(101):
        heightl = []
        for x1,y1,h1 in xyhl:
            hh = abs(x1-x)+abs(y1-y)+h1
            heightl.append(hh)
        height = min(heightl)
        for x1,y1,h1 in xyhl:
            check = max(height - abs(x1-x) - abs(y1-y), 0)
            if check != h1:
                break
        else:
            print(x)
            print(y)
            print(height)
            sys.exit()
        

Measured memory_bytes: 47708
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n, p := io.NextInt(), io.NextInt()
	s := io.Next()
	if p == 2 || p == 5 {
		ans := 0
		for i := range s {
			if int(s[i]-'0')%p == 0 {
				ans += i + 1
			}
		}
		io.Println(ans)
		return
	}
	rests := make([]int, n)
	pow := 1
	for i := range s {
		rests[n-1-i] = int(s[n-1-i]-'0') * pow % p
		pow = pow * 10 % p
	}
	sum := make([]int, n+1)
	for i := range rests {
		sum[i+1] = (sum[i] + rests[i]) % p
	}
	cnt := map[int]int{}
	ans := 0
	for _, v := range sum {
		ans += cnt[v]
		cnt[v]++
	}
	io.Println(ans)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 6544
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll
#define INF INT_MAX/10

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[200100];

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

  set<int> T;
  T.insert(0);
  T.insert(N+1);
  
  for (int i = 1; i <= N; i++) {
    int a; cin >> a;
    Input[a] = i;
  }

  int ans = 0;
  
  for (int i = 1; i <= N; i++) {
    T.insert(Input[i]);
    auto itr = T.find(Input[i]);
    int right = *(next(itr, 1));
    int left = *(prev(itr, 1));

    // cout << right << " " << left << endl;
    ans += i * (right - Input[i]) * (Input[i] - left);
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
#include <iostream>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

int main() {
  int N, Y;
  cin >> N >> Y;
  Y = Y/1000;

  REP(i, N+1) {
    REP(j, N-i+1) {
      if (9*i + 4*j == Y-N) {
        cout << i << ' ' << j << ' ' << N-i-j << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	double n;
	cin>>n;
	cout<<(n/2)*(2*1+(n-1)*1)<<endl;

	return 0;
}


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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define min(a, b) (a < b ? a : b)
#define max(a, b) (b < a ? a : b)
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define read() Read<int>()
typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef double db;

namespace IO {
#define getc() ((S_ == T_) && (T_ = (S_ = Ch_) + fread(Ch_, 1, Buffsize, stdin), S_ == T_) ? 0 : *S_ ++)
	const uint Buffsize = 1 << 15, Output = 1 << 23;
	static char Ch_[Buffsize], *S_ = Ch_, *T_ = Ch_;
	static char Out[Output], *nowps = Out;
	inline void flush(){fwrite(Out, 1, nowps - Out, stdout); nowps = Out;}
	template<typename T >inline T Read() {
		T _ = 0; static char __; T ___ = 1;
		for(__ = getc(); !isdigit(__); __=getc()) if(__ == '-') ___ = -1;
		for(; isdigit(__); __ = getc()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
		return _ *= ___;
	}
	template<typename T>inline void write(T _, char __ = '\n') {
		if(!_) *nowps ++ = '0';
		if(_ < 0) *nowps ++ = '-', _ = -_;
		static uint sta[111], tp;
		for(tp = 0; _; _ /= 10) sta[++ tp] = _ % 10;
		for(; tp; *nowps ++ = sta[tp --] ^ 48); 
		(*nowps ++) = __;
	}
	template<class T>inline bool chkmax(T &_, T __) {return _ < __ ? _ = __, 1 : 0;}
	template<class T>inline bool chkmin(T &_, T __) {return _ > __ ? _ = __, 1 : 0;}
}

using namespace std;
using namespace IO;

const int N = 1e5 + 10;
int n;
int a[N],vis1[N],vis2[N],Mx1,Mx2,cnt1,cnt2,Mx,scnt1,scnt2,sMx1,sMx2;
int main() {
	n = read();
	for(int i = 1;i <= n;++i) {
		a[i] = read();
		if(i & 1) {
			vis1[a[i]] ++;
			if(vis1[a[i]] > cnt1) {
				if(a[i] != Mx1) scnt1 = cnt1,sMx1 = Mx1;
				cnt1 = vis1[a[i]],Mx1 = a[i];
			}
			else if(vis1[a[i]] > scnt1) {
				scnt1 = vis1[a[i]],sMx1 = a[i];
			}
		}
		else {
			vis2[a[i]] ++;
			if(vis2[a[i]] > cnt2) {
				if(a[i] != Mx2) scnt2 = cnt2,sMx2 = Mx2;
				cnt2 = vis2[a[i]],Mx2 = a[i];
			}
			else if(vis2[a[i]] > scnt2) {
				scnt2 = vis2[a[i]],sMx2 = a[i];
			}
		}
	}
	int ans = 0;
	if(Mx1 != Mx2) ans = cnt1 + cnt2;
	else ans = max(cnt1 + scnt2,cnt2 + scnt1);
	printf("%d\n",n - ans);
	return flush(), 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;

int main(){
    lint ans = 0, A[7];
    for(auto& it : A) cin >> it;

    for(int i=0;i<2;i++){
        lint cur = A[1];
        if(A[0] and A[3] and A[4]){
            cur += 3 * i;
            A[0] -= i; A[3] -= i; A[4] -= i;
        }
        cur += (A[0]/2+A[3]/2+A[4]/2) * 2;
        ans = max(ans, cur);
    }

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

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

def solve(S: int):
    ans = []

    S2 = 10**9
    if S <= S2:
        ans = [0,0,1,0,0,S]
    else:
        A = min(int(S**0.5) + 1,10**9)

        B = A**2 - S
        ans = [0,0,A,B,1,A]

    print(" ".join([str(i) for i in ans]))
    return


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

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{

  ll n;
  string s;
  cin >> n;
  cin >> s;

  char last_char;
  ll cnt = 0;

  for (auto i = 0; i < s.length(); i++)
  {
    if (i == 0)
    {
      last_char = s.at(i);
      cnt++;
      continue;
    }

    if (last_char == s.at(i))
    {
      continue;
    }

    last_char = s.at(i);
    cnt++;
  }

  cout << cnt << endl;

  return 0;
}


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

// xが2乗数かチェック
bool check_square(int x){
	bool res = false;
	for(int i=0;i*i<=x;i++){
		if(i*i == x){
			res = true;
			break;
		}
	}
	return res;
}
int main(){
	int n,d;
	cin >> n >> d;
	
	vector<vector<int>> x(n, vector<int>(d));
	vector<vector<int>> squaredist(n, vector<int>(n));
	
	rep(i,n){
		rep(j,d){
			cin >> x[i][j];
		}
	}

	rep(i,n){
		rep(j,n){
			squaredist[i][j] = 0;
			rep(k,d) squaredist[i][j] += pow( (x[i][k] - x[j][k]), 2);
		}
	}
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(check_square(squaredist[i][j])) cnt++;
		}
	}
	
	cout << cnt << endl;

	return 0;
}

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

int main(){
    string s;
    cin >> s;

    int a = s[0]-'0';
    int b = s[1]-'0';
    int c = s[2]-'0';
    int d = s[3]-'0';

    int g[3] = { b,c,d };

    for(int tmp=0;tmp < (1<<3);tmp++){
        bitset<3> t(tmp);

        int sum=a;
        string siki="";
        siki.push_back(s[0]);

        for(int i=0;i<3;i++){
            if(t.test(i)){
                sum += g[i];
                siki.push_back('+');
                siki.push_back('0'+g[i]);
            }else{
                sum -= g[i];
                siki.push_back('-');
                siki.push_back('0'+g[i]);
            }
        }
        if(sum==7){
            siki.append("=7");
            cout << siki << endl;
            return 0;
        }

    } 
}

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

typedef struct {
  string str;
  int t;
} P;

int n,head,tail;
P Q[100001];

void init() {
  head = 0,tail = n;
}

int isEmpty() {
  return head == tail;
}

int isFull(){
  return head == (tail + 1)   % 100000;
}

void enqueue( P x ) {
  if ( isFull() ) cout << "overflow" << endl;
  Q[tail] = x;
  if ( tail + 1 == 100000 ) tail = 0;
  else tail++;
}

P dequeue() {
  if ( isEmpty() ) cout << "underflow" << endl;
  P x = Q[head];
  if ( head + 1 == 100000 ) head = 0;
  else head++;
  return x;
}

int min( int a, int b ) {
  if ( a < b ) return a;
  else return b;
}

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

  for ( int i = 0; i < n; i++ ) cin >> Q[i].str >> Q[i].t;

  int time = 0;
  P u;

  while ( head != tail ) {
    u = dequeue();
    int minn = min(q,u.t);
    u.t -= minn;
    time += minn;
    if ( u.t > 0 ) enqueue(u);
    else cout << u.str << " " << time << endl;
  }
  
  return 0;
}

Measured memory_bytes: 5112
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        tank = []
        while par[x] >= 0:
            tank.append(x)
            x = par[x]
        for elt in tank:
            par[elt] = x
        return x
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

n,m=map(int,input().split())
edge=[]
for _ in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1

    edge.append([a,b])


ans=0
for j in range(m):
    #初期化 
    #根なら-size,子なら親の頂点
    par = [-1]*n
    cnt=0
    for p in range(m):
        if p==j:
            continue
    
        e=edge[p]
        unite(e[0],e[1])  
          
    for k in range(n):
        if par[k]<0:
            cnt+=1

    if cnt>=2:
        ans+=1
    
    

    


print(ans)



Measured memory_bytes: 9192
wlist = [0 for i in range(26)]
w = list(input())
for i in w:
    wlist[ord(i) - 97] += 1
ans = 1
for i in wlist:
    if i % 2 != 0:
        print("No")
        ans = -1
        break
if ans == 1:
    print("Yes")


Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
inline int min(int a, int b){ return a < b ? a : b; }
inline int max(int a, int b){ return a > b ? a : b; }
const int siz = 190;
int dp[2][siz][siz][siz];
char mp[siz][siz]; int sum[siz][siz];
bool pdoc(int u, int d, int l, int r){
	int s = sum[d][r] + sum[u-1][l-1] - sum[u-1][r] - sum[d][l-1];
	return s == 0 || s == (r - l + 1) * (d - u + 1);
}
int main(){
	int n, m; scanf("%d%d", &n, &m);
	for(int i(1); i <= n; ++i){
		scanf("%s", mp[i] + 1);
		for(int j(1); j <= m; ++j) sum[i][j] = (mp[i][j] == '.' ? 0 : 1);
	}	
	for(int i(1); i <= n; ++i){
		for(int j(1); j <= m; ++j){
			sum[i][j] += sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
		}
	}
	memset(dp, 0, sizeof(dp));
	for(int u(1); u <= n; ++u) for(int d(u); d <= n; ++d)
		for(int l(1); l <= m; ++l){
			int L(l), R(m), mid; dp[0][u][d][l] = 0;
			while(L <= R){
				int mid((L + R) >> 1);
				if(pdoc(u, d, l, mid)) dp[0][u][d][l] = mid, L = mid + 1;
				else R = mid - 1;
			}
	}
	int las = 0, nex = 1;
	for(int ans(0); ; ++ans){
		if(dp[las][1][n][1] == m){
			printf("%d\n", ans);
			return 0;
		}
		memset(dp[nex], 0, sizeof(dp[nex]));
		for(int u(1); u <= n; ++u){	for(int d(u); d <= n; ++d)
			for(int l(1); l <= m; ++l){
				dp[nex][u][d][l] = max(dp[las][u][d][dp[las][u][d][l]+1], dp[las][u][d][l]); 
				int L(u), R(d), mid;
				while(L < R){
					int mid((L + R) >> 1);
					dp[nex][u][d][l] = max(dp[nex][u][d][l],
							min(dp[las][u][mid][l], dp[las][mid+1][d][l]));
					if(dp[las][u][mid][l] > dp[las][mid+1][d][l]) L = mid + 1;
					else R = mid;
				}
			}
		}
		nex^=las^=nex^=las;
	}	
	return 0;
}



Measured memory_bytes: 53888
#include<iostream>
#include<string>

using namespace std;

string N;

int main() {
	cin >> N;
	if (N[0] == '7' || N[1] == '7' || N[2] == '7') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };



int main() {
	int i, j, n, d, k, cnt = 0;
	string s;
	//vint list;
	vector<double>list;
	double sum = 0;

	cin >> n;

	rep(i, 0, n) {
		double num;
		cin >> num;
		sum += num;
		list.push_back(num);
	}
	
	double avg = sum / (double)n;

	int index = 0;
	double minn = 9999999;

	rep(i, 0, n) {
		if (minn > fabs(avg - list[i])) {
			minn = fabs(avg - list[i]);
			index = i;
		}

	}


	cout << index << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
A,B = input().split()
A = int(A)

C = ""

for i in range(len(B)):
    if B[i]!=".":
        C+=B[i]
if C[0]=="0" and len(C)>1:
    C = int(C[1:])
else:
    C = int(C)

print((A*C)//100)


Measured memory_bytes: 61836
import std.stdio;
import std.exception;
import std.conv;
import std.container;
import std.algorithm;
import std.functional;
import std.range;
import std.array;

const ulong C = 1000000007;
ulong[100001] fact;
static this() {
    fact[0] = 1;
    foreach (i; 1 .. 100001) {
        fact[i] = fact[i - 1] * i % C;
    }
}

class SegmentTree {
    SegmentTree left, right; 
    SegmentTree parent;
    int from, to;
    int diff;
    ~this() {
        delete left;
        delete right;
    }
    final this(SegmentTree parent, int from, int to) {
        //writeln(parent is null);
        this.parent = parent;
        this.from = from;
        this.to = to;
        this.diff = 0;
        if (from + 1 != to) {
            int mid = (from + to + 1) / 2;
            this.left  = new SegmentTree(this, from, mid);
            this.right = new SegmentTree(this, mid, to);
        }
    }
    final void add(int from, int to) {
        if (from >= to) return;
        if (this.from == from && this.to == to) {
            diff++;
        } else {
            if (from < left.to) {
                if (to <= left.to) left.add(from, to);
                else left.add(from, left.to);
            } 
            if (right.from < to) {
                if (from <= right.from) right.add(right.from, to);
                else right.add(from, to);
            }
            //left.add(max(from, left.from), min(to, left.to));
            //right.add(max(from, right.from), min(to, right.to));
        }
    }
    final int opIndex(ulong index) {
        if (from == index && index + 1 == to) return diff;
        int mid = (from + to + 1) / 2;
        return (index < mid ? left : right).opIndex(index) + diff;
    }
}

void main() {
    int N, R;
    while (readf("%d\n", &N), N) {
        readf("%d\n", &R);
        int[] str = new int[N];
        foreach (int i, ref c; str) c = i;
        foreach (i; 0 .. R) {
            int s, t; readf("%d %d\n", &s, &t);
            s--; t--;
            swap(str[s], str[t]);
        }
        ulong ans = 0;
        auto segtree = new SegmentTree(null, 0, N);
        foreach (i; 0 .. N) {
            ans = (ans + (str[i] - segtree[str[i]]) * fact[N - 1 - i]) % C;
            segtree.add(str[i] + 1, N);
        }
        ans.writeln;
        delete segtree;
        delete str;
    }
}

Measured memory_bytes: 16588
#include<cstdio>
int main(){int f=1,b,a;char s[12];scanf("%d%d%s",&a,&b,s);for(b+=a+1;b--;)if(b==a&&s[b]!='-'||b-a&&(s[b]<'0'||s[b]>'9'))f=0;return !printf("%s",f?"Yes":"No");}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a; cin >> a;
    if(a == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int uf[2][200000];

struct city{
  int dou;
  int tetu;
  int id;
  bool operator<(const struct city & right) const{
    return (dou==right.dou?tetu<right.tetu:dou<right.dou);
  }
};

int find(int i,int a){
  if(a==uf[i][a]) return a;
  else return uf[i][a]=find(i,uf[i][a]);
}

void uni(int i,int a,int b){
  a=find(i,a);
  b=find(i,b);
  if(a==b) return;
  uf[i][a]=b;
  return;
}

int main(){
  int n,k,l;
  cin >> n >> k >> l;
  for(int i=0;i<n;i++){
    uf[0][i]=uf[1][i]=i;
  }
  int p,q;
  for(int i=0;i<k;i++){
    cin >> p >> q;
    uni(0,--p,--q);
  }
  for(int i=0;i<l;i++){
    cin >> p >> q;
    uni(1,--p,--q);
  }
  vector<struct city> kumi(n);
  for(int i=0;i<n;i++){
    kumi[i]={find(0,i),find(1,i),i};
  }
  sort(kumi.begin(),kumi.end());
  int count=0;
  vector<int> ans(n,0);
  vector<int> kosu(n,0);
  kosu[0]=1;
  for(int i=1;i<n;i++){
    if(kumi[i].dou!=kumi[i-1].dou||kumi[i].tetu!=kumi[i-1].tetu) count++;
    ans[kumi[i].id]=count;
    kosu[count]++;
  }
  for(int i=0;i<n;i++){
    cout << kosu[ans[i]] << endl;
  }
  return 0;
}


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

#define int long long

using namespace std;

const int oo = 2e18;

#ifndef ONLINE_JUDGE 
#include "/media/brayand/7801-B00D/debugger.h"
#else
template<typename T>
void db(T x){}
#endif

const int MOD = 1e9 + 7;

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

    int N, K;
    cin >> N >> K;

    int sum = 0;

    int p1 = 0, p2 = N;

    int s1 = 0, s2 = 0;

    for(int i = 0 ; i < K ; i++)
    {
    	s1 += p1;
    	s2 += p2;
    	s1 %= MOD;
    	s1 %= MOD;
    	p1++;
    	p2--;
    }

    for(int i = K ; i <= N+1 ; i++)
    {
    	sum += s2-s1+1;
    	sum %= MOD;

    	s1 += p1;
    	s2 += p2;
    	s1 %= MOD;
    	s1 %= MOD;
    	p1++;
    	p2--;
    }

    cout << sum << '\n';

    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

template <int mod>
struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = 1LL * x * p.x % mod; return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        ll a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(ll n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
};
const int mod = 1000000007;
using mint = ModInt<mod>;

mint dp[100010][15];

int main(){
    string s;
    cin >> s;

    dp[0][0] = 1;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '?') {
            for (int j = 0; j < 13; ++j) {
                for (int k = 0; k <= 9; ++k) {
                   dp[i+1][(10*j+k) % 13] += dp[i][j];
                }
            }
        } else {
            int x = s[i] - '0';
            for (int j = 0; j < 13; ++j) {
                dp[i+1][(10*j+x) % 13] += dp[i][j];
            }
        }
    }
    cout << dp[s.size()][5] << endl;
}

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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    string S;
    cin >> S;
    
    int a = 3;
    fprintf(stdout, "%c", S[0] + 1);
    return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 9)

t = int(input())
for _ in range(t):
    
    n, a, b, c, d = map(int, input().split())
    @lru_cache(None)
    def solve(n):
        tmp = n * d
        if n == 0:
            return 0
        if n == 1:
            return d
            
        if n % 2 == 0:
            tmp = min(tmp, solve(n // 2) + a)
        else:
            tmp = min(tmp, solve(n // 2) + a + d)
            tmp = min(tmp, solve(n // 2 + 1) + a + d)
        
        r = n % 3
        if r == 0:
            tmp = min(tmp, solve(n // 3) + b)
        elif r == 1:
            tmp = min(tmp, solve(n // 3) + b + d)
        else:
            tmp = min(tmp, solve(n // 3 + 1) + b + d)
        
        r = n % 5
        if r == 0:
            tmp = min(tmp, solve(n // 5) + c)
        elif r == 1:
            tmp = min(tmp, solve(n // 5) + c + d)
        elif r == 2:
            tmp = min(tmp, solve(n // 5) + c + d + d)
        elif r == 3:
            tmp = min(tmp, solve(n // 5 + 1) + c + d + d)    
        else:
            tmp = min(tmp, solve(n // 5 + 1) + c + d)
            
        return tmp
    
    ans = solve(n)
    print(ans)

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

int main()
{
	int n; cin>>n;
	int s=0,mx=0;
	int t;
	while(n--)
	{
		cin>>t;
		s+=t;
		mx=max(mx,t);
	}
	cout<<(s-mx/2)<<"\n";
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
void times(alias pred)(int n) {
    foreach(i; 0..n) pred();
}
auto rep(alias pred, T = typeof(pred()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = pred();
    return res;
}

void main() {
    true.reduce!(
        (a, b) => a && (b.front<0 || (writeln(b.front, " ", b.back), false))
    )(readln.chomp.enumerate.array.pipe!(
        s =>
        ((s.length==2 && s.front.value==s.back.value) ? [[1, 2]] : []) ~ (s.length-2).iota.map!(
            i => s[i..i+3]
        ).map!(
            a => (a[0].value==a[1].value || a[1].value==a[2].value || a[2].value==a[0].value) ? [a[0].index+1, a[2].index+1].to!(int[]) : [-1, -1]
        ).array
    )) && writeln("-1 -1");
}


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

int main(){
	int k,x;
	cin >> k >> x;
	int mn = x - k + 1;
	int mx = x + k - 1;
	vector<int> ans;
	for(int i = mn; i < mx; i++) cout << i << " ";
		cout << mx << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3600
from collections import *
from itertools import *
import copy
from heapq import *


N,K=map(int,input().split())
if K>(N-1)*(N-2)//2:
    print(-1)
    exit()

count=(N-1)*(N-2)//2-K
relst=[]
lst=[i for i in range(1,N)]
for l in lst:
    relst.append([l,N])


for l1 in range(1,N):
    for l2 in range(l1+1,N):
        if count>0:
            relst.append([l1,l2])
            count-=1
        else:
            break
print(len(relst))
for a,b in relst:
    print(a,b)


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(10);
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<int> a(n + 1, 2e9);
    a[n] = 0;
    for (int i = n; i > 0; i--) {
        if (s[i] == '1' || a[i] == 2e9)
            continue;
        int mn = i - 1;
        rep(j, max(0, i - m), i) {
            if (s[j] == '0') {
                mn = min(mn, j);
                a[j] = a[i] + 1;
            }
        }
        i = mn + 1;
    }
    if (a[0] == 2e9) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans;
    int k = a[0], c = 0;
    rep(i, 0, n + 1) {
        if (a[i] == k - 1) {
            ans.emplace_back(i - c);
            c = i;
            k--;
        }
    }
    for (auto d0 : ans) {
        cout << d0 << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1480
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)
#include <string>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < (n);++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)

const ll INF = 1e9+7;

// 各桁の和
template<typename T>T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;}
template<typename T>T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}

int main() {
  int n;cin>>n;
  vector<double> v(n+1,INF);rep(i,n)cin>>v[i];
  double ans = 0;

  sort(all(v));
  rep(i,n){
    if(i == 0)continue;
    v[i] = (v[i] + v[i-1])/2;
  }
  print(v[n-1]);
  return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

n = 0
for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            t = i * 500 + j * 100 + k * 50
            if t == x:
                n += 1


print(n)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

typedef long long ll;
using namespace std;
int main() {
  int n;
  cin >> n;
  ll a[n + 1], b[n];
  for(int i = 0; i < n + 1; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> b[i];
  }
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    ll mi = min(a[i], b[i]);
    sum += mi;
    a[i] -= mi;
    b[i] -= mi;
    ll mi1 = min(a[i + 1], b[i]);
    sum += mi1;
    a[i + 1] -= mi1;
    b[i] -= mi1;
  }
  cout << sum << "\n";
  return 0;
}



Measured memory_bytes: 1792
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A, B, N = map(int, input().split())

if B - 1 <= N:
    print(A * (B - 1) // B)
else:
    print(A * N // B - A * (N // B))

Measured memory_bytes: 9568
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=INF;
int n,m;
int d[33][33],c[555][555];
int amari_col[4][33];//あまりiでj色の場所の個数
signed main(){
	
	cin>>n>>m;
	rep(i,m)rep(j,m){
		cin>>d[i][j];
	}
	rep(i,n)rep(j,n){
		cin>>c[i][j];
		c[i][j]--;
		amari_col[(i+j+2)%3][c[i][j]]++;
	}
	
	vector<P> v;
	rep(i,m){//あまり0のマスをi色に
		rep(j,m){//あまり1をjに
			if(i==j)continue;
			rep(k,m){//あまり2をkに
				if(j==k || i==k)continue;
				int cnt=0;
				rep(l,m)cnt+=d[l][i]*amari_col[0][l];//あまりが0のマスのl色をi色に変える
				rep(l,m)cnt+=d[l][j]*amari_col[1][l];
				rep(l,m)cnt+=d[l][k]*amari_col[2][l];
				ans=min(cnt,ans);
			}
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 2432
#include <iostream>

void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
#include <string>
int main() {
	DisableIOSync();
	std::string str;
	std::getline(std::cin, str);
	if(str[0] == '9'
		|| str[1] == '9')
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] num = new int[n];
        int count = 0;
        for (int i = 0; i < n; i++) {
            num[i] = in.nextInt();
            if (check(num[i])) count++;
        }
        System.out.println(count);
    }

    public static boolean check(int num) {
        if (num == 2 || num == 3) return true;  // 两个较小的数另外处理
        if (num % 6 != 1 && num % 6 != 5) return false;  // 不在6的倍数两侧的一定不是质数
        int tmp = (int) Math.sqrt(num);
        for(int i = 5; i <= tmp; i+=6) { // 在6的倍数两侧的也可能不是质数
            if(num % i ==0 || num%(i+2) == 0)
                return false;
        }
        // 排除所有，剩余的是质数
        return true;
    }
}


Measured memory_bytes: 42124
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int p1, p2, p3;
    cin >> p1 >> p2 >> p3;
    int j1, j2;
    cin >> j1 >> j2;

    int min_p = min(p1, min(p2, p3));
    int min_j = min(j1, j2);
    cout << min_p+min_j-50 << endl;
    return 0;
}

Measured memory_bytes: 0
function Main(input) {
	input = input.trim().split("\n").map((input)=>Number(input));
  var len = input[0];
  input.shift();
  input.sort(function(a,b){
  	return a - b;
  });
  var sum = 0;
  for(var i = 0; i < input.length; i++){
    sum += input[i];
  }
  if(sum % 10 == 0){
    for(var i = 0; i < input.length; i++){
      if(input[i] % 10 != 0){
         console.log(sum - input[i]);
      return;
      }
    }
    console.log(0);
  }else{
  	console.log(sum);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
s = input()

#W,Bの総数は変わらない
#WWWWBBBBのような状態になるまでのWの転移回数を求める
wp=s.count('W')

now=0
count=0
for i in range(len(s)):
    if s[i]=='W':
        now+=i
for i in range(wp):
    count+=i
print(now-count)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define FOR(i,a) for (int i=0;i<(a);++i)
#define FORD(i,a) for (int i=(a)-1;i>=0;i--)
#define FORT(i,a,b) for (int i=(a);i<=(b);++i)
#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)
#define trav(i,v) for (auto i : v)
#define all(v) v.begin(),v.end()
#define ad push_back
#define fr first
#define sc second
#define mpr(a,b) make_pair(a,b)
#define pir pair<int,int>
#define all(v) v.begin(),v.end()
#define make_unique(v) v.erase(unique(all(v),v.end()))
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x);
#define dbgv(v);
#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define y1 EsiHancagorcRepa
#ifdef ALEXPC
#define dbg(x); cout<<#x<<" = "<<x<<endl
#define dbgv(v); cout<<#v<<" = ["; trav(tv,v)cout<<"tv,";cout<<"]"<<endl
#endif

//const int N=100,M=N*N;
const ll MOD=1000*1000*1000+7;

const int N=1e6+6;


int main(){
    fastio;
    srng;
    int n,l;
    cin>>n>>l;
    int sum=0;
    FORT(i,l,l+n-1){
        sum+=i;
    }
    if (l<0 && l+n-1<0)
        cout<<sum-(l+n-1)<<endl;
    else if (l>0 && l+n-1>0)
        cout<<sum-l<<endl;
    else cout<<sum<<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);
		String a = sc.next();
		String b = sc.next();
		String c = a + b;
		int e;
		e = Integer.parseInt(c);
		if ((int)Math.sqrt(e)*Math.sqrt(e) !=e)
			System.out.print("No");
		else
			System.out.println("Yes");

	}

}

Measured memory_bytes: 22868
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A&lang=ja

    #include <stdio.h>
    
    int main(void){
        int w,h,i,j;
        while(1){
            scanf("%d %d",&w,&h);
            if(w == 0 && h == 0){
                break;
            }else{
                for(i=0;i<w;i++){
                    for(j=0;j<h;j++){
                        printf("#");
                    }
                    printf("\n");
                }
                printf("\n");
            }
        }

        return 0;
    }


Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i += 2) {
		ans += a[i] % 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007

using namespace std;

bool is_solved[100001];
int penalty[100001];

int32_t main() {
    int t = 1;
    // cin >> t;
    while(t--) {
        int n, m;
        cin >> n >> m;
        int p;
        string s;
        for(int i = 0; i < m; ++i) {
            cin >> p >> s;
            if(!is_solved[p]) {
                if(s == "AC") {
                    is_solved[p] = true;
                } else {
                    penalty[p] += 1;
                }
            }
        }
        int solved = 0, pen = 0;
        for(int i = 1; i <= n; ++i) {
            if(is_solved[i]) {
                solved++;
                pen += penalty[i];
            }
        }
        cout << solved << ' ' << pen << '\n';
    }
    return 0;
}

Measured memory_bytes: 1152
// 最初に自力で思いついた方法はまあまあ合ってた
// 計算量解析を間違っていて、その方法が現実的で無いと
// 思い込んでいた
// 1.8e8
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int gcd(int a, int b){
    return b==0 ? a : gcd(b, a%b);
}

typedef pair<int,int> pii;

int main(){
    int n;
    cin >> n;
    map<pii,vector<int>> m;
    pii p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i].first >> p[i].second;
    }
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int x = p[j].first-p[i].first;
            int y = p[j].second-p[i].second;
            int g = gcd(abs(x), abs(y));
            x /= g, y /= g;
            if(x < 0)   x *= -1, y *= -1;
            // {0, -1}, {0, 1}を同一視したい
            if(x == 0)  y = 1;
            m[{x,y}].push_back((1<<i)+(1<<j));
        }
    }
    vector<int> dp(1<<n, -1);
    dp[0] = 0;
    for(int s = 0; s < 1<<n; s++){
        if(dp[s] == -1) continue;
        for(auto p : m){
            int siz = p.second.size();
            for(int j = 0; j < 1<<siz; j++){
                int ors = 0, flag = 0, popcnt = 0;
                for(int k = 0; k < siz; k++){
                    if(j>>k&1){
                        ors |= p.second[k];
                        if(s&p.second[k])   flag = 1;
                        popcnt++;
                    }
                }
                if(flag==0) dp[s|ors] = max(dp[s|ors], dp[s]+popcnt*(popcnt-1)/2);
            }
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
    return 0;
}


Measured memory_bytes: 3180
#include <iostream>
using namespace std;
int main(void){
    int C[3][3];
    int A[3][2];
    int B[2][3];
    for(int i=0;i<3;i++){
       for(int j=0;j<3;j++){
           cin>>C[i][j];
           
        }
    } 
    for(int i=0;i<3;i++){
       for(int j=0;j<2;j++){
           A[i][j]=C[i][j+1]-C[i][j];
           B[j][i]=C[j+1][i]-C[j][i];
        }
    }
    if(A[0][0]==A[1][0] && A[0][0]==A[2][0]){
        if(A[0][1]==A[1][1] && A[0][1]==A[2][1]){
            if(B[0][0]==B[0][1] && B[0][0]==B[0][2]){
                if(B[1][0]==B[1][1] && B[1][0]==B[1][2]){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256