akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

void dfs(int u, int p, VVI& G, VI& match){
  for(int to: G[u]){
	if(to == p) continue;
	dfs(to, u, G, match);
  }
  if(match[u] == -1 && p != -1 && match[p] == -1){
	match[u] = p;
	match[p] = u;
  }
}

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

  int N;
  cin >> N;
  VVI G(N);
  REP(i,N-1){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u].PB(v);
	G[v].PB(u);
  }

  VI match(N, -1);
  dfs(0, -1, G, match);
  bool win = false;
  REP(i,N) if(match[i] == -1) win = true;
  //REP(i,N) cout << match[i]<<endl;
  cout << (win? "First": "Second") << endl;

  return 0;
}


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

int main() {
    int n, cnt = 0, check=0;
    string s;
    cin >> n >> s;
    bool ca = false, cb = false;
    for (int i = 0; i < n; ++i) {
        char c = s[i];
        if (c == 'A') {
            check = 1;
            continue;
        }
        if (check == 1 && c == 'B') {
            check = 2;
            continue;
        }
        if (check==2 && c == 'C') ++cnt;
        check = 0; 
    } 
    cout << cnt << 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 a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int cnt = 0;
		if(a == b && b == c) {
			cnt = 1;
		} else if(a != b && b != c && a != c) {
			cnt = 3;
		} else {
			cnt = 2;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vvi			vector<vi>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define tr(c,i)		for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)	((c).find(x) != (c).end()) 
#define cpresent(c,x)	(find(all(c),x) != (c).end()) 
#define int ll
using namespace std;

#define N  100005

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		string s;
		cin >> s;

		if(s=="ABC")
			cout << "ARC";
		else
			cout << "ABC";
	}
	return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()
{
    int N ;
    cin >> N ;
    du res ;
    du tep ;

    if (N % 2 == 0) {

        res = 0.5 ;

        cout << res ;
    }

    else {

        tep = N / 2 + 1 ;

        cout << tep/N ;
    }
    return 0 ;
}


Measured memory_bytes: 256
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int M =1e5 ;
int n ;
int a[M][3];
int dp[M][3];
int solve (int i = 0, int last = 0 )
{
    if (i == n )return 0 ;
    int &ret = dp[i][last];
    if (~ret)return ret ;
    for (int j =0 ; j < 3 ; j++)
    {
        if (j == last && i )continue ;
        ret = max ( ret, a[i][j] + solve(i + 1, j ) ) ;
    }
    return ret;
}
int main()
{
    scanf ("%d", &n );
    memset(dp , -1 ,sizeof dp );
    for (int i =0 ; i < n ; i++)
    {
        scanf ("%d%d%d", a[i], a[i]+1, a[i] + 2 );
    }
    printf ("%d\n" , solve());

}


Measured memory_bytes: 10368
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

w,h,n=LI()
x,X=0,w
y,Y=0,h
for i in ' '*n:
    s,t,a=LI()
    if a==1:
        x=max(x,s)
    elif a==2:
        X=min(X,s)
    elif a==3:
        y=max(y,t)
    elif a==4:
        Y=min(Y,t)

print(max(0,X-x)*max(0,Y-y))


Measured memory_bytes: 39276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll ans=a*c;
    chmax(ans,a*d);
    chmax(ans,b*c);
    chmax(ans,b*d);
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxHeapify(int i){
  int l=left(i);
  int r=right(i);
  int largest,tmp;
  if(l<=H && A[l]>A[i])largest = l;
  else largest = i;

  if(r<=H && A[r]>A[largest])largest = r;

  if(largest!=i){
    tmp=A[i];
    A[i]=A[largest];
    A[largest]=tmp;
    maxHeapify(largest);
  }
}

int extract(){
  int maxv;
  if(H<1)return -INFTY;
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}

void increaseKey(int i,int key){
  int tmp;
  if(key<A[i])return;
  A[i]=key;
  while(i>1 && A[i/2]<A[i]){
    tmp=A[i];
    A[i]=A[i/2];
    A[i/2]=tmp;
    i=i/2;
  }
}

void insert(int key){
  H++;
  A[H]=-INFTY;
  increaseKey(H,key);
}

int main(){
  int key;
  char com[10];

  while(1){
    scanf("%s",com);
    if(com[0]=='e'&&com[1]=='n')break;
    if(com[0]=='i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n",extract());
    }
  }
  return 0;
}



Measured memory_bytes: 5588
#include <bits/stdc++.h>
using namespace std;
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }
template<typename T>
auto divisors(T n){
    vector<T>v;
    for(T i = 1; i *  i <= n;i++){
        if(n % i)continue;
        v.push_back(i);
        if(i != 1 and i * i != n)
            v.push_back(n /i);
    }
    // input : 6 ->  1 2 3 6
    // input : 1 -> 1
    // input : 2 -> 2
    if(n != 1) v.push_back(n);
    sort(v.begin(),v.end());
    return v;
}
template<typename T>
auto isPrime(const T num){
    if(num == 1) return true;
    for(T i = 2; i * i <= num ;++i)
        if(num % i == 0) return false;
    return true;
}
int main(){
    long long A,B;
    cin >> A >> B;
    long long gd = gcd(A, B);
    auto v = divisors(gd);
    long long ans = 0;
    for(auto e  : v) ans += isPrime(e);
    cout << ans << endl;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[] res = new int[N];
		res[0] = Query(0); if(res[0] == -1) return;
		res[N/2] = Query(N/2); if(res[N/2] == -1) return;
		res[N/2 + 1] = Query(N/2 + 1);if(res[N/2+1] == -1) return;
		
		int cram = ((N/2) % 2) == 0 ? res[0] : res[0] ^ 1;
			
		int l,r;
		if(res[N/2] != cram){
			l = 0; r = N/2 + 1;
		} else {
			l = N/2 + 1; r = N;
		}
		while(r - l > 1){
			int c = (r + l) / 2;
			int len = c - l;
			int q = Query(c);
			if(q == -1) return;
			res[c] = q;
			int cr = len % 2 == 0 ? res[l] : res[l] ^ 1; 
			if(q == cr){
				l = c;
			} else {
				r = c;
			}
		}
		
		Query(r % N);
		
	}
	
	Dictionary<String,int> di = new Dictionary<String,int>(){
		{"Male", 0},
		{"Female", 1},
		{"Vacant", -1}
	};
	
	
	int Query(int n){
		Console.WriteLine(n);
		Console.Out.Flush();
		return di[rs()];
	}
	
	int N;
	public Sol(){
		N = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13904
#include "bits/stdc++.h"
#include <cmath>

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<int> C(N - 1), S(N - 1), F(N - 1);
    for(int i = 0; i < N - 1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }
    for(int i = 0; i < N; i++){
        ll sum = 0;
        for(int j = i; j < N - 1; j++) {
            if(sum < S[j]) sum = S[j];
            else if(sum % F[j] == 0) goto a;
            else sum += F[j] - sum % F[j];
            a:
            sum += C[j];
        }
        cout << sum << endl;
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

const int M=1000010;

int main() {
  int n;
  cin>>n;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  
  vector<int> C(M);
  
  for(auto t:A){
    if(C[t]!=0){
      C[t]=2;
      continue;
    }
    for(int j=t;j<M;j+=t){
      C[j]++;
    }
  }
  
  int cnt=0;
  for(auto t:A){
    if(C[t]==1) cnt++;
  }
  
  cout<<cnt<<endl;
  
  return 0;
}

Measured memory_bytes: 7932
//AOJ0337.cpp

#include <iostream>
using namespace std;

int main(){
  int E, Y;
  cin >> E >> Y;

  switch(E){
  case 0:
    if(1868<=Y && Y<=1911){
      cout << 'M' << Y-1867 << endl;
    }else if(1912<=Y && Y<=1925){
      cout << 'T' << Y-1911 << endl;
    }else if(1926<=Y && Y<=1988){
      cout << 'S' << Y-1925 << endl;
    }else if(1989<=Y && Y<=2016){
      cout << 'H' << Y-1988 << endl;
    }
    break;
  case 1:
    cout << Y+1867 << endl;
    break;
  case 2:
    cout << Y+1911 << endl;
    break;
  case 3:
   cout << Y+1925 << endl;
   break;
  case 4:
      cout << Y+1988 << endl;
      break;
  }

  return 0;
}

Measured memory_bytes: 3080
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  char c;
  while(~scanf(" %c ",&c)){
    if(c=='0')break;

    int r,g,b;
    scanf("%2x%2x%2x",&r,&g,&b);
    int R[8],G[8],B[8];
    rep(i,8){
      R[i]=i/4*0xff;
      G[i]=i/2%2*0xff;
      B[i]=i%2*0xff;
    }
    string str[]={"black","blue","lime","aqua","red","fuchsia",
      "yellow","white"};

    double mind=sqrt(256*256*3)+1;
    int mini;
    rep(i,8){
      double td=sqrt((r-R[i])*(r-R[i])+(g-G[i])*(g-G[i])+(b-B[i])*(b-B[i]));
      if(td<mind){
        mind=td;
        mini=i;
      }
    }
    cout<<str[mini]<<endl;
  }
}

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

int main()
{
  while (1) {
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x <= y) cout << x << ' ' << y << endl;
    else cout << y << ' ' << x << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0) 
#define X first
#define Y second 
#define nl '\n'
#define AC return 0
#define pb(a) push_back(a) 
#define mst(a,b) memset(a, b, sizeof a)
#define rep(i,n) for(int i = 0; (i)<(n); i++)
#define rep1(i,n) for(int i = 1; (i)<=(n); i++)
#define scd(a) scanf("%lld", &a)
#define scdd(a,b) scanf("%lld%lld", &a, &b)
#define scs(s) scanf("%s", s)
//#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll INF = (ll)0x3f3f3f3f3f3f3f, MAX = 9e18, MIN = -9e18;
const int N = 1e6+10, M = 2e6+10, mod = 998244353, inf = 0x3f3f3f;
ll v[N], sum[N], mm[N]; 

int main()
{
	IOS;
	ll n, m, x, ans = 0, cnt = 0;
	cin>>n>>x>>m;
	
	while(n--)
	{
		ans += x;
		v[x]++;
		if(v[x] > 1)
			mm[++cnt] = x;
		x = x*x%m;
		if(v[x] > 2||!x)
			break;
	}
	if(!x)
	{
		cout<<ans<<nl;
		AC;
	}
	rep1(i, cnt)
		sum[i] = sum[i-1] + mm[i];
	if(cnt)
		ans += (n/cnt)*sum[cnt]+sum[n%cnt];
	cout<<ans<<nl;
	
	AC;
} 

Measured memory_bytes: 5952
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
  ll k,n ;
  cin >> k >> n;
  vector<ll> v(n),d(n) ;
  for(ll i=0;i<n;i++) cin >> v[i] ;
  ll max = k - v[n-1] + v[0] ;
  for(ll i=1;i<n;i++)
  {
    if(max<v[i]-v[i-1]) max = v[i] - v[i-1] ;
  }
  cout << k - max << endl ;
}

Measured memory_bytes: 3328
def is_no_odd(x, y, z):
    return x % 2 == 0 and y % 2 == 0 and z % 2 == 0


def exchange(x, y, z):
    new_x = y / 2 + z / 2
    new_y = x / 2 + z / 2
    new_z = x / 2 + y / 2
    return new_x, new_y, new_z


a, b, c = map(int, input().split())
cnt = 0

while is_no_odd(a, b, c):
    if a == b == c:
        cnt = -1
        break

    a, b, c = exchange(a, b, c)
    cnt += 1

print(cnt)


Measured memory_bytes: 38384
n,m = map(int, input().split())
h = list(map(int, input().split()))

dp = [0]*n

for i in range(m):
    a,b = map(int, input().split())
    if h[a-1] >= h[b-1]:
        dp[b-1] = dp[b-1] + 1
    if h[b-1] >= h[a-1]:
        dp[a-1] = dp[a-1] + 1

print(dp.count(0))

Measured memory_bytes: 19968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
ll GCD(ll x,ll y){
	return y==0?x:GCD(y,x%y);
}
int compare_longlong(const void *a, const void *b) {long long *A = (long long *)a;long long *B = (long long *)b;if (*A > *B) return 1;if (*A < *B) return -1;return 0;}
int main(void){
	int n;
	ll X;
	scanf("%d%lld",&n,&X);
	ll x[n+1],ans;
	for(int i=0;i<n;i++)scanf("%lld",&x[i]);
	x[n]=X;
	qsort(x,n+1,sizeof(ll),compare_longlong);
	ans = x[1]-x[0];
	for(int i=1;i<n;i++){
		ll tmp = x[i+1]-x[i];
		ans = GCD(ans,tmp);
	}
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1788
if __name__ == "__main__":
    q, h, s, d = map(int, input().split())
    n = int(input())

    # まず1リットルあたりの単価を求める
    value = list()
    value.append(q*4)
    value.append(h*2)
    value.append(s)
    value.append(d/2)

    ans = 0
    if min(value) == value[3]:
        if n % 2 == 1:
            ans += n // 2 * d
            ans += min(value[0:3])
        else:
            ans += n // 2 * d
    else:
        ans += min(value) * n

    print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=12e5,mo=998244353;

ll jc[N],ny[N];
int n,m,k;

inline ll ksm(ll o,ll t)
{
	ll y=1;
	for(;t;t>>=1,o=o*o%mo)
	if(t&1)y=y*o%mo;
	return y;
}

inline ll C(ll a,ll b)
{return jc[a]*ny[b]%mo*ny[a-b]%mo;}

int main()
{
	cin>>n>>m;
	if(n<m)swap(n,m);
	k=n<<1;
	jc[0]=ny[0]=1;
	fo(i,1,k)jc[i]=jc[i-1]*i%mo;
	ny[k]=ksm(jc[k],mo-2);
	fd(i,k-1,1)ny[i]=ny[i+1]*(i+1)%mo;
	ll ans=0;
	for(int h=0,z=n-m;h<m;++h,++z)
	ans=(ans+C(h+z,z)*C(n+m-h-z,m-h))%mo;
	ans=ans*ny[2]%mo;
	ll zg=C(n+m,m);
	ans=ans*ksm(zg,mo-2)%mo;
	ans=(ans+n)%mo;
	cout<<ans;
}

Measured memory_bytes: 18688
import java.io._
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, x = sc.nextInt()
    val A = map(N)(_ => sc.nextLong())
    val cost = A.clone()
    val ans = map(N) { k =>
      rep(N) { i =>
        cost(i) = min(cost(i), A((i - k + N) % N))
      }
      cost.sum + k * x.toLong
    }.min

    println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) { f(i); i += 1 }
  }
  def rep_r(n: Int)(f: Int => Unit): Unit = {
    var i = n - 1
    while(i >= 0) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  vector<int> v(n + 1, 0);
  for (int i = 0; i < n - 1; i++) {
    if (h[i] >= h[i + 1]) {
      v[i + 1] = v[i] + 1;
    }
  }
  cout << *max_element(all(v)) << endl;
  return 0;
}

Measured memory_bytes: 1024
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const inputs = input.trim().split('\n');
const n = Number(inputs[0]);
const S = inputs[1].split(' ').map(Number);
const q = Number(inputs[2]);
const T = inputs[3].split(' ').map(Number);

const search = (list, value) => {
  const node = { left: 0, right: list.length };
  while (node.left + 1 < node.right) {
    const index = Math.floor((node.left + node.right) / 2);
    node[list[index] <= value ? 'left' : 'right'] = index;
  }
  return list[node.left] === value;
}

console.log(T.map(v => search(S, v)).reduce((a, b) => a + b));



Measured memory_bytes: 36860
#include <iostream>

int main(int argc, char const *argv[])
{
	int x, a, b;
	std::cin >> x >> a >> b;
    
    if(abs(x - a) > abs(x - b)){
        std::cout << "B" << std::endl;
    }else{
        std::cout << "A" << std::endl;

    }
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    int H,W;cin>>H>>W;
    int cnt[26];
    fill_n(cnt,26,0);
    REP(i,H){
        string s;cin>>s;
        REP(j,W)cnt[s[j]-'a']++;
    }

    if(H%2==0&&W%2==0){
        REP(i,26){
            if(cnt[i]%4!=0){
                cout<<"No"<<endl;return 0;
            }
        }
        cout<<"Yes"<<endl;
    }else if(H%2==1&&W%2==1){
        int n=H/2,m=W/2;
        int cnt4=0;
        REP(i,26){
            cnt4+=cnt[i]/4;
            cnt[i]-=(cnt[i]/4)*4;
        }
        if(cnt4<n*m){
            cout<<"No"<<endl;return 0;
        }
        int cnt2 = (cnt4-n*m)*2;
        REP(i,26){
            cnt2 += cnt[i]/2;
            cnt[i]-=(cnt[i]/2)*2;
        }
        if(cnt2<n+m){
            cout<<"No"<<endl;return 0;
        }
        cout<<"Yes"<<endl;
    }else{
        if(H%2==1)swap(H,W);
        int n=H/2,m=W/2;
        int cnt4=0;
        REP(i,26){
            cnt4+=cnt[i]/4;
            cnt[i]-=(cnt[i]/4)*4;
        }
        if(cnt4<n*m){
            cout<<"No"<<endl;return 0;
        }
        int cnt2 = (cnt4-n*m)*2;
        REP(i,26){
            cnt2 += cnt[i]/2;
            cnt[i]-=(cnt[i]/2)*2;
        }
        
        if(cnt2<n){
            cout<<"No"<<endl;return 0;
        }
        cout<<"Yes"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = input()
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

manz = 0

for i, _ in enumerate(A):
    manz += B[A[i]-1]
    if i >= 1 and A[i] == A[i-1]+1:
        manz += C[A[i]-2]
        
print(manz)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

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

/// WA ?????????????????´????????????
/**
 * in
2
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw y eazqyp pnop pngtg ye obmpngt xmybp mr lygw

 *out
i submit that there is another point of view
i submit that there is another point of view i submit that there is another point of view       @
 
**/
int main(){
    int mod=1000000007;
    int n,len,x,y;
    char s[260];
    scanf("%d",&n);
    while (fgets(s,260,stdin)!=NULL) {
        len=strlen(s)-1;
        bool flg=0;
        for (int a=0;a<26;++a) {
            if (gcd(a,26)!=1) continue;
            for (int b=0;b<26;++b) {
                char chk[len];
                for (int c=0;c<len;++c) {
                    if (islower(s[c])) {
                        chk[c]=(((s[c]-'a')*a+b)%26)+'a';
                    }
                }
                for (int d=0;d<len;++d) {
                    if (!strncmp(&chk[d],"this",4) || !strncmp(&chk[d],"that",4)) {
                        x=a;
                        y=b;
                        flg=1;
                    }
                }
            }
        }
        char ans[len];
        if (flg && len>3) {
            for (int i=0;i<len;++i) {
                if (islower(s[i])) {
                    printf("%c",((s[i]-'a')*x+y)%26+'a');
                } else {
                    printf("%c",s[i]);
                }
            }
            printf("\n");

        //for (int i=0;i<len;++i) {
            //if (islower(s[i])) ans[i]=(((s[i]-'a')*x+y)%26+'a');
            //else ans[i]=s[i];
            //printf("%c",s[i]);
        }
        //if (flg && len>3) printf("%s\n",ans);
        //printf("%d,%d\n",len,strlen(ans));
        flg=0;
    }
    return 0;
}

Measured memory_bytes: 3068
#include <iostream>
using namespace std;
using LL = long long;

int N;
LL X[101] = {};
LL Y[101] = {};
LL H[101] = {};

int main() {
    cin >> N;
    for(int i = 0; i < N; ++i) {
        scanf("%lld%lld%lld", X + i, Y + i, H + i);
    }
    for(int y = 0; y <= 100; ++y) {
        for(int x = 0; x <= 100; ++x) {
            int g = -1;
            for(int i = 0; i < N; ++i) {
                if(H[i] > 0) {
                    g = H[i] + abs(X[i] - x) + abs(Y[i] - y);
                    break;
                }
            }

            bool found = true;
            for(int i = 0; i < N; ++i) {
                if(H[i] != max(g - abs(X[i] - x) - abs(Y[i] - y), 0LL)) {
                    found = false;
                    break;
                }
            }
            if(!found) continue;
            else {
                cout << x << " " << y << " " << g << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

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

const int N = 1e5 + 10;
char s[N];

int main() {
  int n;
  scanf("%d%s", &n, s);
  vector<int> cnt(26, 1);
  for (int i = 0; i < n; ++i) {
    cnt[s[i] - 'a']++;
  }
  int ret = 1;
  for (int k = 0; k < 26; ++k) {
    ret = (int64)ret * cnt[k] % MOD;
  }
  ret = (ret + MOD - 1) % MOD;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int input1 = sc.nextInt();
		sc.close();

		List<Integer> list = new ArrayList<Integer>();
		int num = 0;
		int count = 0;
		for (int i = 1; i <= 9 ; i++ ) {
			for (int j = 1; j <= 9 ; j++ ) {
				num = i*j;
				list.add(num);
			}
		}

		for (int k=0; k < list.size(); k++) {
			if (input1 == list.get(k)) {
				System.out.println("Yes");
				count ++;
				break;
			}
		}
		if(count == 0) {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 23124
#include <stdio.h>

int main(void)
{
	int m1, m2, i, max, i2;
	
	while (1){
		
		scanf("%d %d", &m1, &m2);
		
		if (m1 == 0 && m2 == 0){
			break;
		}
		max = m1 + m2;
		i2 = 0;
		for (i = 1; i < 5; i++){
			scanf ("%d %d", &m1, &m2);
			
			if (m1 + m2 > max){
				max = m1 + m2;
				i2 = i;
			}
		}
		printf("%c %d\n", 'A' + i2, max);
	}
	
	return (0);
}
		

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string s, t; cin >> s >> t;
    
    mat ls(26);
    REP(i, SZ(s)) ls[s[i] - 'a'].pb(i);

    REP(i, SZ(t)) if(SZ(ls[t[i] - 'a']) == 0){
        Out(-1);
        return 0;
    }

    int n = 0;
    int pos = 0;
    REP(i, SZ(t)){
        int x = t[i] - 'a';
        if(ls[x].back() < pos){
            n++;
            pos = 0;
        }
        int i0 = Lower_bound(ls[x], pos);
        pos = ls[x][i0] + 1;
    }
    int ans = n * SZ(s) + pos;
    Out(ans);

    return 0;
}


Measured memory_bytes: 1736
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	int n,m,k;
	cin >> n >> m >> k;
	
	for(int i=0; i<=n; ++i){
		for(int j=0; j<=m; ++j){
			int c = (n-i)*j + (m-j)*i;
			if(c==k){
				cout << "Yes" << endl;
				return 0;
			}	
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3628
//long long使う！！！！！！
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)();
typedef long long ll;

ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}
 
const ll big=998244353;
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x);
    ll t=exp(x,y/2);
    return (t*t);
}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(0);
    /*--------------------------------*/
    
    int n;string s;cin >> n >> s;
    //全探索するとC(n,3)
    vector<bool> al(10);
    vector<bool> alj(10);
    unordered_set<int> ans;
    rep(i,n-2){
        if(al[s[i]-'0'])continue;
        al[s[i]-'0']=true;
        rep(j,10)alj[j]=false;
        rep2(j,i+1,n-1){
            if(alj[s[j]-'0'])continue;
            alj[s[j]-'0']=true;
            rep2(k,j+1,n)ans.insert(s[i]*100+s[j]*10+s[k]-'0'*111);
        }
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
char s[100003];
using namespace std;
int main()
{
	scanf("%s",&s);
	int len=strlen(s);
	if(s[0]==s[len-1])
	  {
	  	if(len%2==1)
	  	  cout<<"Second";
	  	else
		  cout<<"First";  
	  }
	if(s[0]!=s[len-1])
	  {
	  	if(len%2==0)
	  	  cout<<"Second";
	  	else
		  cout<<"First";  
	  }
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String args[]){

        Scanner sc=new Scanner(System.in);
        int rec=0;		//????????¢?????°
        int rho=0;		//????????¢?????°

        while(sc.hasNext()){
            String[] st=sc.next().split(",");
            int a=Integer.parseInt(st[0]);
            int b=Integer.parseInt(st[1]);
            int c=Integer.parseInt(st[2]);

            if(a==b){
            	rho++;
            }
            if(a*a+b*b==c*c){
            	rec++;
            }
        }
        System.out.println(rec);
        System.out.println(rho);
    }
}

Measured memory_bytes: 26280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

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

    int n;
    cin >> n;
    n = pow(n, 3);
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 512
d,g=list(map(int,input().split()))
p=[list(map(int,input().split()))for i in range(d)]

ans=float("inf")
for bit in range(1<<d):
    count=0;
    sum=0;
    nokori=set(range(1,d+1))
    for i in range(d):
        if bit&(1<<i):
            sum+=p[i][0]*(i+1)*100+p[i][1]
            count+=p[i][0]
            nokori.discard(i+1)
    if sum>=g:
        ans=min(ans,count)
    else:
        use=max(nokori)
        n=min(p[use-1][0],-(-(g-sum)//(100*use)))
        count+=n
        sum+=n*use*100
        if sum>=g:
            ans=min(ans,count)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
struct id{
    int p=-1;
    int l=-1;
    int r=-1;
};
id a[25];
void Pre(int b){
    cout<<" "<<b;
    if(a[b].l!=-1){
        Pre(a[b].l);
    }
    if(a[b].r!=-1){
        Pre(a[b].r);
    }
}
void In(int b){
    if(a[b].l!=-1){
        In(a[b].l);
    }
    cout<<" "<<b;
    if(a[b].r!=-1){
        In(a[b].r);
    }
}
void Post(int b){
    if(a[b].l!=-1){
        Post(a[b].l);
    }
    if(a[b].r!=-1){
        Post(a[b].r);
    }
    cout<<" "<<b;
}
int main(){
    int n,pp;
    cin>>n;
    for(int i=0;i<n;i++){
        int d;
        cin>>d;
        cin>>a[d].l>>a[d].r;
        if(a[d].l!=-1){
            a[a[d].l].p=d;
        }
        if(a[d].r!=-1){
            a[a[d].r].p=d;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i].p==-1){
            pp=i;
            break;
        }
    }
    cout<<"Preorder"<<endl;
    Pre(pp);
    cout<<endl;
    cout<<"Inorder"<<endl;
    In(pp);
    cout<<endl;
    cout<<"Postorder"<<endl;
    Post(pp);
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int x = 0;
    int m = 0;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='I')x++;
        else x--;
        m = max(m,x);
    }
    cout<<m<<endl;
}

Measured memory_bytes: 256
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    LL N;
    R(N);
    LL now=26;
    int len=1;
    while(N>now){
        N-=now;
        now*=26;
        len++;
    }
    string an(len,'0');
    N--;
    for(int i=len-1;i>=0;i--){
        an[i]=N%26+'a';
        N/=26;
    }
    W(an);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}

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

A = list(map(int, input().split()))

count = 0
for i in range(1, A[0] + 1):
    value_list = [int(i) for i in list(str(i))]
    sum_value = sum(value_list)
    if A[1] <= sum_value <= A[2]:
        count += i
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#define N 1100000
#define L 1000000
#define eps 1e-7
#define inf 1e9+7
#define db double
#define ll long long
#define ldb long double
using namespace std;
inline ll read()
{
	char ch=0;
	ll x=0,flag=1;
	while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*flag;
}
const ll d=5,mo=924844033;
ll ksm(ll x,ll k)
{
	ll ans=1;
	while(k)
	{
		if(k&1)ans=ans*x%mo;
		k>>=1;
		x=x*x%mo;
	}
	return ans;
}
ll rev[N];
void ntt(ll *f,ll n,ll flag)
{
	for(ll i=0;i<n;i++)
	{
		rev[i]=(rev[i>>1]>>1)+(i&1)*(n>>1);
		if(i<rev[i])swap(f[i],f[rev[i]]);
	}
	for(ll k=2,kk=1;k<=n;k<<=1,kk<<=1)
	{
		ll wn=ksm(d,(mo-1)/k);
		if(flag==-1)wn=ksm(wn,mo-2)%mo;
		for(ll i=0;i<n;i+=k)
		for(ll j=0,w=1;j<kk;j++,w=1ll*w*wn%mo)
		{
			ll t=1ll*w*f[i+j+kk]%mo;
			f[i+j+kk]=(f[i+j]-t+mo)%mo;
			f[i+j]=(f[i+j]+t)%mo; 
		}
	}
	if(flag==-1)
	{
		ll inv=ksm(n,mo-2);
		for(ll i=0;i<n;i++)f[i]=f[i]*inv%mo;
	}
}
ll a[N],b[N];
void mul(ll n)
{
	ll len;
	for(len=1;len<2*n;len<<=1);
	ntt(a,len,+1);ntt(b,len,+1);
	for(ll i=0;i<len;i++)a[i]=a[i]*b[i]%mo;
	ntt(a,len,-1);
}
struct edge{ll to,nxt;}e[N*2];
ll num,head[N];
inline void add(ll x,ll y){e[++num]=(edge){y,head[x]};head[x]=num;}
ll sz[N],cnt[N],fac[N],vac[N];
void dfs(ll x,ll fa)
{
	sz[x]=1;
	for(ll i=head[x];i!=-1;i=e[i].nxt)
	{
		ll to=e[i].to;
		if(to==fa)continue;
		dfs(to,x);
		sz[x]+=sz[to];
	}
}
ll c(ll n,ll m){return n>=m?(fac[n]*vac[m]%mo*vac[n-m]%mo):0;}
int main()
{
	num=-1;memset(head,-1,sizeof(head));
	ll n=read();
	for(ll i=1;i<=n-1;i++){ll x=read(),y=read();add(x,y);add(y,x);}
	dfs(1,1);for(ll i=2;i<=n;i++)cnt[sz[i]]++,cnt[n-sz[i]]++;
	fac[0]=vac[0]=1;for(ll i=1;i<=L;i++)fac[i]=fac[i-1]*i%mo,vac[i]=vac[i-1]*ksm(i,mo-2)%mo;
	for(ll i=0;i<=n;i++)a[i]=1ll*cnt[i]*fac[i]%mo,b[i]=vac[n-i];
	mul(n+1);
	for(ll i=1;i<=n;i++)printf("%lld\n",((n*c(n,i)%mo)-(vac[i]*a[n+i]%mo)+mo)%mo);
	return 0;
}

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

int main() {
    int l[100 + 2];
    int X, N;
    int a1 = 101, a2 = 101, ans;
    
    memset(l, 0x00, sizeof(l));
    
    cin >> X >> N;
    for ( int ii = 0; ii < N; ii++ ) {
        int p; cin >> p;
        l[p] = 1;
    }
    for ( int ii = X; ii >= 0; ii-- ) {
        if ( l[ii] == 1 ) {
            continue;
        }
        int tmp = X - ii;
        if ( tmp < a1 ) {
            a1 = tmp;
        }
    }
    for ( int ii = X; ii < 102; ii++ ) {
        if ( l[ii] == 1 ) {
            continue;
        }
        int tmp = ii - X;
        if ( tmp < a2 ) {
            a2 = tmp;
        }
    }
    if ( a1 == a2 ) {
        ans = X - a1;
    } else if ( a1 > a2 ) {
        ans = X + a2;
    } else {
        ans = X - a1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
n = input()
 
inf = 10000000
 
color = [0 for i in xrange(n)]
M = [[inf for i in xrange(n)] for i in xrange(n)]
d = [inf for i in xrange(n)]
p = [-1 for i in xrange(n)]
 
def mst():
  d[0] = 0
 
  while True:
    cost = inf
    for i in xrange(n):
      if color[i] != 2 and d[i] < cost:
        cost = d[i]
        u = i
 
    if cost == inf:
      break
     
    color[u] = 2
 
    for v in xrange(n):
      if color[v] != 2 and M[u][v] != inf and M[u][v] < d[v]:
        d[v] = M[u][v]
        p[v] = u
        color[v] = 1
 
  sum = 0
  for i in xrange(n):
    if p[i] != -1:
      sum += M[i][p[i]]
  return sum
 
for i in xrange(n):
  G = map(int, raw_input().split())
  for j in range(n):
   if G[j] != -1:
     M[i][j] = G[j]
 
print mst()

Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
string a;
int ans=1<<30; 
int main()
{
    cin>>a;
    for(int i=1;i<a.size();i++)
    {
        if(a[i]!=a[i-1])
            ans=min(ans,max(i,int(a.size())-i)); 
    }      
    cout<<min(ans,int(a.size()))<<endl; 
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n, m, sum = 0;
  cin >> n >> m;
  REP(i, m) {
    int a;
    cin >> a;
    sum += a;
  }
  if(n<sum)cout << "-1" << "\n";
  else cout << n-sum << "\n";
  return 0;
}


Measured memory_bytes: 3636