akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
    int N, M, X, key, key2, i;
    int A[200];
    key = key2 = 0;
    scanf("%d %d %d", &N, &M, &X);
    for ( i = 0; i <= N; i++ ) A[i] = 0;
    for ( i = 1; i <= M; i++ ) {
        scanf("%d", &key);
        A[key] = 1;
    }
    key = 0;
    for ( i = X; i <= N; i++ ) key += A[i];
    for ( i = X; i >= 0; i-- ) key2 += A[i];
    if ( key > key2 ) printf("%d\n", key2);
    else printf("%d\n", key); 

    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String s;
    String t;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.s = sc.next();
        this.t = sc.next();
    }
    
    //解答処理
    private String solve() {
        String answer = "No";
        String[] listS = s.split("");
        String[] listT = t.split("");
        Arrays.sort(listS);
        Arrays.sort(listT,Collections.reverseOrder());
        StringBuilder S = new StringBuilder();
        StringBuilder T = new StringBuilder();
        
        for (int i=0; i<listS.length; i++) {
        	S.append(listS[i]);
        }
        for (int i=0; i<listT.length; i++) {
        	T.append(listT[i]);
        }
        
        String s2 = S.toString();
        String t2 = T.toString();
        if(s2.compareTo(t2) < 0) {
        	answer = "Yes";
        }
        return answer;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int a[n+1];
  int l[n+2],r[n+2];
  for(i=1;i<=n;i++) cin>>a[i];
  l[0]=0;
  r[n+1]=0;
  for(i=1;i<=n;i++)  l[i]=__gcd(l[i-1],a[i]);
  for(i=n;i>=1;i--)  r[i]=__gcd(r[i+1],a[i]);
  int mx=0;
  for(i=1;i<=n;i++)
  {
    mx=max(mx,__gcd(l[i-1],r[i+1]));
  }
  cout<<mx;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

bool compare(const pair<string,int> &a,const pair<string,int> &b){
  if(a.second!=b.second) return a.second>b.second;
  else return a.first<b.first;
}

int main(void){
  int n;
  while(cin>>n,n){
    cin.ignore();
    map<string,int> cnt[26];
    for(int i=0;i<n;++i){
      string s;getline(cin,s);
      stringstream ss;ss<<s;
      while(!ss.eof()){
      	string w;ss>>w;
        ++cnt[w[0]-'a'][w];
      }
    }
    char c;cin>>c;
    vector<pair<string,int> > v;
    for(map<string,int>::iterator it=cnt[c-'a'].begin();it!=cnt[c-'a'].end();++it)
    	v.push_back(make_pair(it->first,it->second));
    sort(v.begin(),v.end(),compare);
    if(v.empty()) cout<<"NA"<<endl;
    for(int i=0;i<5&&i<v.size();++i){
    	cout<<v[i].first;
    	cout<<((i!=v.size()-1&&i!=4)?" ":"\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1244
import collections

N = int(input())
S = [int(i) for i in list(input())]

count = 0
for i in range(10):
    for num,j in enumerate(S):
        if j == i:
            T = S[num+1::]
            for k in list(set(T)):
                for num2, l in enumerate(T):
                    if k == l:
                        U = T[num2+1::]
                        count += len(set(U))
                        break
            
            break
            
print(count)
                

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

ll a[102],b[102];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	for(int i=1;i<n;i++){
		a[i]=a[i-1]+a[i];
		b[i]=b[i-1]+b[i];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		ll A=a[i];
		ll B=b[n-1];
		if(i-1>=0){
			B-=b[i-1];
		}
		ans=max(A+B,ans);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int H = sc.nextInt();
        int W = sc.nextInt();

        _out.println(Math.min(calc(H, W), calc(W, H)));
    }
    private long calc(int h, int w) {
        long res = Long.MAX_VALUE;

        for (int i = h / 3; i <= h / 2; ++i) {
            long a1 = i * w;
            long a2 = ((h - i) / 2) * w;
            long a3 = (h - i - ((h - i) / 2)) * w;

            long smax = Math.max(a1, Math.max(a2, a3));
            long smin = Math.min(a1, Math.min(a2, a3));

            res = Math.min(res, smax - smin);
        }

        for (int i = h / 3; i <= h / 2; ++i) {
            long a1 = i * w;
            long a2 = (h - i) * (w / 2);
            long a3 = (h - i) * (w - (w / 2));

            long smax = Math.max(a1, Math.max(a2, a3));
            long smin = Math.min(a1, Math.min(a2, a3));

            res = Math.min(res, smax - smin);
        }

        return res;
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23764
arr = []
ans = []
for i in range(3):
  arr.extend(list(map(int,input().split())))
N = int(input())
for j in range(N):
  num = int(input())
  if num in arr:
    ans.append(arr.index(num))
ans = set(ans)
if (set([0,1,2])<=ans)or(set([3,4,5])<=ans)or(set([6,7,8])<=ans)or(set([0,3,6])<=ans)or(set([1,4,7])<=ans)or(set([2,5,8])<=ans)or(set([0,4,8])<=ans)or(set([2,4,6])<=ans):
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>

using namespace std;

int main() {
	int a, b, t[101][101]{0};
	cin >> a >> b;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			cin >> t[i][j];
			t[a][j] += t[i][j];
			t[i][b] += t[i][j];
			t[a][b] += t[i][j];
		}
	}
	for (int i = 0; i < a+1; i++) {
		for (int j = 0; j < b+1; j++) {
			if (j == 0)cout << t[i][j];
			else cout << " " << t[i][j];
		}
		cout << endl;
	}
	return 0;
}

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


int main(void){
	int n;
	cin >> n;
	while(n){
		int dice[7] = {0,1,2,3,4,5,6};
		int pattern[6][4] = {{1,2,6,5},{1,4,6,3},{1,3,6,4},{1,5,6,2},{2,3,5,4},{2,4,5,3}};
		int i ,p ,sum = 1;
		string dire;
		for(int i = 0; i < n; i++){
			cin >> dire;
			if(dire == "North") p = 0;
			else if(dire == "East") p = 1;
			else if(dire == "West") p = 2;
			else if(dire == "South") p = 3;
			else if(dire == "Right") p = 4;
			else p = 5;

			dice[0] = dice[pattern[p][0]];
			for(int j = 0; j < 3; j++)
				dice[pattern[p][j]] = dice[pattern[p][j + 1]];
			dice[pattern[p][3]] = dice[0];
			sum += dice[1];
		}	
		cout << sum;
		cout << endl;
		cin >> n;
	}	
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef int64_t LL;
int GCD(int a,int b){return(b==0)?a:GCD(b,a%b);}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int main()
{
  int A,N,M;
  LL x=1;
  cin>>N>>M;
  while(cin>>A){x=LCM(x,(A+1)/2);if(x>M||fmod(2*x/A,2)==0)return cout<<0<<endl,0;}
  return cout<<(M/x+1)/2<<endl,0;
}

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

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

    int ans=100, sum=0;

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

    int sum2=0;

    for(int i=0; i<N; i++){
        sum2+=W.at(i);
        sum-=W.at(i);
        ans=min(abs(sum-sum2), ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
use std::collections::{BTreeMap, BTreeSet};

fn main() {
    let mut sc = Scanner::new();

    let x: i64 = sc.read();
    let y: i64 = sc.read();
    if (x - y).abs() <= 1 {
        println!("Brown");
    } else {
        println!("Alice");
    }
}

fn exp() {
    let mut map = BTreeMap::new();
    for z in 0..10000 {
        for x in 0..(z + 1) {
            let y = z - x;
            if y < x { continue; }
            if grundy(x, y, &mut map) == 0 {
                println!("{} {} {}", x, y, y - x);
            }
        }
    }
}

fn grundy(x: usize, y: usize, map: &mut BTreeMap<(usize, usize), usize>) -> usize {
    let (x, y) = norm(x, y);
    if !map.contains_key(&(x, y)) {
        let mut set = BTreeSet::new();
        for i in 1..(x / 2 + 1) {
            set.insert(grundy(x - 2 * i, y + i, map));
        }
        for i in 1..(y / 2 + 1) {
            set.insert(grundy(x + i, y - 2 * i, map));
        }

        let mut g = 0;
        loop {
            if set.contains(&g) {
                g += 1;
            } else {
                break;
            }
        }
        map.insert((x, y), g);
    }


    let g: usize = *map.get(&(x, y)).unwrap();
    return g;
}


fn norm(x: usize, y: usize) -> (usize, usize) {
    if x >= y { (y, x) } else { (x, y) }
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

typedef pair<int, int> P;
typedef long long ll;

const int MAX = 2005;

char a[MAX], b[MAX];
int n;

int main()
{
  scanf("%s%s", a, b);
  n = (int) strlen(a);

  int ima1 = 0;
  REP(i, n) {
    if (a[i] == '1') ima1 |= 1;
    if (b[i] == '1') ima1 |= 2;
  }

  if (ima1 == 1) printf("-1\n");
  if (ima1 == 0) printf("0\n");
  if (ima1 < 2) return 0;

  int rje = 1e9;
  REP(kek, 2) {
    reverse(a, a + n);
    reverse(b, b + n);
    // TRACE(a);
    // TRACE(b);
 
    
    int prvi = -1, zad = -1;
    REP(i, n) {
      if (b[i] == '1') {
	if (prvi == -1) prvi = i;
	zad = i;
      }
    }

    REP(sift, n) {
      int sw=0;

      int desno[MAX], lijevo[MAX];
      memset(lijevo, -1, sizeof lijevo);
      memset(desno, -1, sizeof desno);
    
      REP(i, n) {
	if (b[i] == '1') lijevo[i] = 0;
	if (!i && lijevo[i] == -1) lijevo[i] = n - zad;
	if (i && lijevo[i] == -1) lijevo[i] = lijevo[i-1] + 1;
      }

      for (int i=n-1; i>=0; i--) {
	if (b[i] == '1') desno[i] = 0;
	if (i == n-1 && desno[i] == -1) desno[i] = prvi + 1;
	if (i != n-1 && desno[i] == -1) desno[i] = desno[i+1] + 1;
      }

      int mxlev[MAX];
      memset(mxlev, 0, sizeof mxlev);
      REP(i, n) {
	if (a[i] != b[(i + sift) % n]) {
	  if (desno[i]) {
	    //	    if (!i && !sift) TRACE(lijevo[i] _ desno[i]);
	    mxlev[desno[i]-1] = max(mxlev[desno[i]-1], lijevo[i]);
	  }
	  sw++;
	}
      }

      for (int i=n-1; i>=0; i--)
	mxlev[i] = max(mxlev[i], mxlev[i+1]);

      // if (sift == 0)
      // 	REP(i, n)
      // 	  if (a[i] != b[(i + sift) % n])
	    //      	    TRACE(i _ desno[i] _ lijevo[i]);

      // if (!sift)
      // 	REP(i, n+1)
      // 	  TRACE(i _ mxlev[i]);
      
    
      //    REP(st, 2) {
      int st = 0;
      REP(r, n+1) {
	int jedna, druga;

	//	if (!st) {
	jedna = max(sift, r);
	druga = mxlev[r];
	  //	}
 	// else {
	//   jedna = max(n-sift, r);
	//   druga = mxlev[r];
	// }
	
	//int uk = jedna + druga + min(jedna, druga);
	int uk;
	if (sift < r)
	  uk = jedna + druga + druga + r - sift;
	else
	  uk = 2 * druga + jedna;
	

	//	if (sift == 2 && r == 2) TRACE(jedna _ druga);

	// if (sift == n-1)
	//   TRACE(st _ sift _ r _ mxlev[r] _ sw _ ta);

	//	if (uk + sw == 7) TRACE(uk _ r _ mxlev[r] _ sw _ sift _ jedna _ druga _ st);
	
	rje = min(rje, uk + sw);
      }
      //    }
      
    }
    //       break;
  }
  printf("%d\n", rje);

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
void init(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main()
{
  init();
  int n;
  cin >> n;
  int x, y; cin >> x >> y;
  vecint ans(n,0);
  for(int i = 1; i <= n; i ++){
    for(int j = i + 1; j <= n; j ++){
      int dis1 = j - i;
      int dis2 = abs(x - i) + 1 + abs(y - j);
      int dis = min(dis1, dis2);
      ans[dis] ++;
    }
  }
  for(int i = 1; i <= n - 1; i ++){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>

int cnt = 0;

void insertionsort(std::vector<int> &v, int n, int g) {
    int elem = 0;
    int j = 0;
    for (int i = g; i < n; i++) {
        elem = v[i];
        j = i - g;
        while ((j >= 0) && (v[j] > elem)) {
            v[j + g] = v[j];
            j -= g;
            cnt++;
        }
        v[j + g] = elem;
    }
}

void shellsort(std::vector<int> &v, int n) {
    const int m = 13;

    std::vector<int> g(m);
    for (int i = 0; i < m; i++) {
        g[i] = (pow(3, i+1) - 1) / 2;
    }

    int tail = m - 1;
    while (tail > 0 && g[tail] > n) tail--;
    std::cout << tail+1 << std::endl;
    for (int i = tail; i > 0; i--) {
        std::cout << g[i] << " ";
    }
    std::cout << g[0] << std::endl;

    for (int i = tail; i >= 0; i--) {
        insertionsort(v, n, g[i]);
    }
}

int main(int argc, char const *argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for (int i = 0; i < n; i++) {
        std::cin >> v[i];
    }

    shellsort(v, n);
    std::cout << cnt << std::endl;
    for (int i = 0; i < n; i++) {
        std::cout << v[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 4896
from sys import stdin
import math
import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = [int(x) for x in stdin.readline().rstrip().split()]
x = []
for i in range(6):
  x.append(int(stdin.readline().rstrip().split()[0]))

N,A,B,C,D,E = x
neck = min([A,B,C,D,E])
k = (N-1)//neck+1
print(k+4)

Measured memory_bytes: 12508
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N =sc.nextInt();//商品の種類
      int M =sc.nextInt();//選択する個数
      
      List<Integer>item = new ArrayList<>();
      
      //int item[] = new int[N];
      double sum =0;
      int count =0;
      
      //各商品の投票数を配列へ
      for(int i=0; i<N; i++){
        	 item.add(sc.nextInt());
             sum += item.get(i);//総投票数
      }
       //選択されるための最低投票数
      double min = sum/(4*M);    
      
      for(int i=0; i<N; i++){
        
        //各投票数が最低投票数を超えているか
        if(item.get(i)>=min){
          count++;
        }
      }
      //最低投票数以上の票がある商品をM 以上選択できるか
      if(count>=M){
          System.out.println("Yes");
            
      }
      else{
          System.out.println("No");   
      }     
    }
}


Measured memory_bytes: 35708
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [tuple(map(int,input().split())) for i in range(M)]
A.sort()
BC.sort(key=lambda x:-x[1])

i = 0
for b,c in BC:
    for _ in range(b):
        if c <= A[i]: break
        A[i] = c
        i += 1
        if i >= N: break
    else:
        continue
    break

print(sum(A))

Measured memory_bytes: 25320
#include<cmath>
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  double a,b,c,d,e,f;
  double x,y;
  while(cin >> a >> b >> c >> d >> e >> f){
    y = (a*f-d*c)/(a*e-b*d);
    x = (c-b*y)/a;
    printf("%.3f %.3f\n",x,y);
  }
}

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

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int n;
    cin >> n;

    map<long long, int> cnt;
    long long a;
    for (int i=0; i<n; ++i) {
        cin >> a;
        cnt[a] ++;
    }

    if (3 < cnt.size()) {
        cout << "No" << endl;
        return 0;
    }

    vector<pair<int,long long>> v;  // (個数,番号)
    for (auto it=cnt.begin(); it!=cnt.end(); ++it) {
        v.emplace_back(it->second, it->first);
    }
    sort(v.begin(), v.end());

    if (v.size() == 1) {
        if ((v[0].second ^ v[0].second) == v[0].second) {
            cout << "Yes" << endl;
            return 0;
        }
    } else if (v.size() == 2 && n % 3 == 0) {
        if (v[0].first * 2 == v[1].first && (v[1].second ^ v[1].second) == v[0].second) {
            cout << "Yes" << endl;
            return 0;
        }
    } else if (v.size() == 3 && n % 3 == 0) {
        if (v[0].first == v[1].first && v[1].first == v[2].first && (v[0].second ^ v[1].second) == v[2].second) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,0,n) cin>>a[i];
    sort(all(a));
    
    vector<int> vec;
    int now=a[0];
    int cnt=1;
    rep(i,1,n){
        if(a[i]==now) cnt++;
        else{
            vec.push_back(cnt);
            now=a[i];
            cnt=1;
        }
    }
    vec.push_back(cnt);
    
    cnt=0;
    for(int x:vec){
        if(x%2==0) cnt++;
    }
    cout<<vec.size()-cnt%2<<endl;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define MAXN 200010
vector<ll> c(MAXN,1);
ll par[MAXN]; // 親
ll deep[MAXN]; // 深さ

// in要素で初期化
ll init(ll in){
  for(int i=0;i<=in;i++){
    par[i]=i;
    deep[i]=0;
  }
}

// 木の根を求める
ll find(ll x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}

// xとyの集合を併合
void unite(ll x,ll y){
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(deep[x]<deep[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(deep[x]==deep[y]) deep[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(ll x,ll y){
  return find(x)==find(y);
}

ll pard[MAXN]; // 親
ll deepd[MAXN]; // 深さ

// in要素で初期化
ll initd(ll in){
  for(int i=0;i<=in;i++){
    pard[i]=i;
    deepd[i]=0;
  }
}

// 木の根を求める
ll findd(ll x){
  if(pard[x]==x){
    return x;
  }else{
    return pard[x]=findd(pard[x]);
  }
}

// xとyの集合を併合
void united(ll x,ll y){
  x=findd(x);
  y=findd(y);
  if(x==y) return;
  if(deepd[x]<deepd[y]){
    pard[x]=y;
  }else{
    pard[y]=x;
    if(deepd[x]==deepd[y]) deepd[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool samed(ll x,ll y){
  return findd(x)==findd(y);
}

int main(){
  ll n,k,l,p,q;
  cin>>n>>k>>l;
  init(n); initd(n);
  for(int i=0;i<k;i++){
    cin>>p>>q;
    unite(p,q);
  }
  for(int i=0;i<l;i++){
    cin>>p>>q;
    united(p,q);
  }
  for(int i=1;i<=n;i++){
    find(i);
    findd(i);
  }
  map<P,ll> mp;
  for(int i=1;i<=n;i++){
    mp[P(par[i],pard[i])]++;
  }
  for(int i=1;i<=n;i++){
    cout<<mp[P(par[i],pard[i])]<<" ";
  }
}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

#define maxn 105
#define maxv 300005
ll A[maxn][2];
ll dp[maxv];

int main() {
    int N, W;
    scanf("%d%d", &N, &W);

    for (int i = 1; i <= N; ++i)
        scanf("%lld%lld", &A[i][0], &A[i][1]);

    for (int i = 0; i < maxv; ++i)
        dp[i] = INF;

    for (int i = 1; i <= N; ++i) {
        for (int v = maxv - 1; v >= 1; --v) {
            if (dp[v] + A[i][0] <= W && dp[v] != INF) {
                dp[v + A[i][1]] = min(dp[v + A[i][1]], dp[v] + A[i][0]);
            }
        }
        dp[A[i][1]] = min(dp[A[i][1]], A[i][0]);
    }

    ll m = 0;
    for (ll i = 1; i < maxv; ++i) {
        m = max(m, ((dp[i] != INF) ? i : 0));
    }
    printf("%lld\n", m);
    return 0;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; i++)
#define repn(i, st, ed) for(ll i=st; i<=ed; i++)
#define repb(i, ed, st) for(ll i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


ll X, Y, Z, K, A[1009], B[1009], C[1009];
// Main Code
int main()
{

	cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; i++) cin >> A[i]; sort(A, A + X, greater<ll>());
	for (int i = 0; i < Y; i++) cin >> B[i]; sort(B, B + Y, greater<ll>());
	for (int i = 0; i < Z; i++) cin >> C[i]; sort(C, C + Z, greater<ll>());
	std::vector<ll> vec;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			for (int k = 0; k < Z; k++) {
				if ((i + 1) * (j + 1) * (k + 1) <= K) vec.push_back(A[i] + B[j] + C[k]);
				else break;
			}
		}
	}
	sort(all(vec), greater<ll>());
	for (int i = 0; i < K; i++) cout << vec[i] << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    
    ll ans = 100000000000;
    for(ll nc=0; nc<=2*max(x, y); nc+=2) {
        int na = max(0, x - nc / 2);
        int nb = max(0, y - nc / 2);
        ans = min(ans, a*na+b*nb+c*nc);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import math
N = int(input())

sqrt_N = math.floor(N**(1/2))

for i in range(sqrt_N,0,-1):
    if N%i == 0:
        a,b = i,int(N/i)
        break

#print(a,b)
calc_F = max(len(str(a)),len(str(b)))
print(calc_F)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<iterator>
#include<math.h>
#include<cstring>
using namespace std;
void lets_play()

{

    int a,b,i;
    cin>>a>>b;
    if(a>=b)
    {
        for(i=1;i<=a;i++)
            cout<<b;
        cout<<endl;
    }
    else
    {
        for(i=1;i<=b;i++)
            cout<<a;
        cout<<endl;
    }
    }

int main()
{
        lets_play();

}


Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s[0] != s.back() && s.length()%2) {
    cout << "First";
  } else if (s[0] != s.back()) {
    cout << "Second";
  } else if (s.length()%2) {
    cout << "Second";
  } else {
    cout << "First";
  }
}

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

int main() {

  int a, b, c;

  cin >> a >> b >> c;

  int ans = 0;
  if (a == b && b != c) ans = 1;
  if (b == c && c != a) ans = 1;
  if (c == a && a != b) ans = 1;

  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl; 

}


Measured memory_bytes: 256
import sys
line = raw_input()
res = dict()
for i in line:
    res[i] = 1
    if len(res) == 26:
        print 'None'
        sys.exit(0)
for i in 'abcdefghijklmnopqrstuvwxyz':
    if res.get(i, None) is None:
        print i
        sys.exit(0)


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

int main(void) {
    int64_t N;
    int64_t cur = 1;
    int64_t a,b = 0;
    cin >> N;

    for(int i=0;i<N;i++) {
        cin >> a;
        if(a == cur) { 
            cur++;
        } else {
            b++;
        }
    }
        
    if(cur == 1) {
        cout << "-1\n";
    } else {
        cout << b << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner tan = new Scanner(System.in);
        String st=tan.next();
        if(st.equals("Sunny"))
            System.out.println("Cloudy");
        else if(st.equals("Cloudy"))
            System.out.println("Rainy");
        else 
            System.out.println("Sunny");
    }
}


Measured memory_bytes: 20692
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(){
  string s;
  int m=0;
  vector<int> v[101];
  int dp[101][101];
  memset(dp,0,sizeof(dp));
  while(getline(cin,s)){
    stringstream ss(s);
    int n;
    char c;
    while(ss>>n){
      v[m].push_back(n);
      ss>>c;
    }
    ++m;
  }
  dp[0][0]=v[0][0];
  for(int i=1;i<m;++i){
    for(int j=0;j<v[i].size();++j){
      dp[i][j]=dp[i-1][j]+v[i][j];
      if(i<=m/2&&j!=0) dp[i][j]=max(dp[i][j],dp[i-1][j-1]+v[i][j]);
      else if(i>m/2&&j<v[i-1].size()-1) dp[i][j]=max(dp[i][j],dp[i-1][j+1]+v[i][j]);
    }
  }
  cout<<dp[m-1][0]<<endl;
  return 0;
}

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

int main() {
  int n, y;
  cin >> n >> y;
  int a = -1, b = -1, c = -1;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; i + j <= n; j++) {
      int k = n - i - j;
      int sum = i * 10000 + j * 5000 + k * 1000;
      if (sum == y) {
        a = i;
        b = j;
        c = k;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
}

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

int main(){
    long long N;
    int answer = 0;
    vector<pair<long long, long long>> prime;
    cin >> N;
    for (long long i = 2; i * i < N; ++i){
        if (N % i != 0) continue;
        int cnt = 0;
        while (N % i == 0){
            ++cnt;
            N /= i;
        }
        prime.push_back(make_pair(i, cnt));
    }
    if (N != 1) prime.push_back(make_pair(N, 1));

    for (long long i = 0; i < prime.size(); ++i){
        int t=1, cnt=0;
        while (prime[i].second > cnt){
            prime[i].second -= t;
            ++cnt;
            ++t;
        }
        answer += cnt;
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3600
// 三井住友信託銀行プログラミングコンテスト2019-C
// 2019.12.1 bal4u

#include <stdio.h>
#include <string.h>

typedef long long ll;

int dp[1001005];

int main()
{
	int i, j, X;
	
	scanf("%d", &X);
	dp[0] = 1;
	for (j = 0; j <= X; ++j) if (dp[j]) {
		for (i = 100; i <= 105; ++i) dp[j+i] = 1;
	}
	putchar(dp[X]+'0'), putchar('\n');
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A,B,C,D,L,R;
    cin>>A>>B>>C>>D;
    
    L=A+B;
    R=C+D;
    
    if(L>R){
        cout<<"Left"<<endl;
    }
    
    if(L==R){
        cout<<"Balanced"<<endl;
    }
    
    if(L<R){
        cout<<"Right"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K, dp[2001] = {};
  vector< int > Book[10];
  cin >> N >> K;
  for(int i = 0; i < N; ++i){
    int C, G;
    cin >> C >> G;
    Book[G - 1].push_back(C);
  }
  dp[0] = 0;
  for(int i = 0; i < 10; ++i){
    sort(Book[i].rbegin(), Book[i].rend());
    for(int j = K - 1; j >= 0; --j){
      int sum = 0;
      for(int k = 0; k < Book[i].size() && j + k + 1 <= K; k++){
        sum += Book[i][k];
        dp[j + k + 1] = max( dp[j + k + 1], dp[j] + sum + (k + 1) * k);
      }
    }
  }
  cout << dp[K] << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

typedef pair<i64, i64> P;

int main() {
    i64 N, M; cin >> N >> M;
    auto c = [](P p1, P p2) { return p1.F > p2.F; };
    priority_queue<P, vector<P>, decltype(c)> pq(c);

    i64 a, b;
    REP(i, N) {
        cin >> a >> b;
        pq.push(mp(a, b));
    }

    i64 min_price = 0;
    P ab;
    while (M > 0 && !pq.empty()) {
        ab = pq.top(); pq.pop();
        min_price += ab.F * min(M, ab.S);
        M -= min(M, ab.S);
    }
    cout << min_price << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <boost/tokenizer.hpp>
#include <boost/lexical_cast.hpp>
#include <vector>
#include <list>

using namespace std;
using namespace boost;


int main(int argc, char* argv[])
{
	using sprtr = char_separator<char>;
	using tknzr = tokenizer<sprtr>;
	sprtr sep(" ", "", keep_empty_tokens);

	int f, mf, mo;

	string line;
	while(1) {

		int n, m;
		{
			getline(cin, line);
			tknzr tkns(line, sep);
			auto it = tkns.begin();
			n = lexical_cast<int>(*it++);
			m = lexical_cast<int>(*it);
		}

		if( n == 0 && m == 0 ) {
			break;
		}
		
		list<int> ps;		
		{
			getline(cin, line);
			tknzr tkns(line, sep);
			for( auto p : tkns ) {
				//cout << p << endl;
				ps.push_back(lexical_cast<int>(p));
			}
		}

		ps.sort(greater<int>());

		int div = n / m;
		int mod = n % m;

		int sum = 0;
		auto it = ps.begin();
		for( int i = 0; i < div; i++ ) {
			for( int j = 0; j < m; j++ ) {
				auto p = *it++;
				if( j == m-1 ) continue;
				sum += p;
			}
		}

		if( mod ) {
			for( int i = 0; i < mod; i++ ) {
				auto p = *it++;
				sum += p;			   
			}
		}

		cout << sum << endl;

		ps.clear();
		
	}

    return 0;
}

Measured memory_bytes: 3048
#include <iostream>

int main() {

    int a[3]; 
    std::cin >> a[0] >> a[1] >> a[2]; 

    for (int i = 0; i < 3; i ++) 
        for (int j = 0; j < 2; j ++)
            if (a[j] > a[j + 1]) std::swap(a[j], a[j + 1]); 

    int cnt = (a[0] == a[1]) + (a[1] == a[2]); 

    printf("%s\n", cnt == 1 ? "Yes" : "No");

    return 0; 
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int k = sc.NextInt();
        int[] a = sc.IntArray();

        Dictionary<int, int> dic = new Dictionary<int, int>();
        foreach (var num in a)
        {
            if (!dic.ContainsKey(num))
            {
                dic.Add(num, 0);
            }
            dic[num]++;
        }

        List<int> list = dic.OrderBy(item => item.Value).Select(item => item.Value).ToList();

        int answer = 0;
        for (int i = 0; i < list.Count - k; i++)
        {
            answer += list[i];
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 39148
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if (u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node *u) {
  if (u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    cin >> com;
    if (com == "insert") {
      scanf("%d", &x);
      insert(x);
    } else if (com == "print") {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26740
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #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 rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<int> vi;
    const int maxN = 100100;

    void solve() {
        ll n; string s;
        cin >> n >> s;
        ll de[n+10], dw[n+10], val = 1e17;
        de[0] = 0, dw[0] = 0;
        repA(i, 1, n) {
            s[i-1] == 'E' ? de[i] = de[i-1] + 1 : de[i] = de[i-1];
            s[i-1] == 'W' ? dw[i] = dw[i-1] + 1 : dw[i] = dw[i-1];
            //cout << de[i] << " " << dw[i] << endl;
        }
        repA(i, 1, n) val = min(val, dw[i-1] + (de[n] - de[i]));
        //cout << dw[i-1] << " " << (de[n] - de[i]) << endl;
        cout << val << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 5396
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;

int kaijo(int a){
  int i,ans=1;
  for(i=1;i<=a;i++){
  ans*=i;
  }
  return ans;
}

int mathC(int a,int b){

  int i,ans=1;
  if(b>a/2) b=a-b;
  for(i=1;i<=b;i++){
    ans*=(a-i+1);
    ans/=i;
  }
  
  return ans;
}

int max(int x[],int N){
  int i,max=x[0];
	for(i=1;i<N;i++){
      if(max<x[i]) max=x[i];
    }
  return max;
}

int min(int x[],int N){
  int i,min=x[0];
	for(i=1;i<N;i++){
      if(min>x[i]) min=x[i];
    }
  return min;
}

void solve(void){
  
  int s[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
  string ans;
  cin >> K;
  
  cout << s[K-1] <<endl;
  return;
}
int main(void){
  
	solve();
	return 0; 
}

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

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

    char temp = s[0];
    int count = 1;
    for(int i = 1;i < n;i++){
        if(temp != s[i]){
            count++;
            temp = s[i];
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    debug("debug test\n");
    int n,k;cin>>n>>k;
    string s;cin>>s;
    int h = 0,c = 0;
    if(s[0] == 'L'){
        h++;
    }
    if(s[n-1] == 'R'){
        h++;
    }
    rep(i, n-1){
        if(s[i]=='R' && s[i+1]=='L'){
            c++;
        }
    }
    /*k = min(k, h+c-1);
    int kk = min(k, c);
    k -= kk;
    c -= kk;
    h -= min(k, h);*/
    cout << min(n - (2*c+h)+2*k, n-1) << endl;
    /*
    int fuko = 2*c+h;
    debug("c %d   h %d   fuko %d\n", c, h, fuko);
    int ans = 0;
    ans += min(k, c)*2;
    k -= min(k, c);
    ans += min(k, h);
    cout << n-(fuko - ans) << endl;*/
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int a,b,c,i,sum;
	scanf("%d %d",&a,&b);

	c = b-a;
	sum = 0;
	for(i = 0;i <= c; i++){
		sum += i;
	}
	printf("%d\n",sum-b);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>

using namespace std;

bool check(set<int>& info, vector<int>& data){
  for(int i=0; i<data.size(); ++i){
    if(info.find(data[i]) == info.end()) return false;
  }
  return true;
}

int solve(vector< set<int> >& info, vector<int>& data){
  vector<int> ans;
  for(int i=0; i<info.size(); ++i){
    if(check(info[i], data)) ans.push_back(i+1);
  }
  if(ans.size() == 1) return ans[0];
  else return -1;
}

int main(){
  int n, m, x;
  while(1){
    cin >> n;
    if(!n) break;

    vector< set<int> > info(n, set<int>());
    for(int i=0; i<n; ++i){
      cin >> m;
      for(int j=0; j<m; ++j){
	cin >> x;
	info[i].insert(x);
      }
    }

    cin >> m;
    vector<int> data(m, 0);
    for(int i=0; i<m; ++i) cin >> data[i];

    cout << solve(info, data) << endl;
  }
  return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A]+=parents[B];
        parents[B]=A;

        return true;
    }
};

int main(void){
    int n, q; cin >> n >> q;
    UnionFind uni(n);

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

        if(com == 0) uni.connect(x, y);
        else{
            cout << (uni.root(x) == uni.root(y)) << endl;
        }
    }
}


Measured memory_bytes: 3164
#include<cstdio>  
#include<cstring>  
#include<iostream>  
using namespace std;  
  
int a,b,c,x,y;  
  
int exgcd(int a,int b){  
    if(!b){  
        x=1;
		y=0;
		return a;  
    }  
    int e=exgcd(b,a%b);  
    int kkz=x;
	x=y;
	y=kkz-a/b*y;  
    return e;  
}  
  
int main()  
{  
    scanf("%d%d",&a,&b);  
    int k=exgcd(a,b);   
    printf("%d %d\n",x,y);
    return 0;  
}  


Measured memory_bytes: 3224
#include <iostream>
#include <vector>

int main(){
	int n,w;
	std::cin>>n>>w;
	
	std::vector<std::pair<int,int> > goods(n);
	
	for(int i=0;i<n;i++){
		int a,b;
		std::cin>>a>>b;
		goods[i]=std::make_pair(a,b);
	}
	
	std::vector<std::vector<long long> > dp(n+1,std::vector<long long>(w+1,0));
	for(int i=0;i<n;i++){
		for(int j=0;j<=w;j++){
			if(goods[i].first<=j){
				dp[i+1][j]=std::max(dp[i][j],dp[i][j-goods[i].first]+goods[i].second);
			}else{
				dp[i+1][j]=dp[i][j];
			}
		}
	}
	
	long long ans=0;
	for(int i=0;i<=w;i++){
		if(ans<dp[n][i]){
			ans=dp[n][i];
		}
	}
	std::cout<<ans<<std::endl;
}

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

/* =0,
 * ="",
 * =false
 * =true
 * std::vector<int>
 * std::sort(.begin(), .end());  ,std::greater<int>()
 */

void solve(int a,int b){
    int k=0;
    while((a-k!=b-k)&&((a-k)*-1!=b-k)&&(a-k!=(b-k)*-1)&&((a-k)*-1!=(b-k)*-1)){
        if((a>b&&k>a)||(b>a&&k>b)){
            printf("IMPOSSIBLE");
            exit(0);
        }
        k++;
    }
    printf("%d",k);
}

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

    int a=0,b=0;
    std::cin>>a>>b;
    solve(a,b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for(int i=0; i<N-1; i++){
    if(a.at(i) == a.at(i+1)){
      cout << "NO" << endl;
      exit(0);
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    String st;
	    int[][] p = new int[14][14];
	    int x, y, size;
	    while((st=sc.readLine())!=null){
		String[] cc = st.split(",");
		x = Integer.valueOf(cc[0])+2;
		y = Integer.valueOf(cc[1])+2;
		size = Integer.valueOf(cc[2]);
		if(size==1){
		    p[y][x]++;
		    p[y][x+1]++;
		    p[y][x-1]++;
		    p[y+1][x]++;
		    p[y-1][x]++;
		}
		else if(size==2){
		    p[y][x]++;
		    p[y][x+1]++;
		    p[y][x-1]++;
		    p[y+1][x]++;
		    p[y-1][x]++;
		    p[y-1][x-1]++;
		    p[y+1][x+1]++;
		    p[y-1][x+1]++;
		    p[y+1][x-1]++;
		}
		else if(size==3){
		    p[y][x]++;
		    p[y][x+1]++;
		    p[y][x-1]++;
		    p[y+1][x]++;
		    p[y-1][x]++;
		    p[y-1][x-1]++;
		    p[y+1][x+1]++;
		    p[y-1][x+1]++;
		    p[y+1][x-1]++;
		    p[y][x-2]++;
		    p[y][x+2]++;
		    p[y-2][x]++;
		    p[y+2][x]++;
		}
	    }
	    int max = 0, count = 0;
	    for(int i=2; i<12; i++)
		for(int j=2; j<12; j++){
		    max = Math.max(max, p[j][i]);
		    if(p[j][i]==0)
			count++;
		}
	    System.out.printf("%d\n%d\n",count,max);
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 12000