akhauriyash/Code-Regression huggingface dataset:
// ABC042_C
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値

ll N, K, num;
vector<ll> vec(10, 0), ok, res;

void dfs(string str) {
    if (N <= stoll(str)) {
        res.push_back(stoll(str));
    } else {
        REP(i, ok.size()) {
            dfs(str + to_string(ok[i]));
        }
    }
}

int main() {
    // input
    cin >> N >> K;
    REP(i, K) {
        cin >> num;
        vec[num]++;
    }
    
    // 大丈夫な数字
    REP(i, 10) {
        if (vec[i] == 0) ok.push_back(i);
    }
    
    // calculation
    REP(i, ok.size()) {
        if (ok[i] == 0) continue;
        dfs(to_string(ok[i]));
    }
    
    cout << *MIN(res) << "\n";
    
    return 0;
}


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

int64_t Koyakusu(int64_t a,int64_t b)
{
  if(a%b==0)
    return b;
  else
  {
    return Koyakusu(b,a%b);
  }
}
int64_t Kobaisu(int64_t a,int64_t b)
{
  return (a*b)/Koyakusu(a,b);
}
  

int main()
{
  int64_t a,b;
  cin>>a>>b;
  cout<<Kobaisu(max(a,b),min(a,b))<<endl;
}
  

Measured memory_bytes: 256
from collections import deque
N = int(input())
A = (map(int, input().split()))
A = sorted(A)
A = deque(A)
l = []
for i in range(N - 1):
    if i == N - 2:
        ans = A[1] - A[0]
        l.append("{} {}".format(A[1], A[0]))
    elif i == N - 3:
        left = A.popleft()
        right = A.pop()
        center = A.pop()

        temp_left = abs(right - (left - center))
        temp_right = abs(left - (right - center))

        if temp_left >= temp_right:
            A.appendleft(left - center)
            A.append(right)
            l.append("{} {}".format(left, center))
        else:
            A.append(right - center)
            A.appendleft(left)
            l.append("{} {}".format(right, center))


    else:
        left = A.popleft()
        left2 = A.popleft()
        right = A.pop()
        right2 = A.pop()
        
        temp_left = abs(right - (left - right2))
        temp_right = abs(left - (right - left2))
        if temp_left >= temp_right:
            A.appendleft(left2)
            A.appendleft(left - right2)
            A.append(right)
            l.append("{} {}".format(left, right2))
        else:
            A.append(right2)
            A.append(right - left2)
            A.appendleft(left)
            l.append("{} {}".format(right, left2))

print(ans)
for line in l:
    print(line)

Measured memory_bytes: 15824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef pair<int, int> ii;
typedef long long int64;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    int first = a * b;
    int second = a + b;
    int third = a - b;
    int ret = INT_MIN;
    ret = max(ret, first);
    ret = max(ret, second);
    ret = max(ret, third);
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
import collections
def main():
    n = int(input())
    v = list(map(int,input().split()))

    even = v[::2]
    odd = v[1::2]
    count_e = collections.Counter(even)
    count_o = collections.Counter(odd)
    ce = count_e.most_common()
    co = count_o.most_common()
    if ce[0][0] != co[0][0]:
        print(n-ce[0][1] - co[0][1])
    else:
        if len(ce) == 1 and len(co) == 1:
            print(n//2)
        elif len(ce) == 1:
            print(n-co[1][1])
        elif len(co) == 1:
            print(n-ce[1][1])
        else:
            print(min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1]))




if __name__ == '__main__':
    main()


Measured memory_bytes: 21952
n,k = map(int,input().split())
a = list(map(int,input().split()))

l = 0
r = 10**10

while r > l + 1:
    m = (r+l)//2
    count = 0
    for i in a:
        if i <= m:
            continue
        count += (i)//m
        
    if count > k:
        l = m
    else:
        r = m
    
print(r)

Measured memory_bytes: 30880
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
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; }
ll MOD = 1000000007;

struct dice
{
	vector<int> pip;
	dice(vector<int> p)
	{
		pip = p;
	}
	void turn_n()
	{
		int tmp = pip[0];
		pip[0] = pip[1];
		pip[1] = pip[5];
		pip[5] = pip[4];
		pip[4] = tmp;
	}
	void turn_s()
	{
		int tmp = pip[0];
		pip[0] = pip[4];
		pip[4] = pip[5];
		pip[5] = pip[1];
		pip[1] = tmp;
	}
	void turn_e()
	{
		int tmp = pip[0];
		pip[0] = pip[3];
		pip[3] = pip[5];
		pip[5] = pip[2];
		pip[2] = tmp;
	}
	void turn_w()
	{
		int tmp = pip[0];
		pip[0] = pip[2];
		pip[2] = pip[5];
		pip[5] = pip[3];
		pip[3] = tmp;
	}
};

void solve()
{	
	vector<int> pip(6);
	rep(i, 6)cin >> pip[i];
	dice d(pip);
	string s;cin >> s;
	rep(i, sz(s))
	{
		if(s[i] == 'N')d.turn_n();
		if(s[i] == 'S')d.turn_s();
		if(s[i] == 'E')d.turn_e();
		if(s[i] == 'W')d.turn_w();
	}
	cout << d.pip[0] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,q,a,b,s[200001],t[200001];
vector<ll>v[200001];
queue<ll> que;
int main(void){
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    while(q--){
        cin>>a>>b;
        t[a]+=b;
    }
    s[1]=1;
    que.push(1);
    while(!que.empty()){
        auto p=que.front();
        que.pop();
        for(auto x:v[p]){
            if(s[x]==0){
                s[x]=1;
                t[x]+=t[p];
                que.push(x);
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<t[i]<<endl;
    }
    
}


Measured memory_bytes: 19440
import java.math.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int kuku[][] = new int[9][9];
        String ans ="No";
        for (int i = 1; i <= 9; i++) {
            if (n % i == 0) {
                if (n / i <= 9)
                    ans = "Yes";
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
s=input()
n=len(s)
s_int=[0]*n
x=(pow(10,n-1))%2019
for i in range(n):
    s_int[i]=(int(s[i])*x)%2019
    x=(x*202)%2019
t=[0]*(n+1)
t[0]=int(s)%2019
for i in range(1,n):
    t[i]=t[i-1]-s_int[i-1]
    t[i]%=2019
t.sort()
t_set=sorted(list(set(t)))
tcnt=[0]*len(t_set)
num=0
for i in range(n+1):
    if t_set[num]==t[i]:
        tcnt[num]+=1
    else:
        num+=1
        tcnt[num]+=1
sum=0
for i in range(len(tcnt)):
    sum+=(tcnt[i]*(tcnt[i]-1))//2
print(sum)


Measured memory_bytes: 24360
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

/*
BFSを書いて最小の経路コストを保持
最大になるように計算するということは、全探索？
任意の.からBFSを伸ばして、その合計では？
一応、始点と終点を得てからその2点で計算すること
いや、ちょっと待って、H,W<=20だから全点間でBFSできるじゃん
*/

int H, W;
const int INF = 1e9 + 1;

int ht[4] = {0, 1, 0, -1};
int wt[4] = {1, 0, -1, 0};

int bfs(vector<string> s, pair<int,int> start, pair<int,int> goal) {
    int cost[H][W];
    for(int hi=0;hi<H;++hi) for(int wi=0;wi<W;++wi) cost[hi][wi] = INF;
    cost[start.first][start.second] = 0;
    
    queue<pair<int,int>> q;
    q.push(start);
    while(!q.empty()) {
        pair<int,int> now = q.front(); q.pop();
        
        if (now.first == goal.first && now.second == goal.second) continue;
        
        for(int i=0;i<4;++i) {
            int nh = now.first + ht[i];
            int nw = now.second + wt[i];
            if (!(0 <= nh && nh < H)) continue;
            if (!(0 <= nw && nw < W)) continue;
            if (s[nh][nw] == '#') continue;
          
            if (cost[nh][nw] > cost[now.first][now.second] + 1) {
                cost[nh][nw] = cost[now.first][now.second] + 1;
              
                q.push(make_pair(nh, nw));
            }
        }
    }
    
    return cost[goal.first][goal.second];
}

int solve(vector<string> s) {
    int cost = 0;
    for(int hi=0;hi<H;++hi){
        for(int wi=0;wi<W;++wi){
            if (s[hi][wi] == '#') continue;
            for(int hj=0;hj<H;++hj){
                for(int wj=0;wj<W;wj++){
                    if (s[hj][wj] == '#') continue;
                    if(hi==hj && wi==wj) continue;
                    pair<int,int> start = make_pair(hi,wi);
                    pair<int,int> goal = make_pair(hj,wj);

                    cost = max(cost, bfs(s, start, goal));
                }
            }
        }
    }
    return cost;
}

int main() {
    cin >> H >> W;
    vector< string > s(H, "");
    for(int hi=0;hi<H;++hi) {
        cin >> s[hi];
    }
    
    cout << solve(s) << endl;
    
    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int d,t , s;cin>>d>>t>>s;
    cout<<((double)d/s <= t?"Yes":"No");
    return 0;

}

Measured memory_bytes: 3648
string = input()
q = int(input())

for i in range(q):
    order_set = list(input().split())
    a, b = int(order_set[1]), int(order_set[2])

    if order_set[0] == "replace":
      string = string[:a] + order_set[3] + string[b+1:]
      
    if order_set[0] == "reverse":
      string = string[:a] + string[a:b+1][::-1] + string[b+1:]
      
    if order_set[0] == "print":
      print(string[a:b+1])



Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long long x;
    cin >> x;
    long long ans;
    ans=2*(x/11);
    if(x%11>6) ans+=2;
    else if(x%11==0) {}
    else ans++;
    cout << ans << endl;



}


Measured memory_bytes: 256
n = int(input())
curr_max = 0
ans = 0
for i in range(n):
    a = int(input())
    if i == 0:
        ans += (a-1)
        curr_max = 1
    else:
        step = curr_max + 1
        if a > step: 
            diff = a - 1
            ans += diff//step
        else:
            curr_max = max(a, curr_max)
            # print(i, curr_max)

print(ans)


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

#define llint long long int
#define pb push_back

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a;
  int as = n;
  while(as--){
    int k;
    cin >> k;
    while(k--){
      int temp;
      cin >> temp;
      a.pb(temp);
    }
  }
  sort(a.begin(), a.end());
  a.pb(1000000);
  int num = 1;
  int ans = 0;
  for(int i = 0; i < a.size()-1; i++){
    if(num == n){
      ans++;
    }
    if(a[i] == a[i+1])
      num++;
    else
      num = 1;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
_ = input()
a = list(map(int, input().split()))
counter = {}

for a_ in a:
    if a_ in counter.keys():
        counter[a_] += 1
    else:
        counter[a_] = 1

ans = 1
cnt = 0

counter = sorted(counter.items(), key=lambda x: x[0],
                 reverse=True)

for k, v in counter:
    while v >= 2:
        if cnt == 2:
            break

        ans *= k
        cnt += 1
        v -= 2

if cnt != 2:
    print(0)
else:
    print(ans)


Measured memory_bytes: 21896
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        Integer A = sc.nextInt();
        Integer B = sc.nextInt();

        int result = A >= 13 ? B :
                       A <= 5 ? 0 :
                       B / 2;
        System.out.println(result);
    }

}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    cout << setprecision(20);
    ll n;
    cin >> n;
    vll a(n-1), b(n-1);
    rep(i, n-1) cin >> a[i] >> b[i];

    vector<set<ll>> e(n);
    rep(i, n-1){
        e[a[i]-1].insert(b[i]-1);
        e[b[i]-1].insert(a[i]-1);
    }

    vector<map<ll, ll>> m(n);
    function<ll(ll, ll, ll)> dfs = [&](ll lc, ll lv, ll v){
        ll cc = 0;
        ll colors = 0;
        for(ll nv : e[v]){
            if(nv==lv) continue;
            if(cc==lc) ++cc;
            m[v][nv] = cc;
            m[nv][v] = cc;
            ll tc = dfs(cc, v, nv);
            colors = max(colors, tc);
            colors = max(colors, cc);
            ++cc;
        }
        return colors;
    };
    ll colors = dfs(-1, -1, 0);
    cout << colors+1 << endl;
    rep(i, n-1){
        cout << m[a[i]-1][b[i]-1]+1 << endl;
    }
}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

const ll mod = 1000000007;


int main() {
    int n,k;
    cin >> n >> k;
    if ((n-1)*(n-2)/2 < k) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, int>> ans(0);
    rep(i,n-1) {
        ans.push_back({i+1, n});
    }
    // rep(i,n-1) cout << ans[i].first << ans[i].second << endl;
    int cnt = (n-1)*(n-2)/2;
    rep(i,n-1) {
        for (int j = i+1; j < n-1; j++) {
            if (cnt == k) {
                cout << ans.size() << endl;
                for (pair<int, int> x : ans) {
                    printf("%d %d\n", x.first, x.second);
                }
                return 0;
            }
            ans.push_back({i+1,j+1});
            cnt--;
        }
    }
    if (cnt == k) {
        cout << ans.size() << endl;
        for (pair<int, int> x : ans) {
            printf("%d %d\n", x.first, x.second);
        }
    }
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
int main(){
    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a>=3200){
        
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    int ans=0;
    
    if(n>0&&m>0){
        ans=(n*(n-1)/2+m*(m-1)/2);
    }
    else if(n==0){
        ans=(m*(m-1)/2);
    }
    else{
        ans=(n*(n-1)/2);
    }
    
    cout<<ans;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
s = int(input())
dp = [0] * (s + 1)
dp[0] = 1
ans = 0
for i in range(s):
    tmp = 0
    for j in range(s + 1):
        tmp += dp[j]
        dp[j] += tmp - dp[j]
        dp[j] %= MOD
    if s - (i + 1) * 3 < 0:
        break
    ans += dp[s - (i + 1) * 3]
print(ans % MOD)


Measured memory_bytes: 66212
#include "bits/stdc++.h"
using namespace std;
vector<int> V[100005];
int Pos[100005];

void Solve( int N , int k ){
	int i , j , length , high;

	for( i = 1 ; i < k ; ++i )
		V[1].emplace_back( i );

	high = k;
	Pos[1] = 0;

	for( i = 2 ; i <= k ; ++i ){
		length = 0;
		Pos[i] = i - 1;

		for( j = 1 ; j < i ; ++j , ++length ){
			V[i].emplace_back( V[j][Pos[j]] );
			++Pos[j];
		}

		while( length < ( k - 1 ) ){
			V[i].emplace_back( high );
			++high;
			++length;
		}
	}
}

int main(){
	int N , value , length , i , j;
	scanf( "%d" , &N );
	value = sqrt( 8 * N + 1 );

	if( value * value != 8 * N + 1 ){
		puts( "No" );
		return 0;
	}
	else if( ( 1 + value ) % 2 ){
		puts( "No" );
		return 0;
	}
	else length = ( 1 + value ) / 2;

	Solve( N , length );
	printf( "Yes\n%d\n" , length );

	for( i = 1 ; i <= length ; ++i ){
		printf( "%d " , length - 1 );

		for( j = 0 ; j < ( length - 1 ) ; ++j )
			printf( "%d " , V[i][j] );

		puts( "" );
	}

	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

const ll mod = 1e9 + 7;


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

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

multiset<long long> prime_factorize(long long N) {
    multiset<ll> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        // 割れる限り割り続ける
        while (N % a == 0) {
            res.insert(a);
            N /= a;
        }
    }
    if (N != 1) res.insert(N);
    return res;
}

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    multiset<ll> lc;
    rep(i, n)
    {
        ll an=1;
        for(auto itr=lc.begin();itr!=lc.end();++itr){
            if(a[i]% *itr !=0){
                an*= *itr;
                an%=mod;
            }
            else a[i]/=*itr;
        }
        if(a[i]!=1){
            multiset<ll> e;
            e=prime_factorize(a[i]);
            for(auto itr=e.begin();itr!=e.end();++itr){
                lc.insert(*itr);
                ans*=*itr;
                ans%=mod;
            }
        }
        ans+=an;
        ans%=mod;
    }
    cout << ans % mod << endl;
}


Measured memory_bytes: 4164
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N, X, T;
    cin >> N >> X >> T;

    ll times;

    times = N / X;
    if(N % X != 0){
        times++;
    }

    cout << times * T << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
#define INF 1 << 30
#define MOD 1000000007;
#define pi 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

int main() { 
  int w, h, n;
  cin >> w >> h >> n;
  int xl = 0, xr = w, yb = 0, yt = h;
  for (int i = 0; i < n; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      if (xl < x) {
        xl = x;
      }
    } else if (a == 2) {
      if (x < xr) {
        xr = x;
      }
    } else if (a == 3) {
      if (yb < y) {
        yb = y;
      }
    } else {
      if (y < yt) {
        yt = y;
      }
    }
  }

  if (xr < xl || yt < yb) {
    D(0);
  } else {
    D((yt - yb) * (xr - xl));
  }
  return 0;
}



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

using namespace std;

int main() {
  int N;
  cin >> N;
  map< int, int > mp;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    mp[x]++;
  }
  int ret = 0;
  for(auto &p : mp) {
    if(p.second & 1) ++ret;
  }
  cout << ret << endl;
}



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

bool isValid(const vector<int> &v) {
  int d = v[1] - v[0];
  for(int i = 1; i+1 < v.size(); ++i) {
    if(v[i+1] - v[i] != d) return false;
  }
  return true;
}

int main() {
  int n;
  while(cin >> n && n) {
    int h[n+1];
    for(int i = 0; i < n+1; ++i) cin >> h[i];
    for(int k = 0; k < n+1; ++k) {
      vector<int> v;
      for(int i = 0; i < n+1; ++i) {
        if(i == k) continue;
        v.push_back(h[i]);
      }
      if(isValid(v)) {
        cout << h[k] << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1216
while true
  w, h = gets.split.map(&:to_i)
  break if w == 0
  xh = {}; yh = {}
  xa = []; ya = []
  xa << 0; xa << w
  ya << 0; ya << h
  points = []
  gets.to_i.times do
    point = gets.split.map(&:to_i)
    points << point
    xa << point[0]; xa << point[2]
    ya << point[1]; ya << point[3]
  end
  xa = xa.sort!.uniq; ya = ya.sort!.uniq
  xs = xa.size; ys = ya.size
  xa.each_with_index{ |a, i| xh[a] = i+1 }
  ya.each_with_index{ |b, i| yh[b] = i+1 }
  fld = Array.new(ys+1){ Array.new(xs+1, true) }
  fld[0].fill(false); fld[ys].fill(false)
  fld.map{ |arr| arr[0] = arr[xs] = false }
 
  for point in points
    x1, y1, x2, y2 = point
    for a in (yh[y1]...yh[y2])
      for b in (xh[x1]...xh[x2])
        fld[a][b] = false
      end
    end
  end
  ret = 0
  for y in (1...ys)
    for x in (1...xs)
      next unless fld[y][x]
      arr = []
      arr << [y, x]
      until arr.empty?
        ny, nx = arr.shift
        [[-1,0],[0,-1],[1,0],[0,1]].each do |dy, dx|
          px = nx+dx; py = ny+dy
          if fld[py][px]
            arr << [py, px] 
            fld[py][px] = false
          end
        end
      end
      ret += 1
    end
  end
  p ret
end

Measured memory_bytes: 14104
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
 
int main()
{
	int H, A;
	int res = 0;

	cin >> H >> A;

	if(H%A != 0){
		res += 1;
	}

	res += H/A;

	cout << res << endl;

	return 0;
}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    for (int i = 0; ; i++) {
        if (i % 2 == 0) {
            c -= b;
        } else {
            a -= d;
        }
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 200'000;
const int LOGN = 19;

int n, m, k;

void solve(int test)
{
  cin >> n;
  cout << n * n * n << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n,k;
cin >> n >> k;
i64 ans = 1;
rep(i,n){
    if(2 * ans > ans + k)ans += k;
    else ans *= 2;
}
cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <bits/stdc++.h>
#include<string>
using namespace std;
 
int main() {
    long long int x,k,d;
    cin>>x>>k>>d;
    long long int y;
    if(x>0)
    {
        long long int z = x/d;
        k = k-z;
        x = x - z*d;
        if(k%2==1&&k>0)
        y = x - d;
        else if(k<0)
        y = x - k*d;
        else
        y = abs(x);
    }
    else if(x==0)
    {
        if(k%2==1)
        y = x+d;
        else
        y = x;
    }
    else
    {
        long long int z = abs(x/d);
        k = k-z;
        x = x + z*d;
        if(k%2==1&&k>0)
        y = x + d;
        else if(k<0)
        y = x + k*d;
        else
        y = abs(x);
    }
    cout<<abs(y);
    return 0;
}

Measured memory_bytes: 3572
/*input
2 1 3 4
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ll long long 
#define ld long double
#define pii pair<int,int>
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define MP make_pair
const ll INF64=4e12;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1){
            res=(res*a)%MOD;
        }
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
const ll maxn=3000+5;
const ll maxlg=__lg(maxn)+2;
int dp[maxn][maxn];
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    dp[a][b]=1;
    for(int i=a;i<=c;i++){
        for(int j=b;j<=d;j++){
            if(i==a and j==b) continue;
            dp[i][j]=(mult(dp[i-1][j],j)+mult(dp[i][j-1],i)-mult(dp[i-1][j-1],mult((i-1),(j-1)))+MOD)%MOD;
        }
    }
    cout<<dp[c][d];
}

Measured memory_bytes: 38740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    ll k;
    cin >> s >> k;
    ll sl = len(s);
    // dp[position][count][smaller] = patterns
    vector<vector<vector<ll>>> dp(sl + 1, vector<vector<ll>>(k + 1, vector<ll>(2, 0)));
    dp[0][0][0] = 1;
    rep(i, sl) {
        rep(j, k + 1) {
            if (s[i] != '0') {
                if (j > 0) dp[i + 1][j][0] = dp[i][j - 1][0];
            }
            else {
                dp[i + 1][j][0] = dp[i][j][0];
            }
            if (j > 0) {
                dp[i + 1][j][1] += dp[i][j - 1][0] * max(0, s[i] - '0' - 1);
                dp[i + 1][j][1] += dp[i][j - 1][1] * 9;
            }
            if (s[i] != '0') dp[i + 1][j][1] += dp[i][j][0];
            dp[i + 1][j][1] += dp[i][j][1];
        }
    }
    cout << (dp[sl][k][0] + dp[sl][k][1]) << endl;
    return 0;
}


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<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;

struct point{
    ll x, y;
};

/*FUNCs=================================================*/



/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    int a, b, k, answer; cin >>a >> b >> k;

    for(int i = max(a, b); i > 0 && k > 0; i--){
        if(a%i == 0 && b%i == 0){
            answer = i;
            k--;
        }
    }

    cout <<answer << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
bool isSquare (int n) {
    for (int i=1; i*i<=n; i++) {
        if (i*i == n) {
            return true;
        }
    }
    return false;
}
int main() {
    int n, d;
    cin >> n >> d;
    int x[n][d];
    for (int i=0; i<n; i++) {
        for (int j=0; j<d; j++) {
            cin >> x[i][j];
        }
    }
    int cnt = 0;
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            int sum = 0;
            for (int k=0; k<d; k++) {
                sum += pow((x[i][k]-x[j][k]), 2);
            }
            if (isSquare(sum)) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = n * (n + 1) - 1  # 1とk 自信
 
    i = 2
    while i * i <= n:
        num = n // i
        min_i = i * i
        max_i = i * num
        ans += (num - i + 1) * (min_i + max_i)  # 自分自身
        ans -= min_i
        i += 1
    print(ans)
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 9056
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
	"unsafe"
)

var (
	sc scanner
)

func main() {
	s := sc.next()
	if s[2] == s[3] && s[4] == s[5] {
		yes()
	} else {
		no()
	}
}

/* template functions */

func init() {
	sc = scanner{
		buf: make([]string, 0, 10000),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 100)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}

func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}

func (s *scanner) resetCur() {
	s.cur = 0
}

func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}

func (s *scanner) nextByte() byte {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur][0]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}

func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur], 64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}

func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i, _ := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i], 64)
	}
	s.resetCur()
	return res
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// 切りあげ
func ceil(x float64) int {
	return int(math.Ceil(float64(x)))
}

// x^y % MOD
func pow(x, y int) (res int) {
	res = 1
	M := 1000000000 + 7
	for y > 0 {
		if (y & 1) == 1 {
			res = (res * x) % M
		}
		x = (x * x) % M
		y = y >> 1
	}
	return res
}

// lower_bound uses binary search to searches for x in a sorted slice of ints and returns the index as specified by Search.
// The return value is the index to insert x if x is not present (it could be len(a)). The slice must be sorted in ascending order.
//
// Searchable
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 60)
// => idx = 5
//
// No present
// idx := lower_bound([]int{-199, -1, 0, 2, 4, 67, 100, 8435}, 10000)
// => idx = 8

func lower_bound(a []int, x int) int {
	return sort.SearchInts(a, x)
}

func var_dump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}


Measured memory_bytes: 640
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
  constexpr auto none = numeric_limits<int>::max() / 2;
  int N, M, L;
  cin >> N >> M >> L;
  vector<vector<int>> graph(N + 1, vector<int>(N + 1, none));
  for (int i = 0; i < M; ++i) {
    int A, B, C;
    cin >> A >> B >> C;
    graph[A][B] = graph[B][A] = C;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      for (int k = 1; k <= N; ++k) {
        graph[j][k] = min(graph[j][k], graph[j][i] + graph[k][i]);
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      graph[i][j] = graph[i][j] <= L ? 1 : none;
    }
  }
  for (int i = 1; i <= N; ++i) {
    graph[i][i] = 0;
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      for (int k = 1; k <= N; ++k) {
        graph[j][k] = min(graph[j][k], graph[j][i] + graph[k][i]);
      }
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    int s, t;
    cin >> s >> t;
    cout << (graph[s][t] == none ? -1 : graph[s][t] - 1) << endl;
  }
}

Measured memory_bytes: 896
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#define for1(i,a,b) for(int i=a;i<=b;++i)
#define for2(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
struct node{int time,end;}m[200001];
inline bool cmp(node x,node y){return x.end<y.end;}
int t;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for1(i,1,n) cin>>m[i].time>>m[i].end;
	sort(m+1,m+1+n,cmp);
	for1(i,1,n){
		t+=m[i].time;
		if(t>m[i].end) cout<<"No",exit(0);
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int p[20001],a[20001],b[20001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>p[i];
    for(int i=1;i<=n;++i){
        a[i-1]=i*(n+1);
        b[n-i]=i*(n+1);
    }
    rep(i,n){
        a[p[i]-1]-=n-i;
        b[p[i]-1]-=n-i;
    }
    rep(i,n) cout<<a[i]<<" ";
    cout<<endl;
    rep(i,n) cout<<b[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll N,M,V,P;
vector<ll> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> M >> V >> P;
    for (int i = 0; i < N; i++)
    {
        ll a; cin >> a; A.push_back(a);
    }
    sort(A.begin(),A.end(),[](ll a, ll b){return a > b;});
}

bool C(int x){
    if(A[x]>=A[P-1]) return true;
    if((A[x]+M)<A[P-1]) return false;
    ll buffer = 0;
    buffer += M*(P-1);
    buffer += M*(N-1-x);
    for (int i = P-1; i <= x; i++)
    {
        buffer += (A[x]+M-A[i]);
    }
    return (buffer>=M*V);
}

int solve(){
    int ok = 0;
    int ng = N;
    DBG(A)
    while((ng-ok)>1){
        int mid = (ok+ng)/2;
        if(C(mid)) ok=mid;
        else ng=mid;
    }
    cout << (ok+1) << endl;
    return 0;        
}   

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


Measured memory_bytes: 1400
#include <iostream>

using namespace std;

main(){
  int h, w;
  char data[50][50];
  cin >> h >> w;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      cin >> data[i][j];
      data[i][j] -= '0';
    }
  }
  int dp[50][50];
  dp[0][0] = data[0][0];
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(i == 0 && j == 0){
      }else if(i == 0){
        dp[i][j] = dp[i][j-1] + data[i][j];
      }else if(j == 0){
        dp[i][j] = dp[i-1][j] + data[i][j];
      }else{
        dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + data[i][j];
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 0
def main():
    tar = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    N = int(input())
    S = input()
    ans = ""
    for s in S:
        ans = ans + tar[(tar.index(s) + N) % 26]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41068
function main(input) {
  const inputs = input.split('\n')
  // const N = Number(inputs[0])
  const Ai = inputs[1].split(' ').map(BigInt)
  if (Ai.includes(0n)){
    console.log(0)
    return
  }
  const l = Ai.length

  // const start = new Date()

  let r = 1n
  for(let i = 0; i < l; i++) {
    r *= Ai[i]
    if (r > 1000000000000000000n) {
      break
    }
  }
  if (r > 1000000000000000000n) {
    console.log(-1)
  } else {
    console.log(r.toString())
  }

  // const end = new Date()
  // console.log(end - start)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 42224
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v;
  int m = 0;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    m += k;
    v.push_back(k);
  }
  sort(v.begin(), v.end());
  int t = 0;
  while(m % 10 == 0 && t != n) {
    if (v[t] % 10 != 0) {
      m -= v[t];
    }
    t++;
  }
  if (m % 10 == 0) printf("0\n");
  else cout << m << endl;
  return 0;
}

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

int main()
{
    long long int a,b,c,d=0,e=0,f=0,g,h,i,j,k,l,p,q,r,s,t,n;
    cin>>n;
    for(i=1;i<=n;i++)
    {
       cin>>a>>b>>c;
       g=a+max(e,f);
       h=b+max(d,f);
       j=c+max(d,e);
       d=g;
       e=h;
       f=j;

    }
    cout<<max(g,max(h,j));

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,x,y,z;
    while(1){
        scanf("%d %d",&x,&y);
        if(x>y){
            z=x;
            x=y;
            y=z;
        }
        if(x==0&&y==0)
        break;
        printf("%d %d\n",x,y);
    }
    return 0;
}


Measured memory_bytes: 2040
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn solve(mut n:i64,en_num:& Vec<i64>) -> bool{
    let mut ret = true;
    while n != 0 {
        let x = n % 10;
        if !en_num.contains(&x){
            ret = false;
        }
        n /= 10;
    }
    ret
}

fn main() {
    let mut enable_num = vec![0,1,2,3,4,5,6,7,8,9];
    let n = read();
    let k = read();
    for _ in 0..k{
        let d = read();
        enable_num.retain(|&x| x != d);
    }

    let mut ans = n;

    while ans < 10*n {
        if solve(ans, &enable_num){
            break;
        }
        ans += 1;
    }

    println!("{}",ans);
}


Measured memory_bytes: 2124
#include<iostream>

using namespace std;

void insertionSort(int A[], int N){
    for(int i=1; i<N; i++){
        int v=A[i];
        int j=i-1;
        while(j>=0 && A[j]>v){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        for(int k=0; k<N-1; k++){
            cout<<A[k]<<" ";
        }
        cout<<A[N-1]<<endl;
    }
}

int main(){
    int N;
    int A[100];
    cin>>N;
    for(int i=0; i<N; i++)  cin>>A[i];
    for(int i=0; i<N-1; i++)  cout<<A[i]<<" ";
    cout<<A[N-1]<<endl;
    insertionSort(A, N);
    //cout<<endl;
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;
	ll ans=0;
	string s;
	cin >> s;
	i=0,n=sz(s);
	while(i<n)
	{
		j=i;
		while(j<n && s[i]==s[j])j++;
		if(s[i]=='R')
			ans=max(ans,j-i);
		i=j;
	}
	cout<<ans<<endl;
}

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

int v[1010];

int main() {
  int n, x;
  int counter = 0;
  int sum = 0;

  cin >> n >> x;

  for(int i = 0; i < n; i++){
    cin >> v[i];
    sum += v[i];
  }

  x = x - sum;
  counter = n;

  sort(v, v + n);

  for(; x > 0;){
    x = x - v[0];
    counter++;
  }

  if (x % v[0] == 0)
    cout << counter << endl;
  else
    cout << counter - 1 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
vector< int > g[N], a[2], b[3];
int n, m, c[N], ans[N];
void dfs(int v, int p){
	c[v] = c[p] ^ 1;
	a[c[v]].pb(v);
	for(auto to : g[v])
		if(to != p)
			dfs(to, v);
}            
int aa(int i){
	int x = a[i].back();
	a[i].pop_back();
	return x;
}
int bb(int i){
	int x = b[i].back();
	b[i].pop_back();
	return x;
}
void ff(int i, int j){
	while(a[i].size() && b[j].size())
		ans[aa(i)] = bb(j);
}
int main()
{
	scanf("%d", &n);
	m = n - 1;
	for(int i = 0; i < m; i++){
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].pb(u);
		g[u].pb(v);
	}
	dfs(1, 1);
	for(int i = 1; i <= n; i++)
		b[i % 3].pb(i);
	if(a[0].size() > a[1].size()){ //如果与1距离为偶的点的个数>与a的距离为奇数的点的个数 
		ff(0, 1); //与1偶数   模3为1 
	}else{
		ff(1, 1); //与1奇数   模3为1
	}        
	if(a[0].size() > a[1].size()){
		ff(0, 2); //与1偶数   模3为2 
	}else{
		ff(1, 2); //与1奇数    模3为2 
	}        
	ff(0, 0);
	ff(1, 0);
	assert(a[0].empty());
	assert(a[1].empty());
	for(int i = 1; i <= n; i++)
		printf("%d ", ans[i]);
}            

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

int main() {
  int w, h, n;
  cin >> w >> h >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> z(n);
  for (int i = 0; i < n; i ++) {
    cin >> x.at(i) >> y.at(i) >> z.at(i);
  }

  int a = 0, b = w, c = 0, d = h;
  for (int i = 0; i < n; i ++) {
    if (z.at(i) == 1) {
      a = max(a, x.at(i));
    } else if (z.at(i) == 2) {
      b = min(b, x.at(i));
    } else if (z.at(i) == 3) {
      c = max(c, y.at(i));
    } else {
      d = min(d, y.at(i));
    }
  }

  if (b - a > 0 && d - c > 0) {
    cout << (b - a) * (d - c) << endl;
  } else {
    cout << 0 << endl;
  }
}


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

int main() {
  int N,M;
  int sum = 0;
  cin >> N >> M;
  vector<int> A(M);
  rep(i,M)
  {
    cin >> A.at(i);
    sum += A.at(i);
  }
  if(sum <= N)
  {
    sum = N - sum;
  }
  else
  {
    sum = -1;
  }
  cout << sum << endl;

}


Measured memory_bytes: 3628