akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
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;}

ll dp[110][100010];
const ll INF = 1e18;
int main() {
    int N,W;
    cin >> N >> W;
    vector<ll>v(N);
    vector<ll>w(N);
    rep(i,N) {
        cin >> w[i] >> v[i];
    }
    rep(i,N+1) rep(j,100005) {
        dp[i][j] = INF;
    }
    dp[0][0] = 0;
    rep(i,N) {
        rep(j,100003) {
            if(j-v[i] >= 0) {
                chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
            }
            chmin(dp[i+1][j],dp[i][j]);
        }
    }
    ll ans = INF;
    for(int j = 100000;j>=0;j--) {
        if(dp[N][j] <= W) {
            ans = j;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 82524
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
	
ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	s.erase(n-8,8);
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;
const int N = 201;
const int X = 1e5 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD; 
}

int sub(int a, int b) {
	return (a - b + MOD) % MOD;
}

int binpow(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

int divv(int a, int b) {
	return mul(a, binpow(b, MOD - 2));
}

int dp[N][X];

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

	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	} 
	sort(a.rbegin(), a.rend());
	dp[0][x] = 1;
	for (int i = 0; i < n; i++) {
		int prob = divv(1, n - i);
		for (int wx = 0; wx <= x; wx++) {
			dp[i + 1][wx] = add(dp[i + 1][wx], mul(sub(1, prob), dp[i][wx]));
			dp[i + 1][wx % a[i]] = add(dp[i + 1][wx % a[i]], mul(prob, dp[i][wx]));
		}
	}
	int ans = 0;
	for (int ex = 0; ex <= x; ex++) {
		ans = add(ans, mul(ex, dp[n][ex]));
	}
	for (int i = 1; i <= n; i++) {
		ans = mul(ans, i);
	}
	cout << ans << '\n';
}


Measured memory_bytes: 156544
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	ll x, y, k, ans = 0;cin >> x >> y;
	for (;;) {
		x *= 2;
		if (x > y) break;
		ans++;
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int,n)
	b := make([]int,n)
	c := make([]int,n-1)

	for i := 0; i < n; i++ {
		var val int
		fmt.Scan(&val)
		a[i] = val
	}

	for i := 0; i < n; i++ {
		var val int
		fmt.Scan(&val)
		b[i] = val
	}

	for i := 0; i < n - 1; i++ {
		var val int
		fmt.Scan(&val)
		c[i] = val
	}

	ans := b[a[0] - 1]
	tmp := a[0]
	for i := 1; i < n; i++ {
		if a[i] == tmp + 1 {
			ans += b[a[i] - 1] + c[a[i] - 2]
		} else {
			ans += b[a[i] - 1]
		}
		tmp = a[i]
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <string>
#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

#define R 10

int r, c;

bitset<10005> bits[15];



int solve(){
	int permutate = 1 << r;
	bitset<10> flag;
	int rst = 0;

	for (int i = 0; i < permutate; i++){
		flag = bitset<10>(i);

		int count = 0;	

		for (int j = 0; j < r; j++){
			if (flag[j]) bits[j].flip();
		}

		for (int j = 0; j < c; j++){
			int a = 0;
			int b = 0;
			for (int k = 0; k < r; k++){
				if (bits[k][j]) a++;
				else b++;
			}
			count += max(a, b);
		}
		for (int j = 0; j < r; j++){
			if (flag[j]) bits[j].flip();
		}
		rst = max(rst, count);
	}
	return rst;
}

int main(){
	while(true){
		cin >> r >> c;
		cin.ignore();
		if (r == 0 && c == 0) break;
		for (int i = 0; i < r; i++){
			string line;
			getline(cin, line);
			line.erase(remove(line.begin(), line.end(), ' '), line.end());
			bits[i] = bitset<10005>(line);
		}
		int ans = solve();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
days = int(input())
clast = list(map(int,input().split()))

allpref = [] #allpref[day][contest]
for i in range(days):
    allpref.append(list(map(int,input().split())))
donelist = [0]*26
resultlist = []
result = 0
for i in range(days):
    held = int(input())

    donelist[held-1] = i+1
    zanen = sum([clast[j]*((i+1)-donelist[j]) for j in range(26)])

    result += allpref[i][held-1] -zanen
    resultlist.append(result)

for num in resultlist:
    print(num)


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

int main(){
    float a, b, x;
    cin >> a >> b >> x;
    
    
    float c;
    bool flag = false;
    float ans;
    c = x*2/a/b;
    
    if(c >= a){
        c = (2*b*a*a - 2*x)/a/a;
        flag = true;
    }
    
    if(flag){
        ans = atan2(c, a) / M_PI * 180;
    }else{
        ans = atan2(b, c) / M_PI * 180;
    }
    cout << fixed << setprecision(10) << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    int n;
    cin>>n;
    vi a(n), b(n), c(n);
    for(int i = 0; i< n; i++)
        cin>>a[i] >>b[i] >>c[i];
    int dp[n+1][3];
    dp[n][0] = a[n-1];
    dp[n][1] = b[n-1];
    dp[n][2] = c[n-1];
    for(int i = n-1; i > 0; i--)
    {
        dp[i][0] = max(dp[i+1][1], dp[i+1][2]) + a[i-1];
        dp[i][1] = max(dp[i+1][0], dp[i+1][2]) + b[i-1];
        dp[i][2] = max(dp[i+1][0], dp[i+1][1]) + c[i-1];
    }
    cout<<max(dp[1][0], max(dp[1][1], dp[1][2]));
    return 0;
}

Measured memory_bytes: 5620
from itertools import permutations
n, c = map(int, input().split())

d_lst = [list(map(int, input().split())) for _ in range(c)]
c_lst = [list(map(int, input().split())) for _ in range(n)]

lst = [[0] * c for _ in range(3)]

for i in range(n):
    for j in range(n):
        lst[(i + j) % 3][c_lst[i][j]-1] += 1
        
cnt = []

for i in range(c):
    temp = []
    for j in range(3):
        cal = 0
        for k in range(c):
            cal += lst[j][k] * d_lst[k][i]
        temp.append(cal)
    cnt.append(temp) 

 
temp = []
for l in permutations(list(range(c)), 3):
    temp.append(cnt[l[0]][0] + cnt[l[1]][1] + cnt[l[2]][2])

print(min(temp))

Measured memory_bytes: 12632
#include <bits/stdc++.h>
using namespace std;
int main(){
  string A,B,C;
  cin>>A>>B>>C;
  cout<<char(A[0]-'a'+'A')<<char(B[0]-'a'+'A')<<char(C[0]-'a'+'A')<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
  
  int N;
  
  scanf("%d", &N);
  
  int A, B;
  
  scanf("%d %d", &A, &B);
  
  int i;
  
  int count=0;
  
  int sum;
  
  int a, b, c, d, e;
  
  for (i=1; i<=N; i++){   
      e = i % 10;
      d = ((i-e)/10) % 10;
      c = ((i-10*d-e)/100) % 10;
      b = ((i-100*c-10*d-e)/1000) % 10;
      a = ((i-1000*b-100*c-10*d-e)/10000) % 10;
      sum = a+b+c+d+e;
    if (A <= sum && sum <= B)
    {count = count + i;}
  }
  printf("%d", count);
  
  return 0;
}

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

import sys


def mat_mul_opt(_mat_info):
    rc_info = list(map(int, _mat_info[0]))
    rc_info.extend(list(map(lambda x: int(x[1]), _mat_info[1:])))

    ans = [[0] * (mat_num + 1) for _ in range(mat_num + 1)]

    for l in range(2, mat_num + 1):
        for i in range(1, mat_num - l + 2):
            j = i + l - 1
            ans[i][j] = 1e7
            for k in range(i, j):
                ans[i][j] = min(ans[i][j], ans[i][k] + ans[k + 1][j] +
                                rc_info[i - 1] * rc_info[k] * rc_info[j])

    return ans[1][mat_num]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    mat_num = int(_input[0])
    mat_info = tuple(map(lambda x: x.split(), _input[1:]))
    # assert len(mat_info) == mat_num

    print(mat_mul_opt(mat_info))

Measured memory_bytes: 7860
#include <bits/stdc++.h>
#define PI 3.1415926535897932384626433832795029L
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

long double check_rad(long double rad) {
  if (rad <= -PI) {
    rad += 2 * PI;
  } else if (rad > PI) {
    rad -= 2 * PI;
  }

  return rad;
}
bool check_direction(complex<long double> comp, long double term_m,
                     double term_p) {
  long double now = arg(comp);

  if (term_m < term_p) {
    if (term_m <= now && now <= term_p)
      return true;
    else
      return false;
  } else {
    if (term_m <= now || now <= term_p)
      return true;
    else
      return false;
  }

  return -1;
}

long double Pythagoras(long double x, long double y) {
  return sqrtl(powl(x, 2) + powl(y, 2));
}

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

  int N;
  cin >> N;
  vector<complex<long double>> engine(N);
  for (auto &v : engine) {
    long double in1, in2;
    cin >> in1 >> in2;
    v.real(in1);
    v.imag(in2);
  }

  long double max_d = 0;
  for (int i = 0; i < 360; i++) {
    long double temp_arg =
        check_rad((-(long double)i / 180 + 1) * (long double)PI);
    long double temp_plus90 = check_rad(temp_arg + PI / 2);
    long double temp_minus90 = check_rad(temp_arg - PI / 2);

    long double now_x = 0, now_y = 0;
    for (auto &v : engine) {
      if (check_direction(v, temp_minus90, temp_plus90)) {
        now_x += v.real();
        now_y += v.imag();
      }
    }
    long double now_d = Pythagoras(now_x, now_y);
    if (max_d < now_d) {
      max_d = now_d;
    }
  }

  cout << setprecision(52) << max_d << endl;

  return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

int main(){
    int a , b;
    cin >> a >> b;
    if(a > 9 || b > 9){
        cout << -1 << endl;
        return 0;
    }
    cout << a*b << endl;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    s = 0
    ans = "YES"
    for i in range(n):
        k = input()
        if k == "Un":
            s -= 1
        else:
            s += 1
        if s < 0:
            ans = "NO"
    if s:
        print("NO")
    else:
        print(ans)
    return

#B
def B():
    s = S()
    t = S()
    n = len(s)
    t_ = [s[i*2] for i in range(n//2)]
    j = 0
    if not t_:
        print("Yes")
        quit()
    for i in range(n):
        if t_[j] == t[i]:
            j += 1
            if j == len(t_):
                print("Yes")
                quit()
    t_ = [s[i*2+1] for i in range(n//2)]
    j = 0
    if not t_:
        print("Yes")
        quit()
    for i in range(n):
        if t_[j] == t[i]:
            j += 1
            if j == len(t_):
                print("Yes")
                quit()
    print("No")
    return

#C
def C():
    n,q = LI()
    p = LIR(n)
    for _ in range(q):
        x0,y0,z0,s,t,u = LI()
        a,b,c = (s-x0,t-y0,u-z0)
        ans = 0
        su = a**2+b**2+c**2
        for xr,yr,zr,r,l in p:
            x = (su-a**2)/su*x0-a/su*(b*y0+c*z0-a*xr-b*yr-c*zr)
            y = (su-b**2)/su*y0-b/su*(a*x0+c*z0-a*xr-b*yr-c*zr)
            z = (su-c**2)/su*z0-c/su*(b*y0+a*x0-a*xr-b*yr-c*zr)
            if min(x0,s)-1e-4 <= x <= max(x0,s)+1e-4 and min(y0,t)-1e-4 <= y <= max(y0,t)+1e-4 and min(z0,u)-1e-4 <= z <= max(z0,u)+1e-4:
                x -= xr
                y -= yr
                z -= zr
                r2 = x**2+y**2+z**2
                if r2 <= r**2+1e-4:
                    ans += l
        print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()



Measured memory_bytes: 8292
#include<iostream>
#include<queue>

using namespace std;

long long int f(int k)
{
    long long int x;

    if( k <= 9 ) return k;
    
    queue<long long int> queue;
    for ( int i=1; i<=9; i++ )
    {
        queue.push(i);
    }

    for ( int i=1; i<=k; i++ )
    {
        x = queue.front();
        queue.pop();
        if ( x % 10 != 0 ) queue.push (10*x+x%10-1);
        queue.push (10*x+x%10);
        if ( x % 10 != 9 ) queue.push (10*x+x%10+1);
    }

    return x;
}

int main()
{
    int k;
    cin >> k;
    cout << f(k) << "\n";
    return 0;


}


Measured memory_bytes: 1792
alp=[s.upper() for s in list('aqwsedrftgyhujikolpmnbvcxz')]
alp.sort()
H,W=map(int,input().split())
S=[input().split() for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=='snuke':
            print(str(alp[j])+str(i+1))

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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = IOUtils.ReadInt();
            var vals = IOUtils.ReadInts();
            var min = vals[0];
            var max = vals[1];

            var can = Enumerable.Range(min, max - min + 1)
                                .Any(n => n % k == 0);

            Console.WriteLine(can ? "OK" : "NG");

        }
    }

    static class IOUtils
    {
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


Measured memory_bytes: 19124
import sys
fin = sys.stdin.readline


N, K = [int(elem) for elem in fin().split()]
A_list = [int(elem) for elem in fin().split()]
assert len(A_list) == N

n_digits_K = 0
cur_K = K
while cur_K > 0:
    n_digits_K += 1
    cur_K >>= 1

# count_1_by_digit = [0] * max(n_digits_K, n_digits_max_A)
count_1_by_digit = [0] * n_digits_K
for A in A_list:
    i = 0
    while A > 0 and i < len(count_1_by_digit):
        count_1_by_digit[i] += A & 1
        i += 1
        A >>= 1

# print(count_1_by_digit)
should_up = [i for i, count in enumerate(count_1_by_digit) if count <= (N - 1) // 2]
should_up.append(-1)
max_f = 0
# print(should_up)
for down_digit in should_up:
    X = 0
    for i in reversed(range(len(count_1_by_digit))):
        count = count_1_by_digit[i]
        if count <= (N - 1) // 2 and i != down_digit:  # should set to 1
            X += (1 << i)
            if X > K:
                X -= (1 << i)
    # print(X)
    # calculate
    f = 0
    for A in A_list:
        f += A ^ X
    max_f = max(max_f, f)

print(max_f)


Measured memory_bytes: 63704
#include<stdio.h>
#include<math.h>
int main (void)
{
  int time;
  int h,m,s;

  scanf("%d",&time);
  h=time/3600;
  time%=3600;
  m=time/60;
  time%=60;
  s=time;

  printf("%d:%d:%d\n",h,m,s);

  return 0;
}




Measured memory_bytes: 2100
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;
#define PI 3.141592653589793


int main(){
  string S; cin >> S; int N = S.size();
  int cum[N+1] = {}, sum[N+1] = {}; int pum = 1;
  for(int i=N-1; i>=0; i--){
    int K = S[i] - '0';
    cum[N-i] = (cum[N-i-1]+K)%3;
    sum[N-i] = (sum[N-i-1]+(K*pum)%673)%673;
    pum*=10; pum%=673;
  }
  vector<int> to[673][3] = {}; vector<int> a[3];
  for(int i=0; i<=N; i++){
     to[sum[i]][cum[i]].push_back(i);
  }
  ll ans = 0;
  //rep(i, 3){
    //rep(j, a[i].size()){
      //to[i][sum[a[i][j]]%673].push_back(a[i][j]);
      //if(a[i][j]==4){
        //cout << i << " " << j << endl;
      //}
      //if(i==1 && sum[a[i][j]]%673==98)
        //for(auto k: to[i][sum[a[i][j]]%673]){
          //cout << k << endl;
        //}
    //}
  //}
  //for(auto k: to[1][98]){
    //cout << k << endl;
  //}
  rep(i, 673){
    rep(j, 3){
      ll p = to[i][j].size();
      //}
      ans+=p*(p-1)/2;
    }
  }
  cout << ans << endl;
}

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

int main() {
    int n, l=0, m=0;
    string s, t="";
    cin>>n>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='('){
            l++;
        }else{
            l--;
        }
        if(l==-1){
            m++;
            l++;
        }
    }
    t=string(m, '(')+s+string(l, ')');
    cout<<t<<endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

using namespace std;

int d[110];
string bord[60];
int dx[] = {-1,-1,-1,0,0,1,1,1};
int dy[] = {-1,0,1,-1,1,-1,0,1};

int main() {
  int h,w;
  cin >> h >> w;
  rep(i,h)
  cin >> bord[i];

  rep(i,h){
     rep(j,w){
        if(bord[i][j]=='.'){
         int cnt = 0;
         rep(k,8){
            int x = i + dx[k];
            int y = j + dy[k];
            if(x>=0 && x<h && y>=0 && y<w && bord[x][y]=='#')
            cnt++;
         }
         bord[i][j]= '0'+ cnt;
        }
     }
  }
  
  rep(i,h)
  cout << bord[i] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int n,k,x,y,i,s1,t,s2;
    scanf("%lld%lld%lld%lld",&n,&k,&x,&y);
    if(n>k)
    {
        s1=k*x;
        s2=(n-k)*y;
        t=s1+s2;
        printf("%lld\n",t);
    }
    else if(n<=k)
    {
        s1=n*x;
        t=s1;
        printf("%lld\n",t);
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.lang.Math;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int hour = sc.nextInt();
        int minute = sc.nextInt();

        int time = hour * 60 + minute;

        double[] aPosition = new double[2];
        double[] bPosition = new double[2];

        double shortRad = 2.0 * Math.PI * (double)time / (60.0 * 12.0);
        double longRad = 2.0 * Math.PI * (double)time / 60.0;


        aPosition[0] = A * Math.sin(shortRad);
        aPosition[1] = A * Math.cos(shortRad);

        bPosition[0] = B * Math.sin(longRad);
        bPosition[1] = B * Math.cos(longRad);

        double distance;
        distance = Math.sqrt((aPosition[0] - bPosition[0])*(aPosition[0] - bPosition[0]) + (aPosition[1] - bPosition[1])*(aPosition[1] - bPosition[1]));
        System.out.println(distance);
    }
}

Measured memory_bytes: 36032
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int x, ans;
    double sqrtx;
    bool ok;
    cin >> x;
    if(x<=2){
        ans = 2;
    }else{
        if(x%2==0){
            x++;
        }
        while(1){
            sqrtx = sqrt(x);
            ok = true;
            for(int i = 3; i <= sqrtx; i+=2){
                if(x % i == 0){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ans = x;
                break;
            }
            x += 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  
  set<int> st;
  int ans = 0;
  rep(i,n) {
    if (!st.count(a[i])) {
      ans++;
      st.insert(a[i]);
    }
    else {
      ans--;
      st.erase(a[i]);
    }
  }

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

Measured memory_bytes: 5248
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-6;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, m;
    cin >> n >> m;
    int a[n][m];
    rep(i, 0, n)
        rep(j, 0, m)
        {
            cin >> a[i][j];
            a[i][j]--;
        }
    int l = 0, r = n, mid;
    while (r - l > 1)
    {
        mid = (l + r) / 2;
        vector<bool> used(m, false);
        map<int, int> cnt;
        map<int, set<int> > arr;
        vector<int> pos(n, 0);
        int rem = m;
        bool ok = true;
        rep(i, 0, n)
        {
            int v = a[i][pos[i]];
            if (cnt.find(v) != cnt.end())
            {
                arr[cnt[v]].erase(v);
                if (sz(arr[cnt[v]]) == 0)
                    arr.erase(cnt[v]);
            }
            cnt[v]++;
            arr[cnt[v]].insert(v);
        }
        while (true)
        {
            auto it = --arr.end();
            if (it->fi <= mid)
                break;
            int x = *it->se.begin();
            it->se.erase(x);
            if (sz(it->se) == 0)
                arr.erase(it);
            cnt.erase(x);
            used[x] = true;
            rem--;
            if (rem == 0)
            {
                ok = false;
                break;
            }
            rep(i, 0, n)
            {
                if (a[i][pos[i]] != x)
                    continue;
                while (used[a[i][pos[i]]])
                    pos[i]++;
                int v = a[i][pos[i]];
                if (cnt.find(v) != cnt.end())
                {
                    arr[cnt[v]].erase(v);
                    if (sz(arr[cnt[v]]) == 0)
                        arr.erase(cnt[v]);
                }
                cnt[v]++;
                arr[cnt[v]].insert(v);
            }
        }
        ok ? r = mid : l = mid;
    }
    cout << r << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,count=0;
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
    cout << "vowel" <<endl;
  }
  else{
    cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b[10000],n,u,i;
scanf("%d",&a);
for(i=0;i<a;i++)
scanf("%d",&b[i]);
for(i=a-1;i>=0;i--){
printf("%d",b[i]);
if(i!=0)
printf(" ");
}
printf("\n");
return 0;
}

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li m, k;

int main() {
    cin >> m >> k;
    if (k >= bit(m)) {
        puts("-1");
        return 0;
    }

    if (m == 1) {
        if (k != 0) {
            puts("-1");
            return 0;
        }
        puts("0 0 1 1");
        return 0;
    }

    cout << k << " ";
    rep(i, bit(m)) {
        if (i != k) {
            cout << i << " ";
        }
    }
    cout << k << " ";
    rep(i, bit(m)) {
        li num = bit(m) - 1 - i;
        if (num != k) {
            cout << num << " ";
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,M;
    cin >> N >> M;
    pair <ll,ll> a[N];
    ll i;
    for(i=0;i<N;i++){
      cin>> a[i].first >>a[i].second;
    }
    sort(a,a+N);
    i=0;
    ll ans=0;
    while(M>0){
      ans+=a[i].first*min(M,a[i].second);
      M=M-a[i].second;
      i++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main (int argc, char* argv[]) {
  int a, b;
  scanf("%d %d", &a, &b);

  if (a >= 13) printf("%d\n", b);
  else if (6 <= a && a <= 12) printf("%d\n", b/2);
  else printf("0\n");

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string w;
	cin >> w;
	vector<int> cnt(100001, 0);
	for (char wc : w) {
		cnt[wc]++;
	}
	rep(i, 100001) {
		if (cnt[i] % 2 != 0) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if 1<=A<=9 and 1<=B<=9:
        print(A*B)
    else:
        print(-1)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import heapq as hp
x,y,z,k = map(int, input().split()) 
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
h = [0]*k
hp.heapify(h)
for i in a:
  for j in b:
    cur = i+j
    t = 0
    while t < z and h[0] < cur+c[t]:
      hp.heappushpop(h, cur + c[t])
      t += 1
r = [hp.heappop(h) for _ in range(k)]
for _ in range(k):
  print(r.pop())

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	string S;
	cin>>S;
	REP(i,(int)S.length()) if(i%2==0) printf("%c",S[i]);
	puts("");
}



Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = readline().rstrip().decode('utf-8')

def solve_partial(S):
    INF = 10**18
    """
    ・Sは1から始まり、1で終わる
    ・Sは00を含まない
    ・したがって、Sは1,01に分解可能
    ・残る最小個数を調べるdp。これは、1, 101111,111101 の3種を数えることと同じ
    ・a, b0cccc, dddd0e として、「現在の1がどれであるか -> 最小個数」でdp
    ・個数はa,b,eのときに数える
    """
    S = S.replace('01','2')
    a,b,c,d,e = 1,1,INF,0,INF
    for x in S[1:]:
        ace = min(a,c,e)
        if x == '1':
            a2 = ace+1
            c2 = c
            d2 = ace if ace<d else d
            e2 = INF
        else:
            a2 = ace+1
            c2 = a
            d2 = ace
            e2 = d+1
        a,c,d,e = a2,c2,d2,e2
    return len(S)-min(a,c,e)

answer = 0
for x in S.split('00'):
    x = x.strip('0')
    if x:
        answer += solve_partial(x)

print(answer)

Measured memory_bytes: 8360
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n;

signed main() {
	cin >> n;
	int cnt = 0;
	for (int i = 1;; i++) {
		cnt += i;
		if (n <= cnt) {
			for (int j = i; j >= 1; j--)if (j <= n) {
				cout << j << endl;
				n -= j;
			}
			return 0;
		}
	}
}


Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(N: int, A: "List[int]"):
    l = [0 if(i%2 == 0) else 1 for i in A]
    if(sum(l) == 0 or l.count(1)%2 == 0):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16628
#C++のコードを移植
def Expected_value(n):
    return n + 1

n,k = map(int, input().split())
a = input().split()
sm = 0
mx = 0
for i in range(n):
    if i <= k-1:
        sm += Expected_value(int(a[i]))
        mx = sm
    else:
        sm = sm + Expected_value(int(a[i])) - Expected_value(int(a[i-k]))
        mx = max(mx,sm)

print(mx/2)





Measured memory_bytes: 17892
import java.io.PrintWriter;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
             String s1 = nstr(sc);
             String s2 = nstr(sc);
             String s3 = nstr(sc);

             s1 = s1.substring(0,1);
             s2 = s2.substring(0, 1);
             s3 = s3.substring(0, 1);
             
             s1 = s1.toUpperCase();
             s2 = s2.toUpperCase();
             s3 = s3.toUpperCase();
             
             out.println(s1+s2+s3);

        }
    }


    static int nint(Scanner sc) {
        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
int a[N], f[N], vs[N];
priority_queue<int> q, p;

bool cmp(int x, int y) {
  return a[x] < a[y];
}

int main() {
  int n, len, Q;
  cin >> n >> len >> Q;
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    f[i] = i;
  }
  sort(f + 1, f + 1 + n, cmp);
  int ans = 1e9;
  for(int i = 1; i <= n; ++i) {
    int o = f[i];
    for(int j = 1; j <= n; ++j) {
      if(vs[j]) continue;
      int k = j;
      for(; k <= n && !vs[k]; k++) p.push(-a[k]);
      k--;
      while(p.size() >= len) {
        q.push(p.top());
        p.pop();
      }
      while(!p.empty()) p.pop();
      j = k;
    }
    vs[o] = 1;
    int res = 0, be = -1;
    while(!q.empty()) {
      res++;
      if(res == Q) be = -q.top();
      q.pop();
    }
    if(be != -1) ans = min(ans, be - a[o]);
    else break;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())
c = [0 for i in range(b)]
cc = [0 for i in range(b)]
for i in range(a):
	l = list(map(int,input().split()))
	for j in range(l[0]):
		if cc[l[j+1]-1] == 0:
			c[l[j+1]-1] += 1
			cc[l[j+1]-1] += 1
	cc = [0 for i in range(b)]
co = 0
for i in range(b):
	if c[i] == a:
		co += 1

print(co)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


signed main(){
	//cout << fixed << setprecision(10);
	ll n,m; cin >> n >> m;
	ll cnt = 0, cnt2 = 0;
	vector<bool> ok(n,0);
	map<ll,ll> mp;
	rep(i,0,m){
		ll p; string s; 
		cin >> p >> s;
		if(ok[p])continue;
		if(s == "AC"){
			ok[p] = 1;
			cnt++;
		}
		else mp[p]++;
	}
	for(auto c:mp){
		if(!ok[c.first])continue;
		cnt2 += c.second;
	}
	cout << cnt << " " << cnt2 << endl;

	return 0;
}

Measured memory_bytes: 7412
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;


int main(){
   string s;
   cin >> s;
   int count=0;
   REP(i,s.size()/2){
      if(s[i]!=s[s.size()-1-i]) count++;
   }
   cout << count << endl;
   
   
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

struct Trie {
  Trie *child[2];
  Trie() { child[0] = child[1] = nullptr; }
  void insert(const string &s) {
    Trie *node = this;
    for (char c : s) {
      int k = c - '0';
      if (node->child[k] == nullptr) {
        node->child[k] = new Trie();
      }
      node = node->child[k];
    }
  }
};

ll grundy(Trie *node, ll L) {
  if (node == nullptr) {
    return L & -L;
  }
  return grundy(node->child[0], L - 1) ^ grundy(node->child[1], L - 1);
}

int main() {
  int N;
  ll L;
  cin >> N >> L;
  Trie *trie = new Trie();
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    trie->insert(s);
  }
  cout << (grundy(trie, L + 1) != 0 ? "Alice" : "Bob") << endl;
  return 0;
}


Measured memory_bytes: 6656
#include<cstdio>
using namespace std;
int main(void)
{
	char c,buf[1025];
	int i,j,p,flg;
	p=0;
	flg=1;
	while(scanf("%c",&c)!=EOF)	{
		if(c==' ' || c=='.' || c==',')	{
			if(p>=3 && p<=6)	{
				if(flg!=1)	{
					printf(" ");
				}
				else {
					flg=0;
				}			
				for(i=0;i<p;i++)	{
					printf("%c",buf[i]);
				}
			}
			p=0;
		}
		else {
			buf[p]=c;
			p++;
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 936
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline
n,m=map(int,input().split())
z=n*(n-1)//2
l=[-1]*n
a=[1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[z]
def f(s):
  s=int(s)-1
  t=l[s]
  if t<0:
    return s
  j=0
  while(t>=0):
    j=t
    t=l[t]
  l[s]=j
  return j
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  if x!=y:
    l[x]=y
    z-=a[x]*a[y]
    a[y]+=a[x]
  c[i]=z
for x in c[1:]:
  print(x)

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,q; cin >> n >> q;
    vvl G(n);
    vl res(n);
    vector<bool> visited(n);
    rep(i,n-1){
        int x,y; cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    rep(i,q){
        int x,c; cin >> x >> c;x--;
        res[x] += c;
    }
    //根が若い番号から処理    
    queue<int> que; que.push(0);
    visited[0] = true;
    
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(auto nv: G[v]){
            if(visited[nv] == false){
                que.push(nv);
                res[nv] += res[v];
                visited[nv] = true;
            }
        }
    }

    rep(i,n){
        if(i)cout << " ";
        cout << res[i];
    }
    cout << endl;
}


Measured memory_bytes: 17136
import math


def distance(v1, v2, deg):
    left = v1 ** 2 + v2 ** 2
    right = 2 * v1 * v2 * math.cos(math.radians(deg))
    return math.sqrt(left - right)


a, b, h, m = map(int, input().split())

hr = h * 30 + (m / 60) * 30
mr = m * 6

diff = math.fabs(hr - mr)

print(distance(a, b, diff))


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

int main(){
	int c[9];
	for(int i = 0; i < 9; i++)
		cin >> c[i];
	int a1 = c[0]+c[1]+c[2];
	int a2 = c[3]+c[4]+c[5];
	int a3 = c[6]+c[7]+c[8];
	int b1 = c[0]+c[3]+c[6];
	int b2 = c[1]+c[4]+c[7];
	int b3 = c[2]+c[5]+c[8];
	bool a = (abs(a1-a2)%3 == 0) && (abs(a2-a3)%3 == 0) && (abs(a3-a1)%3 == 0);
	bool b = (abs(b1-b2)%3 == 0) && (abs(b2-b3)%3 == 0) && (abs(b3-b1)%3 == 0);
	if(a && b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256