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

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        rd.readLine();
        String s = rd.readLine();
        out(s.contains("Y")?"Four":"Three");
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


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

int N, M, V, P, A[101010];

bool check(int i) {
    int bigger = 0, less = 0;
    ll other = 0;
    for (int j = 0; j < N; j++) {
        if (j != i) {
            if (A[i] + M < A[j]) bigger++;
            else if (A[j] <= A[i]) less++;
            else other++;
        }
    }

    if (P <= bigger) return false;

    ll rest = V - 1 - bigger - less;
    if (rest <= 0) return true;

    ll tot = 0;
    ll cnt = 0;
    for (int j = 0; j < N; j++) {
        if (A[i] < A[j] and A[j] <= A[i] + M) {
            tot += A[i] + M - A[j];

            cnt++;
            ll ok = min({tot / M, other, rest});
            ll ng = rest - ok;
            if (bigger + ng < P and cnt + ng <= other) {
                return true;
            }
        }
    }

    return false;
}

int main() {
    cin >> N >> M >> V >> P;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A, A + N);

    int ng = -1, ok = N;
    while(ng + 1 != ok) {
        int md = (ng + ok) / 2;
        if (check(md)) {
            ok = md;
        }
        else ng = md;
    }

    int ans = N - ok;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n;
    cin >> n;
    int a = 0,b = 0,ab = 0;
    string s;
    int ans = 0;
    REP(i,n){
        cin >> s;
        if(s[0] == 'B'){
            if(s[s.length() -1] == 'A') ab ++;
            else b ++;
        }
        else if( s[ s.length() -1] == 'A') a ++;
        REP(j,s.length() -1){
            if(s[j] == 'A' and s[j+1] =='B') ans ++;
        }
    }
    if(ab == 0) ans += min(a,b);
    else{
        ans += ab - 1;
        if(a == 0 and b == 0){
            int dd;
        }
        else if(a != 0 and b != 0){
            a -= 1;
            b -= 1;
            ans += 2;
            ans += min(a,b);
        }
        else ans += 1;
    }
    cout << ans << endl;


}








Measured memory_bytes: 256
N, M, X = gets.chomp.split(" ").map(&:to_i)

line = []
N.times do
  line << gets.chomp
end


DATA = []
line.each_with_index do |row, i|
  values = row.split(" ").map(&:to_i)
  DATA[i] = {c: values.shift, a: values}
end
#p DATA


def hoge(arr)
  price = 0
  lern = []

  arr.each do |i|
    price += DATA[i][:c]

    M.times do |j|
      # 全参考書の学習度
      lern[j] = 0 unless lern[j]
      lern[j] += DATA[i][:a][j]
    end
  end

  {
    arr: arr,
    price: price,
    val: lern.map{|l| X - l},
    learned: lern.map{|l| X - l}.all?{|v| v <= 0}
  }
end

results = []

N.times do |j|
  (0..N-1).to_a.combination(j+1).to_a.each do |_arr|
    results << hoge(_arr)
  end
end

lern_arr = results.select{|h| h[:learned]}

if lern_arr.count == 0
  puts -1
else
  puts lern_arr.map{|h| h[:price]}.sort.first
end

Measured memory_bytes: 16680
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)

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

    if(n==1&&m>1)cout<<m-2<<endl;
if(n>1&&m==1)cout<<n-2<<endl;
if(n==1&&m==1)cout<<1<<endl;
    if(n>1&&m>1)cout<<(n-2)*(m-2)<<endl;

}


Measured memory_bytes: 256
import java.security.cert.CollectionCertStoreParameters;
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
#define ll long long

static const int MAX = 300000;

ll A[MAX], B[MAX], n, ans;

void print(int k){
    cout << ans - (B[A[k]] - 1) << endl;
}

int main(){
    ans = 0;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        B[A[i]]++;
    }

    for(int i = 0; i <= n; i++){
        ll m = B[i];
        ans += m*(m-1)/2;
    }

    for(int i = 0; i < n; i++){
        print(i);
    }

    return 0;

}


Measured memory_bytes: 5248
A,B,K=map(int,input().split())
if A>=K:
    c=A-K
    d=B
elif A==0 and B>=K:
    c=0
    d=B-K
elif A+B<=K:
    c=0
    d=0
else:
    d=B-(K-A)
    c=0
print(str(c)+' '+str(d))

Measured memory_bytes: 9192
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import product
def main():
    n, m, x = map(int, input().split())
    books = []
    for _ in range(n):
        book = tuple(map(int, input().split()))
        books.append(book)
    pro = product((1, 0),repeat=n)
    costs = []

    for proe in pro:
        cost = 0
        algo = [0] * m
        for i1, proee in enumerate(proe):
            if proee:
                cost += books[i1][0]
                for al in range(1, m + 1):
                    algo[al-1] += books[i1][al]
                if all([i >= x for i in algo]):
                    costs.append(cost)
    if not costs:
        print(-1)
    else:
        print(min(costs))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9836
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe

ll gcd(ll c, ll d) { return d ? gcd(d, c%d) : c;}
ll lcm(ll c, ll d) { return c / gcd(c,   d) * d;}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int n,v[100]={},c[100] = {},x=0,y=0;
cin >> n;
rep(i,n){
    cin >> v[i];
}
rep(i,n){
    cin >> c[i];
}
rep(i,n){
    if (v[i]>c[i])
    {
        x += v[i];
        y += c[i];
    }
}

cout << x-y << endl;









//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
long long a[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	long long res=0LL;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		res+=a[i]/2;
		a[i]=a[i]%2;
		if(a[i]&&a[i+1]){
			res+=1LL;
			a[i]--;
			a[i+1]--;
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int fact(int x){
    if(x==0) return 0;
    int ans=1; for(int i=2;i<=x;i++) ans*=i;
    return ans;
}
int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n;  cin>>n;  vector<int> a(n),b(n);
  for(int i=0;i<n;i++) cin>>a[i]; 
  for(int i=0;i<n;i++) cin>>b[i];
  int ans1,ans2; ans1=ans2=0;
  for(int i=0;i<n;i++){
        int x,y; x=y=0;
        for(int j=i+1;j<n;j++) {if(a[i]>a[j]) x++; if(b[i]>b[j]) y++;} 
    ans1+=x*fact(n-i-1); ans2+=y*fact(n-i-1);
   }
  cout<<abs(ans1-ans2);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;

ll jou2(ll x) {
	ll ans = 1, a = 2;
	while (x) {
		if (x % 2)ans *= a;
		a *= a;
		ans %= MOD;
		a %= MOD;
		x /= 2;
	}
	return ans;
}

int main(){
	int N;
	cin >> N;
	vector<ll> A(N), ZC(1048577, 1), PC(1048577, 0), La = PC;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		if (i)A[i] ^= A[i - 1];
	}

	ll zc, pc = 0, ans = 0;
	if (A[N - 1]) {
		zc = 1;
		for (int i = 0;i < N - 1;i++) {
			if (A[i] == 0)
				zc += pc;
			if (A[i] == A[N - 1])
				pc += zc;
			zc %= MOD;
			pc %= MOD;
		}
		ans = zc;
	}
	else {
		zc = 0;
		//まず正と0の交互
		for (int i = 0;i < N - 1;i++) {
			if (A[i]) {
				ZC[A[i]] += (zc - La[A[i]])*PC[A[i]];
				ZC[A[i]] %= MOD;
				PC[A[i]] += ZC[A[i]];
				PC[A[i]] %= MOD;
				La[A[i]] = zc;
			}
			else
				zc++;
		}

		for (ll i : PC) {
			ans += i;
			ans %= MOD;
		}

		//次に0のみの連続
		ans += jou2(zc);
		ans %= MOD;
	}
	cout << ans << endl;
}

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

using namespace std;
const int maxn = 2e5 + 5;
char a[maxn], b[maxn];
int f[maxn];
int nxt[maxn][30];
int main() {
    cin >> a + 1 >> b + 1;
    int aa = strlen(a + 1);
    for (int i = 1; i <= aa; ++i) {
        if (f[a[i] - 'a'] == 0) {
            f[a[i] - 'a'] = i;
        }
    }
    for (int i = aa; i >= 1; --i) {
        for (int j = 0; j < 26; ++j) {
            nxt[i - 1][j] = nxt[i][j];
        }
        nxt[i - 1][a[i] - 'a'] = i;
    }
    int now = 0;
    long long ans = 0;
    int bb = strlen(b + 1);
    for (int i = 1; i <= bb; ++i) {
        if (f[b[i] - 'a'] == 0) {
            // cout << "b[i] " << b[i] << endl;
            cout << -1;
            return 0;
        }
        if (nxt[now][b[i] - 'a'] != 0) {
            ans += nxt[now][b[i] - 'a'] - now;
            now = nxt[now][b[i] - 'a'];
        }else {
            ans += aa - now;
            ans += f[b[i] - 'a'];
            now = f[b[i] - 'a'];
        }
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

const int INF = 1001001001;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
}


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

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

  cout << ans<< endl;
}
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main(void){
    int a, b;
    cin >> a >> b;
    
    for(long long i=1; i<=b; i++){
        if(a*i % b == 0){
            cout << a*i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int n; cin >> n;
	vi a(n), b(n), c(n);
	rep(i, n) {
		cin >> a.at(i);
	}
	sort(all(a));
	rep(i, n) {
		cin >> b.at(i);
	}
	rep(i, n) {
		cin >> c.at(i);
	}
	sort(all(c));

	long ans = 0;
	rep(i, n) {
		auto iter1 = lower_bound(all(a), b.at(i));
		auto iter2 = upper_bound(all(c), b.at(i));
		long k1 = iter1 - a.begin();
		long k2 = c.end() - iter2;
		ans += k1 * k2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		int d = (int)Math.ceil(Math.log10(n + 1) / Math.log10(k));
		System.out.println(d);
		scan.close();
	}
}

Measured memory_bytes: 23892
import itertools

def prime_boolean_table(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, n + 1):
        if primes[i]:
            for j in range(i + i, n + 1, i):
                primes[j] = False
    return primes

pl = prime_boolean_table(10**5)
ql = [0]*(10**5+1)
for i in range(1,10**5+1):
    if pl[i] and pl[(i+1)//2]:
        ql[i] += 1
ql = list(itertools.accumulate(ql))
q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    print(ql[r]-ql[l-1])


Measured memory_bytes: 7716
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    priority_queue<pair<int, int>> q;
    rep(i, N) {
        int A;
        cin >> A;
        q.push({A, 1});
    }

    rep(i, M) {
        int B, C;
        cin >> B >> C;
        q.push({C, B});
    }

    LL ans = 0;
    while (0 < N) {
        pair<int, int> p = q.top(); q.pop();
        LL cnt = min(N, p.second);
        ans += p.first * cnt;
        N -= cnt;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, s[100000], t[100000];
ll res;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
	}
	for (int i = 0; i < N; ++i) {
		t[i] = s[i] + s[N - i - 1];
	}
	for (int i = 1; i < N; ++i) {
		ll s = 0;
		for (int j = 0; j < N; j += i) {
			s += t[j];
			if (j < N / 2)res = max(res, s);
			else {
				int a = N - 1 - j;
				if (a < i)break;
				if (a%i) {
					res = max(res, s);
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
// inputに入力データ全体が入る
function Main(input) {
	// ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	bef = input[1].split(' ').map((n) => (parseInt(n)))
	bef = bef.sort()
	var ans = 'YES'
	for (i = 0; i < bef.length; i++) {
		if (i > 0 && (bef[i] == bef[i - 1])) {
			ans = 'NO'
		}
	}

	//出力
	console.log(ans)
	}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

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

int A[30];

bool judge(int i,int m){
	if(m==0) return true;
	if(i==0) {
		if(m==A[0]) return true;
		else return false;
	}
	if(judge(i-1,m)) return true;
	else if(judge(i-1,m-A[i])) return true;
	return false;
}

int main (){
	int n,q,m;
	cin>>n;
	for(int i = 0;i<n;i++) cin>>A[i];
	cin>>q;
	for(int i = 0;i<q;i++) {
		cin>>m;
		if(judge(n,m)) cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
	
}


Measured memory_bytes: 3096
import sys


# N, M = map(int, input().split())
# nums = list(map(int, input().split()))
# nums_2d = [list(map(int, input().split())) for _ in range(N)]


def main():
    print(solve())


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    ok = True

    for a in As:
        if a % 2 == 1:
            continue
        if a % 3 == 0:
            continue
        if a % 5 == 0:
            continue
        ok = False

    if ok:
        return 'APPROVED'
    else:
        return 'DENIED'


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys
import os
import itertools
import numpy as np
from collections import deque

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

    S=input()

    if S.islower():
        print('a')
    else:
        print('A')

if __name__ == '__main__':
    main()


Measured memory_bytes: 27084
#include <bits/stdc++.h>
using namespace std;
int main () {
    string s;
    cin >> s;
    int ans = s.length();
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'A') {
            ans -= i;
            break;
        }
    }
    reverse(s.begin(), s.end());
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == 'Z') {
            ans -= i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
#define mid (p[i]-p[i-1]>>1)
typedef long long ll;
int n,a[1005],p[1005],st[1005];
int main(){
	scanf("%d",&n);int f=1;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),f=a[i]>0?0:f;
	if(f){
		int mx=1,v=a[1],cnt=0;
		for(int i=2;i<=n;i++)if(a[i]>v)mx=i,v=a[i];
		printf("%d\n%d\n",v,n-1);
		for(int i=1;i<mx;i++)printf("%d\n",1);
		for(int i=n;i>mx;i--)printf("%d\n",i-mx+1);
		return 0;
	}
	ll sum1=0,sum2=0;int cnt=0,ans=0;
	for(int i=1;i<=n;i+=2)sum1+=max(a[i],0);
	for(int i=2;i<=n;i+=2)sum2+=max(a[i],0);
	f=(sum1<sum2);printf("%lld\n",max(sum1,sum2));
	for(int i=1+f;i<=n;i+=2)if(a[i]>=0)p[++cnt]=i;
	for(int i=1;i<p[1];i++)st[++ans]=1;
	for(int i=n;i>p[cnt];i--)st[++ans]=i-p[1]+1;
	for(int i=2;i<=cnt;i++)
		for(int j=mid+1;j>1;j--)st[++ans]=j;
	printf("%d\n",ans);
	for(int i=1;i<=ans;i++)printf("%d\n",st[i]);
    return 0;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n,k = m()

s = [[] for i in range(n)]

sss = [[Max,Max,Max] for i in range(n)]

for i in range(k):
    u,v = m()
    u -= 1
    v -= 1
    if v not in s[u]:
        s[u].append(v)

st,g = m()
st -= 1
g -= 1
co = Max

eee = [[s,0,st,0]]
eee = cl.deque(eee)
def bfs(x,nn,now,coun):
    global eee,sss,g,co
    if sss[now][nn] == Max:
        if nn == 0 and g == now:
            co = min(co,coun)
        else:
            sss[now][nn] = coun
            if nn == 2:
                nn = 0
                coun += 1
            else:
                nn += 1
            for i in x[now]:
                eee.append([x,nn,i,coun])
    else:
        if now == g and nn == 0:
            co = min(co,coun)

while eee:
    op = eee.popleft()
    bfs(op[0],op[1],op[2],op[3])

#dfs(s,0,g,0)
if co == Max:
    print(-1)
else:
    print(co)



Measured memory_bytes: 103004
H,W = map(int,input().split())
data = [list(input()) for i in range(H)]

A = [[0]*(W) for i in range(H)]
B = [[0]*(W) for i in range(H)]

for i in range(H):
    a = 0
    f = 0
    t = 0
    for j in range(W):
        if data[i][j] == '.' and j < W-1:
            a += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                A[i][k] = a
            t = j+1
            f = j+1
            a = 0
        else:
            for k in range(f,t+1):
                A[i][k] = a+1
for j in range(W):
    b = 0
    f = 0
    t = 0
    for i in range(H):
        if data[i][j] == '.' and i < H-1:
            b += 1
            t += 1
        elif data[i][j] == '#':
            for k in range(f,t):
                B[k][j] = b
            t = i+1
            f = i+1
            b = 0
        else:
            for k in range(f,t+1):
                B[k][j] = b+1
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans,A[i][j]+B[i][j])
print(ans-1)

Measured memory_bytes: 249352
#include <iostream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin>>N;
  int num[N];
  for(int i=0;i<N;i++){
      cin>>num[i];
  }
  sort(num,num+N);
  int sum=0; int count=0; int min=-1;
  for(int i=0;i<N;i++){
     sum+=num[i];
     if(num[i]%10==0) {count++;}
     if(num[i]%10!=0&&min==-1) {min=num[i];}
  }
  if(sum%10!=0) {cout<<sum;}
  else if(count==N) {cout<<0;}
  else {cout<<sum-min;}
  return  0;
}


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

void call(int n){
	if(!(n%3)){
		cout << " " << n;
		return;
	}
	for(int i=n;i>0;i/=10){
		if(i%10==3){
			cout << " " << n;
			return;
		}
	}
	return;
}

int main() {
	int n;
	cin >> n;
	for(int i=3;i<=n;i++) call(i);
	cout << endl;
    return 0;
}

Measured memory_bytes: 1164
def solve():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N, Q = map(int, input().split())
    adjL = [[] for _ in range(N)]
    for _ in range(N-1):
        A, B = map(int, input().split())
        A, B = A-1, B-1
        adjL[A].append(B)
        adjL[B].append(A)

    anss = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p = p-1
        anss[p] += x

    def dfs(vNow, vPar, x):
        anss[vNow] += x
        ans = anss[vNow]
        for v2 in adjL[vNow]:
            if v2 != vPar:
                dfs(v2, vNow, ans)

    dfs(0, -1, 0)

    print(' '.join(map(str, anss)))

solve()


Measured memory_bytes: 284052
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    bool bWin = false;
    for(int i = 0; i < n; i++){
        int a;
        scanf("%d", &a);
        if(a % 2 == 1){
            bWin = true;
        }
    }
    
    if(bWin) {
        printf("first");
    } else {
        printf("second");
    }
    return 0;
}


Measured memory_bytes: 3236
import sys
input=sys.stdin.readline

N,M=map(int,input().split())
st=[list(map(int,input().split())) for i in range(M)]

data=[[] for i in range(N)]
edge_num=[0]*N
for s,t in st:
    s-=1
    t-=1
    edge_num[s]+=1
    data[s].append(t)

dp=[0]*N

for i in range(N-2,-1,-1):
    kkk=edge_num[i]
    for v in data[i]:
        dp[i]+=(dp[v]+1)/kkk

ans=dp[0]

for i in range(N-1):
    new_dp=dp[:]
    num=data[i][0]
    for v in data[i]:
        if dp[v]>dp[num]:
            num=v
    kkk=edge_num[i]
    if kkk==1:
        continue
    new_dp[i]=0
    for v in data[i]:
        if num==v:
            continue
        else:
            new_dp[i]+=(dp[v]+1)/(kkk-1)
    for j in range(i-1,-1,-1):
        new_dp[j]=0
        kkk=edge_num[j]
        for v in data[j]:
            new_dp[j]+=(new_dp[v]+1)/kkk
    ans=min(ans,new_dp[0])

print(ans)

Measured memory_bytes: 78812
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

if ((a1 - b1) * (a2 - b2) > 0) or (abs(a1 - b1) * t1 > abs(a2 - b2) * t2):
  print(0)
elif abs(a1 - b1) * t1 == abs(a2 - b2) * t2:
  print("infinity")
else:
  d, m = divmod(abs(a1 - b1) * t1, abs(a2 - b2) * t2 - abs(a1 - b1) * t1)
  ans = d * 2
  if m > 0:
    ans += 1
  print(ans)


Measured memory_bytes: 9144
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    String[] lines = getStdin();
    String a = lines[0];
    int num = Integer.parseInt(a);
    
    long total = 0;
    for (int i = 1; i <= num; i++){
        if (i % 3 == 0 && i % 5 == 0){
            String s = Integer.toString(i);
            s = "FizzBuzz";
        } else if (i % 3 == 0){
            String s = Integer.toString(i);
            s = "Fizz";
        } else if (i % 5 == 0){
            String s = Integer.toString(i);
            s = "Buzz";
        } else {
            total = total + i;
        }
    }
    System.out.println(total);
   
}
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> vec(n);
  rep(i,2*m){
    int x;
    cin >> x;
    vec[x-1]++;
  }
  rep(i,n) cout << vec[i] << endl;

}

Measured memory_bytes: 3556
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    long a = cin.nextLong();
    long b = cin.nextLong();

    long res = 0;

    if (a%2==1&&b%2==0) {
      res = a^b;
      a++;
      b--;
    }
    else if (a%2==1&&b%2==1) {
      res = a;
      a++;
    }
    else if (a%2==0&&b%2==0) {
      res = b;
      b--;
    }

    long diff = (b-a+1)/2;
    int mark = 0;
    if (diff%2==1) {
      mark = 1;
    }
    System.out.println(res^mark);

  }

}

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

int main()
{
	string str;
	cin>>str;
	string str1,str2;
	str1=str;
	str2=str;

	int cnt=0;
	int l=str.size();
	reverse(str1.begin(),str1.end());
	
	if(str==str1)
	cnt++;
	
	reverse(str1.begin(),str1.end());
	
	reverse(str1.begin(),str1.begin()+(l-1)/2);
	
	if(str==str1)
	cnt++;
	
	reverse(str2.begin()+((l+3)/2)-1,str2.end());
	
	if(str==str2)
	cnt++;
	if(cnt==3)
	cout<<"Yes";
	else cout<<"No";
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); 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; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

	

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;

	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; ++i) {
		if (i % k == 0) {
			cout << "OK";
			return 0;
		}
	}
	cout << "NG";
	return 0;
}

Measured memory_bytes: 3692
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n, m, q = MI()
train = [LI() for _ in range(m)]
query = [LI() for _ in range(q)]
table = [[0 for _ in range(n+1)] for _ in range(n+1)]
ruisekiwa = [[0 for _ in range(n+1)] for _ in range(n+1)]
for left, right in train:
    table[left][right] += 1
for i in range(1, n+1):
    for j in range(1, n+1):
        ruisekiwa[i][j] = table[i][j]
        if j > 1:
            ruisekiwa[i][j] += ruisekiwa[i][j-1]
        if i > 1:
            ruisekiwa[i][j] += ruisekiwa[i-1][j]
        if j > 1 and i > 1:
            ruisekiwa[i][j] -= ruisekiwa[i-1][j-1]
for p, q in query:
    print(ruisekiwa[q][q] - ruisekiwa[p-1][q] - ruisekiwa[q][p-1] + ruisekiwa[p-1][p-1])




Measured memory_bytes: 122584
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>
#include<map>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	ff(i, 0, 1000) {
		int s1=30000, s2=30000;
		int v;
		if (i <100) {
			v = 0;
		}
		else {
			v = i / 100;
		}
		int w;
		if ((i % 100) == 0) {
			w = 0;
		}
		else {
			w = (i % 100) / 10;
		}
		int z;
		z = i % 10;


		ff(i1, 0, s.size()) {
			if (s[i1]-'0' == v) {
				s1 = i1;
				break;
			}
		}
		ff(i2, s1+1, s.size()) {
			if (s[i2]-'0' == w) {
				s2 = i2;
				break;
			}
		}
		ff(i3, s2+1, s.size()) {
			if (s[i3] -'0'== z) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool x=1;
    rep(i,s.size())
    {
        if((i%2==0)&s[i]=='L')
            x=0;
        if((i%2)&s[i]=='R')
            x=0;
    }
    if(x==0)
        cout<<"No";
    else
        cout<<"Yes";
}


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

int main() {
    int K,X; cin >> K >> X;
    for(int i=X-K+1; i<=K+X-1;i++){
        cout << i << " " << flush;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
ls=list(map(int,input().split()))
ans=0

for i in range(1,sum(ls)//n+1):
    am=0
    ans+=1
    for j in range(0,n-1):
        am=am+ls[j]-i
        if am<0:
            break
    else:
        continue
    if am!=0:
        ans=ans-1
    break

print(ans)



Measured memory_bytes: 5596
#include <stdio.h>
 
int main(void){
int n,i,j,m,a[100],t,c;
c = 0;
scanf("%d", &n);
for(i=0;i<n;++i){
scanf("%d", &a[i]);
}
for(i=0;i<n;++i){
m=i;
for (j=i;j<n;++j){
if(a[j]<a[m]) 
m=j;
}
if(m!=i){
t=a[i];
a[i]=a[m];
a[m]=t;
c=c+1;
}
}
for(i=0;i<n;++i){
printf("%d",a[i]);
if(i!=n-1)putchar(' ');
}
putchar('\n');
printf("%d\n",c);
return 0;
}

Measured memory_bytes: 1796
N = int(input())
D = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
Ans = [["a"]]
for i in range(1, 10):
    before = Ans[i - 1]
    # print(before)
    next = []
    for j in before:
        L = set(list(j))
        # print(L)
        for k in range(len(L) + 1):
            # print(j)
            next.append(j + D[k])
    Ans.append(next)
# print(Ans)
print(*Ans[N - 1], sep="\n")



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x; cin >> x;
  if(x<1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
  
  return 0;
}


Measured memory_bytes: 3608
N = int(input())
list = list(map(int,input().split()))
list.sort()

cnt_min = len([i for i in list if i < 0])
num_min = min([abs(i) for i in list])
sum_abs = sum([abs(i) for i in list])

if cnt_min%2 == 0:
    print(sum_abs)
else:
    print(sum_abs-2*num_min)

Measured memory_bytes: 14412
#include <cstdio>
#include <cmath>
	
int main(){
	int num, x[100],y[100];
	
	scanf("%d", &num);
	for(int i=0; i<num; ++i){
		scanf("%d", &x[i]);
	}	
	for(int i=0; i<num; ++i){
		scanf("%d", &y[i]);
	}
	
	for(int p=1; p<=3; ++p){
		double tmp = 0;
		for(int i=0; i<num; ++i){
			tmp += pow( fabs(x[i]-y[i]),p);
		}
		printf("%lf\n", pow(tmp,1.0/p));
	}
	
	double ma =0;
	for(int i=0; i<num; ++i){
		if(ma < fabs(x[i]-y[i])){
			ma = fabs(x[i]-y[i]);
		}
	}
	printf("%lf\n", ma);
	
	return 0;	
}


Measured memory_bytes: 2820
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if(s.size() % 2 == 0){
        for(int n = s.size() - 2; n >= 0; n-=2){
            string s_sub1 = s.substr(0, n/2);
            string s_sub2 = s.substr(n/2, n/2);
            if(s_sub1 == s_sub2){
                ans = n;
                break;
            }
        }
    } else {
        string t = s.substr(0, s.size()-1);
        for(int n = t.size() - 2; n >= 0; n-=2){
            string t_sub1 = t.substr(0, n/2);
            string t_sub2 = t.substr(n/2, n/2);
            if(t_sub1 == t_sub2){
                ans = n;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}


ll getFirstSetBitPos(ll n) 
{ 
    return log2(n & -n) + 1; 
} 

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

    ll current = 1, ans = 0;
    
    while(current < b)
    {
        current -= 1;
        current += a;
        ans++;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define MAX 100000
typedef long long llong;
int N,K;
llong T[MAX];

int check(llong P){
    int bagNum=0;
    for(int trackNum=0;trackNum<K;trackNum++){
        llong sum=0;
        while(sum+T[bagNum] <= P){
            sum += T[bagNum];
            bagNum++;
            if(bagNum == N){
                return N;
            }
        }
    }
    return bagNum;
}

int Ans(){
    llong left=0;
    llong right=100000*10000;
    llong mid;
    while(right-left>1){
        mid=(left+right)/2;
        int p = check(mid);
        if(p>=N){
            right=mid;
        }else{
            left=mid;
        }
    }
    return right;
}

int main(){
    scanf("%d %d", &N,&K);
    for(int i=0;i<N;i++){
        scanf("%d",&T[i]);
    }
    llong ans = Ans();
    printf("%d\n", ans);
}


Measured memory_bytes: 3472
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int[] counts = new int[101];
        int max = 0;
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            int n = Integer.parseInt(line);
            max = Math.max(++counts[n], max);
        }
        for (int i = 1; i <= 100; i++) {
            if (counts[i] == max) {
                out.println(i);
            }
        }
    }
}

Measured memory_bytes: 9368
import heapq

n, m = map(int, input().split())

INF = 2147483647
G = [[] for i in range(n)]
MST = [[-1 for j in range(n)] for i in range(n)]


def dijkstra(s):
    check, dist = [0 for i in range(n)], [INF for i in range(n)]
    dist[s], pq = 0, []
    heapq.heappush(pq, (0, s))
    p = [-1 for i in range(n)]

    while len(pq) != 0:
        u = heapq.heappop(pq)
        check[u[1]] = 2

        if dist[u[1]] < u[0]:
            continue

        if p[u[1]] != -1:
            MST[p[u[1]]][u[1]], MST[u[1]][p[u[1]]] = 1, 1
        for v in G[u[1]]:
            if check[v[0]] != 2:
                if dist[u[1]] + v[1] < dist[v[0]]:
                    dist[v[0]], check[v[0]] = dist[u[1]] + v[1], 1
                    p[v[0]] = u[1]
                    heapq.heappush(pq, (dist[v[0]], v[0]))


def main():
    for i in range(m):
        a, b, c = map(int, input().split())
        G[a-1].append((b-1, c))
        G[b-1].append((a-1, c))
        MST[a-1][b-1] = MST[b-1][a-1] = INF

    for i in range(n):
        dijkstra(i)

    cnt = 0
    for i in range(n):
        for j in range(n):
            if MST[i][j] == INF:
                cnt += 1

    print(cnt//2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
ll solve(ll n, ll a){
      if(n-a < a){
            a = n-a;
      }
      ll x = 1, y = 1;
      for(ll i = 1; i<=a; i++){
            x = (x * i)  % mod;
            y = (y * (n - i + 1)) % mod;
      }
      return (y*power(x, mod-2, mod))%mod;
}

int run_test(){
      ll n,a ,b;
      cin >> n >> a >> b; 
      ll t  = power(2, n, mod);
      t = (t - 1 + mod)%mod;
      t = (t - solve(n ,a) + mod) % mod;
      t = (t - solve(n, b) + mod) % mod;
      cout << t;
      return 0; 
}
    
int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

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

int main() {
  
  int n;
  cin >> n;
  
  vector<int> num(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  
  int64_t min_total = 100000000000000;
  int64_t total = 0;
  for (int i = 0; i < 100; i++) {
    
    for (int data : num) {
      total += (data - i) * (data - i);
    }
    
    min_total = min(min_total, total);
    total = 0;
  }
  
  cout << min_total << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAX 100000000000000000
int main()
{

    //freopen("inputfile.txt","r",stdin);
    int n;cin>>n;
    if(n>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <vector>

using namespace std;

const int MAXN = 1e5+5;

int n, a, b;

vector <int> G[MAXN];
int dad[MAXN], sz[MAXN], h[MAXN];

void dfs(int x, int p) {
	dad[x] = p;
	for (int i: G[x]) {
		if (i == p) continue;
		h[i] = h[x] + 1;
		dfs(i, x);
		sz[x] += sz[i];
	}
	sz[x]++;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n-1; ++i) {
		scanf("%d%d", &a, &b); a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(0, -1);
	int v = n-1;
	for (int i = 0; i < (h[n-1]-1)/2; ++i) v = dad[v];
	printf("%s\n", (sz[v] >= sz[0]-sz[v]) ? "Snuke" : "Fennec");
	return 0;
}



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

namespace ITP1 {
	class Program {
		public static void Main() {
			int[] input = Console.ReadLine()
				.Split()
				.Select(int.Parse)
				.ToArray();

			int result = Enumerable.Range(input[0], input[1] - input[0] + 1)
				.Where(i => input[2] % i == 0)
				.Count();
			Console.WriteLine(result);
		}

	}
}



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

int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(c-a-b>0&&0<((a-b)*(a-b)+c*(c-2*a-2*b)))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
alpha = list("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")
i = 0
while i < len(s):
  j = 0
  while j < 26:
    if s[i] == alpha[j]:
      s[i] = alpha[j+n]
      break
    else:j += 1
  i += 1

k = 0
while k < len(s) :
  print(s[k],end ="")
  k += 1

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

int main()
{
	char a[4], b[4], s[7];
	long ab,c;
	scanf("%s %s",&a,&b);
	sprintf(s,"%s%s",a,b);
	ab = atol(s);
	c = floor(sqrt(ab)+0.5);
	printf("%s\n",(ab==c*c)? "Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <cassert>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <sstream>
#include <vector>
 
using namespace std;
 
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  int H[N];
  for (auto i = 0; i < N; i++) {
    cin >> H[i];
  }

  auto maxCnt = 0;
  auto i = 0;
  while (i < N) {
    auto cnt = 0;
    for (auto oi = i + 1; oi < N; oi++) {
      auto h = H[i + cnt];
      auto oh = H[oi];
      if (h < oh) {
        break;
      }
      cnt++;
    }

    if (cnt > maxCnt) {
      maxCnt = cnt;
    }
    i += cnt + 1;
  }

  cout << maxCnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdlib>
#include<string>
#include <limits>
using namespace std;

int main(){
	int H,W,h,w;
	int masu,ans;
	cin>>H>>W>>h>>w;

	masu = H*W;
	ans = masu - ( h*W + w*(H-h));



	cout<<ans<<endl;

}

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

int main(){
  long long a,b,x;
  cin>>a>>b>>x;
  
  long long count=0;
  /*for(long long i=a%x==0?a/x:a/x+1;i*x<=b;i++){
    //if(i*x>=a){
      count++;  
    //}
  }*/
  
  //cout<<b/x+1<<endl;
  //long tmp=a%x==0?a/x:a/x+1;
  //cout<<tmp<<endl;
  count = (b/x+1) - (a%x==0?a/x:a/x+1);
  
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve(){
    int n,x=0; cin>>n;
    int v[n],c[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>v[i];
    }
    for (int i = 0; i < n; ++i)
    {
        cin>>c[i];
    }
    for (int i = 0; i < n; ++i)
    {
        if(v[i]>c[i]){
            x+=v[i]-c[i];
        }
    }
    cout<<x;
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256