akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

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

	    int x=gi();
        int a=gi();
        int b=gi();
        
	    int c= x-a;
	    while(c>=b) {
	    	c-=b;
	    }
        System.out.println(c);
//        if ((a*b) %2==0) {
//        	System.out.print("Even");
//        }else {
//        	System.out.print("Odd");
//        }


	}

	// 文字列として入力を取得
	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: 35556
#include <bits/stdc++.h>



using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}



int main() {

	ll a, b;
	cin >> a >> b;

	cout << a * b / gcd(a, b) << endl;

}

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

using namespace std;

#define MAXN int(1e5 + 10)

int n, dp[MAXN];
vector<int> adj[MAXN];

// fdsagfakjsdgfkasdf
//fasdfgaskgfkasdf
//asdfgasdkjfgaskjdf
int skjdfsakjhdkashdkhasdh = 213213;
long long dfadasdsadasdasd  = 11213121;

void dfs(int v, int par = MAXN) {
	int cnt = 0;
	for (auto e : adj[v])
		if (e ^ par) {
			dfs(e, v);
			dp[v] += dp[e];
			if (!dp[e])
				cnt++;
		}
	if (cnt)
		dp[v] += cnt - 1;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n; 
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[v].push_back(u);
		adj[u].push_back(v);
	}
	int root = 0;
	for (int i = 1; i < n; i++)
		if (adj[i].size() >= adj[root].size())
			root = i;
	if (adj[root].size() <= 2) return cout << 1 << endl, 0;
	dfs(root);
	cout << dp[root] << endl;
	//system("pause");
	return 0;
}

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

    
int main(){
    int a,b;
    cin >> a >> b;
    if(a>=13){cout << b << endl;}    
    if(a<13 && a>=6){cout << b/2 << endl;}
    if(a<=5){cout << 0 << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
	VL a(n); rep(i,n) cin>>a[i];
	const ll skip = 1+n%2;
	vector<VL> dp(n+2,VL(skip+1,-LINF));
	dp[0][0] = 0LL;
	for(ll i=0; i<=n; i++){
		for(ll j=0; j<=skip; j++){
			if(j<skip) chmax(dp[i+1][j+1],dp[i][j]);
			if(i<n) chmax(dp[i+2][j],dp[i][j]+a[i]);
		}
	}
	cout<<dp[n+1][skip]<<endl;
	return 0;
}


Measured memory_bytes: 15884
n,m = map(int,input().split())
vve = [list(map(int,input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,e in vve:
  graph[a].append((b,-e))
score = [10**15 for i in range(n+1)]
score[1] = 0
for j in range(n+1):
  flg = 0
  for i in range(m):
    v1,v2,e = vve[i]
    e = -e
    if score[v1] != 10**15 and score[v2] > score[v1]+e:
      score[v2] = score[v1]+e
      flg = 1
      if j == n-1:
        p = -score[n]
      if j == n:
        q = -score[n]
  if flg == 0:
    break
if flg == 0:
  print(-score[n])
else:
  if p == q:
    print(p)
  else:
    print("inf")

Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,s;
int dp[55][3003];

int main(void){
  while(cin >> n >> m >> s && n){
    memset(dp,0,sizeof(dp));
    dp[n*n][s] = 1;
    for(int i = 1; i <= m; i++){
      for(int j = 0; j < n*n; j++){
	for(int k = 0; k+i <= s; k++){
	  dp[j][k] += dp[j + 1][k + i];
	  dp[j][k] %= 100000;
	}
      }
    }
    cout << dp[0][0] << endl;
  }
}

Measured memory_bytes: 1808
#include <iostream>
using namespace std;
int main(void){
    
    int n;
    cin>>n;
    int v[25];
    int c[25];
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=max(0,v[i]-c[i]);
    }
    cout<<ans;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        int num = rint();
        int[] read = inta();
        int ans = 999999999;
        for(int i= 1;i<=100;i++){
            int total = 0;
            for(int j=0;j<num;j++){
                total += (read[j] - i) * (read[j] - i);
            }
            ans = Min(ans,total);
        }
        WriteLine(ans);
    
    
    
    
    
    
    }
    //各種読取
    static string rstr(){
        return ReadLine();
    }
    static int rint(){
        return int.Parse(ReadLine());
    }
    static long rlong(){
        return long.Parse(ReadLine());
    }
    static string[] stra(){
        return ReadLine().Split(' ');
    }
    static int[] inta(){
        string[] read_str_array = ReadLine().Split(' ');
        int[] return_int_array = new int[read_str_array.Length];
        for(int countup_i=0;countup_i<read_str_array.Length;countup_i++){
            return_int_array[countup_i] = int.Parse(read_str_array[countup_i]);
        }
        return return_int_array;
    }
    static int[,] inta2(int num_array,int in_array){
        int[,] int_array2 = new int[num_array,in_array];
        for(int i=0;i<num_array;i++){
            int[] temp_array = inta();
            for(int j=0;j<in_array;j++){
                int_array2[i,j] = temp_array[j];
            }
        }
        return int_array2;
    }
    // A/B小数点以下切上
    static int divideup(int divided,int divid){
        int temp_divide = divided/divid;
        if(divided % divid > 0){
            temp_divide++;
        }
        return temp_divide;
    }
}


Measured memory_bytes: 13140
//pragma GCC optimize("Ofast")
//pragma GCC optimize("unroint-loops")
//pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (int) a.size()
#define aint(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
//#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii ;
typedef vector<int>  vi ;
typedef vector<ii> vii ;


const int MAX = 1e5+6;
const ll inf = 5e18;
ll mod=998244353;



int main(){
	fastio;
	ld n,m;
	cin>>n;
	cout<<fixed<<setprecision(12)<<(n/3)*(n/3)*(n/3)<<endl;
}

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

map<int, int> cnt;
int n, a;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n ;
	for (int i = 0; i < n; i++){
		cin >> a;
		cnt[a] ++;
	}
	ll ans = 0;
	for (auto u:cnt){
		if (u.S < u.F) ans += u.S;
		else ans += u.S - u.F;
	}
	cout << ans;











	return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main(void)
{
	int a,b,i,c,cnt,flg;
	scanf("%d %d",&a,&b);
	c=b;
	cnt=0;
	while(1){
		if(c>0){
			c=c/10;
			cnt++;
		}
		else	break;
	}
	for(i=0;i<cnt;i++)	a*=10;
	flg=0;
	for(i=0;i<2000;i++)	{
		if(a+b==i*i)	flg=1;
	}
	if(flg==1)	printf("Yes\n");
	else	printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,x,y,z,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;

ll xorf(ll x){
    if(x%4==0)return x;
    else if(x%4==1)return 1;
    else if(x%4==2)return x+1;
    else if(x%4==3)return 0;
}


int main(){
    cin>>n>>m;
    p(xorf(n-1)^xorf(m));
    return 0;
}


Measured memory_bytes: 256
import copy
def acgt_2(t):
    w = ["A","C","G","T"]
    string_list = []
    for i in range(4):
        a = t // (4**(3-i))
        t = t % (4**(3-i))
        s = w[a]
        string_list.append(s)
    
    def acgt_sw(inst,a,b):
        st = copy.deepcopy(inst)
        st[a], st[b] = st[b], st[a]
        return "".join(st)

    
    string_list_2 = ["".join(string_list)] + [acgt_sw(string_list,i,i+1) for i in range(3)] 
    judge = False
    for i in string_list_2:

        if i[:3] == "AGC":
            judge = True

        if i[1:] == "AGC":
            judge = True

    return judge, "".join(string_list)
        

mod = 10**9+7
ng_list = []
for i in range(256):
    if acgt_2(i)[0]:
        ng_list.append(i)



n = int(input())
if n == 3:
    ans = 61
else:
    dp_list = [ 1 for i in range(4**4) ]
    for i in ng_list:
        dp_list[i] = 0

    for i in range(n-4):
        new_dp_list = [ 0 for i in range(4**4) ]
        for j in range(4**4):
            base = dp_list[j]
            new_index = [ 4*(j % 64) + k for k in range(4) ]
            for k in new_index:
                new_dp_list[k] += base
        for j in ng_list:
            new_dp_list[j] = 0
            dp_list = [ i%mod for i in new_dp_list]
    ans = sum(dp_list)%mod

print(ans)


Measured memory_bytes: 45148
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

ll pow_(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1)
      x = (x * a) % MOD;
    a = (a * a) % MOD;
    n >>= 1;
  }
  return x;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

ll dp[100003] = {};

int main() {
  ll N, W, M = 0;
  vector<ll> w, v;
  cin >> N >> W;
  REP(i, 100003) dp[i] = llINF;
  REP(i, N) {
    ll po, yo;
    cin >> po >> yo;
    w.push_back(po);
    v.push_back(yo);
    M += yo;
  }
  for (ll i = N - 1; i >= 0; i--) {
    for (ll j = M; j >= 0; j--) {
      if (dp[j] < llINF) {
        dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
      }
    }
    dp[v[i]] = min(dp[v[i]], w[i]);
  }
  for (ll i = M + 1; i >= 0; i--) {
    if (dp[i] <= W) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define H 251
#define N 2000000001
typedef struct{
  int key,p,dep,l,r;
}Tree;
Tree T[H];
 
int main(){
  int h,i;
 
  scanf("%d",&h); 
  for(i=1;i<=h;i++){
    T[i].p=T[i].l=T[i].r=N;
    scanf("%d",&T[i].key); 
  } 
 for(i=1;i<=h;i++){
   if(i!=1)T[i].p = T[i/2].key; 
   if(2*i<=h) T[i].l=T[2*i].key;  
   if(2*i+1<=h) T[i].r=T[2*i+1].key;
  }
 
  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,T[i].key);  
    if(i!=1) printf("parent key = %d, ",T[i].p); 
    if(T[i].l!=N) printf("left key = %d, ",T[i].l);
    if(T[i].r!=N) printf("right key = %d, ",T[i].r);  
    printf("\n");
  } 
  return 0;
}
 
  
    

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
char s[1000005];int n;
int main(){
    scanf("%s",s+1);n=strlen(s+1);
    printf("%s",((s[1]==s[n])^((n&1)==0))?"Second\n":"First\n");
    return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

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

#define N 1000010
#define MOD 1000000007

char str[N];
int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int a, b ,m;
	cin >> a >> b >> m;

	int a1[a], b1[b], ans = INT_MAX;

	for (int i = 0; i < a; ++i)
	{
		cin >> a1[i];
	}

	for (int i = 0; i < b; ++i)
	{
		cin >> b1[i];
	}

	ans = *min_element(a1, a1 + a) + *min_element(b1, b1 + b); 
	
	for (int i = 0; i < m; ++i)
	{
		int l, r, k;
		cin >> l >> r >> k;

		ans = min(ans, a1[l - 1] + b1[r - 1] - k);
		ans = max(0ll, ans);
	}

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

Measured memory_bytes: 1792
n=int(input())
x=list(map(int,input().split()))
imax=int(max(x))
imin=int(min(x))
lis=[]
re=0
for k in range(imax+1):
  for i in x:
    re=re+(i-k)**2
  lis.append(re)
  re=0
print(min(lis))

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

using namespace std;

int choose(const int &day, const int &last_activity, const int activities[][3], const int &n, int memo[][4]){
    int ans;
    if(day == n){
        ans = 0;
    }
    else{
        if(memo[day][last_activity] != -1){
            ans = memo[day][last_activity];
        }
        else if(last_activity == 0){
            ans = memo[day][0] = max(activities[day][0] + choose(day + 1, 1, activities, n, memo), max(activities[day][1] + choose(day + 1, 2, activities, n, memo), activities[day][2] + choose(day + 1, 3, activities, n, memo)));
        }
        else if(last_activity == 1){
            ans = memo[day][1] = max(activities[day][1] + choose(day + 1, 2, activities, n, memo), activities[day][2] + choose(day + 1, 3, activities, n, memo));
        }
        else if(last_activity == 2){
            ans = memo[day][2] = max(activities[day][0] + choose(day + 1, 1, activities, n, memo), activities[day][2] + choose(day + 1, 3, activities, n, memo));
        }
        else{
            ans = memo[day][3] = max(activities[day][0] + choose(day + 1, 1, activities, n, memo), activities[day][1] + choose(day + 1, 2, activities, n, memo));
        }
    }
    return ans;
}

int solve(const int activities[][3], const int &n, int memo[][4]){
    return choose(0, 0, activities, n, memo);
}

int main(){
    int n;
    while(scanf("%d", &n) != EOF){
        int activities[n][3], memo[n][4];
        for(int i = 0; i < n; i++){
            scanf("%d %d %d", &activities[i][0], &activities[i][1], &activities[i][2]);
            memo[i][0] = -1; memo[i][1] = -1; memo[i][2] = -1; memo[i][3] = -1;
        }
        printf("%d\n", solve(activities, n, memo));
    }
    return 0;
}

Measured memory_bytes: 17360
// C - Otoshidama

#include <bits/stdc++.h>
using namespace std;

int sum(int x, int y, int z);



int main()
{
    int N, Y;
    cin >> N >> Y;
//    cout << N << endl;
//    cout << Y << endl;
  
    int x=0; //10000円札の枚数
    int y=0; // 5000円札の枚数
    int z=0; // 1000円札の枚数
    bool flag = false;

    // 条件
    // x+y+z=N
    // 10000x+5000y+1000z=Y

    for(x=0; x<=N;x++)
    {
        for(y=0;y<=N;y++)
        {
            z = N-(x+y);
            //cout << x <<" " << y <<" " << z << endl;
            if(z<0)
            {
                continue;
            }
          
            if(sum(x,y,z)==Y)
            {
                flag=true;
              cout << x <<" " << y <<" " << z << endl;
              	return 0;
            }
        }
    }
	if(flag==false)
    {
        x=-1,y=-1,z=-1;
      cout << x <<" " << y <<" " << z << endl;
    }

}


int sum(int x, int y, int z)
{
    int ret = (10000*x) + (5000*y) + (1000*z);
    
    return ret;
}


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
   int a,b;
   cin>>a>>b;
   if(b%a==0){
       cout<<a+b<<endl;
   }else{
       cout<<b-a<<endl;
   }
    return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k, t;
    cin >> n >> k >> t;
    int x = n/k;
    if(n%k > 0){
        x++;
    }
    cout << x * t;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  for(int i=0; i<S.size(); i++) {
    for(int j=0; j<S.size(); j++) {
      if(i!=j) {
        if(S[i] == S[j]) {
          cout << "no";
          return 0;
        }
      }
    }
  }
  cout << "yes";
  return 0;
}

Measured memory_bytes: 256
//do not think about past and stay in this moment
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int prime[1000005];
void seive(){
	for(int i=2;i<1000005;++i){
		if(prime[i]==0)
		for(int j=2*i;j<1000005;j+=i)
			prime[j]=1;
	}
}			
int digit(int n){
	int xp=0;
	while(n!=0){
		n/=10;
		xp++;
	}
	return xp;
}
void q1(){
	string s,t;
	cin>>s>>t;
	cout<<t<<s;
}
void q2(){
	int a,b,k;
	cin>>a>>b>>k;
	int mn=min(a,k);
	a-=mn; k-=mn;
	mn=min(b,k);
	b-=mn; k-=mn;
	cout<<a<<" "<<b;
}
void q3(){
	int x;
	cin>>x;
	seive();
	while(prime[x])
	x++;
	cout<<x<<endl;
}
void q4(){
	
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q3();
	return 0;
}
	


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x,y;
	cin >> x>> y;
      cout << (x+y)%24 << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int seg_tree[1200000];

int dp[300001];

int find_max(int left , int right , int low , int high , int cur)
{
	if(left == low && right == high) 
	{
		return seg_tree[cur];
	}
	
	int mid = (left + right)/2;
	
	if(low >= left && high <= mid)
	{
		return find_max(left , mid , low , high , cur*2+1);	
	}
	else if(low > mid && high <= right)
	{
		return find_max(mid+1 , right , low , high , cur*2 + 2);
	}
	else
	{
		int low1 = max(left , low);
		int maxi1 = find_max(left , mid ,low1 , mid , cur*2+1);
		int high1 = min(right , high);
		
		int maxi2 = find_max(mid+1 , right , mid+1 , high1 , cur*2+2);
		
		return max(maxi1 , maxi2);
	}
	
}

void fix_it(int left , int right , int key , int ne , int cur)
{
	if(left == right)
	{
		seg_tree[cur] = max(ne , seg_tree[cur]);
		return;
	}
	
	int mid = (left + right)/2;
	
	if(key <= mid)
	{
		fix_it(left , mid , key , ne , cur*2+1);
	}
	else
	{
		fix_it(mid+1 , right , key , ne , cur*2+2);
	}
	
	seg_tree[cur] = max(seg_tree[2*cur+1] , seg_tree[2*cur+2]);
}

int main()
{
	int n,k;cin>>n>>k;
	
	vector<int> vec;
	
	for(int i = 0;i<n;i++)
	{
		int x;s(x);
		vec.push_back(x);	
	}
	
	int maxii = 0;
	for(int i = n-1;i>=0;i--)
	{
		int low = max(0 , vec[i]-k);
		int high = min(300000 , vec[i] + k);
		
		int maxi = find_max(0 , 300000, low , high , 0);
		
		dp[i] = 1 + maxi;
		
		maxii = max(maxii , dp[i]);
		
		fix_it(0 , 300000,vec[i], dp[i] , 0);	
	}
	
	
	cout<<maxii<<endl;
	
	
	return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> A(N + 2);
  for(int i = 1; i <= N; i++){
    cin >> A[i];
  }
  A[N + 1] = -1;
  sort(A.begin(), A.end());
  bool ans = true;
  for(int i = 1; i <= N; i++){
    if(A[i] == A[i + 1]) ans = false;
  }
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    double x,y,x1,y1;
    scanf("%lf %lf %lf %lf", &x,&y,&x1,&y1);
    printf("%lf ", x*(y/2));
    if(x1==x/2&&y1==y/2)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;




int main(){
    ll N;
    cin >> N;
    vector<ll> P(N);
    vector<ll> Q(N);
    for(int i=0;i<N;i++){
        cin>>P[i]
    ;}
    for(int i=0;i<N;i++){
        cin>>Q[i]
    ;}
    if(P<Q)swap(P,Q);
    ll counter=0;
    while(1){
        if(P==Q){break;}
        next_permutation(Q.begin(), Q.end());
        counter++;
    }
    cout<<counter<<endl;


return 0;
}  



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var S = new string[N];
        for (int i = 0; i < N; i++)
        {
            S[i] = ReadLine();
        }

        WriteLine(S.Distinct().Count());
    }
}


Measured memory_bytes: 48128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void dfs(int v,int vis[],vector<int> adj[],int dp[])
{
    vis[v] = 1;
    for(int i = 0; i<adj[v].size(); i++)
    {
        if(vis[adj[v][i]] == 0)
            dfs(adj[v][i],vis,adj,dp);
        dp[v] = max(dp[v],dp[adj[v][i]]+1);
    }
}

int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];
    for(int i = 0; i<m; i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    int vis[n+1] = {0};
    int dp[n+1] = {0};
    for(int i = 1; i<=n; i++)
    {
        if(vis[i] == 1)
            continue;
        dfs(i,vis,adj,dp);
    }
    int ans = 0;
    for(int i = 1; i<=n; i++)
        ans = max(ans,dp[i]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 13156
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
/// ye tec khaphan ke yadam bemone : age jayi didi soale masir hamiltoni mikhad rasasho bokon yal oilery;
/// age ye ja mikhasti to dp az ozv i k ta entekhab koni bejash ye log bezan (nominal) hamoon 2**k va o 1 ent kon

///\\\///\\\///\\\\\\\\\\\\\\\\\///\\\///\\\///

const int N=2e5,mod=1e9+7;
ll a[N];

int32_t main(){
    ll n;
    cin >> n;
    for (int i=0;i<n;i++){
        ll x;
        cin >> x;
        a[x]++;
    }
    ll ma=0;
    for (int i=1;i<N-1;i++){
        ma=max(ma,a[i]+a[i-1]+a[i+1]);
    }
    cout << ma;

}
















Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(br.readLine());

		int a=Integer.parseInt(st.nextToken());
		int b=Integer.parseInt(st.nextToken());
		int c=Integer.parseInt(st.nextToken());

		int d=0;

		if(a>b) {
			d=a;
			a=b;
			b=d;
		}
		if(b>c) {
			d=b;
			b=c;
			c=d;
		}
		if(a>b) {
			d=a;
			a=b;
			b=d;
		}
		System.out.println(a+" "+b+" "+c);
	}

}


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

int main() {
	string joi;
	while (cin >> joi) {
		int cjo=0,cio=0;
		int z = joi.size();
		for (int i = 0; i < z - 2; i++) {
			string sb = joi.substr(i, 3);
			if (sb == "JOI") { cjo++; }
			if (sb == "IOI") { cio++; }
		}
		cout << cjo << endl << cio << endl;
	}
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n, m;
  cin >> n >> m;
  vector<P> p(n);

  arep(i, p) cin >> i.first >> i.second;
  sort(all(p));

  max_heap<int> pq;
  int sum = 0, ans = 0;

  rep(i, 0, m + 1) {
    while (p[sum].first == i) {
      pq.push(p[sum].second);
      ++sum;
    }
    if (pq.size()) {
      ans += pq.top();
      pq.pop();
    } else
      continue;
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 2936
using System;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = input[0];
            var k = input[1];

            var ans = 0;

            while(n > 0)
            {
                n /= k;
                ans++;
            }
            Console.WriteLine(ans);
        }
    }
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

bool isEightDivisors(int p,int q,int m,int n){
  if( p ==  1 && q ==  0 ) return true;
  if( p ==  0 && q ==  1 ) return true;
  if( p == -1 && q ==  0 ) return true;
  if( p ==  0 && q == -1 ) return true;
  if( p ==  m && q ==  n ) return true;
  if( p == -n && q ==  m ) return true;
  if( p == -m && q == -n ) return true;
  if( p ==  n && q == -m ) return true;
  return false;
}

#define EPS (1e-8)

bool isSqrt(ll x){
  ll tmp = sqrt(x) + EPS;
  return tmp * tmp == x;
}

bool isPrime(int p,int q){
  int p2 = p * p, q2 = q * q;
  for(int a=1;a*a<=p2+q2;a++) {
    if( ( p2 + q2 ) % a ) continue;
    int b = ( p2 + q2 ) / a;

    int base_a = sqrt(a);
    int base_b = sqrt(b);

    for(int m=-base_a;m<=base_a;m++) {
      if( base_a * base_a > a ) continue;
      int n2 = a - m * m;

      if( !isSqrt(n2) ) continue;

      int n = sqrt(n2);

      if( ( m*m + n*n ) == 0 ) continue;

      if( !( ( m*p + n*q ) % ( m*m+n*n ) == 0 &&
             ( m*q - n*p ) % ( m*m+n*n ) == 0 ) ) continue;

      for(int x=-base_b;x<=base_b;x++){
        if( base_b * base_b > b ) continue;
        int y2 = b - x * x;
        //if( y2 <= 0 ) continue;
        if( !isSqrt(y2) ) continue;
        int y = sqrt(y2);
        //cout << m << "," << n << " " << x << "," << y << endl;
        /*
        if( !( ( m*x-n*y == p && m*y + n*x == q ) ||
               ( m*x-n*y == q && m*y + n*x == p ) ) ) continue;

        assert( ( m*x-n*y == p && m*y + n*x == q ) ||
                ( m*x-n*y == q && m*y + n*x == p ) );
        */
        
        if( !isEightDivisors(m,n,p,q) && !isEightDivisors(n,m,p,q) ) {
          return false;
        }

        if( !isEightDivisors(x,y,p,q) && !isEightDivisors(y,x,p,q) ) {
          return false;
        }
        
      }
    }
  }
  return true;
}

int main(){
  int T;
  cin >> T;
  rep(_,T){
    int n,m;
    cin >> n >> m;
    puts(isPrime(n,m)?"P":"C");
  }
  return 0;
}

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

int gcd(int a, int b){
  int x = max(a, b), y = min(a, b);
  if(y == 0){
    return x;
  }
  return gcd(y, x % y);
}

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

  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  int gcd_A = A[0];
  for(int i = 1; i < N; i++){
    gcd_A = gcd(gcd_A, A[i]);
  }

  cout << gcd_A << endl;
}

                            


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll D, G;
    cin >> D >> G;
    vector<ll> P(D), C(D);
    for ( int i = 0; i < D; i++ ) {
        cin >> P[i] >> C[i];
    }

    auto can_get_g = [&](ll n) {
        for ( int bb = 0; bb < 1<<D; bb++ ) {
            ll r = n;
            vector<ll> ns(D);
            for ( int b = 0; b < D; b++ ) {
                if ( (bb >> b) & 1 ) {
                    r -= P[b];
                    ns[b] = P[b];
                }
            }
            if ( r < 0 ) continue;
            for ( int b = D-1; b >= 0; b-- ) {
                ll d = min(P[b] - ns[b], r);
                ns[b] += d;
                r -= d;
            }
            ll s = 0;
            for ( int b = 0; b < D; b++ ) {
                s += ns[b] * (b+1) * 100;
                if ( ns[b] == P[b] ) s += C[b];
            }
            if ( s >= G ) return true;
        }
        return false;
    };

    ll ng = 0, ok = 1001;
    while ( ok - ng > 1 ) {
        ll m = ( ok + ng ) / 2;
        if ( can_get_g(m) ) ok = m;
        else ng = m;
    }
    return ok;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
'use strict';
function Main(stdin){
  const input = stdin.trim().split(/\r?\n/g);
  const S = input[0];
  const T = input[1];
  let count = 0;
  for(let i = 0; i < S.length; i++){
    if(S.charAt(i) !== T.charAt(i)) count++;
  }
  console.log(count);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33172
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 1000000007

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vector<vector<int>> data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
ll n, a, b, c, d;

int main() {
    cin >> n >> a >> b >> c >> d;
    ll lower, upper;
    lower = a - (n - 1) * d, upper = a - (n - 1) * c;
    ll tmp = c + d;
    for (int i = 0; i < n; ++i) {
        if (b >= lower && b <= upper) {
            cout << "YES";
            return 0;
        }
        lower += tmp, upper += tmp;
    }
    cout << "NO";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

void mainSolve()
{
  get(n);
  getvec(v, n);
  sort(all(v), greater<ll>());
  ll ans = 0;
  if (n == 1)
  {
    p1(0);
    return;
  }
  if (n == 2)
  {
    p1(v[0]);
    return;
  }
  ll num = 2;
  ll pos = 1;
  ans = v[0];
  while (num < n)
  {
    ans += v[pos];
    ++num;
    if (num == n)
      break;
    ans += v[pos];
    ++num, ++pos;
  }
  p1(ans);
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  //get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


Measured memory_bytes: 4692
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
int l;
const int maxN = 1e5 + 10;
int x[maxN];
const int LOG = 20;
int up[LOG][maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    cin >> l;
    for (int i = 1; i <= n; i++) {
        if (i == n) {
            up[0][i] = i;
            continue;
        }
        int p = upper_bound(x + 1, x + n + 1, x[i] + l) - x;
        p--;
        assert(p > i);
        up[0][i] = p;
    }
    for (int k = 0; k + 1 < LOG; k++) {
        for (int i = 1; i <= n; i++) {
            up[k + 1][i] = up[k][up[k][i]];
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        int ans = 0;
        for (int p = LOG - 1; p >= 0; p--) {
            if (up[p][a] < b) {
                ans += (1 << p);
                a = up[p][a];
            }
        }
        ans++;
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 9088
#include<stdio.h>
#define MAX 2000000

int size, A[MAX+1];

void maxHeapify(int i){
  int l, r, largest, t;
  l = 2*i;
  r = 2*i+1;
  if ( l <= size && A[l] > A[i] ) largest = l;
  else largest = i;
  if ( r <= size && A[r] > A[largest] ) largest = r;
  if ( largest != i ){
    t = A[i]; A[i] = A[largest]; A[largest] = t;
    maxHeapify(largest);
  }
}

main(){
  scanf("%d", &size);
  int i;
  for ( i = 1; i <= size; i++ ) scanf("%d", &A[i]);
  
  for ( i = size/2; i >= 1; i-- ) maxHeapify(i);

  for ( i = 1; i <= size; i++ ) {
    printf(" %d", A[i]);
  }
  printf("\n");
  

  
  return 0;
}




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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  rep (i, n) {
    char c = s[i];
    if (i == k - 1) c = c - 'A' + 'a';
    cout << c;
  }
  cout << endl;
}


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

using namespace std;
using ll = long long;

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

    int ans=0;
    bool ok = true;
    while(ok){
        int zeronum = 0;
        for(int i=0;i<n;i++){
            zeronum = 0;
            if(a[i]%2 == 1){
                cout<<ans<<endl;
                return 0;
            }
            else if(a[i] == 0){
                zeronum++;
            }
            else{
                a[i] /= 2;
            }
        }
        ans++;
        if(zeronum == n) ok = false;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let s: Vec<u8> = itr.next().unwrap().bytes().collect();

    let n = s.len();
    let mut tmp = n * 9;
    let mut pittari = 0;
    let mut ans = 0;
    for i in 0..n {
        tmp -= 9;
        let x = (s[i] - '0' as u8) as usize;
        if x > 0 {
            ans = max(ans, pittari + tmp + x - 1);
        }
        pittari += x;
        ans = max(ans, pittari);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	int x, t;
	cin >> x >> t;

	if (x - t > 0)
		cout << x - t << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N, M;
    cin >> N >> M;

    vi a(N);
    REP(i, N) cin >> a[i];

    int cnt = 0;
    int sum = accumulate(ALL(a), 0);
    REP(i, N) {
        if ((double) a[i] >= (double) sum/(4*M)) cnt++;
    }

    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

using ll = long long int;
ll A, B, Q;
const ll INMAX = 1000001;
ll s[INMAX], t[INMAX];
using namespace std;

#define INF 100000000000LL


ll bs_lower(ll a[], size_t n, ll target) {
  ll *p = lower_bound(a, a + n, target);

  if (p != a) {
    return *(p - 1);
  } else {
    return INF;
  }
}

ll bs_upper(ll a[], size_t n, ll target) {
  return *lower_bound(a, a + n, target);
}

ll lower_upper(ll a[], size_t n, ll target) {
  ll west = bs_upper(a, n, target);
  ll east = bs_lower(a, n, target);

  if (abs(west - target) < abs(east - target)) {
    return west;
  } else {
    return east;
  }
}

ll length(ll a, ll b, ll c)
{
  return abs(a - b) + abs(b - c);
}

int main() {
  cin >> A >> B >> Q;

  int i;
  for (i = 0; i < A; i++) {
    cin >> s[i];
  }
  s[i] = INF;

  for (i = 0; i < B; i++) {
    cin >> t[i];
  }
  t[i] = INF;

  for (i = 0; i < Q; i++) {
    ll x; cin >> x;
    ll res = INF;

    // s -> t
    {
      ll s0 = bs_lower(s, A, x);
      ll s1 = bs_upper(s, A, x);
      ll t0 = lower_upper(t, B, s0);
      ll t1 = lower_upper(t, B, s1);

      res = min({res, length(x, s0, t0), length(x, s1, t1)});
    }
    {
      ll t0 = bs_lower(t, B, x);
      ll t1 = bs_upper(t, B, x);
      ll s0 = lower_upper(s, A, t0);
      ll s1 = lower_upper(s, A, t1);

      res = min({res, length(x, t0, s0), length(x, t1, s1)});
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 6144
use proconio::{fastout, input};

fn main() {
    input! {
        x: i128
    };

    'outer: for a in -130..130 {
        let a = a as i128;
        for b in -130..130 {
            let b = b as i128;
            if a.pow(5) - b.pow(5) == x {
                println!("{} {}", a, b);
                break 'outer;
            }
        }
    }
}


Measured memory_bytes: 2124