akhauriyash/Code-Regression huggingface dataset:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

n = int(input())
print("Yes" if n%9==0 else "No")









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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a,b,val=0;
	cin>>n>>a>>b;
	rep(i,2,n)
	{
		ll x;
		cin>>x;
		val^=x;
	}
	if((a+b-val)<0||(a+b-val)%2==1)
	{
		cout<<"-1\n";
		return 0;
	}
	ll ans=(a+b-val)/2;
	if(ans>a)
	{
		cout<<"-1\n";
		return 0;
	}
	for(int i=50;i>=0;i--)
	{
		if((1ll<<i)&val)
		{
			if(ans+(1ll<<i)<=a)
			{
				ans+=(1ll<<i);
			}
		}
	}
	if(((a+b-ans)^ans)!=val||ans==0)
	{
		cout<<"-1\n";
		return 0;
	}
	cout<<a-ans<<"\n";
	return 0;
}

Measured memory_bytes: 3656
MOD = 10 ** 9 + 7
N = int(input())

Sall = pow(10, N, MOD)
S0 = S9 = pow(9, N, MOD)
S09 = pow(8, N, MOD)

ans = (Sall - (S0 + S9 - S09)) % MOD
print(ans)

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

int main() {
  int N;
  cin >> N;
  int Y=0;

  for (int i =0; i<N; i++) {
    string x;
    cin >> x;
    if (x == "Y") {
     Y = 1;
     break;
    }
    else {
      continue;
    }
  }
  if (Y) {
    cout << "Four";
  }
  else {
    cout << "Three";
  }
}


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

int main()
{
    int n,m;
    double a;
    cin >> n >> m;
    priority_queue<double> pq;
    for(int i = 0 ; i < n ; i += 1){
        cin >> a;
        pq.push(a);
    }
    for(int i = 0 ; i < m ; i += 1){
        a = pq.top();
        a /= 2;
        pq.pop();
        pq.push(a);
    }
    long long ans = 0;
    while(pq.size() > 0){
        ans += floor(pq.top());
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
import sys
input=sys.stdin.readline
n=int(input())
s=list(input())
r=[]
g=[]
b=[]
for i in range(n):
    if s[i]=='R':
        r.append(i)
    elif s[i]=='G':
        g.append(i)
    else:
        b.append(i)
ans=len(r)*len(g)*len(b)
r=set(r)
g=set(g)
b=set(b)
for i in r:
    for j in g:
        if (i+j)%2==0 and ((i+j)//2 in b):
            ans-=1
for i in r:
    for j in b:
        if (i+j)%2==0 and ((i+j)//2 in g):
            ans-=1
for i in b:
    for j in g:
        if (i+j)%2==0 and ((i+j)//2 in r):
            ans-=1
print(ans)

Measured memory_bytes: 73940
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N, T int
	con.Scan(&N, &T)
	sum := 0
	last := -1
	for i := 0; i < N; i++ {
		var t int
		con.Scan(&t)
		if last >= 0 {
			if t < last+T {
				sum += t - last
			} else {
				sum += T
			}
		}
		last = t
	}
	sum += T
	con.Println(sum)
	return nil
}


Measured memory_bytes: 5504
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll A, B, C, K ;
    cin >> A >> B >> C >> K ;
    
    if( K % 2 == 1) cout <<  B - A << endl;
    else cout << A - B << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int N=gi();
        int M=gi();
       
        long s=0;
        for (int i=0; i<M;i++) {
        	s+=gi();
        }

        System.out.println(Math.max(N-s, -1));
	}


	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 41416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
    a[i]--;
  }
  ll ans = 0;
  ll p = 0;
  while (p != 1) {
    p = a[p];
    ans++;
    if (ans >= n + 5) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
n, p = gets.split.map(&:to_i)
as = gets.split.map(&:to_i).map { |n| n % 2 }

evens = as.count(0)
odds = as.count(1)

if odds == 0
  puts p == 0 ? 2 ** n : 0
else
  puts 2 ** (n - 1)
end


Measured memory_bytes: 3836
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = 0;

        while (A * ans - (ans - 1) < B) {
            ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int time = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0; i < n - 1; i++) {
            if (array[i + 1] - array[i] < time) {
                sum += (array[i + 1] - array[i]);
            } else {
                sum += time;
            }
        }
        sum += time;
        System.out.println(sum);
    }
}


Measured memory_bytes: 64140
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	int x, y, a, b; 
	cin >> x >> y; 
	for(int i = 0; i <= x; ++i) {
		a = i;
		b = x - i;
		if(2 * a + (4 * b) == y) {
			cout << "Yes" << endl;
			return;
			}
		}
		cout << "No" << endl;
		return;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
	int t;
		solve();
	return 0;
}
 















Measured memory_bytes: 3644
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	cin >> n;
	int a,ans=0;
	for (int i = 0;i < n;i++) {
		cin >> a;
		ans += (a - 1);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int V[] = new int[N];
		int C[] = new int[N];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			if (V[i] > C[i]) {
				ans += (V[i] - C[i]);
			}
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import numpy as np
import math


n,m,x = map(int, input().split())
lis = [np.asarray(list(map(int, input().split()))) for _ in range(n)]
lis = np.array(lis)

res = []
for i in range(2**n):
    t = np.array([0]*(m+1))
    for j in range(n):
        if ((i >> j) & 1):
            t += lis[j]
    res.append(t)

res = np.array(res)

z = math.inf

for i in res:
    if np.amin(i[1:]) >= x and i[0] < z:
        z = i[0]

print(z if z != math.inf else -1)

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

int N,A[100010] = {0};
int main(){
	cin >> N;
	for(int i=1;i<=N;i++) cin >> A[i];
	int ans = 1;
	int now = 0;
	for(int i=2;i<=N;i++){
		if(now==0){
			if(A[i-1]<A[i]) now = 1;
			else if(A[i-1]>A[i]) now = 2;
		}else if(now==1 && A[i-1]>A[i]){
			now = 0; ans++;
		}else if(now==2 && A[i-1]<A[i]){
			now = 0; ans++;
		}

	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
const int MAXN = 1e6 + 5;
long long  a[MAXN];
map <long long, long long>vis;
map <long long,long long>ans;
map <long long ,long long>sum;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        vis[a[i]]++;
    }
    sort(a+1, a+n+1);
    int b = 0,t = 0;
    for(int i = n; i >= 1; i -= vis[a[i]]){
        if(vis[a[i]] >= 4) {
            sum[++b] = a[i];
        }
        else if(vis[a[i]] >= 2) ans[++t] = a[i];
    }
    if(sum[1] > ans[1]){
        long long x = sum[1]*sum[1];
        printf("%lld\n",x);
    }
    else if(sum[1] < ans[1] && ans[2] > sum[1]){
        long long x = ans[1]*ans[2];
        printf("%lld\n",x);
    }
    else if(sum[1] < ans[1] && sum[1] > ans[2]) {
        long long x = sum[1]*ans[1];
        printf("%lld\n",x);
    }
    else printf("0\n");

}

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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    ll n, k;
    cin >> n >> k;

    cout << min(n % k, abs(n % k - k));

    return 0;
}


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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 10001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int a[5000];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    int cost = 50000 * 1000;
    for (int val = -200; val <= 200; ++val) {
        int cur = 0;
        for (int i = 1; i <= n; ++i) {
            cur += (val - a[i]) * (val - a[i]);
        }
        cost = min(cost, cur);
    }
    cout << cost;
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



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

int main() {
  string str = "Good";
  int a, b, c, d;
  cin >> a;
  b = a / 1000;
  c = (a - b * 1000) / 100;
  d = (a - b * 1000 - c * 100) /10;
  a = a % 10;
  if(a == d || b == c || c == d){
    str = "Bad";
  }
  cout << str << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
long long n, k, s, ans, a[5005];
int main() {
	int i;
	cin>>n>>k;
	for(i=0; i<n; i++) cin>>a[i];
	sort(a, a+n);
	for(i=n-1; i>=0; i--) {
		if(s+a[i]>=k) ans = 0;
		else ans++, s += a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
k=int(input())
#n,k=map(int,input().split())
#pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
from collections import deque
q=[i for i in range(1,10)]
q=deque(q)

for i in range(k):
    val=q.popleft()
    mod=val%10
    for add in range(max(mod-1,0),min(mod+1,9)+1):
        q.append(val*10+add)
print(val)


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

int main(){
  ll N,x;cin>>N;
  set<ll> s;
  int a=0;
  int b;
  
  rep(i,N){
    cin>>x;
    
    if(s.find(x) != s.end()){
      a=1;
      break;
    }
    s.insert(x);
    
  }
  if(a==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
  
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n - 1; i++) cin >> c[i];

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += b[a[i] - 1];
        if(a[i]+1 == a[i + 1]){
            ans += c[a[i] - 1];
        }
    }
    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();
    int d[]=new int[n];
    for (int i=0;i<n;i++) {
      d[i]=sc.nextInt();
    }
    int total=0;

    for (int i=0;i<n-1;i++) {
      for (int j=1+i;j<n;j++) {
        total+=d[i]*d[j];
      }
    }

    System.out.println(total);
  }
}


Measured memory_bytes: 21460
#include <cstdio>
#include <algorithm>

using namespace std;

int second(int h, int m, int s) {
	return h * 3600 + m * 60 + s;
}

int main() {
	int n;
	int train[24 * 60 * 60];
	const int trainNum = sizeof train / sizeof train[0];
	while (true) {
		scanf("%d", &n);
		if (n == 0) {
			break;
		}
		for (int i = 0; i < trainNum; i++) {
			train[i] = 0;
		}
		for (int i = 0; i < n; i++) {
			int h1, m1, s1, h2, m2, s2;
			scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
			int tmp1 = second(h1, m1, s1);
			int tmp2 = second(h2, m2, s2);
			train[tmp1]++;
			train[tmp2]--;
		}
		int a = 0;
		int ans = 0;
		for (int i = 0; i < trainNum; i++) {
			a += train[i];
			ans = max(a, ans);
		}
		printf("%d\n", ans);

	}

	return 0;
}

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

int N, A, B;
char S[100000];
int pass = 0;
int pass_abroad = 0;

int main(){
    cin >> N >> A >> B;
    // for (int i = 0; i < N; i++)
    // {
        
    //     /* code */
    // }

    for (int i = 0; i < N; i++)
    {
        cin >> S[i];
        if (S[i] == 'a')
        {
            if(pass < A + B){
                pass++;
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if (S[i] == 'b'){
            if(pass < A + B && pass_abroad < B){
                pass++;
                pass_abroad++;
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }

        /* code */
    }
    
}

Measured memory_bytes: 3660
import sys
input = sys.stdin.readline

n,m,x = (int(x) for x in input().split())
seq = []
for _ in range(n):
    seq.append([int(i) for i in input().split()])
ans = float('inf')
for i in xrange(2**n):
    cost = 0
    knowledge = [0 for _ in xrange(m)]
    for j, c in enumerate(bin(i)[2:], n-len(bin(i)[2:])):
        if c =='1':
            cost += seq[j][0]
            for k in xrange(m):
                knowledge[k] += seq[j][1+k]
    if all([val >= x for val in knowledge]):
        ans = min(cost, ans)
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 73684
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y))
#define PI 3.14159265359
typedef long long LL;
typedef vector<vector<int>> Graph;
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
template <class T> inline T mpower(T x, T n) {
    if(n == 0) {
        return 1;
    } else if(n % 2 == 0) {
        return mpower(x * x % MOD, n / 2);
    } else {
        return x * mpower(x, n - 1) % MOD;
    }
}
LL mfrac(LL x) {
    LL res = 1;
    for(LL i = x; i >= 1; i--) {
        res *= i;
        res %= MOD;
    }
    return res;
}
LL mcomb(LL n, LL r) {

    if(n == 0 and r == 0) {
        return 1;
    } else if(n < r || n < 0) {
        return 0;
    }

    LL res = mfrac(n) * mpower(mfrac(r), MOD - 2) % MOD;
    res *= mpower(mfrac(n - r), MOD - 2) % MOD;

    return res;
}

int main(void) {
    int N;
    string S;
    cin >> N >> S;

    rep(i, S.size()) {
        if(S[i] + N > 'Z') {
            cout << char(S[i] + N - 26);
        } else {
            cout << char(S[i] + N);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a>b)
  {a=a+b;
   b=a-b;a=a-b;
  }
  for(int i=1;i<=b;i++)
    cout<<a;
}

Measured memory_bytes: 256
def solve():
    import sys

    input = sys.stdin.readline

    # usage: update, query = SegmentTreeClosure(init_val=dp, segfunc=max, ide_ele=0)
    # 再帰なしsegment tree
    # https://proc-cpuinfo.fixstars.com/2017/07/optimize-segment-tree/
    # class版original: @solzard_
    def SegmentTreeClosure(init_val, segfunc, ide_ele) -> 'update,query':
        size = 1 << (len(init_val) - 1).bit_length()

        # _build
        tree = [ide_ele] * (size * 2 - 1)
        for idx, val in enumerate(init_val, size - 1):  # set
            # modify val if needed (e.g. str -> ord())
            tree[idx] = val
        for idx in range(size - 2, -1, -1):  # build
            tree[idx] = segfunc(tree[idx * 2 + 1], tree[idx * 2 + 2])

        # closure_1
        def update(idx: int, val) -> None:
            nonlocal size
            nonlocal tree
            nonlocal segfunc

            idx += size - 1
            # modify val if needed as same as in _build()
            tree[idx] = val
            while idx > 0:
                idx = (idx - 1) // 2
                tree[idx] = segfunc(tree[idx * 2 + 1], tree[idx * 2 + 2])

        # closure_2
        def query(left: int, right: int) -> 'result':
            nonlocal size
            nonlocal tree
            nonlocal segfunc

            left += size
            right += size
            ret = ide_ele  # left >= right: return ide_ele
            while left < right:  # どの段も奇偶...順
                if left % 2:  # odd
                    ret = segfunc(ret, tree[left - 1])
                    left += 1
                if right % 2:  # odd
                    right -= 1
                    ret = segfunc(ret, tree[right - 1])
                left //= 2
                right //= 2

            return ret

        return update, query

    n = int(input())
    h = tuple(map(int, input().split()))
    a = tuple(map(int, input().split()))

    dp = [0] * (n + 1)
    # dp[j] := 末尾jの単調増加列の美しさの総和の最大値

    update, query = SegmentTreeClosure(init_val=dp, segfunc=max, ide_ele=0)
    for h_, a_ in zip(h, a):
        # i本目を取って末尾にするとき
        max_ = query(0, h_) + a_
        update(h_, max_)
    print(query(0, n + 1))


solve()


Measured memory_bytes: 122960
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



a,b,n = MI()
i = min(n,b-1)
tmp = floor((a*i)/b) - a*floor(i/b)
print(tmp)

# n,m,q = MI()
# A =[]
# B = []
# C = []
# D = []

# for _ in rage(q):
# 	a,b,c,d = MI()
# 	A.append(a)
# 	B.append(b)
# 	C.append(c)
# 	D.append(d)

# for i in range(n):



Measured memory_bytes: 68020
#include<iostream>

using namespace std;

int main(){
  int h, w, hchk[109], wchk[109];cin >> h >> w;
  char a[109][109];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<h;i++){
    bool tmp=true;
    for(int j=0;j<w;j++){
      if(a[i][j]=='#'){
        tmp=false;
        break;
      }
    }
    if(tmp)hchk[i]=1;
  }
  for(int i=0;i<w;i++){
    bool tmp=true;
    for(int j=0;j<h;j++){
      if(a[j][i]=='#'){
        tmp=false;
        break;
      }
    }
    if(tmp)wchk[i]=1;
  }
  for(int i=0;i<h;i++){
    if(hchk[i]==1)continue;
    for(int j=0;j<w;j++){
      if(wchk[j]==1)continue;
      cout << a[i][j];
    }
    cout << endl;
  }
}

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

#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define pi acos(-1)
#define flag bool fl=true;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {


    int n;
    cin>>n;
    set<string>s;
    for(int i=0; i<n; i++)
    {
        string t;
        cin>>t;
        s.insert(t);

    }
    cout<<s.size()<<endl;
    return 0;
}

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

using namespace std;

int main() {
    unsigned long long n;
    cin >> n;
    vector<long long> a(n);
    for(unsigned long long i = 0; i < n; ++i) cin >> a[i];
    unsigned long long op_1 = 0;
    long long sum = 0;
    for (unsigned long long i = 0; i < n; ++i) {
        sum += a[i];
        if (i % 2 == 0) {
            while (sum <= 0) {
                ++sum;
                ++op_1;
            }
        }
        else {
            while (sum >= 0) {
                --sum;
                ++op_1;
            }
        }
    }
    unsigned long long op_2 = 0;
    sum = 0;
    for (unsigned long long i = 0; i < n; ++i) {
        sum += a[i];
        if (i % 2 == 0) {
            while (sum >= 0) {
                --sum;
                ++op_2;
            }
        }
        else {
            while (sum <= 0) {
                ++sum;
                ++op_2;
            }
        }
    }
    cout << min(op_1, op_2) << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include<math.h>
typedef struct {
double x;
double y;
} XY;
void koch(int,XY,XY);
void show(XY);
int main(void) {
int i,n;
XY p1={0,0},p2={100,0};

scanf("%d",&n);
show(p1);
koch(n,p1,p2);
show(p2);
  return 0;
}
void koch(int n,XY p1,XY p2){
XY s,t,u;
if(n==0)
return;
s.x=(2.0*p1.x+p2.x)/3.0;
t.x=(p1.x+2.0*p2.x)/3.0;
s.y=(2.0*p1.y+p2.y)/3.0;
t.y=(p1.y+p2.y*2.0)/3.0;
u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;
koch(n-1,p1,s);
show(s);
koch(n-1,s,u);
show(u);
koch(n-1,u,t);
show(t);
koch(n-1,t,p2);

}
void show(XY p){

  printf("%lf %lf\n",p.x,p.y);
}


Measured memory_bytes: 2104
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, K, kari;
	cin >> N >> K;

	int k = N - K;
	int A[100000];
	char kotae[800000], *it = kotae;

	if (k <= K) {
		rep(i, k) cin >> A[i];
		rep(i, K - k) cin >> kari;
		rep(i, k) {
			cin >> kari;
			if (kari > A[i]) {
				*it++ = 'Y';
				*it++ = 'e';
				*it++ = 's';
				*it++ = '\n';
			}
			else {
				*it++ = 'N';
				*it++ = 'o';
				*it++ = '\n';
			}
		}
	}
	else {
		rep(i, K) cin >> A[i];
		int kazu = k / K;
		int amari = k % K;
		rep(j, kazu) rep(i, K) {
			cin >> kari;
			if (kari > A[i]) {
				*it++ = 'Y';
				*it++ = 'e';
				*it++ = 's';
				*it++ = '\n';
			}
			else {
				*it++ = 'N';
				*it++ = 'o';
				*it++ = '\n';
			}
			A[i] = kari;
		}
		rep(i, amari) {
			cin >> kari;
			if (kari > A[i]) {
				*it++ = 'Y';
				*it++ = 'e';
				*it++ = 's';
				*it++ = '\n';
			}
			else {
				*it++ = 'N';
				*it++ = 'o';
				*it++ = '\n';
			}
		}
	}

	fwrite(kotae, 1, it - kotae, stdout);


	Would you please return 0;
}

Measured memory_bytes: 4380
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

#a = list(map(int, input().split()))


a = int(input())

times=0

for i in range(999):
    if(a==0):
        break
    a = a//2
    times+=1
    


print(2**times-1)

Measured memory_bytes: 65516
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	const int A = inputVal<int>();
	const int B = inputVal<int>();
	outputVal(min(N*A, B));
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        int ans = 0;
        for (int i = 0; i < 3; i++) {
            if (S.charAt(i) == T.charAt(i))
                ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22864
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    uint n;
    cin >> n;

    vector<bool> s(13), h(13), c(13), d(13);

    for (uint i = 0; i < n; i++) {
        char type;
        uint num;
        cin >> type >> num;
        num--;

        switch (type) {
        case 'S':
            s[num] = true;
            break;

        case 'H':
            h[num] = true;
            break;

        case 'C':
            c[num] = true;
            break;

        default:
            d[num] = true;
            break;
        }
    }

    for (size_t i = 0; i < s.size(); i++) {
        if (!s[i]) {
            printf("S %d\n", i + 1);
        }
    }
    for (size_t i = 0; i < h.size(); i++) {
        if (!h[i]) {
            printf("H %d\n", i + 1);
        }
    }
    for (size_t i = 0; i < c.size(); i++) {
        if (!c[i]) {
            printf("C %d\n", i + 1);
        }
    }
    for (size_t i = 0; i < d.size(); i++) {
        if (!d[i]) {
            printf("D %d\n", i + 1);
        }
    }
}



Measured memory_bytes: 3148
#include<cstdio>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef double db;
#define ls(x) x<<1
#define rs(x) x<<1|1
#define low(x) (x&-x)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define X first
#define Y second
#ifdef _DEBUG
    const int N=1e6+10;
#else
    const int N=1e6+10;
#endif
const ll mod=1e9+7;
template<typename T> inline T gcd(T a,T b){return !b?a:gcd(b,a%b);}
template<typename T> inline T q_pow(T a,T x){T ans=1,tmp=a;while(x){if(x&1)(ans*=tmp)%=mod;(tmp*=tmp)%=mod;x>>=1;}return ans;}
template<typename T> inline void re(T &N){int f=1;char c;while((c=getchar())< '0'||c> '9')if(c=='-')f=-1;N=c-'0';while((c=getchar())>='0'&&c<='9')N=N*10+c-'0';N*=f;}
int m,n,k,t=1,st,en;
ll p[N];
ll mul[N],inv[N];
inline ll C(int m,int n)
{
    if(m< 0||m> n)return 0;
    return mul[n]*inv[m]%mod*inv[n-m]%mod;
}

int main()
{
    // freopen("data.txt","r",stdin);
    p[0]=1;
    for(int i=1;i< N;i++)p[i]=p[i-1]*3%mod;
    inv[0]=mul[0]=1;
    for(int i=1;i< N;i++)mul[i]=mul[i-1]*i%mod,inv[i]=q_pow(mul[i],mod-2);
    re(n);re(m);re(k);
    ll ans=0,s1=0,s2=0;
    for(int i=0;i<=m+k;i++)
    {
        if(!i)s1=1;
        else if(i<=m)(s1*=2)%=mod;
        else s1=(((s1-C(m,i-1))*2+C(m,i-1))%mod+mod)%mod;

        if(i-k> 0)(s2=s2*2+C(i-k-1,i-1))%=mod;

        (ans+=C(n-1,n+i-1)*p[m+k-i]%mod*(s1-s2+mod)%mod)%=mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 23808
#include<stdio.h>
#include<string.h>
char s[50];

int main(){
	gets(s);
	int len=strlen(s);
	for(int i=0;i<len;i++){
		if(s[i]==',')	s[i]=' ';
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
// 139 B-Power Socket
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    // 入力
    int A, B;
    cin >> A >> B;

    int sashikomiguthi = 1;
    int tap_num = 0;
    while (true) {
        if (sashikomiguthi >= B) {
            break;
        } else {
            tap_num++;
            sashikomiguthi += A - 1;
        }
    }

    cout << tap_num << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
//#define MOD 1000000007LL
#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[&](auto f,auto... args){return f(f,args...);};

int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        s[i]='x';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vl cum(n + 1);
  cum[0] = 0LL;
  REP(i, n) {
    cin >> cum[i + 1];
    cum[i + 1] += cum[i];
  }

  vl s;
  REP(i, n) {
    FOR(j, i, n + 1) { s.push_back(cum[j] - cum[i]); }
  }

  vi bit(41, 0);
  int m = s.size();
  REP(i, m) {
    ll tmp = s[i];
    int c = 0;
    while (tmp != 0) {
      tmp /= 2;
      c++;
    }
    bit[c]++;
  }

  int sum = 0;
  int ki = 0;
  for (int i = 40; i >= 0; i--) {
    sum += bit[i];
    if (sum >= k) {
      ki = i;
      break;
    }
  }

  vl tv;
  REP(i, m) {
    if ((s[i] & (1LL << (ki - 1))) != 0) {
      tv.push_back(s[i]);
    }
  }
  ll ans = (1LL << (ki - 1));
  ki--;

  for (int i = ki; i >= 1; i--) {
    vl ttv;
    ll mask = (1LL << (i - 1));
    REP(i, tv.size()) {
      if ((mask & tv[i]) != 0LL) {
        ttv.push_back(tv[i]);
      }
    }
    if (ttv.size() >= k) {
      ans += mask;
      tv = ttv;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6516
#include<stdio.h>
#define swap(a,b)({a ^= b; b ^= a; a ^= b;})

int main(){
    int a, b;
    while(1){
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0)break;
        if(a>b)swap(a,b);
        printf("%d %d\n", a, b);
    }
return 0;
}



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

long long int N, a[364364], b, i;

int main(){
    scanf("%lld", &N);
    for(; i < N; ++i){
        scanf("%lld", &b);
        a[i + 1] = a[i] + b;
    }
    b = 1145141919810LL;
    for(i = 1; i < N; ++i){
        b = min(abs(a[N] - a[i] * 2), b);
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 1920
#include<stdio.h>
#include<string.h>
int main()
{
    char S[4];
    scanf("%s",S);
        if((S[0]!=S[1] && S[1]!=S[2]) && S[2]!=S[3] )
            {
            printf("Good\n");
        }
        else
            printf("Bad\n");




    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b;
  cin >> a >> b;
  int n = b-a;
  int cnt = 0;
  for (int i=1; i<=n; i++) {
    cnt += i;
  }
  int ans = cnt-b;
  cout << ans << endl;
}
    

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

vvi g;
vector<set<int> > gs;
vi degree;

set<int> universe;

void remove(int u, int v) {
  for (int w : gs[v]) {
    gs[w].erase(v);
  }
  universe.erase(u);
  universe.erase(v);
}

int degree1(int u) {
  int cnt = 0;
  for (int v : gs[u]) {
    if ((int)gs[v].size() == 1) {
      cnt += 1;
    }
  }
  return cnt;
}

int main() {
  int n;
  scanf("%d", &n);
  g.resize(n);
  gs.resize(n);

  rep (i, n-1) {
    int a, b;
    scanf("%d%d", &a, &b);
    a -= 1;
    b -= 1;
    g[a].push_back(b);
    g[b].push_back(a);
    gs[a].insert(b);
    gs[b].insert(a);
  }

  rep (i, n) {
    universe.insert(i);
  }

  deque<int> deg1;
  rep (i, n) {
    if ((int)gs[i].size() == 1) {
      deg1.push_back(i);
    }
  }

  while ((int)deg1.size() >= 2) {
    int u = deg1.front();
    debug(u);
    deg1.pop_front();
    bool continue_flag = false;
    for (int v : gs[u]) {
      if (degree1(v) >= 2) {
        printf("First\n");
        return 0;
      }
      if ((int)gs[v].size() <= 2) {
        remove(u, v);
        if ((int)gs[v].size() == 2) {
          for (int w : gs[v]) {
            if (w != u && (int)gs[w].size() == 1) {
              deg1.push_front(w);
            }
          }
        }
        continue_flag = true;
        break;
      }
      if (continue_flag) { continue; }
      deg1.push_back(u);
    }
  }

  if ((int)universe.size() == 1) {
    printf("First\n");
  } else {
    printf("Second\n");
  }

  return 0;
}


Measured memory_bytes: 22400
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] ch = s.toCharArray();
        String[] result = new String[ch.length];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            c += n;
            if (c >= 91) {
                c -= 26;
            }
            result[i] = String.valueOf(c);
        }
        System.out.println(String.join("", result));
    }

}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  vector<string> s(2);
  rep(i, 2) cin >> s[i];
  bool ans = true;
  rep(i, 2) rep(j, 3) if (s[(i + 1) % 2][j] != s[i][2 - j]) ans = false;
  Yes_No(ans);
}
int main(void) { solve(); }


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  string  ans="NO";
  if (a <= x && a + b >= x) ans = "YES";
  cout << ans << endl;
  return 0;
}


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

int solve(string S)
{
    long long Ssize = S.size();
    long long sum = 0;
    if (Ssize == 1)
    {
        int ss = S[0] - '0';
        cout << ss << endl;
        return 0;
    }

    for (long long bit = 0; bit < (1 << (Ssize - 1)); bit++)
    {
        string num = "";
        for (long long i = 0; i < Ssize; i++)
        //全体10桁だと, i→0 ~9箇所 Ssize-1と思ってしまっている。
        {
            num += S[i];
            //cout << Ssize << endl;
            /*if (i == 9)
            {
                cout << bitset<10>(bit) << endl;
                cout << bitset<10>(1 << i) << endl;
            }*/

            if (bit & (1 << i)) //0:nasi 1:+
            {
                if (i == 9)
                {
                    cout << num << endl;
                }
                sum += stoll(num);
                num = "";
            }
        }
        sum += stoll(num);
    }

    cout << sum << endl;
    return 0;
}

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


Measured memory_bytes: 256