akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

class UnionFind():
    def __init__(self, n, m = None, read = 0):
        self.n = n
        self.parents = [-1] * n
        if read:
            if m is None:
                raise ValueError("What is M")
            for i in range(m):
                a, b = map(int, input().split())
                self.union(a - 1, b - 1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n, m = map(int, input().split())
*p, = map(int, input().split())
UF = UnionFind(n, m, read = 1)

a = 0
for i in range(n):
    P = p[i] - 1
    if UF.same(P, i):
        a += 1
print(a)

Measured memory_bytes: 13876
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}


int main(void) {
	ll x, y;
	cin >> x >> y;
	if (x < y) {
		cout << x * (y - 1) << endl;
		return 0;
	}
	if (x%y == 0)cout << -1 << endl;
	else {
		cout << x << endl;
	}
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	int i = 0, zero = 0, one = 0;
	while(s[i] != '\0'){
		if(s[i] == '0')zero++;
		else one++;
		i++;
	}
	cout << min(zero, one) * 2 << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

int A[5][5];
int N;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    rep(i, 3) rep(j, 3) {
      cin >> A[i][j];
    }
    cin >> N;
    rep(_, N) {
      int b; cin >> b;
      rep(i, 3) rep(j, 3) {
        if (A[i][j] == b) A[i][j] = -1;
      }
    }
    rep(i, 3) {
      bool flag = false;
      rep(j, 3) {
        if (A[i][j] != -1) flag = true;
      }
      if (!flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    rep(j, 3) {
      bool flag = false;
      rep(i, 3) {
        if (A[i][j] != -1) flag = true;
      }
      if (!flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    if (A[0][0] == A[1][1] && A[1][1] == A[2][2] && A[0][0] == -1) {
      cout << "Yes" << endl;
      return 0;
    }
    if (A[0][2] == A[1][1] && A[1][1] == A[2][0] && A[2][0] == -1) {
      cout << "Yes" << endl;
      return 0;
    }
    cout << "No" << endl;
    return 0;
}

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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    
    int now = 1;
    int count = 0;
    while(now < B) {
        now--;
        now = now + A;
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,K;
    cin >> N >> K ;
    int i=0;
    int x[N];
    int dist=0;

    for(i=0; i<N; i++){
        cin >> x[i];
        if(abs(x[i]-K) < x[i]){
            dist+=abs(x[i]-K)*2;
        }else{
            dist+=x[i]*2;
        }
    }

    cout << dist << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
cin >> n;
switch(n%10)
{
case  2:
case 4:
case 5:
case 7:
case 9: cout << "hon";
break;
case  0:
case 1:
case 6:
case 8: cout << "pon";
break;
case 3: cout << "bon";
}
return 0;
}


Measured memory_bytes: 3640
fn main() {
    let n: usize = read();
    let a: Vec<i32> = read_lines(n as u32);

    let mut p = 0;
    let mut result: i64 = 0;

    for i in (0..n).rev() {
        if p - a[i] > 1 {
            result = -1;
            break;
        } else if a[i] >= p {
            result += a[i] as i64;
        }
        p = a[i];
    }
    if a[0] != 0 {
        result = -1;
    }
    println!("{}", result);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_lines<T: std::str::FromStr>(n: u32) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5;
#define endl '\n'

int main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n;
	string S,T;
	cin>>S>>T;
	n=S.size();
	bool flag=1;
	for(int i=0;i<n;i++)
	if(S[i]!=T[i]){
		flag=0;
		break;
	}
	if(!flag) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = ll(1e18) + 5;

void solve(std::string S, std::string T) {
    ll SN = S.size();
    ll TN = T.size();
    ll ans = INF;
    for (int i = 0; i <= (SN - TN); i++) {
        ll temp = 0;
        for (int j = 0; j < TN; j++) {
            if (S[i + j] != T[j]) {
                temp++;
            }
        }
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3636
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)
#template
ans = 10**18
N,A,B,C = inputlist()
l = [0]*N
for i in range(N):
    l[i] = int(input())

n = 4**N

def count(li,n):
    co = 0
    co += (len(li)-1)*10
    co += abs(sum(li) - n)
    return co

for i in range(n+1):
    k = base10to(i,4)
    if len(k) < N:
        d = N-len(k)
        for j in range(d):
            k = '0'+k
    c = Counter(list(k))
    if c['1'] < 1 or c['2'] < 1 or c['3'] < 1:
        continue
    ans_k = 0
    la = []
    lb = []
    lc = []
    for j in range(N):
        if k[j] == '1':
            la.append(l[j])
        if k[j] == '2':
            lb.append(l[j])
        if k[j] == '3':
            lc.append(l[j])
    ans_k += count(la,A) + count(lb,B) + count(lc,C)
    ans = min(ans,ans_k)
print(ans)


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

# In[3]:


H,W = map(int, input().split())
C = []
for _ in range(H):
    tmp = input()
    C.append(tmp)
    C.append(tmp)
for i in range(len(C)):
    print(C[i])


# In[ ]:






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

int main() {
	vector<int> data(3);
	cin >> data.at(0) >> data.at(1) >> data.at(2);
	sort(data.begin(), data.end());
	cout << data.at(0) << ' ' << data.at(1) << ' ' << data.at(2) << endl;
}


Measured memory_bytes: 3156
package main

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

func main() {
	sc := NewScanner()
	S := sc.NextLine()

	next := []byte(S + string('a'-1))

	for l := len(S); l >= 0; l-- {
		for {
			next[l]++
			if next[l] <= 'z' {
				b := func() bool {
					mp := map[byte]bool{}
					for _, v := range next[:l+1] {
						if _, ok := mp[v]; ok {
							return false
						}
						mp[v] = true
					}
					return true
				}()
				if b {
					fmt.Println(string(next[:l+1]))
					return
				}
			} else {
				break
			}
		}
		next[l]--

	}

	fmt.Println(-1)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S = input()

ans = 0
for i in range(N):
	X = S[:i]
	Y = S[i:]
	ans = max(ans, len(set(X)&set(Y)))
print(ans)

Measured memory_bytes: 3892
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int n, ans = 0;
	std::cin >> n;
	
	int v[n], c[n], m[n];
	for (int i = 0; i < n; i++) {
	    std::cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
	    std::cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
	    m[i] = v[i] - c[i];
	    if(m[i] > 0) ans += m[i];
	}
	
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll k = in(), t = in();
	vector<ll>a(t); REP(i, t)a[i] = in(); sort(ALL(a));
	cout << (a.back() <= (k + 1) / 2 ? 0 : 2 * (a.back() - (k + 1) / 2) - (k % 2 == 0 ? 1 : 0)) << endl;
}

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

int main(){
	long long n;cin>>n;
	if(n%2==0){
		long long t=25,cnt=0;
		while(t<=n){
			cnt+=n/t/2;
			t*=5;
		}
		cout<<cnt+n/10<<endl;
	}else{
		cout<<0<<endl;
	}
}

Measured memory_bytes: 256
n=int(raw_input())
a=sorted(map(int,raw_input().split()))
a.reverse()
i=0
while i<n and a[i]>=i+1:i+=1
j=i
while j<n and a[j]>=i:j+=1
print 'First' if (a[i-1]-i)%2 or (j-i)%2 else 'Second'

Measured memory_bytes: 23920
n=int(input())
m=0
a=0
r=0
c=0
h=0
for i in range(n):
	s=input()[0]
	if s=='M':
		m+=1
	elif s=='A':
		a+=1
	elif s=='R':
		r+=1
	elif s=='C':
		c+=1
	elif s=='H':
		h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 100005

vector<ll> yakusuu_rekkyo(ll n){
    vector<ll> divisors;
    for(ll i = 1; i <= n; i++){
        if(i * i > n)break;
        if(i * i == n){
            divisors.push_back(i);
            break;
        }else if(n % i == 0){
            divisors.push_back(i);
            divisors.push_back(n/i);
        }   
    }
    sort(divisors.begin(), divisors.end());
    return divisors;
}

vector<ll> sum[MAX_N], sum2[MAX_N];

int main() {
    int n; cin >> n;
    ll a[n] = {};
    rep(i,n) cin >> a[i];

    srep(i,1,n-1){
        int now = 0;
        ll tmp = 0;
        sum[i].push_back(tmp);
        while(true){
            now += i;
            if(now < n-1){
                tmp += a[now];
                sum[i].push_back(tmp);
            }else{
                break;
            }
        }
    }

    srep(i,1,n-1){
        int now = n-1;
        ll tmp = 0;
        sum2[i].push_back(tmp);
        while(true){
            now -= i;
            if(now >= 0){
                tmp += a[now];
                sum2[i].push_back(tmp);
            }else{
                break;
            }
        }
    }

    ll ans = 0;
    srep(i,1,n-1){
        vector<ll> v = yakusuu_rekkyo(n-1-i);
        int m = v.size();
        rep(j,m){
            int c = v[j];
            if(c >= i) break;
            int b = i - c;
            if(b >= i) continue;
        
            ll loop = (n-1-i) / c;
            ll tmp = sum[c][loop] + sum2[c][loop];

            if(i % c == 0 && i/c <= loop) continue;

            /*
            int now = 0;
            while(true){
                now += i;
                if(now == n - 1) break;
                tmp += a[now];
                now -= b;
                tmp += a[now];
                if(now - i >= 0 && (now-i)%c == 0){
                    tmp = -1;
                    break;
                }
            }
            */
            // cout << i << ' ' << b << ' ' << tmp << endl;
            ans = max(ans, tmp);
        }
    }

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




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

typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

int h,w,final_c;

int di[] = {0,0,-1,1};
int dj[] = {-1,1,0,0};

VVI change(int col, VVI board){
  deque<PII> que;
  que.push_back({0,0});
  bool checked[h][w];
  memset(checked,false,sizeof(checked));
  int col0 = board[0][0];

  // bfs
  while( ! que.empty()){
    PII p = que.front(); que.pop_front();
    int ci = p.first, cj = p.second;
    board[ci][cj] = col;
    rep(dir,4){
      int ni = ci + di[dir];
      int nj = cj + dj[dir];
      if(ni >= 0 && nj >= 0 && ni < h && nj < w && checked[ni][nj] == false && board[ni][nj] == col0){
        checked[ni][nj] = true;
        que.push_back({ni,nj});
      }
    }
  }

  return board;
}

int cntBFS(int col, VVI board){
  deque<PII> que;
  que.push_back({0,0});
  bool checked[h][w];
  memset(checked,false,sizeof(checked));
  checked[0][0] = true;
  int cnt = 0;
  // bfs
  while( ! que.empty()){
    PII p = que.front(); que.pop_front();
    int ci = p.first, cj = p.second;
    cnt++;
    rep(dir,4){
      int ni = ci + di[dir];
      int nj = cj + dj[dir];
      if(ni >= 0 && nj >= 0 && ni < h && nj < w && checked[ni][nj] == false && board[ni][nj] == col){
        checked[ni][nj] = true;
        que.push_back({ni,nj});
      }
    }
  }

  return cnt;
}

void solve(VVI& board){
  // 右角と同じパネルに隣接する数が最大の色を発見する。
  int ans = -1;
  FOR(a,1,7){
    VVI board_a = change(a,board);
    FOR(b,1,7){
      VVI board_b = change(b,board_a);
      FOR(c,1,7){
        VVI board_c = change(c,board_b);
        FOR(d,1,7){
          VVI board_d = change(d,board_c);
          FOR(e,1,7){
            VVI board_e = change(d,board_d);
            board_e = change(final_c,board_e);
            ans = max(cntBFS(final_c,board_e),ans);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

int main(){
  while(true){
    cin >> h >> w >> final_c;
    if(h == 0 && w == 0 && final_c == 0) break;
    VVI board(h,VI(w));
    rep(i,h)rep(j,w) cin >> board[i][j];
    solve(board);
  }
  return 0;
}



Measured memory_bytes: 3152
let (n1, n2) = (4, 16)

let area =
  [| [1; 4]; [0; 2; 5]; [1; 3; 6]; [2; 7]
   ; [0; 5; 8]; [1; 4; 6; 9]; [2; 5; 7; 10]; [3; 6; 11]
   ; [4; 9; 12]; [5; 8; 10; 13]; [6; 9; 11; 14]; [7; 10; 15]
   ; [8; 13]; [9; 12; 14]; [10; 13; 15]; [11; 14] |]

let md = Array.make_matrix n2 n2 0

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space_i lower goal =
  let rec doit i space_i moved lower =
    if i = limit then begin
      if a = goal then begin
        Printf.printf "%d\n" (List.length moved - 1);
        exit 0;
      end
    end else
      List.iter (fun j ->
        let x = a.(j) in
        if x = List.hd moved then () else
        let lower = lower - md.(x).(j) + md.(x).(space_i) in
        if lower + i > limit then ()
        else begin
          a.(j) <- 0;
          a.(space_i) <- x;
          doit (i + 1) j (x :: moved) lower;
          a.(j) <- x;
          a.(space_i) <- 0;
        end) area.(space_i) in
  doit 0 space_i [-1] lower

let () =
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let rec f i =
    if i = n2 then assert false
    else if a.(i) = 0 then i
    else f (i + 1) in
  let space_i = f 0 in
  let rec g i acc =
    if i = n2 then acc
    else g (i + 1) (acc + md.(a.(i)).(i)) in
  let lower = g 0 0 in
  let goal = [|1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 0|] in
  for limit = lower to 45 do
    idastar a limit space_i lower goal
  done

Measured memory_bytes: 4548
C = input()
lis = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
       'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for x in range(len(lis)):
  if C == lis[x]:
    print(lis[x+1])
    break

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main() {
  ll n, x;
  cin >> n >> x;
  ll a = x, b = n - x;
  if (a > b)
    swap(a, b);
  ll ans = a;
  while (1) {
    ll t = b / a;
    // cout << a << b << endl;
    ans += (2 * t - 1) * a + b;
    if (b % a == 0)
      break;
    else {
      auto buf = b;
      b = a;
      a = buf % a;
    }
    // cout << a << b << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math

x = list(map(int,input().split()))

A = x[0]
B = x[1]
H = x[2]
M = x[3]

y = 2*math.pi*((H*60+M)/720-M/60)

z = math.sqrt(A**2+B**2-2*A*B*math.cos(y))

print(z)

Measured memory_bytes: 9348
class bitset:
    def __init__(self,minimum):
        self.b=0
        self.pcnt=0
        self.minimum=abs(minimum)
    def merge(self,x):
        self.b|=x
    def add(self,x):
        self.b|=1<<(x+self.minimum)
        self.pcnt+=1
    def remove(self,x):
        self.b^=1<<(x+self.minimum)
        self.pcnt-=1
    def isin(self,x):
        return self.b>>(x+self.minimum)&1
    def shift(self,x):
        return self.b<<x if x>=0 else self.b>>(abs(x))

H,W=map(int,input().split())
G=[list(map(int,input().split())) for i in range(H)]
for i in range(H):
    B=list(map(int,input().split()))
    for j in range(W):
        G[i][j]=abs(G[i][j]-B[j])

Min=80*(H+W)
s=[[bitset(Min) for i in range(W)] for i in range(H)]
s[0][0].add(G[0][0])
s[0][0].add(-G[0][0])

for i in range(H):
    for j in range(W):
        if i<H-1:
            s[i+1][j].merge(s[i][j].shift(G[i+1][j]))
            s[i+1][j].merge(s[i][j].shift(-G[i+1][j]))
        if j<W-1:
            s[i][j+1].merge(s[i][j].shift(G[i][j+1]))
            s[i][j+1].merge(s[i][j].shift(-G[i][j+1]))
ans=10**30
for i in range(-Min,Min+1):
    if s[H-1][W-1].isin(i):
        ans=min(ans,abs(i))
print(ans)

Measured memory_bytes: 93352
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int a, b;
    cin >> a >> b;
    int d = b - a;
    d--;
    int N = d * (d + 1) / 2;
    cout << N - a << endl;
}


Measured memory_bytes: 256
/*
 * author: calgagi
 *         Calvin Gagliano 
 */
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define ar array
#define f first
#define s second
#define dd long double

int main() {
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);
    srand(chrono::steady_clock::now().time_since_epoch().count()); 
    // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 
    
    ll x;
    cin >> x;

    int ans = 0;
    for (ll i = 100; i < x; i += i/100) {
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  int n; cin >> n;
  vector<int> a(n);
  map<int, long long> m;
  for(int i=0; i<n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  long long cnt = 0;
  for(auto i=m.begin(); i!=m.end(); i++) {
    cnt += (i->second)*(i->second-1) / 2;
  }

  for(int i=0; i<n; i++) {
    long long p = m[a[i]];
    cout << cnt - p*(p-1)/2 + (p-1)*(p-2)/2 << endl;
  }

}

// EOF


Measured memory_bytes: 12288
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<functional>
#define LL long long
#define int LL
using namespace std;
class point{
public:
	long long num;
	vector<int> line;
	point() {
		line.resize(3);
		num = 0;
	}
};

bool operator<(const point&a, const point&b) {
	return a.num < b.num;
}

bool operator>(const point&a, const point&b) {
	return a.num > b.num;
}

bool operator==(const point&a, const point&b) {
	return a.num == b.num;
}

signed main() {
	int ABC[3];
	int ABCL[3][1000];
	int K;
	for (int i = 0; i < 3; ++i) {
		cin >> ABC[i];
	}
	cin >> K;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < ABC[i]; ++j) {
			cin >> ABCL[i][j];
		}
	}
	for (int i = 0; i < 3; ++i) {
		sort(ABCL[i], ABCL[i] + ABC[i],greater<int>());
	}
	set<vector<int> > s;
	vector<int> p(3);
	point pp;
	for (int i = 0; i < 3; ++i) {
		pp.line[i] = p[i] = 0;
		pp.num += ABCL[i][0];
	}
	s.insert(p);
	priority_queue<point> que;
	que.push(pp);
	for (int i = 0; i < K; ++i) {
		pp = que.top();
		que.pop();
		cout << pp.num << endl;
		for (int i = 0; i < 3; ++i) {
			point np = pp;
			if(np.line[i] + 1 == ABC[i])continue;
			np.num -= ABCL[i][np.line[i]];
			++np.line[i];
			np.num += ABCL[i][np.line[i]];
			p = np.line;
			set<vector<int> >::iterator pl = s.find(p);
			if (s.end() != pl)continue;
			s.insert(p);
			que.push(np);
		}
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int ac = 0, wa = 0, t = 0, re = 0;
		
		for(int i = 0; i < a; i++) {
			String asd = scan.next();
			if(asd.equals("AC")) {
				ac++;
			}else if(asd.equals("WA")) {
				wa++;
				
			}else if(asd.equals("TLE")) {
				t++;
			}else {
				re++;
			}
			
		}
		
		System.out.print("AC x " + ac + "\nWA x " + wa + "\nTLE x " + t + "\nRE x " + re);


	}


}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int x,a;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> x >> a;
  if (x < a)
    cout << 0 << endl;
  else
    cout << 10 << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/**
AHMAD;HASSAN;SAEED
*/
using namespace std;
bool isPrim(long long a){
    if(a==1ll)
        return false;
    for(long long i=2ll;i*i<=a;i++){
        if(a%i==0)
        return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a;
    cin>>a;
    long long ans=0ll;
    long long tma=a;
    for(long long i=1ll;i*i<=tma;i++){

        if(isPrim(i)&&(a%i==0ll)){
            long long num=i;
            while(a%num==0){
                a/=num;
                ans++;
                num*=i;
            }
        }
        if(isPrim((tma/i))&&(a%(tma/i)==0ll)&&(a/i!=i)){
            long long num=(tma/i);
            while(a%num==0){
                a/=num;
                ans++;
                num*=(tma/i);
            }
        }
    }

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


Measured memory_bytes: 3632
N = int(input())
L = list(map(int,input().split()))
ans = 0
L.sort()
lst = [0 for i in range(10**3+1)]
for i in range(N):
    lst[L[i]]+=1
for i in range(10**3+1):
    if i != 0:
        lst[i]=lst[i-1]+lst[i]
for i in range(N-1):
    for j in range(i+1,N):
        p = L[i]+L[j]
        if p-1>=10**3+1:
            ans += lst[10**3]-(j+1)
        else:
            ans += lst[p-1]-(j+1)
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=5e6+10;
const int mod=1e9+7;
int arr[N],iarr[N];
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
int poww2(int x,int y){int pro=1;while(y){if(y&1)pro=pro*x;y=y>>1;x=x*x;}return pro;}
double poww1(double x,int y){double pro=1.000000000;while(y){if(y&1)pro=((pro)*(x));y=y>>1;x=((x)*(x));}return pro;}
map<int,int> mp1,mp2;
set<int> st;
int arr1[1000001],arr2[1000001];

int solve()
{
	int n;
	cin>>n;
	int x=(n/500)*1000;
	n=n%500;
	int y=(n/5)*5;
	int ans=x+y;
	cout<<ans;
}
int32_t main()																																	
{
	//fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<long> vec;
	for(int i = 0; i < n; i++)
	{
		long a;
		scanf("%ld",&a);
		if(a % 2 == 0)
			vec.push_back(a);
	}
	long ans = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int x = vec[i];
		while(1)
		{
			if(x % 2 == 0)
			{
				x /= 2;
				ans++;
			}
			else
				break;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
   

    int n,a;
    cin >> n >> a;
    static const int N = n;
    long x[N],dp[110][2600];
    for (int i=0;i<n;i++){
        cin >> x[i];
    }
    for (int i=0;i<51;i++){
        for (int j=0;j<2501;j++){
            dp[i][j] = 0;
        }
    }
    for (int r=0;r<n;r++){
        int w = x[r];
        for (int i=50;i>=0;i--){
            for (int j=2500;j>=0;j--){
                if(dp[i][j] != 0){
                    dp[i+1][j+w] += dp[i][j];
                }
            }
        }
        dp[1][w] += 1;
    }
    long long ans = 0;
    for (int i=1;i<=50;i++){
        for (int j=1;j<=2500;j++){
            if((j)%(i) == 0 and (j)/(i) == a){
                ans += dp[i][j];
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <queue>
#define eol '\n'
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  
  queue<int> que;
  vector< vector<int> > list(n+1);
  vector<int> d(n+1, -1);

  for (int i = 0; i < n; i++) {
    int u,k;
    cin >> u >> k;
    
    vector<int> row(k);
    for (int j = 0; j < k; j++) {
      cin >> row[j];
    }
    list[u] = row;
  }

  d[1] = 0;
  que.push(1);
  while(que.size()) {
    int v = que.front();
    que.pop();

    int dis = d[v];

    for (int i = 0; i < list[v].size(); i++) {
      int next = list[v][i];
      if (d[next] == -1) {
        d[next] = dis+1;
        que.push(next);
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << i << " " << d[i] << eol;
  }
  
  return 0;
}

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

int cnt[100001];
vector<vector<int>>fight;

int solve(int n) {
	int ans = cnt[n];
	vector<int>win;
	for (int i = 0; i < fight[n].size(); i++) {
		win.push_back(solve(fight[n][i]));
	}
	sort(win.begin(), win.end());
	reverse(win.begin(), win.end());
	for (int i = 0; i < fight[n].size(); i++) {
		win[i] += i + 1;
		ans = max(ans, win[i]);
	}

	return ans;
}

int main()
{
	int N; cin >> N;
	fight.resize(N+1);
	for (int i = 2; i <= N; i++) {
		int a;
		cin >> a;
		cnt[a]++;
		fight[a].push_back(i);
	}

	cout << solve(1) << endl;

    return 0;
}

Measured memory_bytes: 15488
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
    }

    let aa = a / d + if a % d != 0 { 1 } else { 0 };
    let bb = c / b + if c % b != 0 { 1 } else { 0 };
    println!("{}",if   aa >= bb  { "Yes" } else { "No" });

}


Measured memory_bytes: 2164
// in the name if Allah
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll INF = 1<<30 ;
const ll N= 1e6 ;
#define f first
#define s second
ll n , a[N] , ans=INF , sum=0 , pre[N] ;
map<ll,ll> m , h ;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n ;
cin >> a[1] ;
sum += a[1] ;
pre[1] = a[1] ;
for(int i = 2 ; i <= n ; i ++){cin >> a[i] ;pre[i]=pre[i-1]+a[i];sum+=a[i] ;}
for(int i = 1 ; i < n ; i ++){
    ll x = sum-pre[i] ;
    ans = min(ans , abs(x-pre[i]) );
}
cout << ans ;
    return 0;
}


Measured memory_bytes: 2304
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    s = input()

    stack = []
    flat_pools = []
    for (i, c) in enumerate(s):
        if c == '\\':
            stack.append(i)
        elif c == '/' and len(stack) > 0:
            flat_pools.append((stack.pop(), i))

    flat_pools.sort(key=lambda pool: pool[0])

    last_index = 0
    pools = []
    area = 0

    for pool in flat_pools:
        area += pool[1] - pool[0]
        if last_index <= pool[0]:
            pools.append(pool[1] - pool[0])
            last_index = pool[1]
        else:
            pools[-1] = pools[-1] + pool[1] - pool[0]

    pools.insert(0, len(pools))
    print(area)
    print(" ".join(map(str, pools)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 10352
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    double a, b, x;
    cin >> a >> b >> x;
    if (a * a * b < 2 * x)
    {
        double l = 0., r = atan2(b, a);
        for (int i = 0; i < 1000000; i++)
        {
            double m = (l + r) / 2;
            //cout << setprecision(15) << m / M_PI * 180 << endl;
            (((2 * b - a * tan(m)) * a * a < 2 * x) ? r : l) = m;
        }
        cout << setprecision(15) << l / M_PI * 180 << endl;
    }
    else
    {
        double l = atan2(b, a), r = M_PI / 2;
        for (int i = 0; i < 1000000; i++)
        {
            double m = (l + r) / 2;
            //cout << setprecision(15) << m / M_PI * 180 << endl;
            ((b * b * a < 2 * x * tan(m)) ? r : l) = m;
        }
        cout << setprecision(15) << l / M_PI * 180 << endl;
    }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
void get_unique(vector<T>& x) {
    x.erase(unique(x.begin(), x.end()), x.end());
}
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    string s;
    cin >> s;
    cout << s << (s.back() == 's' ? "es" : "s") << '\n';
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        System.out.println(run());
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int x = sc.nextInt(), n = sc.nextInt(), result = 0;
            if (n == 0) {
                return x;
            }
            ArrayList<Integer> p = nScan(sc, n);
            for (int i = x;;i++) {
                if (!p.contains(i)) {
                    result = i;
                    break;
                }
            }
            for (int i = x;;i--) {
                if (!p.contains(i)) {
                    if (result - x >= x - i) {
                        result = i;
                    }
                    break;
                }
            }
            return result;
        }
    }
}

Measured memory_bytes: 27188
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int h, w, k; cin>>h>>w>>k;
    k--;

    if(w == 1){
        cout << 1 << endl;
        return 0;
    }

    vector<vector<ll>> dp(h+1, vector<ll>(w, 0));
    dp[0][0] = 1;
    for(int i=0; i<h; i++){
        for(int bit=0; bit<(1<<(w-1)); bit++){
            bool valid = true;
            for(int j=0; j+1<w-1; j++){
                if((bit & (1 << j)) && (bit & (1 << (j + 1)))) valid = false;
            }

            if(!valid) continue;

            // 横棒があるとき
            for(int j=0; j<w-1; j++){
                if(bit & (1 << j)){
                    // 左側に降りる
                    dp[i+1][j] += dp[i][j+1];
                    dp[i+1][j] %= MOD;

                    // 右側に降りる
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= MOD;
                }
            }

            // 横棒がないとき、下に流れる
            if(!(bit & 1)){
                dp[i+1][0] += dp[i][0];
                dp[i+1][0] %= MOD;
            }

            for(int j=0; j+1<w-1; j++){
                if(!(bit & (1 << j)) && !(bit & (1 << (j + 1)))){
                    dp[i+1][j+1] += dp[i][j+1];
                    dp[i+1][j+1] %= MOD;
                }
            }

            if(!(bit & (1 << (w - 2)))){
                dp[i+1][w-1] += dp[i][w-1];
                dp[i+1][w-1] %= MOD;
            }
        }
    }

    cout << dp[h][k] << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 * FileName:     C
 * CreatedDate:  2020-06-25 22:40:43 +0900
 * LastModified: 2020-06-25 22:47:09 +0900
 */

#include <stdio.h>
#include <math.h>
#define s_m 100100
int box[s_m];
int main(void){
    int x;scanf("%d",&x);
    int y = x+100;
    for(int i=2;i<(int)sqrt(y);i++){
        for(int j=2;j*i<y;j++){
            if(box[i*j]==0){
                box[i*j]=1;
            }
        }
    }
    for(int i=x;i<s_m;i++){
        if(box[i]==0){
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 2520
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    REP(i,n){
        a[i].second = i;
        cin >> a[i].first;
    }

    sort(all(a));

    REP(i,n - 1){
        cout << a[i].second  + 1 << " ";
    }

    cout << a[n - 1].second + 1 << endl;

    return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<string> a;
  vector<string> b;
  for (int k = 0; k < n; k++)
  {
    string s;
    cin >> s;
    a.push_back(s);
  }
  for (int k = 0; k < m; k++)
  {
    string s;
    cin >> s;
    b.push_back(s);
  }

  bool ans = false;
  for (int i = 0; i < n - m + 1; i++)
  {
    for (int j = 0; j < n - m + 1; j++)
    {
      int count = 0;
      for (int k = 0; k < m; k++)
      {
        if (b.at(k) == a.at(i + k).substr(j, m))
        {
          count++;
        }
      }
      if (count == m)
      {
        ans = true;
        break;
      }
    }
    if (ans)
    {
      break;
    }
  }
  ans ? cout << "Yes" << endl : cout << "No" << endl;
}

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

typedef long long ll;

// http://www.usaco.org/index.php?page=viewproblem2&cpid=495
// https://cses.fi/problemset/task/1740

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N; cin >> N;
    vector<int> v;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    int res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            for (int k = j+1; k < N; ++k) {
                set<int> s;
                s.insert(v[i]); s.insert(v[k]); s.insert(v[j]);
                if (s.size() != 3)
                    continue;
                res += (*(--s.end()) < *(s.begin()) + *(++s.begin()));
            }
        }
    }
    cout << res;
}
/*

















*/


Measured memory_bytes: 3672
# -*- coding: utf-8 -*-
"""
Created on Sat May 25 20:54:22 2019

@author: Yamazaki Kenichi
"""

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

A.sort()
B.sort(reverse=True, key=lambda x: x[1])

tmp = 0
for i in range(N):
    if B[tmp][1] > A[i]:
        A[i] = B[tmp][1]
        B[tmp][0] -= 1
        if B[tmp][0] == 0:
            tmp += 1
        if tmp >= M:
            break
    else:
        break
print(sum(A))
    

Measured memory_bytes: 33288
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var dct = new Dictionary<string, long>();
            for (var i = 0; i < N; ++i)
            {
                var s = ReadLine();
                if (!dct.ContainsKey(s)) dct[s] = 0;
                ++dct[s];
            }
            var M = Sarray()[0];
            for (var i = 0; i < M; ++i)
            {
                var t = ReadLine();
                if (dct.ContainsKey(t)) --dct[t];
            }
            WriteLine(Max(0, dct.Max(d => d.Value)));
        }

        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28428
s = input()
list_s = list(s)
odd_list = ['R','U','D']
even_list= ['L','U','D']
identifier = [] 
for i in range(1,len(list_s)+1):
    if s[i-1] in even_list and i % 2 == 0: 
            identifier.append(1) 
    if i % 2 != 0 and s[i-1]in odd_list:
            identifier.append(1)
if identifier == [1]*len(list_s):
    print('Yes')
else:
    print('No')
    

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

using namespace std;

using ll = long long;

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

    int a, b, c;

    cin >> a >> b >> c;
    int n = max({10 * a + b + c, 10 * b + a + c, 10 * c + a + b});
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
char a,b;
int main(){
	a=getchar();
	getchar();
	b=getchar();
	if(a>b) putchar('>');
	if(a==b) putchar('=');
	if(a<b) putchar('<');
	exit(0);
}

Measured memory_bytes: 256