akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

"""
参考：http://drken1215.hatenablog.com/entry/2018/11/06/120600
　　　https://emtubasa.hateblo.jp/entry/2018/10/06/224022
・約数とか。理解は出来たものの、自分で気付けるにはどうすれば…。
・この前作ったけど使えなかった約数列挙ライブラリが役に立った。
"""

from math import sqrt

def num_div_set2(N):
    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て+1
    end = int(sqrt(N)) + 1
    for i in range(2, end+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N, M = map(int, input().split())

ans = 1
for d in num_div_set2(M):
    # aNを全てdとするより大きいのは、Mに収まらないからダメ
    # 逆にそれ以下の約数なら、全dの最後の1つだけ調整すればどうにでも作れるからOK
    if d * N <= M:
        ans = max(d, ans)
print(ans)


Measured memory_bytes: 3064
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

def Lcm(a,b):
    return (a*b)//gcd(a,b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=l[0]
    for i in range(n):
        lcm=Lcm(lcm,l[i])
    ans=0
    mod=1000000007
    for i in range(n):
        ans+=lcm//l[i]
    print(ans%mod)

if __name__ == "__main__":
    dp()

Measured memory_bytes: 4084
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()
    A = Scanner.map_int()
    L = defaultdict(int)
    for i in range(N):
        L[(i + 1 + A[i])] += 1
    R = defaultdict(int)
    for i in range(N):
        R[i + 1 - A[i]] += 1
    ans = 0
    for k, v in L.items():
        ans += v * R[k]
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 81296
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<iostream>
using namespace std;
int a[1000010];
int n;
string t;
map<string , int> mp;
int main(){
    //freopen("sort.in","r",stdin);
    //freopen("sort.out","w",stdout);
    while (scanf("%d",&n)!=EOF) {
        mp.clear();
        mp["AC"] = 0;
        mp["WA"] = 0;
        mp["TLE"] = 0;
        mp["RE"] = 0;
        while (n--) {
            cin >>  t;
            mp[t]++;
        }
        printf("AC x %d\n",mp["AC"]);
        printf("WA x %d\n",mp["WA"]);
        printf("TLE x %d\n",mp["TLE"]);
        printf("RE x %d\n",mp["RE"]);
    }
    return 0;
}


Measured memory_bytes: 3292
#include <cstdio>

int main() {
  int A, B;
  scanf("%d %d", &A, &B);

  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    printf("Possible\n");
  } else {
    printf("Impossible\n");
  }

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
typedef pair<ll,ll> P;

int main() {
  int a,b,c,d,e,f;
  cin >>a>>b>>c>>d>>e>>f;
  P ans=P(100*a,0);
  P co=P(1,0);
  vector<int>s,w;
  rep(i,f+1){
    rep(j,f+1){
      int now=c*i+d*j;
      if(now<f){
        s.push_back(now);
      }
    }
  }
  rep(i,f+1){
    rep(j,f+1){
      int now=100*a*i+100*b*j;
      if(0<now&&now<=f){
        w.push_back(now);
      }
    }
  }
  rep(i,s.size()){
    rep(j,w.size()){
      if(s[i]+w[j]<=f&&s[i]*100<=w[j]*e){
        if(co.second*w[j]<co.first*s[i]){
          ans=P(w[j],s[i]);
          co=P(w[j],s[i]);
        }
      }
    }
  }
        
      
  cout<<ans.first+ans.second<<" "<<ans.second<<endl;
}

Measured memory_bytes: 4216
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;


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

	string s,t;
	cin >> s >> t;

	int num=0,tmp=-1;
	vector<int> heads;
	for(int i=0;i<s.size();i++){
		tmp=-1;
		
//		cout << i << " " << s[i] << "\n";

		for(int j=0;j<t.size();j++){
			if(s[i+j] == t[j] || s[i+j] == '?'){
				if(j==0) tmp = i;
			}
			else break;

			if(j == t.size()-1) {
		//		cout << "    " << tmp << "\n";
				heads.push_back(tmp);
			}
		}
	}
	if(heads.size() == 0) cout << "UNRESTORABLE\n";
	else{
		s.replace(*(heads.end()-1),t.size(),t);
		for(int i=0;i<s.size();i++){
			if(s[i] == '?') s[i]='a';
		}
		cout << s << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias Pair = Tuple!(long, "begin", long, "end");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, d;
    scan(n, d);
    auto dims = new long[][](n, d);
    foreach (ref e; dims[])
    {
        e = aryread();
    }
    long count;
    long[] dist = [1];
    long tmp;
    while (dist[tmp] < (40 ^^ 2) * 10)
        dist ~= (++tmp + 1) ^^ 2;
    foreach (e1; dims[])
    {
        foreach (e2; dims[])
        {
            auto s = iota(0, d).map!(x => (e1[x] - e2[x]) ^^ 2).sum;
            foreach (e3; dist)
                if (s == e3)
                    count++;
        }
    }
    (count / 2).writeln();
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll A, B;
    cin >> A >> B;
    ll n = 1;
    ll ans = 0;
    while (n < B)
    {
        n = n - 1 + A;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
namespace P_TEMPLATE{
	#define endl '\n'
	#define rgi register int
	typedef long long ll;
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdout,NULL),setbuf(stdin,NULL);
	#endif
}}using namespace P_TEMPLATE;
// ----------------------------
// #define int ll
using namespace std;
const int maxn=200004;
const int mod=998244353,inf=1201201201;

int l[14],r[14],dp[maxn];

signed main()
{P_INIT();
	int n,k,sum=0;
	fin>>n>>k;
	for(rgi i=1;i<=k;++i) fin>>l[i]>>r[i];
	dp[1]=1;
	for(rgi i=2;i<=n;++i) {
		for(rgi j=1;j<=k;++j) {
			if(i-l[j]>0) (sum+=dp[i-l[j]])%=mod;
			if(i-r[j]>1) (sum+=mod-dp[i-r[j]-1])%=mod;
		} dp[i]=sum;
	} fout<<dp[n];
	return 0;
}
// ----------------------------
// by imzzy

Measured memory_bytes: 4408
M = 998244353

N = int(input())
d_list = list(map(int, input().split()))

def check():
	if d_list[0] != 0:
		print(0)
		return
	d_list.sort()
	d_counts = []
	prev_d = -1
	for d in d_list:
		if prev_d == d:
			d_counts[prev_d] += 1
		elif prev_d + 1 == d:
			d_counts.append(1)
			prev_d = d
		else:
			print(0)
			return
	count = 1
	prev_c = d_counts.pop(0)
	if prev_c != 1:
		print(0)
	else:
		for c in d_counts:
			count = (count * pow(prev_c, c, M)) % M
			prev_c = c
		print(count)

check()


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll n;
map<ll, ll> cnt;

void input(){
    cin >> n;
    for(int i=0;i<n;i++){
        ll x;
        cin >> x;
        cnt[x]++;   
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    // for(auto p:cnt) cout << p.first << ' ' << p.second << endl;
    ll ans = 1;
    if(n % 2){
        for(int i=0;i<n;i+=2){
            if(i == 0 && cnt[i] != 1){
                cout << 0 << endl;
                return 0;
            }
            else if(i != 0 && cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            } 
        }
        for(int i=2;i<n;i+=2) ans = ans * 2 % MOD;
    }
    else{
        for(int i=1;i<n;i+=2){
            if(cnt[i] != 2){
                cout << 0 << endl;
                return 0;
            }
            ans = ans * 2 % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4224
s = input()
K = int(input())
def same_head_num(a,b):
    n = 0
    N = min(len(a),len(b))
    while n < N:
        if a[n] == b[n]:
            n += 1
        else:
            break
    return n

strings = ['']
N = len(s)
for i in range(N):
    strings.append(s[i:])
strings.sort()
for i in range(1,N+1):
    head_n = same_head_num(strings[i-1],strings[i])
    tail_n = len(strings[i]) - head_n
    if tail_n < K:
        K -= tail_n
        continue
    else:
        print(strings[i][:head_n+K])
        break

Measured memory_bytes: 15604
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int N =sc.nextInt();
    int M =sc.nextInt();
    int P[]=new int[M];
    String Q[]=new String[M];
    int R[] =new int[N];
    int S[] =new int[N];
    int x=0;int y=0;
    for(int i=0;i<M;i++){
      P[i]=sc.nextInt();
      Q[i]=sc.next();
      if(R[P[i]-1]==1){continue;}
      if(Q[i].equals("AC")){
        R[P[i]-1]=1;x=x+1;y=y+S[P[i]-1];}
      else{S[P[i]-1]=S[P[i]-1]+1;}}
    System.out.println (x+" "+y);
  }
}

Measured memory_bytes: 71436
/*
ID: alec3
LANG: C++14
PROG:
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

//ifstream fin("maze1.in");
//ofstream fout("maze1.out");


const int MOD = 10e7;
int main()
{
    io;
    string s, t;
    cin >> s >> t;

    int ans = INT_MAX;
    int c = 0;
    for (int i = 0; i < s.size(); i++){
        int index = i, i2 = 0;
        bool good = true;
        c = 0;
        while (i2 < t.size()){
            if (index >= s.size()){
                good = false;
                break;
            }

            if (s[index] != t[i2])
                c ++;
            index ++; i2++;
        }
        if (good)
            ans = min(c, ans);
    }
    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = iN / 2;
            if (iN % 2 != 0) { iOut += 1; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
N = int(input())
S = input()
i = 0
b = S.count('.')
w = 0
min = b
for i in range(N):
    if S[i] == '#':
        w += 1
    else:
        b -= 1
    
    T = b + w
    if T < min:
        min = T

print(min)

Measured memory_bytes: 3500
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

vector<vector<int>> A(3, vector<int>(3, 0));

bool check()
{
    int cnt = 0;

    repi(i, 3, 0)
    {
        cnt = 0;
        repi(j, 3, 0)
        {
            if (A.at(i).at(j) == -1)
            {
                cnt++;
            }
        }
        if (cnt == 3)
        {
            return true;
        }
    }
    repi(i, 3, 0)
    {
        cnt = 0;
        repi(j, 3, 0)
        {
            if (A.at(j).at(i) == -1)
            {
                cnt++;
            }
        }
        if (cnt == 3)
        {
            return true;
        }
    }
    cnt = 0;
    repi(i, 3, 0)
    {
        if (A.at(i).at(i) == -1)
        {
            cnt++;
        }
    }
    if (cnt == 3)
    {
        return true;
    }
    cnt = 0;
    repi(i, 3, 0)
    {
        if (A.at(i).at(2 - i) == -1)
        {
            cnt++;
        }
    }
    if (cnt == 3)
    {
        return true;
    }
    return false;
}

void set(int num)
{
    repi(i, 3, 0)
    {
        repi(j, 3, 0)
        {
            if (A.at(i).at(j) == num)
            {
                A.at(i).at(j) = -1;
            }
        }
    }
}

int main()
{

    repi(i, 3, 0)
    {
        repi(j, 3, 0)
        {
            cin >> A.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    bool state = false;
    repi(i, n, 0)
    {
        int b;
        cin >> b;
        set(b);
        if (i > 2)
        {
            state = check();
        }
        if (state)
        {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, Q, AB, PX):
    from collections import defaultdict
    g = defaultdict(set)
    for a, b in AB:
        g[a].add(b)
        g[b].add(a)

    C = [0] * (N+1)
    for p, x in PX:
        C[p] += x

    s = [(1, -1)]
    while s:
        u, p = s.pop()
        for v in g[u]:
            if v == p:
                continue
            s.append((v, u))
            C[v] += C[u]
    return C[1:]







def main():
    N, Q = read_int_n()
    AB = [read_int_n() for _ in range(N-1)]
    PX = [read_int_n() for _ in range(Q)]
    print(*slv(N, Q, AB, PX))


if __name__ == '__main__':
    main()


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

int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;

    for (int i = 1; i <= N; ++i){
        int s = i;
        int sum = 0;
        while( s>0 ){
            sum += s % 10;
            s = s / 10;
        }
        if( A <= sum and sum <= B){
            ans += i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

	bool comp(pair<int,int>p,pair<int,int>q){
		return p.first+p.second<q.first+q.second;
	}
	bool comp2(pair<int,int>p,pair<int,int>q){
		return p.first-p.second<q.first-q.second;
	}
	int32_t main(){
		IOS;
		int n;
		cin>>n;
		set<pair<int,int>>s;
		for(int i=0;i<n;i++){
			int a,b;
			cin>>a>>b;
			s.insert({a,b});
		}
		vector<pair<int,int>>v;
		vector<pair<int,int>>vec;
		for(auto u:s){
			v.pb(u);
			vec.pb(u);
		}
		sort(v.begin(),v.end(),comp);
		sort(vec.begin(),vec.end(),comp2);
		int ans=abs(v[0].first-v.back().first)+abs(v[0].second-v.back().second);
		ans=max(ans,abs(vec[0].first-vec.back().first)+abs(vec[0].second-vec.back().second));
		cout<<ans<<endl;
		return 0;
	}


Measured memory_bytes: 22248
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int N;
	long long A[100100],ans=0,x=0;
	cin >> N;
	for (int i = 0; i < N; i++)cin >> A[i];
	sort(A, A + N);
	for (int i = 0; i <N;) {
		int odd=0;
		for (int j = i; A[j] == A[i]; j++) {
			odd = j - i+1;
			x = j;
		}
		ans += odd % 2;
		i = x + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main(void){
  string s;
  cin>>s;
  int f(0),c(0);
  if(s[0]!='A')f++;
  size_t size=s.length();
  for(int i(2);i<size-1;i++){
    if(s[i]=='C')c++;
  }
  if(c!=1)f++;
  c=0;
  for(int i(0);i<size;i++){
    if(islower(s[i])==0)c++;
  }
  if(c!=2)f++;
  if(f==0)cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;
string s, t;
int dp[3005][3005];

int main()
{
    cin >> s;
    cin >> t;
    int s_len = s.size();
    int t_len = t.size();
    for (int i = 1; i <= s_len; ++i) {
        for (int j = 1; j <= t_len; ++j) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    // cerr << dp[s_len][t_len] << endl;

    string ans = "";
    int i = s.size();
    int j = t.size();
    while (i >= 0 || j >= 0) {
        if (i && dp[i][j] == dp[i - 1][j]) {
            i--;
        } else if (j && dp[i][j] == dp[i][j - 1]) {
            j--;
        } else {
            if (i && j) ans += s[i - 1];
            i--;
            j--;
        }
    }
    reverse(ans.begin(), ans.end());
    // cerr << ans.size() << endl;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;

int main(){
    int n,m;
    cin >> n;
    unordered_set<string> u(n);
    string tmp;
    for(int i=0; i<n; i++){
        cin >> tmp;
        u.insert(tmp);
    }
    cin >> m;

    bool locked=true;
    for(int i=0; i<m; i++){
        cin >> tmp;
        auto itr = find(u.begin(), u.end(), tmp);
        if(itr!=u.end()){
            if(locked){
                cout << "Opened by " << tmp << endl;
                locked = false;
            }else{
                cout << "Closed by " << tmp << endl;
                locked = true;
            }
        }else{
            cout << "Unknown " << tmp << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3180
def q_b():
    n = int(input())
    st = input().split()
    s = st[0]
    t = st[1]

    word = []
    for i in range(n):
        word.append(s[i])
        word.append(t[i])
    print("".join(word))

if __name__ == '__main__':
    q_b()

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

int main() {
  long N;
  cin>>N;
  vector<long> a(N);
  for(int i=0;i<N;i++) cin>>a[i];

  long ans=0;
  long sum=0;
  long xsm=0;
  int   r=0;
  for(int l=0;l<N;l++){
    while((sum+a[r])==(sum^a[r])&&r<N){
      sum+=a[r];
      r++;
    }
    ans += r-l;
    sum-=a[l];
    if(l==r) r++;
  }
    cout<<ans<<endl;

}


Measured memory_bytes: 4760
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
N, M = map(int, input().split())
A = sorted([int(x) for x in input().split()])
# S = input()

BC = [[int(x) for x in input().split()] for _ in range(M)]
BC.sort(key=lambda x : x[1], reverse=True)

ans = 0
i = 0
used = 0
flag = True
for a in A:
    if flag and used >= BC[i][0]:
        i += 1
        used = 0

        if i >= M:
            flag = False

    if flag and a < BC[i][1]:
        ans += BC[i][1]
        used += 1
    else:
        ans += a

print(ans)


Measured memory_bytes: 27016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll H,W,K;
ll dp[110][10];
const long long con[8]={1ll,1ll,2ll,3ll,5ll,8ll,13ll,21ll};
int main()
{
	cin>>H>>W>>K;
	dp[0][0]=1;
	for(ll i=1;i<=H;i++)
		for(ll j=0;j<W;j++)
		{
			dp[i][j]=con[j]*con[max(0ll,W-j-1)]%(ll)MOD*dp[i-1][j]%(ll)MOD;
			if(j) (dp[i][j]+=con[max(j-1,0ll)]*con[max(0ll,W-j-1ll)]%MOD*dp[i-1ll][j-1ll]%(ll)MOD)%=(ll)MOD;
			if(j<W-1) (dp[i][j]+=con[j]*con[max(0ll,W-j-2ll)]%MOD*dp[i-1ll][j+1ll]%(ll)MOD)%=(ll)MOD;
		}
	cout<<dp[H][K-1]<<endl;
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  vll a(4);
  rep(i,4) a[i]=s[i]-'0';
  
  for(ll bit=0; bit<(1<<3); bit++){
    ll sum=a[0];
    rep(i,3){
      if(bit>>i&1){
        sum+=a[i+1];
      }else{
        sum-=a[i+1];
      }
    }
    if(sum==7){
      cout<<a[0];
      rep(i,3){
        if(bit>>i&1){
          cout<<'+';
        }else{
          cout<<'-';
        }
        cout<<a[i+1];
      }
      cout<<"=7"<<endl;
      break;
    }
  }
}


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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int gcd(lint a, lint b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {
  int N, X;
  cin >> N >> X;

  cout << 3 * (N - gcd(N, X)) << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n = int(input())
d = defaultdict(int)
for i in range(n): d[input()]+=1
ds = sorted(d.items(), key = lambda x : (-x[1], x[0]))
nmx = ds[0][1]
for i in ds:
  if nmx != i[1]: break
  print(i[0])


Measured memory_bytes: 59800
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

int main(){
	int count=0,ans=0;
	char s[11];
	cin>>s;
	for(int i=0;i<strlen(s);i++)
	{
		if(s[i]=='T'||s[i]=='G'||s[i]=='C'||s[i]=='A')count++;
		else
		{
			count=0;
		}
			ans=max(ans,count);
	}
	cout<<ans;
	return 0;
	}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

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

	string name = "";
	vector<int> vec;
	for (int i = 11; 0 <= i; --i) {
		int digit = N % 26;
		N = floor(N / 26);
		vec.push_back(digit);
	}

	bool flags = true;
	while (flags) {
		flags = false;
		for (int i = 0; i < vec.size() - 1; ++i) {
			if (vec[i] == 0 && vec[i + 1] != 0) {
				vec[i + 1] -= 1;
				vec[i] += 26;
				flags = true;
				break;
			}
		}
	}

	for (int i = 0; i < vec.size(); ++i) {
		if (0 < vec[i] && vec[i] < 27) {
			name += char(97 + vec[i] - 1);
		}
	}

	reverse(name.begin(), name.end());
	cout << name;
	return 0;
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n, res[3] , cnt[100100][3];
string s[100100];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    ms(cnt, 0);
    cin >> n >> res[0] >> res[1] >> res[2];
    vector<char> ans;
    forn(i, n) {
        cin >> s[i];
        ++cnt[i][int(s[i][0]-'A')];
        ++cnt[i][int(s[i][1]-'A')];
    }
    bool flag = true;
    forn(i, n) {
        int ta = int(s[i][0]-'A'), tb = int(s[i][1]-'A');
        if (res[ta] > res[tb]) {
            --res[ta];
            ++res[tb];
            ans.eb('A'+tb);
        } else if (res[ta] < res[tb]) {
            ++res[ta];
            --res[tb];
            ans.eb('A'+ta);
        } else {
            if (!res[ta]) {
                flag = false;
                break;
            }
            if (i == n-1 || s[i][0] == s[i+1][0] || s[i][0] == s[i+1][1]) {
                ++res[ta];
                --res[tb];
                ans.eb('A'+ta);
            } else {
                --res[ta];
                ++res[tb];
                ans.eb('A'+tb);
            }
        }
      //  cerr << res[0] << ' ' << res[1] << ' ' << res[2] << endl;
    }
    if (!flag) cout << "No" << '\n';
    else {
        cout << "Yes" << '\n';
        for (char x : ans) cout << x << '\n';
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 8100
from collections import defaultdict
N=int(input())
alist=list(map(int,input().split()))

sum_alist=sum(alist)
adic=defaultdict(int)
for a in alist:
  adic[a]+=1

Q=int(input())
for i in range(Q):
  b,c=map(int,input().split())
  
  sum_alist+=(c-b)*adic[b]
  print(sum_alist)
  adic[c]+=adic[b]
  adic[b]=0

Measured memory_bytes: 24184
import numpy as np
import fractions
from functools import reduce

N, X = map(int, input().split())
x = list(map(int, input().split()))
x = np.array(x)

x -= X
x = abs(x)
x = x.tolist()

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd(x))

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = (b); i <= (e); i++)
#define RPT0(i, n) RPT(i, 0, n - 1)
#define RPT1(i, n) RPT(i, 1, n)
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    RPT0(i, N) cin >> h[i];

    vector<int> dp(N);
    dp[0] = 0;
    RPT(i, 1, N - 1)
    {
        int min_step = INT32_MAX;
        RPT(j, max(0, i - K), i - 1)
        min_step = min(min_step, dp[j] + abs(h[i] - h[j]));
        dp[i] = min_step;
    }
    cout << dp[N - 1] << endl;
}

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


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

using namespace std;
using ll = long long;

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

  int n;
  cin >> n;

  // 上司の番号
  vector<int> ans(n, 0);

  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    ans[a]++;
  }

  for (auto &x : ans)
    cout << x << endl;

  return 0;
}


Measured memory_bytes: 3968
X, Y = map(int, input().split())
ans = 0

if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000
if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000
if X == Y == 1:
    ans += 400000
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
using namespace std;
char s[100005];
int main(){
	int n,k,ans,ls=1;
	char x,xx='A';
	scanf("%d%d",&n,&k);
	scanf("%s",s);
	for(int i=1;i<n;i++){
		if(s[i]!=s[i-1]) ls++;
	}
	if(ls-2*k<=1) ans=n-1;
	else ans=n-(ls-2*k);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1828
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  int a;
  int k,x,y,m,memo=1,sx=1,sy=1,gx,gy;
  string ka,ss;
  double n,ans;
  map<string,int>mp;
  cin>>n;
  ans=(n/3)*(n/3)*(n/3);
  cout<<fixed << setprecision(12) <<ans<<endl;

  vector<string> field(y);
  
  
  //cout<<dp[x-1][y-1]<<endl;

  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll a,b;
  cin>>a>>b;
  if(a==1&&b==1){
    cout << 1000000 << endl;
  }
  else{
    ll ans = 0;
    if(a==1)ans+=300000;
    if(a==2)ans+=200000;
    if(a==3)ans+=100000;
    if(b==1)ans+=300000;
    if(b==2)ans+=200000;
    if(b==3)ans+=100000;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long ans = 0;
		double[] A = new double[N];
		for(int i = 0; i < N; i++)
			A[i] = sc.nextInt();
		Arrays.sort(A);
		int[] B = new int[N];
		for(int i = 0; i < N; i++)
			B[i] = sc.nextInt();
		Arrays.sort(B);
		double[] C = new double[N];
		for(int i = 0; i < N; i++)
			C[i] = sc.nextInt();
		Arrays.sort(C);
		for(int i = 0; i < N; i++) {
			long AB = 0, BC = 0;
			AB = - 1 - Arrays.binarySearch(A, B[i]-0.1);
			BC = N + 1 + Arrays.binarySearch(C, B[i]+0.1);
			ans += AB * BC;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 95636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>


using namespace std;


int main(){
    int a, b, c , d;
    cin>>a>> b>> c>> d;
    int T=(c%b==0)? c/b : c/b+1;
    int A = (a%d==0)? a/d : a/d+1;
    if(T<=A) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
	int n;
	int x[100];
	int ans = 10000000;
	int sum = 0;

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

	for(int i = 1; i < 101; i++){
		for(int j = 0; j < n; j++){
			sum += (x[j] - i) * (x[j] - i); 
		}

		if(ans >= sum){
			ans = sum;
		}

		sum = 0;
	}

	printf("%d", ans);

	return 0;

}

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

int main()
{
  double w, h;
  int n;
  int c = 0;
  while (scanf("%d,%lf,%lf", &n, &w, &h) != EOF){
    if (w / h / h >= 25.0){
      cout << n << endl;
      c++;
    }
  }
  if (c == 0){
    cout << "????????????" << endl;
  }

  return 0;
}

Measured memory_bytes: 1232
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var s = next();
	var list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	if(list.indexOf(s) != -1){
		myout("A");
	}else{
		myout("a");
	}
}


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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/


int main(){
  //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string s;
    cin >> s;
  
  	int c_l = 0,c_r = 0;

	rep(i,N){
      if(s[i] == '('){
        c_l++;
      }else{
        if(c_l>0)c_l--;
        else c_r++;
      }
    }

  	
    rep(i,c_r)cout << '(';
    cout<<s;
    rep(i,c_l)cout << ')';
    cout << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
const constexpr ll mod = 1000000007;
ll powMod(ll n, ll p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= n) %= mod;
		(n *= n) %= mod;
		p >>= 1;
	}
	return res;
}
ll n,x,h[200001],ans=0,r=1;
int main() {
	cin>>n;
	for (ll i = 1; i < n + 1; ++i) {
		h[i]=(h[i-1]+powMod(i,mod-2))%mod;
	}
	for (ll i = 1; i < n + 1; ++i) {
		cin>>x;
		(ans+=x*(h[i]+h[n-i+1]-1+mod))%=mod;
		(r*=i)%=mod;
	}
	print(ans * r % mod);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


vector<int> a(100001);
ll ans;
int n, x;

void calc(int i, int j) {
    if (a[i] + a[j] > x) {
        ans += min(a[j], a[i] + a[j] - x);
        a[j] -= min(a[j], a[i] + a[j] - x);
        if (a[i] > x) {
            ans += a[i] - x;
            a[i] -= a[i] - x;
        }
    }
}

int main() {
   
    cin >> n >> x;
    
    rep(i, n) cin >> a[i];
    
    calc(0, 1);
    
    rep3(i, 1, n) {
        if (a[i] + a[i + 1] > x) {
            ans += a[i] + a[i + 1] - x;
            a[i + 1] -= a[i] + a[i + 1] - x;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector> // vectorを使うためにインクルードする
using namespace std;

int main() {
	int n;
	int m;

	scanf("%d", &n);
	scanf("%d", &m);

	vector<int> count(m, 0);
	int ans = 0;

	for (int i = 0; i <n ;i++) {
		int k;
		scanf("%d",&k);
		for (int j = 0; j < k; j++) {
			int u;
			scanf("%d", &u);
			count[u - 1] += 1;
		}
		
	}

	for (int i = 0; i < m; i++) {
		if(count[i]==n){
			ans+=1;
		}

	}
	printf("%d",ans);
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

char s[110], t[110];

int N;

int main()
{
	gi(N);
	scanf("%s", s + 1);
	scanf("%s", t + 1);
	for (int i = N; i; --i)
	{
		int flag = 1;
		for (int j = 1; j <= i; ++j)
			if (s[N - i + j] != t[j])
				flag = 0;
		if (flag)
		{
			printf("%d\n", N + N - i);
			return 0;
		}
	}
	printf("%d\n", N + N);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main (){
	int A,B,C,ans = 0;
  	cin >> A >> B >> C;
  	ans = (B + C) - A;
  	if(ans <= 0){
    	cout << 0;
    }
  	else{
    	cout << ans;
    }
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if(a*c<b) {
			System.out.println(c);
		}else {
			System.out.println(b/a);
		}
	}
}



Measured memory_bytes: 22996