akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const int maxN = 150010;
const int MAXM = 310;
const int MAXK = 17;
const int MOD = 1000000007;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;

int A,B,K;


int main()
{
    scanf("%d%d%d",&A,&B,&K);
	int c = min(A,B);
	int cnt = 0;
	vector<int> p;
	for(int i=1;i<=c;i++)
	{
		if(A%i==0 && B%i==0)
		{
			p.push_back(i);
		}
	}
	
	sort(p.begin(),p.end());
	reverse(p.begin(),p.end());
	cout<<p[K-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int H = scan.nextInt();
			int W = scan.nextInt();
			GM[][]map = new GM[H][W];

			for(int i = 0;i<H;i++) {
				String s = scan.next();
				char[]c = s.toCharArray();
				for(int j = 0;j<W;j++) {
					map[i][j] = new GM(i,j,c[j]);
				}
			}

			int ok = 1;

			int[]dx =  {1,0,-1,0};//右下左上
			int[]dy =  {0,1,0,-1};

			Deque<GM>queue = new ArrayDeque<GM>();
			queue.addFirst(map[0][0]);
			map[0][0].ch = true;

			while(!queue.isEmpty()) {
				GM p = queue.removeLast();
				for(int i = 0;i<4;i++) {
					int x = dx[i]+p.x;
					int y = dy[i]+p.y;
					if(0<=x&&x<W&&0<=y&&y<H) {
						if(map[y][x].ch==false&&map[y][x].type!='.') {
							queue.addFirst(map[y][x]);
							map[y][x].ch = true;
							map[y][x].d = p.d+1;
							if((dx[i]==0&&dy[i]==-1)||(dx[i]==-1&&dy[i]==0)) {
								ok=0;
								break;
							}
						}
					}
				}
			}

			if(ok==0) {
				System.out.println("Impossible");
				return;
			}

			Map<Integer,Integer>mp = new TreeMap<Integer,Integer>();

			for(int i = 0;i<H;i++) {
				for(int j = 0;j<W;j++) {
					if(map[i][j].type=='#') {
					//System.out.println(map[i][j].d);
					if(mp.containsKey(map[i][j].d))mp.put(map[i][j].d, mp.get(map[i][j].d)+1);
					else mp.put(map[i][j].d, 1);
					}
				}
			}

			for(Integer key:mp.keySet()) {
				int a = mp.get(key);
				if(a>1) {
					ok=0;
					break;
				}
			}

			if(ok==0)System.out.println("Impossible");
			else System.out.println("Possible");






		}


	}




	private static class GM{
		int y;
		int x;
		boolean ch = false;
		char type;
		int d = 0;
		GM(int i,int j,char c){
			y = i;
			x = j;
			type = c;
		}
	}


}


Measured memory_bytes: 35692
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> table = new ArrayList<>();
		for(int i = 0; i < m; i++){
			int k = sc.nextInt();
			List<Integer> l = new ArrayList<>(k);
			for(int j = 0;j < k; j++)
				l.add(sc.nextInt());
			table.add(l);
		}
		int[] p = sc.nextIntArray(m);

		int count = 0;

		for(int i = 0; i < Math.pow(2,n); i++){
//			System.out.println("i=" +i);
			String s = Integer.toBinaryString(i);
			int zero = n - s.length();
			for(int z =0;z < zero; z++)
				s = "0" + s;
			boolean isOk = true;
			for(int j = 0;j < m; j++){
				List<Integer> l = table.get(j);
				int pj = p[j];
				final String str = s;
				int sum = (int)l.stream().filter(num -> str.charAt(num-1) == '1').count();
//				System.out.println("l="+l);
//				System.out.println("pj="+pj);
//				System.out.println("sum="+sum);
//				System.out.println("s="+s);
				isOk &= sum % 2 == pj;
			}
			if(isOk)
				count++;
		}
		System.out.println(count);

	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 30804
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 絶対値を求める
UInt Abs(const Int a) {
    return a > 0 ? a : -a;
}

int main(void) {
    Int n;
    cin >> n;
    Int t = 0;
    Int x = 0;
    Int y = 0;
    Int dt, dx, dy;

    bool result = true;
    for (Int i = 0; i < n; ++i) {
        cin >> dt >> dx >> dy;
        Int dist = Abs(dx - x) + Abs(dy - y);
        Int time = dt - t;
        //cout << dist << " " << time << endl;
        if (dist > time) {
            result = false;
        } else if (dist < time && ((time - dist) % 2 == 1)) {
            result = false;
        }
        x = dx;
        y = dy;
        t = dt;
    }
    if (result) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3640
//by The_One_Solver
#include<bits/stdc++.h>
using namespace std;
long long  n,m,c,k,sum;
int main()
{
    cin>>n>>m>>c>>k;
    if(n>=k)return cout<<k,0;
    else if(n<k)
    {
        sum+=n;
       long long  r =(k-n)-m;
       if(r<=0)return cout<<sum,0;
       else
       {
           if(r-c>=0)return cout<<sum+(c*-1),0;
           else if(r-c<0)return cout<<sum+(r*-1),0;

       }

    }


    return 0;
}


Measured memory_bytes: 3620
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print

output: in_order + pre_order
1 12 17 20 25 30 88
30 12 1 20 17 25 88

def pre_order(node):
    if node is not None:
        print('', node.data, end='')
        pre_order(node.left)
        pre_order(node.right)
    return None


def in_order(node):
    if node is not None:
        in_order(node.left)
        print('', node.data, end='')
        in_order(node.right)
    return None

"""

import sys


class Node(object):
    def __init__(self, data):
        self.data = data
        self.left, self.right = None, None

    def insert(self, data):
        """
        insert data according to BST rules
        """
        if data < self.data:
            if self.left is None:
                self.left = Node(data)
            else:
                self.left.insert(data)
        else:
            if self.right is None:
                self.right = Node(data)
            else:
                self.right.insert(data)

        return None

    def tree_data(self):
        """
        ???????????°?????????
        """
        stack = []
        node = self
        while stack or node:
            if node:
                stack.append(node)
                node = node.left
            else:
                node = stack.pop()
                yield node.data
                node = node.right


def pre_order(node):
    if node is not None:
        print('', node.data, end='')
        pre_order(node.left)
        pre_order(node.right)
    return None


def action(command, content):
    if command[0] == 'i':
        tree_root.insert(data=int(content))

    elif command[0] == 'p':
        print('', *tree_root.tree_data())
        pre_order(tree_root)
        print('')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    command_list = list(map(lambda x: x.split(), _input[1:]))
    # assert len(command_list) == array_length
    # print(array_length, *command_list)

    flag, tree_root = False, None
    for each in command_list:
        command, content = each[0], each[-1]
        if (not flag) and command.startswith('in'):
            tree_root = Node(data=int(content))
            flag = True
            continue
        action(command=command, content=content)

Measured memory_bytes: 296312
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[5];
		for(int i=0; i<5; i++) {
			num[i]=sc.nextInt();
		}
		int k=sc.nextInt();
		if(num[4]-num[0]>k) System.out.println(":(");
		else System.out.println("Yay!");
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    ll n, m, ans=0;
    cin >> n >> m;
    ans += min(n, m/2);
    n -= ans;
    m -= ans * 2;
    ans += m/4;
    cout << ans;
}

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


int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N+1, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A.at(i);
        B.at(A.at(i)) = i+1;
    }
    for (int i = 1; i <= N; ++i) {
        cout << B.at(i) << endl;
    }
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
	long long L[87];
	L[0]=2;
	L[1]=1;
	for(int i=2;i<=86;i++)
		L[i]=L[i-1]+L[i-2];
	int N;
	scanf("%d",&N);
	printf("%lld\n",L[N]);
	return 0;
 } 

Measured memory_bytes: 128
#include<stdio.h>
int main(void) {
	unsigned long n, m, i;
	scanf("%lu%lu", &n, &m);
        if(n == 1){
             printf("%d",(m != 1) ? m - 2 : 1);
}
else if(m == 1){
              printf("%d",(n != 1) ? n - 2 : 1);
}
else{	printf("%lu", (n * m - (2 * m + 2 * n) + 4));}
	return 0;
}

Measured memory_bytes: 128
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int a, b;
	cin >> a >> b;
	long double ret = 0;
	for (int i = 1; i <= a; ++i) {
		double tmp = 1.0 / a;
		int now = i;
		while (now < b) {
			now *= 2;
			tmp /= 2;
		}
		ret += tmp;
	}
	cout << setprecision(12) <<  ret << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
cost_list = [float('inf') for _ in range(N)]
cost_list[0]  = 0

for i in range(1, N):
    if cost_list[i] > (cost_list[i-1] + abs(h[i] - h[i-1])):
        cost_list[i] = cost_list[i-1] + abs(h[i]-h[i-1])

    if i > 1:
        if cost_list[i] > (cost_list[i-2] + abs(h[i] - h[i-2])):
            cost_list[i] = cost_list[i-2] + abs(h[i]-h[i-2])

print(cost_list[N-1])

Measured memory_bytes: 13976
import sys
sys.setrecursionlimit(10**7)


def test(array, index, last_position, count, min_count):
    # 除去数が多いパターンは破棄する
    if min_count[0] != -1 and count >= min_count[0]:
        return
    if index + 1 == len(array):
        # print("count:{}".format(count))
        min_count[0] = count if min_count[0] == - \
            1 or count < min_count[0] else min_count[0]
        return
    current = array[index]

    # 前のと手がぶつかる場合は取り除く
    if last_position >= current[2]:
        test(array, index + 1, last_position, count + 1, min_count)
    # 前のとぶつからない場合は取り除かないパターンも
    else:
        test(array, index + 1, index, count, min_count)


N = int(input())
array = [list(map(int, input().split())) for i in range(N)]
for line in array:
    line.append(line[0] - line[1])
    line.append(line[0] + line[1])
array = sorted(array, key=lambda x: x[3])

count = 0
max_r = -float('inf')
for i in range(N):
    current = array[i]
    # print(max_r)
    # print(current[2])
    if current[2] >= max_r:
        # print("残す")
        count += 1
        max_r = current[3]
# test(array, 0, -1, 0, min_count)
print(count)


Measured memory_bytes: 66692
#include<iostream>
using namespace std;
 
static const int N = 1000;
 
void trace(int A[], int n){
  for ( int i = 1; i <= n; i++ ){
    if ( i >1 ) cout << " ";
    cout << A[i];
  }
  cout << endl;
}
 
main(){
  int n;
  int A[N+1];
  cin >> n;
  for ( int i = 1; i <= n; i++ ) cin >> A[i];
   
  trace(A, n);
  for ( int j = 2; j <= n; j++ ){
    int key = A[j];
    int i = j - 1;
    while( i > 0 && A[i] > key ){
      A[i+1] = A[i];
      i--;
    }
    A[i+1] = key;
 
    trace(A, n);
  }
}

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

N = int(input())
A = list(map(int, input().split()))
count=0
L = [0]*N
R = [0]*N
N2=2*N
hash_L=[0]*N2
hash_R=[0]*N2

sheet_L=[0]*N2
sheet_R=[0]*N2
for i in range(N):
    L[i]=A[i]+i+1
    if L[i]<N2:
        if sheet_L[L[i]]==0:
            hash_L[L[i]]=L[i]
            sheet_L[L[i]]=1
        else:
            sheet_L[L[i]]=sheet_L[L[i]]+1

    R[i]=-A[i]+i+1
    if R[i]>0:
        if sheet_R[R[i]]==0:
            hash_R[R[i]]=R[i]
            sheet_R[R[i]]=1
        else:
            sheet_R[R[i]]=sheet_R[R[i]]+1


for i in range(2*N):
    if not hash_L[i]==0:
        if hash_L[i]==hash_R[i]:
            count=count+sheet_L[i]*sheet_R[i]
#print("{}".format(hash_L))
#print("{}".format(hash_R))
print("{}".format(count))


Measured memory_bytes: 45980
d,g=map(int,input().split())
PC=[list(map(int,input().split())) for i in range(d)]
P=list(map(lambda x:x[0],PC))
C=list(map(lambda x:x[1],PC))
ans=10**9
def dfs(cur,target):
  if cur==0:
    return 10**9
  cnt=min(target//(cur*100),P[cur-1]) #P[j]の一部を利用する/全部利用のどちらか小さい方選択
  tmp=(100*cur)*cnt
  if cnt==P[cur-1]:
    tmp+=C[cur-1]
  if tmp<target:
    cnt+=dfs(cur-1,target-tmp)       #減らした値でdfs実行
  return min(cnt,dfs(cur-1,target))
print(dfs(d,g))

Measured memory_bytes: 3064
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    a = nl()

    arr = [0]
    arr.extend(a)
    arr.append(0)
    total = sum([abs(arr[i-1] - arr[i]) for i in range(1, n+2)])

    for i in range(1, n+1):
        #print(abs(arr[i-1] - arr[i]), abs(arr[i-1] - arr[i+1]))
        ans = total - abs(arr[i-1] - arr[i]) - abs(arr[i] - arr[i+1]) + abs(arr[i-1] - arr[i+1])
        print(ans)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 14560
#include<stdio.h>
int main(){
    int n;
    int i,j;
    scanf("%d",&n);
    for(i=1;i<10;i++)
        for(j=1;j<10;j++)
            if(i*j==n){
                printf("Yes\n");
                return 0;
            }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#A
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

ant = [a,b,c,d,e]
flg = True
for i in range(5):
    for j in range(5):
        if i != j:
            #print(dist)
            dist = abs(ant[i]-ant[j])
            if dist > k:
                flg = False
                break
if flg:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

vector<int> cut(vector<int> d,int k){
	vector<int> ans;
	for(int i=k;i<d.size();i++)ans.push_back(d[i]);
	for(int i=0;i<k;i++)ans.push_back(d[i]);
	return ans;
}
vector<int> lift(vector<int> d,int k){
	vector<int> ans;
	for(int i=k;i<d.size()/2;i++){
		ans.push_back(d[i]);
		ans.push_back(d[i+d.size()/2]);
	}
	return ans;
}
int main(){
	int n,m,k;
	cin >> n >> m;
	vector<int> d(2*n);
	rep(i,2*n)d[i] = i+1;
	rep(i,m){
		cin >> k;
		if(k==0){
			d = lift(d,k);
		}else{
			d = cut(d,k);
		}
	}
	rep(i,2*n) cout << d[i] << endl;
	
}

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

int main() {
    int n;
    cin >> n;
    int p = 1;
    long long cnt = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a == p) p++;
        else if (p < a) {
            cnt += (long long)(a - 1) / p;
            if (p == 1) p++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
Var S:String;
Begin
    Readln(S);
    If S='SUN' then writeln(7)
    Else if S='MON' then writeln(6)
    Else if S='TUE' then writeln(5)
    Else if S='WED' then writeln(4)
    Else if S='THU' then writeln(3)
    Else if S='FRI' then writeln(2)
    Else writeln(1);
End.

Measured memory_bytes: 128
mod = 998244353

N, S, *A = map(int, open(0).read().split())

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i, a in enumerate(A):
    for j in range(S + 1):
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod

        if j + a <= S:
            dp[i + 1][j + a] += dp[i][j]
            dp[i + 1][j + a] %= mod

print(dp[N][S])

Measured memory_bytes: 139376
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int n;
  cin>>n;
  if(n%2 == 1){
    cout<<0;
    return 0;
  }
  n = n/2;
  int ans = 0;
  int k = 5;
  while( n/k > 0){
	ans += n/k;
    k *= 5;
  }
  cout<<ans;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool PN(T x)
{
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

void solve()
{
  int n; cin >> n;
  int letter[n][26] ={};
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    for(int j = 0; j < s.size(); ++j){
      letter[i][s[j]-'a']++;
    }
  }
  string ans;
  for(int i = 0; i < 26; ++i){
    int mm = 100;
    for(int j = 0; j < n; ++j){
      if(mm > letter[j][i]) mm = letter[j][i];
    }
    // cout << "i: " << i << " ,mm:" << mm << endl;
    char ch = 'a' + i;
    for(int k = 0; k < mm; ++k){
      ans += ch;
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair

    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

    int main(){
        
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);   
    // #endif  
 
        fast;
        ll x,ans;
        cin>>x;
        ll t=x;
        x/=500;
        ans=x*1000;
        t%=500;
        //cout<<t<<" ";
        t/=5;
        ans+=t*5;
        cout<<ans;
        return 0;  
    } 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; ++i) {
        int oisisa, syurui; cin >> syurui >> oisisa;
        v.push_back({oisisa, syurui});
    }
    //その種類取ったか
    vector<bool> check(n + 1, false); //最大でも全種類バラバラでしょう
    //まず美味しさを上から
    sort(v.begin(), v.end(), greater<pair<int, int> >());
    priority_queue<int> unused; //大きい順
    priority_queue<int, vector<int>, greater<int> > used; //greaterだけでど小さい順 小さいのから篩に掛けます
    long long score = 0;
    int cnt = 0; //何種類？
    for (int i = 0; i < n; ++i) {
        int oisisa = v[i].first;
        int syurui = v[i].second;
        if (check[syurui] == 0) { //その種類まだ取ってないよ
            check[syurui] = 1;
            if (i < k) { //美味しさ順にとります!
                score += oisisa + 2 * cnt + 1; // n^2 - (n - 1)^2 = 2(n - 1) + 1
                cnt++;
            } else { //種類増やしたら点高くなるか後で確かめまする
                unused.push(oisisa);
            }
        } else { //もう取った種類
            if (i < k) {
                score += oisisa;
                used.push(oisisa); //待って減らすとき種類減ったらどうすんの
            }
        }
    }
    long long ans = score;
    while (!used.empty() && !unused.empty()) {
        int uused = used.top(); //小さいの
        used.pop(); //新しい種類とる以上ただ小さいのから捨てても種類減ることはない
        int uunused = unused.top(); //大きいの
        unused.pop();
        score += uunused - uused + 2 * cnt + 1;
        cnt++;
        ans = max(ans, score);
    }
    cout << ans << endl;
    return 0;
}





Measured memory_bytes: 1524
hoge=[]
for i in range(1001):
  hoge.append(str(i))
n,m=map(int,input().split())
if(m==0 and n==1):
  print(0)
  exit()
if(m==0 and n==2):
  print(10)
  exit()
if(m==0 and n==3):
  print(100)
  exit()
huga=[]
for i in range(m):
  a,b=map(int,input().split())
  huga.append([a,b])
for i in range(1001):
  flag=0
  for j in range(m):
    if(len(hoge[i])==n):
      if(hoge[i][huga[j][0]-1]==str(huga[j][1])):
        flag+=1
  if(flag==m):
    print(hoge[i])
    exit()
print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
// bool cmp()
// {
//     return 
// }
int32_t main()
{
  // int t;cin>>t;
  // while(t--)
  // {
    int n;cin >> n;

    int ans = 1000 - n%1000 ;
    if(ans==1000)ans=0;
    cout<<ans<<endl;
  // }
  return 0;
}


Measured memory_bytes: 3624
N,M = map(int, input().split())
ng = set()
for i in range(M):
  ng.add(int(input()))
  
dp = [0] * (N + 1)
dp[0] = 1
if 1 not in ng:
  dp[1] = 1

for i in range(2, len(dp)):
  if i in ng:
    continue
  dp[i] += (dp[i - 2] + dp[i - 1])
  dp[i] %= 1000000007
  
print(dp[N])

Measured memory_bytes: 17360
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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; }
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};
struct DATA{
    int a, b, c;
    DATA(int a,int b,int c) :a(a), b(b), c(c){};
     bool operator<(const DATA& rhs) const
    {
        if (a < rhs.a)
        {
           return true;
        }
        else if (a == rhs.a)
        {
            if (b < rhs.b)
            {
                return true;
            }
            else if (b == rhs.b)
            {
                return c < rhs.c;
            }
        }
        return false;
    }
};
int main()
{
    int N;
    cin >> N;
    vector<DATA> A;
    rep(i, N){
        int x, y;
        cin >> x >> y;
        A.emplace_back(x, y, i);
    }
    sort(ALL(A));
    set<P> s;
    //rep2(i, 1, N) s.insert(P(A[i].b, A[i].c));

    UnionFind UF(N);
    rep(i, N){
        int x = A[i].a;
        int y = A[i].b;
        int idx = A[i].c;
        while(!s.empty() && A[i].b >= s.begin()->first){
            UF.unite(s.begin()->second, idx);
            chmin(y, s.begin()->first);
            s.erase(s.begin());
        }
        s.insert(P(y, idx));
    }
    // rep(j, N)rep(i, j){
    //     int x = A[i].a;
    //     int y = A[i].b;
    //     int index = A[i].c;
    //     if(y < A[j].b) UF.unite(index, A[j].c);            

    // }
    rep(i, N){
        cout << UF.size(i) << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef long double ld;

pair <int, int> niz[100005];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> niz[i].first;
        niz[i].second = i;
    }
    sort(niz+1, niz+1+n);
    for(int i=1; i<=n; i++){
        cout << niz[i].second << " ";
    }
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'o') {
            ans++;
        }
    }
    int date = 15 - s.size();
    if (date + ans >= 8) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


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

  if(a<1200) {
  cout << "ABC" << endl;
  return 0;
  }
  
  cout << "ARC" << endl;
      
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll a[3],b[3],v[5]={};
  for(int i=0;i<3;i++){
    cin >> a[i] >> b[i];
    v[a[i]]++;
    v[b[i]]++;
  }
  for(int i=1;i<=4;i++){
    if(v[i]>=3){
      cout <<"NO\n";
      return 0;
    }
  }
  cout <<"YES\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int maxn=2e5+10;
int n;
pair<int,int> p[maxn];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>p[i].second>>p[i].first;
	sort(p,p+n);
	int now=0;
	for(int i=0;i<n;i++)
	{
		now+=p[i].second;
		if(now>p[i].first)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl; 
	return 0;
}

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

int main()
{
    int n, cout = 0;
    long long int l[110];

    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &l[i]);
    }

    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            for (int k = j+1; k < n; k++) {
                if ((l[i] != l[j]) && (l[j] != l[k]) && (l[k] !=  l[i])) {
                    if ((l[i]+l[j] > l[k]) && (l[i]+l[k] > l[j]) && (l[j]+l[k] > l[i])) {
                        cout++;
                    }
                }
            }
        }
    }
    
    printf("%d\n", cout);
    

    return 0;
}

Measured memory_bytes: 3788
#include <iostream>

using namespace std;

int main(){
  int cnt=0;
  int x;
  cin >> x;
  long s[x];
  for(int i=0;i<x;i++) cin >> s[i];
  int y;
  cin >> y;
  long t[y];
  for(int j=0;j<y;j++){
    cin >> t[j];
    for(int i=0;i<x;i++){
      if(t[j]==s[i]){
        cnt++;
        break;
      }
    }
  }
  cout << cnt << endl;
}

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

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

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int d;
    cin>>d;
    vector<int> c(26);
    rep(i,26){
        cin>>c[i];
    }
    vector<vector<int>> s(d,vector<int>(26));
    rep(i,d){
        rep(j,26){
            cin>>s[i][j];
        }
    }
    int ans=0;
    vector<int> last(d,0);
    rep(i,d){
        int t;
        cin>>t;
        t--;
        ans+=s[i][t];
        last[t]=i+1;
        rep(j,26){
            ans-=c[j]*(i+1-last[j]);
        }
        cout<<ans<<endl;
    }   
}

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vector<vector<int>> A(N, vector<int>(2));
    int X, L;
    rep(i, N) {
        cin >> X >> L;
        A[i][0] = X - L;
        A[i][1] = X + L;
    }

    sort(A.begin(), A.end(), [](auto a, auto b) {return a[1] < b[1];});
    int ans = 0;
    int prev_end = -1e+9;
    rep(i, N) {
        if (prev_end <= A[i][0]) {
            prev_end = A[i][1];
            ans++;
        }
    }
    cout << ans << '\n';

    return 0;
}

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

int A;
int c[200010];
int n,now;


int main()
{
	scanf("%d",&A);
	n=1;
	while ((ll)n*(n+1)/2<(ll)A) n++;
	int p=A-(ll)n*(n-1)/2;
	c[1]=1;	c[1+p]=2;now=1;
	for(int i=1;i<=2*n;i++) if(c[i]==0) if(now<n) c[i]=1,now++;else c[i]=2;
	for(int i=1;i<=2*n;i++) if(c[i]==1) printf(")");else printf("(");
	printf("\n");
	return 0;
}

Measured memory_bytes: 3444
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int K, T;
    cin >> K >> T;
    int A[T];
    for (int i = 0; i < T; i++) {
        cin >> A[i];
    }
    int pre = 101;
    int result = 0;
    for (int i = 0; i < K; i++) {
        int max = 0;
        int _pre = pre;
        for (int j = 0; j < T; j++) {
            if (A[j] > max && pre != j) {
                max = A[j];
                _pre = j;
            }
        }
        if (pre == _pre) {
            result++;
        }
        A[_pre]--;
        pre = _pre;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(w, h, cost) = io.Source.stdin.getLines.flatMap(_.split(" ")).map(_.toInt).toArray

  def gcd(num: Int, reminder: Int): Int = {
    if (num % reminder == 0) reminder else gcd(reminder, num % reminder)
  }

  val gCD = gcd(w, h)
  println((w/gCD) * (h/gCD) * cost)
}



Measured memory_bytes: 44112
#include<bits/stdc++.h>
using namespace std;
int main(void){
	double a,b,c;
	double s,l,h;
	cin>>a>>b>>c;
	s=0.5*a*b*sin(M_PI*c/180);
	l=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(M_PI*c/180))+a+b;
	h=b*sin(M_PI*c/180);
	cout<<fixed;
	cout<<s<<endl;
	cout<<l<<endl;
	cout<<h<<endl;
	return 0;
}
	


Measured memory_bytes: 3472
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  long long k;
  cin >> k;
  vector<long long> pos, neg;
  long long zero = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (a > 0) pos.push_back(a);
    if (a < 0) neg.push_back(-a);
    if (a == 0) zero++;
  }
  sort(pos.begin(), pos.end());
  sort(neg.begin(), neg.end());
  int np = (int) pos.size(), nn = (int) neg.size();
  long long lo = - (1e18 + 100), hi = 1e18 + 100;
  while (hi - lo > 1) {
    long long mid = (hi + lo) >> 1;
    long long cnt = 0;
    if (mid == 0) {
      cnt += zero * (zero - 1) / 2;
      cnt += zero * (long long) (pos.size() + neg.size());
      cnt += (long long) pos.size() * (long long) neg.size();
    } else if (mid > 0) {
      cnt += zero * (zero - 1) / 2;
      cnt += zero * (long long) (pos.size() + neg.size());
      cnt += (long long) pos.size() * (long long) neg.size();
      for (int i = 0, j = np - 1; i < np; i++) {
        while (j >= 0 && pos[i] * pos[j] > mid) j--;
        cnt += max(0, j - i);
      }
      for (int i = 0, j = nn - 1; i < nn; i++) {
        while (j >= 0 && neg[i] * neg[j] > mid) j--;
        cnt += max(0, j - i);
      }
    } else {
      for (int i = np - 1, j = 0; i >= 0; i--) {
        while (j < nn && -1LL * pos[i] * neg[j] > mid) j++;
        cnt += max(0, nn - j);
      }
    }
    //cerr << mid << " " << cnt << endl;
    if (cnt >= k) hi = mid;
    else lo = mid;
  }
  cout << hi << endl;
  return 0;
}

Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline

def main():
    n = int(input())
    nums = list(map(int, input().split()))

    for x in reversed(range(1, len(nums))):
        if nums[x-1] > nums[x]:
            nums[x-1] -= 1

        if nums[x-1] > nums[x]:
            print('No')
            sys.exit()

    print('Yes')


if __name__ == '__main__':
    main()

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


#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl


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

	string sh; cin>>sh;
	if (sh == "Sunny")
	{
		cout<<"Cloudy"<<endl;
	}
	else if (sh == "Cloudy")
	{
		cout<<"Rainy"<<endl;
	}
	else
		cout<<"Sunny"<<endl;
	return 0;

}

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

n =int(input())

xyl = []
for _ in range(n):
    x,y = map(int,input().split())
    xyl.append((x,y))

distl = []
for i in range(n):
    for j in range(i+1,n):
        dist1 = (xyl[i][0] - xyl[j][0]) ** 2
        dist2 = (xyl[i][1] - xyl[j][1]) ** 2
        dist3 = (dist1 + dist2) ** (1/2)
        distl.append(dist3)


print(sum(distl)*2/n)

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

int main() {
    string S;
    cin >> S;
    int N = S.size();

    vector<vector<bool>> data(N, vector<bool>(26, false));
    data.at(0).at(S.at(0) - 'a') = true;
    for (int i = 1; i < N; i++) {
        data.at(i) = data.at(i - 1);
        data.at(i).at(S.at(i) - 'a') = true;
    }

    bool can = false;
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            if (!data.at(i).at(j)) {
                if (i < N - 1) {
                    if (S.at(i + 1) - 'a' >= j) {
                        continue;
                    }
                }
                can = true;
                char c = 'a' + j;
                S = S.substr(0, i + 1) + c;
                break;
            }
        }
        if (can) {
            break;
        }
    }

    if (can) {
        cout << S << endl;
    }
    else if (S != "zyxwvutsrqponmlkjihgfedcba") {
        char c = S.at(0) + 1;
        cout << c << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
def main() :
    n = int(input())
    A = [list(map(int, input().split())) for _ in range(n)]

    ans = 0
    for i in range(n) :
        for j in range(i+1, n) :
            cost = A[i][j]
            for k in range(n) :
                if i == k or j == k:
                    continue

                d = A[i][k] + A[k][j]
                if d == A[i][j] :
                    cost = 0
                elif d < A[i][j] :
                    print(-1)
                    exit()
            ans += cost
    print(ans)

main()

Measured memory_bytes: 42204
import java.util.Scanner;
import java.io.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = null;
		int[] result = new int[10000];
		int index = 0;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				int d = 0;
				if( stdIn.hasNextInt() ){
					d = stdIn.nextInt();
				} else {
					stdIn.next();
				}
				
				int n = 600/d;
				result[index] = d*d*d*(n-1)*n*(2*n-1)/6;
				index++;
			}
			
			for(int i = 0; i < index; i++){
				System.out.println(result[i]);
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
using System;

public class AtCoderA
{
    static void Main()
    {
        int x;
        int a;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            x = int.Parse(words[0]);
            a = int.Parse(words[1]);
        }

        Console.WriteLine(x < a ? 0 : 10);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
set<int> s;
int mp[N];
int main(){
    int n;sc(n);
    fr(i, 1, n){
        int x;sc(x);
        s.insert(x);
        mp[x]++;
    }
    for(auto u: s){
        for(int i=u+u; i<N;i+=u) mp[i] =0;
    }
    int ans = 0;
    fr(i, 1, N-1){
        if (mp[i]==1) ans++;
    }
    pr(ans);n_l;
    return 0;
}



Measured memory_bytes: 16992
#include<bits/stdc++.h>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

// PMAMP :)
// INL , IIWOIL

int main()
{
    jaldi
    int n;
    cin>>n;
    map<int,bool> m;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        if(!m[x]) m[x]=1;
        else
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}

Measured memory_bytes: 9600
f=input; from bisect import bisect_left as g, insort as h
f(); s,i=list(f()),0
from collections import *
d=defaultdict(list)
for c in s: d[c]+=[i]; i+=1
for _ in range(int(f())):
  a,b,c=f().split(); b=int(b)-1
  if a>'1': print(sum(1 for l in d.values() if g(l,b)<len(l) and l[g(l,b)]<int(c)))
  elif s[b]!=c: l=d[s[b]]; l.pop(g(l,b)); s[b]=c; h(d[c],b)

Measured memory_bytes: 28928
#include <iostream>
using namespace std;
int main() {
  int a[5];
  int index, max = 0, rest;
  int ans = 0;
  for(int i = 0; i < 5; i++) {
    cin >> a[i];
    if((rest = 10 - a[i] % 10) > max && a[i] % 10 != 0) {
      max = rest;
      index = i;
    }
  }
  for(int i = 0; i < 5; i++) {
    if(i == index) ans += a[i];
    else if(a[i] % 10 == 0) ans += a[i];
    else ans += (a[i] / 10 + 1) * 10;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from pprint import pprint
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]

h.sort()

diff = [10**10 for _ in range(N-K+1)]

for i in range(N-K+1):
    diff[i] = h[i+K-1]-h[i]

print(min(diff))


Measured memory_bytes: 11824
N = int(input())
a = [int(i) for i in input().split()]

ave = sum(a)/len(a)
sub = 100000
ans = -1

for i in reversed(range(len(a))):
    if abs(a[i]-ave) <= sub:
        sub = abs(a[i]-ave)
        ans = i

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int bfs(int k, string s, string g){
	map<string, int> d;
	d[s] = 0;
	queue<string> q;
	q.push(s);
	
	int res = 0;
	while( !q.empty() ){
		string now = q.front(); q.pop();
		int cost = d[now];
		if( now == g ) return cost;
		
		int pos = 0, diff;
		for(int i = 0; i < k; i++){
			if( now[i] != g[i] ){
				pos = i;
				diff = (g[i] - '0') - (now[i] - '0');
				break;
			}
		}
		for(int i = pos; i < k; i++){
			string next = now;
			
			for(int j = pos; j <= i; j++){
				next[j] += diff;
				while( '9' < next[j] ) next[j] -= 10;
				while( next[j] < '0' ) next[j] += 10;
			}
			if( !d.count(next) ){
				d[next] = cost + 1;
				q.push(next);
			}
		}
	}
	return -1;
}

int main(){
	int k;
	while( cin >> k , k ){
		string s, g;
		cin >> s >> g;
		
		cout << bfs(k, s, g) << endl;
	}
}

Measured memory_bytes: 2648
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  int a;
  cin >> a;
  if(a < 1200) 
    cout << "ABC" << endl;
  else if(a < 2800)
    cout << "ARC" << endl;
  else cout << "AGC" << endl;
}

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

int dp[5005][5005];

int main(){
	int n;
  	string s;
  	cin >> n >> s;
  	
  	for(int i = n-1; i >= 0; i--){
    	for(int j = n-1; j >= 0; j--){
        	if(s[i] != s[j]) dp[i][j] = 0;
          	else dp[i][j] = dp[i+1][j+1]+1;
        }
    }
  
  	int ans = 0;
  	rep(i, n)rep(j, n){
      	if(i >= j) continue;
    	int now = min(dp[i][j], j-i);
      	ans = max(ans, now);
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 101352
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import *
from heapq import *

def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]

maxd = -1
ans = None

A, B, C, D, E, F = reads()
for i, j, k in product(range(31), range(31), range(3001)):
  water100 = A * i + B * j
  if C * k > water100 * E or C * k > F - water100 * 100 or water100 == 0:
    continue
  l = min(water100 * E - C * k, F - water100 * 100 - C * k) // D
  sugar = C * k + D * l
  mass = water100 * 100 + sugar
  density = sugar / mass
  if mass <= F and maxd < density:
    maxd = density
    ans = (mass, sugar)

print(ans[0], ans[1])



Measured memory_bytes: 44140
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int table[][] = new int[r+1][c+1];
		
		for(int i=0; i<r; i++){
			for(int j=0; j<c; j++){
				table[i][j] = sc.nextInt();
				table[i][c]+=table[i][j];
				table[r][j]+=table[i][j];
				table[r][c]+=table[i][j];
			}
		}
	
		for(int i=0; i<r+1; i++){
			for(int j=0; j<c+1; j++){
				System.out.print(table[i][j]);
				if(j!=c) System.out.print(" ");
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 38024
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int check = 0;
    
    int[] P = new int[N];
    for(int i = 0; i < N; i++){
      P[i] = scanner.nextInt();
      
      if(P[i] != i+1){
        check++;
      }
    }
    
    if(check == 0 || check == 2){
      System.out.println("YES");
    } else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 24020
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void makeSet(int x);
void unite(int x, int y);
void link(int x, int y);
int findSet(int x);

int p[10000], r[10000];

int main(){
  int n, q;
  int com, x, y;
  int count = 0, judge[100000];

  cin >> n >> q;
  for(int i = 0; i < n; ++i) makeSet(i);


  for(int i = 0; i < q; ++i){
    cin >> com >> x >> y;

    if(com == 0) unite(x, y);
    else{
      if(findSet(x) == findSet(y)) judge[count++] = 1;
      else judge[count++] = 0;
    }
  }

  for(int i = 0; i < count; ++i){
    cout << judge[i] << endl;
  }


  return 0;
}

void makeSet(int x){
  p[x] = x;
  r[x] = 0;
}

void unite(int x, int y){
  link(findSet(x), findSet(y));
}

void link(int x, int y){
  if(r[x] > r[y])
    p[y] = x;
  else{
    p[x] = y;
    if(r[x] == r[y]){
      r[y] = r[y] + 1;
    }
  }
}

int findSet(int x){
  if(x != p[x])
    p[x] = findSet(p[x]);
  return p[x];
}



Measured memory_bytes: 3324