akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

for i in range(m):
    H, W = map(lambda x: int(x) - 1, input().split())
    col[W] += 1
    row[H] += 1
    bomb.append((H, W))

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)

Measured memory_bytes: 90172
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String ans = "APPROVED";
		for(int i = 0;i < N;i++){
			int A = sc.nextInt();
			if(A % 2 == 0){
				if(A % 3 != 0 && A % 5 != 0){
					ans = "DENIED";
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25300
N = int(input())
A = list(map(int, input().split()))
alta = []
for i in range(N):
    alta.append(A[i] - (i + 1))
plus = min(alta)
for i in range(N):
    alta[i] -= plus

def f(x):
    sum = 0
    for i in alta:
        sum += abs(x - i)
    return sum

left, right = 0, max(alta)
while abs(right - left) > 3:
    mid1 = (right * 2 + left) // 3 + 1
    mid2 = (right + left * 2) // 3
    if f(mid1) >= f(mid2):
        # 上限を下げる（最小値をとるxはもうちょい下めの数だな）
        right = mid1
    else:
        # 下限を上げる（最小値をとるxはもうちょい上めの数だな）
        left = mid2
ans = float('inf')
for i in range(left, right + 1):
    ans = min(ans, f(i))
print(ans)

Measured memory_bytes: 97748
w, h, n = gets.split.map(&:to_i)
lim = [0, w, 0, h]
n.times do
  x, y, a = gets.split.map(&:to_i)
  if a == 1
    lim[0] = x if lim[0] < x
  elsif a == 2
    lim[1] = x if lim[1] > x
  elsif a == 3
    lim[2] = y if lim[2] < y
  elsif a == 4
    lim[3] = y if lim[3] > y
  end
end

if lim[0] >= lim[1] || lim[2] >= lim[3]
  puts 0
else
  puts (lim[1] - lim[0]) * (lim[3] - lim[2])
end


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int A,B,M;
    cin >> A >> B >> M;
    vector<int>a(A),aa(A),bb(B),b(B),x(M),y(M),c(M);
    
    int answer = 3000000;
    REP(i,A){
        cin >> a[i];
        aa[i] = a[i];
    }
    REP(i,B){
        cin >> b[i];
        bb[i] = b[i];
    }
    SORT(aa);
    SORT(bb);
    answer = min(answer,aa[0]+bb[0]);
    REP(i,M){
        cin >> x[i] >> y[i] >> c[i];
        x[i]--;
        y[i]--;
    }

    REP(i,M){
        answer = min(answer,a[x[i]]+b[y[i]]-c[i]);
    }
    cout << answer << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> L(N);
  ll cnt=1, n=0;
  for (int i = 0; i < N; ++i) {
    cin >> L[i];
    n+=L[i];
    if(n<=X)
      cnt++;
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 256
import math

N = int(input())

def find_desired_prime(n):
    primenums = []
    i = 2
    while True:
        isprime = True
        for j in range (2, math.ceil(math.sqrt(i)) + 1):
            if (i % j == 0):
                isprime = False
                break
        if isprime and i % 5 == 1:
            primenums.append(i)
        if len(primenums) >= n:
            break
        i += 1
    
    return primenums

print(' '.join(str(res) for res in find_desired_prime(N)))

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-

n=list(map(int, input().split()))[0]
lst=[]
name_lst=[]
for i in range(n):
    name,score=input().split()
    if name not in name_lst:
        name_lst.append(name)
    lst.append({"number":i,"name":name,"score":int(score)})

answer=[]
for n in sorted(name_lst):
    l1=[i for i in lst if i["name"]==n]
    l1=sorted(l1,key=lambda x:x["score"])
    answer.extend(reversed(l1))

a=[print(i["number"]+1) for i in answer]
#4
#khabarovsk 20
#moscow 10

Measured memory_bytes: 3064
import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**20
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = ri()
a = rl()
ans=1
flag=False
for i in a:
    ans*=i
    if ans>10**18:
        flag=True
        break
   
zero=False
for i in a:
    if i==0:
        zero=True
        break
if zero:
    print(0)    
elif flag:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 83288
import java.util.*;
import java.util.stream.IntStream;

public class Main {

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

        ArrayList<ArrayList<Integer>> students = parse(N,sc);
        ArrayList<ArrayList<Integer>> checkpoints =  parse(M,sc);
        ArrayList<ArrayList<Integer>> result = new ArrayList<>();
        for(ArrayList<Integer> student : students){
           // result.add();
                    search(student, checkpoints);

        }
       // debugPrint(result);
    }

    private static int distance(ArrayList<Integer> a ,ArrayList<Integer> b ){
        int a_ = Math.abs(a.get(0) -  b.get(0) ) ;
        int b_ = Math.abs(a.get(1) -  b.get(1) );
        return a_ + b_ ;
    }

    private static ArrayList<Integer>  search(ArrayList<Integer> student,ArrayList<ArrayList<Integer>> checkpoints ){
        ArrayList<Integer> distances  =  new ArrayList<Integer>();

        for (ArrayList<Integer> checkpoint : checkpoints){
            distances.add(distance(checkpoint, student));
        }

        Integer minDistance = Collections.min(distances);

        int index = 0;
        for(int i=0  ; i < distances.size();i++ ){
            if(minDistance  == distances.get(i)){
                index = i;
                break;
            }
        }

        System.out.print( index +1);

        System.out.print('\n' );


        return checkpoints.get(index);
    }

    private static ArrayList<ArrayList<Integer>> parse(int rowNum,Scanner sc){
        ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
        IntStream.range(0,rowNum).forEach( n -> {
            int x = sc.nextInt();
            int y = sc.nextInt();
            ArrayList<Integer>  row = new ArrayList<Integer>();
            row.add(x);
            row.add(y);
            result.add(row);
        });
        return result;
    }

    private static void debugPrint( ArrayList<ArrayList<Integer>> data ){
        for(ArrayList<Integer> row : data){
            for(Integer cell : row){
                System.out.print(cell);
                System.out.print(' ');
            }
            System.out.print('\n');
        }
    }
}




Measured memory_bytes: 26836
#include <iostream>
#include <stack>

using namespace std;

int main() {

	int j, n, end=0;
	stack<int> B, C;
	int A[10];

	cin >> n;
	for(; n!=0; n--) {
		for(int i=0; i<10; i++) {
			cin >> A[i];
		}
		B.push(0);
		C.push(0);
		for(int i=0; i<10; i++) {
			j=A[i];
			if(B.top()==0)
				B.push(j);
			else {
				if(B.top()>j) {
					if(C.top()>j) {
						end++;
						break;
					}
					else 
						C.push(j);
				}
				else {
					if(C.top()>j)
						B.push(j);
					else
						(j-B.top()>j-C.top()) ? C.push(j) : B.push(j);
				}
			}
		}

		if (end!=0)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
		end=0;
	}

	return 0;

}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    int n,i,j;
    cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);
    for(i = 0;i < n-1;++i){
        cin >> c.at(i) >> s.at(i) >> f.at(i);
    }
    
    for(i = 0;i < n-1;++i){
        int temp = 0;
        for(j = i;j < n-1;++j){
            if(temp < s.at(j)){
                temp = s.at(j)+c.at(j);
            }else{
                if((temp-s.at(j))%f.at(j)){
                    temp = temp-(temp-s.at(j))%f.at(j)+f.at(j)+c.at(j);
                }else{
                    temp += c.at(j);
                }
            }
        }
        cout << temp << endl;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair< int64, int > Pi;
const int64 INF = 1LL << 60;
struct edge {
  int to, cost;
};
vector< edge > graph[400004];
int64 min_cost[400004];
int H, W, K;
vector< Pi > X[100001], Y[100001];
  
int64 Dijkstra()
{
  fill_n(min_cost, 400004, INF);
  priority_queue< Pi, vector< Pi >, greater< Pi > > Que;
  min_cost[K - 2] = 0;
  Que.push(Pi(0, K - 2));
  while(!Que.empty()) {
    Pi p = Que.top(); Que.pop();
    if(min_cost[p.second] < p.first) continue;
    if(p.second == K - 1) return(p.first);
    for(auto e : graph[p.second]) {
      int64 next = p.first + e.cost;
      if(min_cost[e.to] > next) {
        min_cost[e.to] = next;
        Que.push(Pi(next, e.to));
      }
    }
  }
  return(-1);
}
  
  
int main()
{
  cin >> W >> H >> K;
  for(int i = 0; i < K; i++) {
    int x, y;
    cin >> x >> y;
    X[x].push_back(Pi(y, i));
    Y[y].push_back(Pi(x, i));
  }
  
  X[1].push_back(Pi(1, K));
  Y[1].push_back(Pi(1, K));
  
  X[W].push_back(Pi(H, K + 1));
  Y[H].push_back(Pi(W, K + 1));
  
  K += 2;
  
  for(int i = 0; i < 100001; i++) {
    sort(X[i].begin(), X[i].end());
    sort(Y[i].begin(), Y[i].end());
    for(int j = 1; j < X[i].size(); ++j) {
      const Pi &prev = X[i][j - 1], &curr = X[i][j];
      graph[prev.second].push_back((edge){curr.second, (int)(curr.first - prev.first)});
      graph[curr.second].push_back((edge){prev.second, (int)(curr.first - prev.first)});
    }
    for(int j = 1; j < Y[i].size(); ++j) {
      const Pi &prev = Y[i][j - 1], &curr = Y[i][j];
      graph[prev.second + K].push_back((edge){curr.second + K, (int)(curr.first - prev.first)});
      graph[curr.second + K].push_back((edge){prev.second + K, (int)(curr.first - prev.first)});
    }
  }
  
  
  for(int i = 0; i < K - 2; i++) {
    graph[i].push_back((edge){i + K, 1});
    graph[i + K].push_back((edge){i, 1});
  }
  graph[K - 1 + K].push_back((edge){K - 1, 0});  cout << Dijkstra() << endl;
}

Measured memory_bytes: 51724
N = gets.to_i
v = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
d = []
sum = 0

for i in 0..(N-1)
  d[i] = v[i] - c[i]
end
for i in 0..(N-1)
  if d[i] > 0
    sum += d[i]
  end
end
puts sum

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

using namespace std;
const string MINUSINF = "-";

void chmax(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

long long match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

int main() {
    int N, M; cin >> N >> M;
    vector<int> A(M);
    for (int i = 0; i < M; ++i) cin >> A[i];

    // 初期化
    for (int i = 0; i < 11000; ++i) dp[i] = MINUSINF;

    // 初期条件
    dp[0] = "";

    // DP ループ
    for (int i = 0; i <= N; ++i) {
        if (dp[i] == MINUSINF) continue;
        for (auto a : A)  chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 43776
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]


# Warshall–Floyd
def main():
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j] = min(c[i][j], c[i][k] + c[k][j])

    print(
        sum(
            c[a][1] for column in A for a in column if a >= 0 
        )
    )


if __name__ == "__main__":
    main()



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

int main() {
  int a;
  cin>>a;
  vector<int> vec(a);
  for(int i=0;i<a;i++){
    cin>>vec.at(i);
  }
  int count=0;
  
  for(int i=0;i<a;i++){
    for(int j=0;j<a;j++){
      if(i!=j){
        count+=(vec.at(i))*(vec.at(j));
      }
    }
  }
  cout<<count/2<<endl;
        
}

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

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int arr[n];
    unordered_map<long long,long long> freq;
    for(int i=0;i<n;i++)  {
        cin >> arr[i];
        freq[arr[i]]++;         // calculating the freq of all the elements
    }
    long long sum = 0;
    for(auto x : freq) {
        sum += (x.second*(x.second-1))/2;
    }

    for(int i=0;i<n;i++) {
        // when i lose an element when counting ways...so ways before losing that element - ways after losing that element and subtract this difference with the sum...those are the ways to pick two unique elements left 
        long long before = (freq[arr[i]] * (freq[arr[i]]-1))/2;
        long long after = ((freq[arr[i]]-1) * (freq[arr[i]]-2))/2;
        long long temp = sum - (before-after);
        cout << temp << endl;
    }
}

Measured memory_bytes: 8392
import java.util.Scanner;

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

        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                int totalYen = i * 10000 + j * 5000 + (n - i - j) * 1000;
                if (totalYen == y) {
                    System.out.print(i + " " + j + " " + (n - i - j));
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 39308
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define nax 200000
using namespace std;
typedef struct {
	int a;
	int b;
	int c;
}Data;

int main() {
	int N;
	Data data[nax];
	int max = 0;
	int sum = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		data[i].a = x;
		data[i].b = y;
		data[i].c = y-x;
		sum += x;
		max = (y > max ? y : max);
	}
	if (sum > max) {
		cout << "No";
		return 0;
	}
	sort(data, data + N, [](Data i, Data j)->bool {return i.b < j.b; });
	int a[nax] = { 0 };
	int t = 0;
	for (int i = 0; i < N; i++) {
		t += data[i].a;
		if (t > data[i].b) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 2560
S=input()
h=S[:2]
t=S[2:]
if S[0]!='0':
    h=int(h)
else:
    h=int(S[1])
if S[2]!='0':
    t=int(t)
else:
    t=int(S[3])
if (h>12 or h==0) and (t>12 or t==0):
    print('NA')
elif (h>12 or h==0) and t<=12:
    print('YYMM')
elif h<=12 and (t>12 or t==0):
    print('MMYY')
else:
    print('AMBIGUOUS')

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

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    int tmp = 0;
    vector<int> leng;
    vector<int> gain;

    // enumerating switching points
    leng.push_back(0);
    for(int i = 1; i < S.length(); i++){
        if(S[i] != S[i-1]) leng.push_back(i);
    }

    // calculating gain depending on each element of leng
    for(int i = 0; i < leng.size(); i++){
        if(S[leng[i]] == '0') tmp = 2*K;
        else tmp = 2*K + 1;

        if(i+tmp >= leng.size()) gain.push_back(N-leng[i]);
        else gain.push_back(leng[i+tmp]-leng[i]);
    }

    cout << *max_element(gain.begin(), gain.end()) << '\n';

    return 0;
};


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

int main() {
	char x, y;
	cin >> x >> y;
	if (x < y) {
		cout << "<";
	}
	else if (x > y) {
		cout << ">";
	}
	else {
		cout << "=";
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# ITP2_6_A: Binary Search

from bisect import bisect


def search(li, x):
    """Returns True if x exists in li else False.
    Assumes li is sorted in ascending order.

    >>> search([1, 2, 3], 2)
    True
    >>> search([1, 2, 3], 4)
    False
    >>> search([1, 2, 3], 3)
    True
    >>> search([1, 2, 3], 0)
    False
    >>> search([1, 2, 3], 1)
    True
    """
    i = bisect(li, x)
    return 0 < i <= len(li) and li[i-1] == x


def run():
    n = int(input())
    a = [int(x) for x in input().split()]
    assert(n == len(a))

    q = int(input())
    for _ in range(q):
        k = int(input())
        if search(a, k):
            print(1)
        else:
            print(0)


if __name__ == '__main__':
    run()



Measured memory_bytes: 17212
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
	long long N,M;
	cin>>N>>M;
	long long ans=min(N,M/2);
	M=M-ans*2;
	//cout<<ans<<endl;
	//cout<<M<<endl;
	if(M>0)ans+=(M/4);
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 764
#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>;

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    string S;
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a= [0] + list(map(int, input().split())) + [0]

b = 0
for i in range(n + 1):
    b += abs(a[i] - a[i+1])

for i in range(n):
    print(b - abs(a[i] - a[i+1]) - abs(a[i+1] - a[i+2]) + abs(a[i] - a[i+2]))

Measured memory_bytes: 13920
#include <iostream>
#include <string.h>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main( void ) {

    int N, K, count;
    vector<int> human;
    cin >> N >> K;
    count = 0;

    for ( int i = 0; i < N; i++ ) {
        int tmp;
        cin >> tmp;
        
        if ( tmp >= K ) {
            count++;
        }
    }

    cout << count << endl;

    return 0;   
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()

    for i in range(K, N):
        if A[i-K] < A[i]:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 32476
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <fstream>

using namespace std;


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

const string sep = " ";

class Compare {
public:
    bool operator()(int a, int b) {
        return a > b;
    }
};

std::vector<size_t> ZFunction(const std::string &text) {
    if (text.empty()) {
        return std::vector<size_t>();
    }
    std::vector<size_t> result(text.size());
    size_t left = 0;
    size_t right = 0;
    for (int i = 1; i < text.size(); ++i) {
        result[i] = std::max(0, std::min(static_cast<int>(right) - i,
                                         static_cast<int>(result[i - left])));
        while ((i + result[i] < text.size()) &&
               (text[result[i]] == text[i + result[i]])) {
            ++result[i];
        }
        if (i + result[i] > right) {
            left = i;
            right = i + result[i];
        }
    }
    return result;
}

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int count1, count2;
    count1 = ceil(c * 1.0 / b);
    count2 = ceil(a * 1.0 / d);
    cout << ((count2 < count1) ? "No" : "Yes");
    return 0;
}

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

void Coordinate(int K, int X){
    for(int i=X-K+1;i<K+X;i++){
        cout << i << " ";
    }
}

int main(){
    int K,X; cin >> K >> X;
    Coordinate(K,X);
    return 0;
}

Measured memory_bytes: 256
#入力
read N L

#りんごのリストを作る
for (( i=1; i <= $N; i++)); do
  lst+=($((L + i - 1)))
done

#りんごリストから食べるりんごを選び出す
eat=${lst[0]}
for apl in ${lst[@]}; do

  #絶対値で比較して、小さいやつを食べる候補にする
  if [ ${apl/#-/} -lt ${eat/#-/} ]; then
    eat=${apl}
  fi

  if [ ${apl} -eq "1" ]; then
    break
  fi

done

#食べたりんご以外でアップルパイにする(合計する)
pai=0
for apl in ${lst[@]}; do
  if [ ${apl} != ${eat} ]; then
    pai=$((pai + apl))
  fi
done

#結果出力
echo $pai


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i, n) cin >> p.at(i);
    rep(i, n) cin >> q.at(i);

    string s_p, s_q;
    rep(i, n)
    {
        s_p += to_string(p.at(i));
        s_q += to_string(q.at(i));
    }

    int nq = 1;
    rep(i, n) nq = nq * (i + 1);

    vector<string> all(nq);
    vector<int> v(n);
    rep(i, n) v.at(i) = i + 1;

    rep(i, nq)
    {
        string s;
        rep(j, n) s += to_string(v.at(j));
        all.at(i) = s;
        next_permutation(v.begin(), v.end());
    }

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

    int a = 0, b = 0;
    rep(i, nq)
    {
        if (s_p == all.at(i))
        {
            a = i + 1;
        }
        if (s_q == all.at(i))
        {
            b = i + 1;
        }
    }

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    string t;
    for (int i = 0; i < n; i++) {
        cin >> t;
        mp[t]++;
    }
    priority_queue<int> que;
    for (auto x : mp) {
        que.push(x.second);
    }
    vector<string> vec;
    for (auto x : mp) {
        if (que.top() == x.second) {
            vec.push_back(x.first);
        }
    }
    sort(vec.begin(), vec.end());
    for (auto x : vec) {
        cout << x << endl;
    }
}

Measured memory_bytes: 27636
var
  a:array[0..400005]of longint;
  n,i,ans,x:longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(x);
    if x>n then
      inc(ans) else
      inc(a[x]);
  end;
  readln;
  for i:=1 to n do
    if a[i]<i then
      ans:=ans+a[i] else
      ans:=ans+a[i]-i;
  writeln(ans);
end.

Measured memory_bytes: 128
require 'prime'

n, p = gets.split.map(&:to_i)
h = Prime.prime_division(p).to_h
if h == {} || p == 1
  puts 1
elsif n == 1
  puts p
else
  ans = 1
  h.sort_by{|k, v| -v}.each do |k, v|
    while v >= n
      ans *= k
      v -= n
    end
  end
  puts ans
end

Measured memory_bytes: 2300
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }


//A
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  bool p=true;
  if(a==b&&b==c)p=false;
  if(a!=b&&b!=c&&c!=a)p=false;
  if(p)cout<<"Yes";
  else cout<<"No";
}



Measured memory_bytes: 256
def info(c):
    b = range(max([max(i) for i in c])+1)
    for i in b:
        for p in b:
            for o in b:
                cnt = 0
                for x in c:
                    if (x[0]-i)==(x[1]-p)and(x[1]-p)==(x[2]-o):
                        cnt += 1
                if cnt == 3:
                    return 'Yes'
    return 'No'
C = [list(map(int, input().split())) for i in range(3)]
print(info(C))

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	// 1 floor 10 room
	// 3 floors
	// 4 buildings
	var a [4][3][10]int // b, f, r
	var n int
	fmt.Scan(&n)
	var b, f, r, v int
	for i := 0; i < n; i++ {
		fmt.Scan(&b, &f, &r, &v)
		b--
		f--
		r--
		a[b][f][r] += v
	}
	for b := 0; b < 4; b++ {
		if b > 0 {
			fmt.Println("####################")
		}
		for f := 0; f < 3; f++ {
			for r := 0; r < 10; r++ {
				fmt.Printf(" %d", a[b][f][r])
			}
			fmt.Println()
		}
	}
}



Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define INF 1LL<<62
#define inf 1000000007 

int main() {
	long double h,w,x,y;
	cin>>h>>w>>x>>y;
	printf("%.10Lf ",h*w/2.0);
	if(x*2==h&&y*2==w){
		cout << 1<<endl;
	}
	else{
		cout << 0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3740
using System;
using System.Linq;
using System.Collections.Generic;

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
         
        var primeFactors = PrimeFactors(n);
        //primeFactors.Dump();
         
        string output = primeFactors.Count() == 0 
                        ? n.ToString() 
                        : string.Join(" ", primeFactors.Select (f => f.ToString()).ToArray()); //AOJ??¨
                        //:string.Join(" ", primeFactors);
        Console.WriteLine("{0}: {1}", n, output);
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i <= n)
        {
            if(n % i == 0){
                n /= i;
                yield return i;
            }else{
                i++;
            }
             
            if(i > Math.Sqrt(tmp)){
                i = int.MaxValue; //???????????????
                yield return n;
            }
        }
    }
}

Measured memory_bytes: 20320
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    ans="No"
    for i in 1:length(s)-1
        if s[i:i+1]=="AC"
            ans="Yes"
            break
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 110376
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <cstring>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <sstream>

using namespace std;
typedef long long Long;
typedef long double Double;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
typedef pair<Long,Long> PLL;

int read(int &x) { return scanf("%d", &x); }
int read(int &x, int &y) { return scanf("%d%d", &x, &y); }
int read(int &x, int &y, int &z) { return scanf("%d%d%d", &x, &y, &z); }
int read(Long &x) { return scanf("%lld", &x); }
int read(Long &x, Long &y) { return scanf("%lld%lld", &x, &y); }
int read(double &x) { return scanf("%lf", &x); }
char buff[2000010];
int read(string &s) { int r = scanf("%s", buff); s = buff; return r; }

#define dlog2(n) ((n) == -1 ? 0 : (31-__builtin_clz(n)))

#define sz(a) int(a.size())

int main() {

	int N;
	read(N);

	cout << N*N << endl;

}
























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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct idou
{
    int y;
    int x;
    int ny;
    int nx;
};
vector<vector<int> > coin;
int main()
{
    int h,w; cin >> h >> w;
    coin.resize(h);
    rep(i,h)coin[i].resize(w);
    rep(i,h)
    {
        rep(j,w)
        {
            cin >> coin[i][j];
        }
    }
    vector<idou> sousa;
    int flag = 0;
    rep(i,h-1)
    {
        rep(j,w)
        {
            if(coin[i][j]%2==1)
            {
                coin[i+1][j]++;
                idou temp;
                temp.y = i;temp.x = j;temp.ny = i+1;temp.nx = j;
                sousa.push_back(temp);
            }

        }
    }
    rep(i,w-1)
    {
        if(coin[h-1][i]%2==1)
        {
            coin[h-1][i+1]++;
            idou temp;
            temp.y = h-1;temp.x = i;temp.ny = h-1;temp.nx = i+1;
            sousa.push_back(temp);
        }
    }

    int num = (int)sz(sousa);
    cout << num << endl;
    rep(i,num)
    {
        ++sousa[i].y;
        ++sousa[i].x;
        ++sousa[i].ny;
        ++sousa[i].nx;
        cout << sousa[i].y << " " << sousa[i].x << " " << sousa[i].ny << " " << sousa[i].nx << endl;
    }

}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  int s[100];
  int sum=0;
  cin>>n;
  rep(i,n){cin>>s[i];sum+=s[i];}
  sort(s,s+n);
  if(sum%10){cout<<sum<<endl;return 0;}
  rep(i,n){
    if(s[i]%10){
      cout<<sum-s[i]<<endl;
      return 0;
    }
  }
  cout<<0<<endl;
  return 0;
}



Measured memory_bytes: 256
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) {
    cout << "bon" << '\n';
    return 0;
  }
  if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << '\n';
    return 0;
  }
  cout << "hon" << '\n';
  return 0;
}

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

const int N = 610;

int n, col[N][N], cnt[3];
vector<pair<int,int>> diff;

void dfs(int x, int y, int c) {
    if (x >= 0 && x < 2*n && y >= 0 && y < 2*n && col[x][y] == 0) {
        col[x][y] = c;
        cnt[c]++;
        for (auto d : diff) dfs(x+d.first, y+d.second, 3-c);
    }
}

int main() {
    cin >> n;

    int iter = 2; while (iter--) {
        // calcular arcos
        int d; cin >> d;
        diff.clear();
        for (int dx = 0; dx < 2*n; dx++) 
            for (int dy = 0; dy < 2*n; dy++) 
                if (dx*dx + dy*dy == d) {
                    diff.emplace_back(dx,dy);
                    diff.emplace_back(-dx,dy);
                    diff.emplace_back(dx,-dy);
                    diff.emplace_back(-dx,-dy);
                }

        // partir bipartito
        for (int i = 0; i < 2*n; i++) 
            for (int j = 0; j < 2*n; j++) if (col[i][j] == 0) 
                dfs(i,j,1);

        // quedarse con particion mayor
        int best = (cnt[1] > cnt[2] ? 1 : 2);
        for (int i = 0; i < 2*n; i++) 
            for (int j = 0; j < 2*n; j++) 
                col[i][j] = (col[i][j] == best ? 0 : 3);
    }

    int need = n*n;
    for (int i = 0; i < 2*n; i++) 
        for (int j = 0; j < 2*n; j++) if (col[i][j] == 0) {
            cout << i << ' ' << j << endl;
            if (--need == 0) return 0;
        }

    return 0;
}


Measured memory_bytes: 19200
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

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

using namespace std;

int main(void) {	
	int n, k;
	while (cin >> n >> k && (n > 0 || k > 0)) {
		int ans = 0;
		FOR(i, 1, n - 2) {
			FOR(j, i + 1, n - 1) {
				FOR(l, j + 1, n) {
					if (i + j + l == k) {
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
		
	}
	
				  
	return 0;
}

Measured memory_bytes: 1160
use proconio::input;
use proconio::marker::Usize1;

#[proconio::fastout]
fn main() {
    input! {
    N:usize,
    M:usize,
    H:[i64;N],
    AB:[(Usize1,Usize1);M],
    }
    let mut good = vec![true; N];
    for ab in AB {
        let a = ab.0;
        let b = ab.1;
        if H[a] <= H[b] {
            good[a] = false;
        }
        if H[b] <= H[a] {
            good[b] = false;
        }
    }
    println!("{}", good.into_iter().filter(|&x| x).count());
}


Measured memory_bytes: 6732
N = int(input())

D, X = map(int, input().split())

choco = 0

for i in range(N):
    A = int(input())
    choco += 1
    for j in range(1, 100):
        if A*j + 1 <= D:
            choco += 1
        else:
            break

print(choco+X)

Measured memory_bytes: 9100
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

int main()
{
    vector<int> mountain;
    for(int i = 0; i < 10; i++){
        int tmp;
        cin >> tmp;
        mountain.push_back(tmp);
    }
    sort(mountain.begin(), mountain.end());
    reverse(mountain.begin(), mountain.end());
    for(int i = 0; i < 3; i++){
        cout << mountain[i] << endl;
    }
    return 0;
}

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

int main()
{
  int left[2],right[2];
  cin>>left[0]>>left[1]>>right[0]>>right[1];
  left[0]+=left[1];
  right[0]+=right[1];
  if(left[0]<right[0])
  cout<<"Right";
  else if(left[0]>right[0])
  cout<<"Left";
  else
  cout<<"Balanced";
  cout<<endl;
  return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }



int main()
{
  fastio();

  int r; cin >> r;
  cout << r*r << endl;

  return 0;
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=input()
A=[input() for i in range(N)]

def ans121(N:int, M:int, C:int, B:str, A:list):
    B=list(map(int,B.split()))
    judge_count=0
    for i in range(N):
        A_list=list(map(int,A[i].split()))#N回検証を繰り返す
        math_count=0
        for j in range(M):#リストの中の要素Mの数だけB[j]*A_list[j]を繰り返し足していく
           math_count+=B[j]*A_list[j]
        if math_count+C>0:
           judge_count+=1
    return judge_count

print(ans121(N,M,C,B,A))


Measured memory_bytes: 9084
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())

using namespace std;


int main() {
string wtr;
int count = 0;
cin>>wtr;

if(wtr.at(1)=='S'){
    if(wtr.at(0)=='R' || wtr.at(2)=='R'){
        count = 1;
    }
}else if(wtr.at(0)=='S' && wtr.at(1)=='S' &&wtr.at(2)=='S'){
}else{
        rep(i,wtr.size()){
        if(wtr.at(i)=='R'){
            count = count+1;
        }
    }
}
cout<<count<<endl;
}


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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long n,k;
    cin>>n>>k;
    pair<int,int> ab[n];
    for(int i=0;i<n;i++){
        cin>>ab[i].first>>ab[i].second;
    }
    sort(ab,ab+n);
    for(int i=0;i<n;i++){
        if(ab[i].second<k){
            k-=ab[i].second;
        }
        else{
            cout <<ab[i].first<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
    int a, b, c, f = 0 ;
    cin >> a >> b >> c ;

    for ( int x = a ; x <= b ; x++ ) {
        if ( c % x == 0 ) f++ ;
    }
    
    cout << f << endl;
    
    return 0 ;
}



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

int main() {
  string s;
  cin >> s;
  vector<int> dp(s.size());
  dp[0] = 0;
  int cnt_g = 1, cnt_p = 0, i;
  for (i = 1; i < s.size(); ++i) {
    char h = s[i];
    if (h == 'p') {
      if (cnt_p < cnt_g) {
        ++cnt_p;
        dp[i] = dp[i - 1];
      } else {
        ++cnt_g;
        dp[i] = dp[i - 1] - 1;
      }
    } else {
      if (cnt_p < cnt_g) {
        ++cnt_p;
        dp[i] = dp[i - 1] + 1;
      } else {
        ++cnt_g;
        dp[i] = dp[i - 1];
      }
    }
  }
  cout << dp[s.size() - 1] << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <cmath>

using namespace std;

void solve()
{
	double xa, ya, ra;
	double xb, yb, rb;
	int n;
	cin >> n;
	while(n--)
	{
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double dist = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
		if(dist > ra + rb)
		{
			cout << 0 << endl;
		}
		else if(dist + rb < ra)
		{
			cout << 2 << endl;
		}
		else if(dist + ra < rb)
		{
			cout << -2 << endl;
		}
		else
		{
			cout << 1 << endl;
		}
	}
}

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

Measured memory_bytes: 0
class Dice
  def initialize(n)
    @n = n
  end
  #     ^N
  #     [0]:top
  # [3] [1] [2] [4]  2:right 3:left 4:back
  #     [5]:bottom
  #     vS
  attr_reader :n

  def roll(d)
    case d
    when ?N
      @n = [@n[1], @n[5], @n[2], @n[3], @n[0], @n[4]]
    when ?S
      @n = [@n[4], @n[0], @n[2], @n[3], @n[5], @n[1]]
    when ?E
      @n = [@n[3], @n[1], @n[0], @n[5], @n[4], @n[2]]
    when ?W
      @n = [@n[2], @n[1], @n[5], @n[0], @n[4], @n[3]]
    else
      raise
    end
    self
  end
  def rotate_right
    @n = [@n[0], @n[2], @n[4], @n[1], @n[3], @n[5]]
    self
  end
  def rotate_left
    @n = [@n[0], @n[3], @n[1], @n[4], @n[2], @n[5]]
    self
  end
  def print
    puts "  #{@n[0]}"
    puts "#{@n[3]} #{@n[1]} #{@n[2]} #{@n[4]}"
    puts "  #{@n[5]}"
  end
  # THIS FUNCTION WILL ROTATE DICE
  def ==(other)
    c = @n.uniq.map{|e| [e, @n.count(e)]}.sort{|a,b|a[1]<=>b[1]}
    other.set_upper_by_value(c[0][0])
    return true if c.size < 2 # only 1 number
    idx = @n.map.with_index{|p,i| i if p==c[0][0]}.compact
    idx.each{|i|
      set_upper_by_index(i)
      4.times{
        return true if self.n == other.n
        rotate_right
      }
    }
    return false
  end
  def set_upper_by_index(idx)
    case idx
    when 0
      ;
    when 1
      self.roll(?N)
    when 2
      self.roll(?W)
    when 3
      self.roll(?E)
    when 4
      self.roll(?S)
    when 5
      self.roll(?N)
      self.roll(?N)
    when nil
      raise "@n:#{@n} u:#{u} f:#{f}"
    end
    self
  end
  def set_upper_by_value(u)
    set_upper_by_index(@n.index(u))
  end
  def set_up_n_front(u, f)
    set_upper_by_value(u)
    case @n.index(f)
    when 1
      ;
    when 2
      self.rotate_right
    when 3
      self.rotate_left
    when 4
      self.rotate_left.rotate_left
    when 0, 5, nil
      raise "@n:#{@n} u:#{u} f:#{f}"
    end
    self
  end
end

d1=Dice.new(gets.split.map(&:to_i))
d2=Dice.new(gets.split.map(&:to_i))
puts (d1==d2 ? "Yes" : "No")



Measured memory_bytes: 8912
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

string s, t;
vector<string> ans;


void dfs(int T){
    if(s.size() == t.size()){
        ans.push_back(t);
        return;
    }
    char c = s[t.size()];
    if(T & (1 << (c -'a'))) {
        t.push_back(c);
        dfs(T);
        t.pop_back();
    }
    if(!(T & (1 << (c+1-'a'))) &&  c != 'z'){
        t.push_back(c+1);
        dfs(T|(1 << (c+1-'a')));
        t.pop_back();
    }
}

int main() {
    while(cin >> s, s != "#"){
        dfs(1);
        cout << ans.size() << "\n";
        if(ans.size() < 10){
            for(auto &&i: ans) cout << i << "\n";
        }else {
            for (int i = 0; i < 5; ++i) {
                cout << ans[i] << "\n";
            }
            for (int i = (int)ans.size()-5; i < ans.size(); ++i) {
                cout << ans[i] << "\n";
            }
        }
        ans.clear();
    }
    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;

const int prime[25] = {
    2, 3, 5, 7, 11,
    13, 17, 19, 23, 29,
    31, 37, 41, 43, 47,
    53, 59, 61, 67, 71,
    73, 79, 83, 89, 97};

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

    vector<int> prime_cnt(25, 0);

    repd(i, 1, N + 1) {
        int k = i;
        rep(j, 25) {
            while (k != 0) {
                if (k % prime[j] == 0) prime_cnt[j]++;
                else break;
                k /= prime[j];
            }
        }
    }

    ll ans = 0;
    rep(i, 25) {
        if (prime_cnt[i] >= 74) {
            ans++;
        }
    }

    rep(i, 25) {
        rep(j, 25) {
            if (i == j) continue;
            if (prime_cnt[i] >= 24 && prime_cnt[j] >= 2) ans++;
            if (prime_cnt[i] >= 14 && prime_cnt[j] >= 4) ans++;
        }
    }

    rep(i, 25) {
        rep(j, 25) {
            repd(k, j + 1, 25) {
                if (i == j || i == k) continue;
                if (prime_cnt[i] >= 2 && prime_cnt[j] >= 4 && prime_cnt[k] >= 4) ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace csx_std {
	using namespace std;
	typedef long long ll;
	#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
	#define For(i,a,b) for (register int i=(a);i>=(b);i--)
	#define mem(i,j) memset(i,j,sizeof(i))
	#define pii pair<int,int>
	#define MP make_pair
	#define fi first
	#define se second
	#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
	const int N=1e5+5;
	const int mod=1e9+7;
	inline int qpow(int x,int y) {int ret=1;for (;y;y>>=1,x=1LL*x*x%mod) if (y&1) ret=1LL*ret*x%mod;return ret;}
	inline int Inv(int x) {return qpow(x,mod-2);}
	inline void upd(int &x,int y) {x=(1LL*x+y)%mod;return;}
	inline int chkmax(int &x,int y) {return (x<y)?(x=y,1):0;}
	inline int chkmin(int &x,int y) {return (x>y)?(x=y,1):0;}
	inline int read()
	{
		int x=0,f=1;
		char c=getchar();
		while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
		while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
		return f*x;
	}
	inline void write(int x)
	{
		if (x<0) x=-x,putchar('-');
		if (x>9) write(x/10);
		putchar(x%10+'0');
		return;
	}
}
using namespace csx_std;
int a,tag=0;
int main()
{
	a=read();
	FOR(i,1,9) FOR(j,1,9) if (i*j==a) tag=1;
	if (tag) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{

    string S;
    int ans=0;
    cin >> S;

    for(int i=1;i<S.length();i++){
        if(S[i]!=S[i-1])ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

double dis(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

void solve(long long x_s, long long y_s, long long x_t, long long y_t, long long N, std::vector<long long> x, std::vector<long long> y, std::vector<long long> r){
    x.push_back(x_s);
    y.push_back(y_s);
    r.push_back(0);
    x.push_back(x_t);
    y.push_back(y_t);
    r.push_back(0);
    vector<vector<double>> d(N+2,vector<double>(N+2,LINF));
    rep(i,N+2)rep(j,N+2)d[i][j]=max(0.0,dis(x[i],y[i],x[j],y[j])-r[i]-r[j]);
    rep(i,N+2)rep(j,N+2)rep(k,N+2)chmin(d[j][k],d[j][i]+d[i][k]);
    printf("%.10f\n",d[N][N+1]);
}

int main(){
    long long x_s;
    scanf("%lld",&x_s);
    long long y_s;
    scanf("%lld",&y_s);
    long long x_t;
    scanf("%lld",&x_t);
    long long y_t;
    scanf("%lld",&y_t);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> x(N);
    std::vector<long long> y(N);
    std::vector<long long> r(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&r[i]);
    }
    solve(x_s, y_s, x_t, y_t, N, std::move(x), std::move(y), std::move(r));
}


Measured memory_bytes: 10240
int main(){

  int p,q,r,a;

  scanf("%d%d",&p,&q);

  if(p<q){
    a=p;
    p=q;
    q=a;
  }

  while(q>0){
    r=p%q;
    p=q;
    q=r;
  }

  printf("%d\n",p);

  return 0;
}


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

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

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

#define INF INT_MAX/3

ll n;
ll a[101010],b[101010];

int main(){
	cin>>n;
  rep(i,n)cin>>a[i];
  sort(a,a+n);
  memcpy(b,a,sizeof(b));
  reverse(a,a+n);
  rep(i,n-1){
    if(a[i+1]<=i+1){
      ll idx=lower_bound(b,b+n,i+1)-b;
      ll w=n-i-idx;
      ll h=a[i]-i;
      if(w%2==0||h%2==0){
        cout<<"First"<<endl;
      }else{
        cout<<"Second"<<endl;
      }
      return 0;
    }
  }
  ll w=1;
  ll h=a[n-1]-n+1;
  if(w%2==0||h%2==0){
    cout<<"First"<<endl;
  }else{
    cout<<"Second"<<endl;
  }
	return 0;
}


Measured memory_bytes: 1792