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

const ll maxs = 1e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

ll fact[maxs];
ll ifact[maxs];

ll mul(ll a,ll b){
    return (a*b)%mod;
}

ll add(ll a,ll b){
    ll ans = a+b;
    if(ans > mod)
        ans -= mod;
    return ans;
}

ll fast(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1)
            res = mul(res,x);
        x = mul(x,x);
        y >>= 1;
    }
    return res;
}


void pre(){
    
}


void solve(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll dp[k+1];
    for(ll i=k;i>=1;i--){
        dp[i] = fast(k/i,n);
        for(ll j=i*2;j<=k;j+=i){
            dp[i] -= dp[j];
            if(dp[i] < 0)
                dp[i] += mod;
        }
        ans += mul(i,dp[i]);
        if(ans > mod)
            ans -= mod;
    } 
    cout << ans;
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 4420
#include<iostream>
#include<string>

int main(){

	while (true){
		std::string str;
		std::getline(std::cin, str);

		if (str == "END OF INPUT")break;

		int cnt = 0;
		for (int i = 0; i < str.size(); i++){
			if (str[i] == ' ')std::cout << cnt, cnt = 0;
			else cnt++;
		}
		std::cout << cnt << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    for(int i = 0; i < k; ++i){
        cin >> l[i] >> r[i];
    }
    vector<ll> dp(n, 0);
    const ll MOD = 998244353;
    dp[0] = 1;
    dp[1] = -1;
    for(int i = 0; i < n; ++i){
        if(i > 0)
            dp[i] += dp[i - 1];
        dp[i] %= MOD;
        for(int j = 0; j < k; ++j){
            if(i + l[j] < n)
                dp[i + l[j]] = (dp[i] + dp[i + l[j]]) % MOD;
            if(i + r[j] + 1 < n)
                dp[i + r[j] + 1] = (MOD + (dp[i + r[j] + 1] - dp[i]) % MOD) % MOD;
        }
    }
    cout << dp[n - 1] << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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

int main()
{
    int H,W;
    cin >> H >> W;
    char s[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> s[i][j];
        }
    }
    for(int i=0;i<H;i++){//マスを調べていく
        for(int j=0;j<W;j++){
            int count = 0;
            if(s[i][j] == '.'){
                //cout << i << j;
                for(int k=i-1;k<=i+1;k++){//周りを調べる
                    for(int l=j-1;l<=j+1;l++){
                        //cout << "i:" << i << " j:" << j << " k:" << k << " l:" << l << endl;;
                        if(0<=k && k<H && 0<=l && l<W && s[k][l]=='#'){
                            count++;
                        }
                    }
                }
                cout << count;
            }
            else{
                cout << s[i][j];
            }
            if(j==W-1){
                cout << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main(void) {
    int N, K;
    cin >> N >> K;

    int R, S, P;
    cin >> R >> S >> P;
    map<char, int> win;
    win['r'] = P;
    win['s'] = R;
    win['p'] = S;

    string T;
    cin >> T;
    int tlen = (int) T.size();

    int acc = 0;
    for (int i = 0; i < K; i++) {
        char prev = 'z';
        bool ok = true;
        for (int j = i; j < tlen; j += K) {
            if (T[j] == prev) {
                if (ok) {
                    acc += win[T[j]];
                }
                ok = !ok;
            } else {
                acc += win[T[j]];
                ok = false;
                prev = T[j];
            }
        }
    }

    cout << acc << endl;

    return 0;
}


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

typedef long long ll;

int main() {
    int N, t = 0;
    cin >> N;
    vector<int> s(N);
    rep(i, N) {
        cin >> s[i];
        t += s[i];
    }
    if (t % 10 != 0) {
        cout << t << "\n";
        return 0;
    }
    sort(s.begin(), s.end());
    rep(i, N) {
        if (s[i] % 10 != 0) {
            cout << t - s[i] << "\n";
            return 0;
        }
    }
    cout << "0 \n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;
const int maxN = 1e3+10;
const int MOD = 1e9+7;
const ll INF = 1000000000000000010LL;
const ll inf = 1e9+10;

int a[maxN];
ll dis[maxN][maxN];
ll b[maxN][maxN];
int main() {
	int n,m,L;
	scanf("%d%d%d",&n,&m,&L);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i!=j)
				dis[i][j] = inf;
		}
	}
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		if(z > L)continue;
		dis[x][y] = dis[y][x] = z;
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				dis[i][j] = min(dis[i][j],dis[i][k] + dis[k][j]);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(dis[i][j] <= L)
			{
				b[i][j] = 1;
			}
			else
			{
				b[i][j] = inf;
			}
		}
	}
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				b[i][j] = min(b[i][j],b[i][k] + b[k][j]);
			}
		}
	}
	int Q;
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		if(b[x][y] == inf)
		{
			puts("-1");
		}
		else
		{
			printf("%lld\n",b[x][y]-1);
		}
	}
    return 0;
}

Measured memory_bytes: 10368
def FindSumOfDigits(n):
    Sum=0
    len_n=len(str(n))
    for i in range(len_n):
        Sum+=int(n%10)
        n=n/10
    return Sum

N,A,B=map(int,input().split())
ans=0
#ans_list=[]
#sumlist=[]
for i in range(1,N+1):
    #sumlist.append(FindSumOfDigits(i))
    if A<=FindSumOfDigits(i)<=B:
        ans+=i
        #ans_list.append(i)
print(ans)
#print(ans_list)
#print(sum_list)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c,n;

int main(){
	cin>>a>>b>>c>>n;
  	if(max(a,c)-min(a,c)<=n||(max(a,b)-min(a,b)<=n&&max(b,c)-min(b,c)<=n)){
		cout<<"Yes"<<endl;
    }else{
		cout<<"No"<<endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=305;
ll n,m,mo;
ll f[N][N],C[N][N],q[N][N];
ll move(ll &a,ll b){
	a=(a+b)%mo;
}
int main(){
	cin>>n>>m>>mo;
	for (int i=0;i<=n;i++){
		C[i][0]=C[i][i]=1;
		for (int j=1;j<i;j++)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mo;
	}
	for (int i=0;i<=m;i++)
		f[1][i]=1,q[1][i]=i+1;
	for (int i=2;i<=n+1;i++)
		for (int j=0;j<=m;j++){
			for (int k=1;k<i;k++)
				move(f[i][j],q[k][j-1]*f[i-k][j]%mo*C[i-2][k-1]);
			q[i][j]=(f[i][j]+q[i][j-1])%mo;
		}
	cout<<f[n+1][m]<<endl;
}

Measured memory_bytes: 2432
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {

    string S;
    cin >> S;
    string T = "";
    string out = "YES";
    int tLength = 0;
    while(S.length() > tLength){
        int t = 0;
        if(S.length()-tLength >= 7){
            if(S.substr(S.length()-7-tLength,7) == "dreamer") t = 7;
        }
        if(S.length()-tLength >= 6){
            if(S.substr(S.length()-6-tLength,6) == "eraser") t = 6;
        }
        if(S.length()-tLength >= 5){
            if(S.substr(S.length()-5-tLength,5) == "dream") t = 5;
            else if(S.substr(S.length()-5-tLength,5) == "erase") t = 5;
        }
        if(t == 0){
            out = "NO";
            break;
        }
        tLength += t;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 512
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 A[] = new int[b];
        int sum =0;
        for (int i = 0; i < b; i++) {
            A[i] = sc.nextInt();
            sum += A[i];
        }
        if (a <= sum ) {
            System.out.printf("Yes");
        }else{
            System.out.printf("No");
        }
    }
}


Measured memory_bytes: 49508
def solve():
    N = int(raw_input())
    ret = 0
    for i in range(2, int(N**0.5 + 1)):
        if N % i == 0:
            inv_i = N//i
            if N % (inv_i - 1) == N / (inv_i - 1):
                ret += inv_i - 1
    if N > 2:
        ret += N -1
    print str(ret)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 34436
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	if (s < t)print("Yes");
	else print("No");
}

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

int main() {
int square = 0, marbles = 0;
int i = 0;

  cin >> square;
  
  for(i = 1; i <= square; i = i * 10)
  {
    if( (square % (10 * i) / i) > 0 )
    {
      marbles++;
    }
  }
  
  cout << marbles << endl;
}

Measured memory_bytes: 256
import core.stdc.stdio;
import std.typecons;
import std.algorithm;

struct Seg{
	Seg* l,r;
	int c;
}

int Count(Seg* x){
	return x is null?0:x.c;
}

Seg* Left(Seg* x){
	return x is null?null:x.l;
}

Seg* Right(Seg* x){
	return x is null?null:x.r;
}

Seg[] buf;
Seg* newSeg(Seg* l,Seg* r){
	static int i;
	buf[i]=Seg(l,r,l.Count+r.Count);
	return &buf[i++];
}

Seg* Add(Seg* x,int i,int l=0,int r=1<<30){
	if(i<l||r<=i)
		return x;
	if(i==l&&i+1==r){
		Seg* t=newSeg(null,null);
		t.c=1+x.Count;
		return t;
	}else
		return newSeg(Add(x.Left,i,l,(l+r)/2),Add(x.Right,i,(l+r)/2,r));
}

int Get(Seg* x,int i,int l=0,int r=1<<30){
	if(x is null)
		return 0;
	if(i<=l)
		return 0;
	if(r<=i)
		return x.Count;
	return Get(x.Left,i,l,(l+r)/2)+Get(x.Right,i,(l+r)/2,r);
}

int[][] par;
int[] dep;
void LCA_Init(){
	foreach(i;1..20)
		foreach(j,ref p;par[i])
			p=par[i-1][j]>=0?par[i-1][par[i-1][j]]:-1;
}

int LCA(int a,int b){
	if(dep[a]>dep[b])
		swap(a,b);
	int d=dep[b]-dep[a];
	foreach(i;0..20)
		if((d>>i)&1)
			b=par[i][b];
	if(a==b)
		return a;
	foreach_reverse(i;0..20)
		if(par[i][a]!=par[i][b])
			a=par[i][a],b=par[i][b];
	return par[0][a];
}

void main(){
	buf = new Seg[6000000];
	int n,q;
	scanf("%d%d",&n,&q);
	int[] x=new int[n];
	foreach(ref v;x)
		scanf("%d",&v);
	int[][] graph=new int[][n];
	foreach(i;0..n-1){
		int a,b;
		scanf("%d%d",&a,&b);
		graph[--a]~=--b;
		graph[b]~=a;
	}
	
	Seg*[] segs=new Seg*[n];
	par=new int[][](20,n);
	dep=new int[n];
	
	alias Tuple!(int,"i",int,"p",Seg*,"s",int,"d") stack;
	stack[] st=new stack[n*2];
	st[0]=stack(0,-1,null,0);
	int ss=1;
	while(ss){
		stack cur=st[--ss];
		with(cur){
			par[0][i]=p;
			dep[i]=d;
			segs[i]=s.Add(x[i]);
			foreach(c;graph[i])
				if(c!=p)
					st[ss++]=stack(c,i,segs[i],d+1);
		}
	}
	LCA_Init;
	
	foreach(_;0..q){
		int v,w,k,l=0,r=1<<30;
		scanf("%d%d%d",&v,&w,&k);
		int p=LCA(--v,--w);
		Seg* a=segs[v],b=segs[w],c=segs[p],d=p?segs[par[0][p]]:null;
		while(r-l>1){
			int m=(r+l)/2;
			if(k<=a.Get(m)+b.Get(m)-c.Get(m)-d.Get(m))
				r=m;
			else
				l=m;
		}
		printf("%d\n",l);
	}
}

Measured memory_bytes: 160724
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,string> PP;

set<string> se;
map<string,int> m;
vector<PP> a;
vector<string> v;
int ans[26],u[26],uu[100],n,c;

void dfs(int k) {
  if(k==a.size()||c>1) {
    for(int i=0; i<26; i++) {
      if(u[i]==-1) continue;
      if(u[u[i]]!=i) return;
    }
    c++;
    for(int i=0; i<26; i++) ans[i]=u[i];
    return;
  }
  string r=a[k].second;
  for(int i=0; i<n; i++) {
    string t=v[i];
    if(uu[i]||r.size()!=t.size()) continue;
    for(int j=0; j<t.size(); j++) {
      if(u[t[j]-'A']!=-1&&u[t[j]-'A']!=r[j]-'A') goto next;
      if(u[r[j]-'A']!=-1&&u[r[j]-'A']!=t[j]-'A') goto next;
    }
    int u2[26];
    for(int j=0; j<26; j++) u2[j]=u[j];
    for(int j=0; j<t.size(); j++) {
      u[t[j]-'A']=r[j]-'A';
      u[r[j]-'A']=t[j]-'A';
    }
    uu[i]=1;
    dfs(k+1);
    uu[i]=0;
    for(int j=0; j<26; j++) u[j]=u2[j];
  next:;
  }
}
string s;

int main() {
  while(cin >> n && n) {
    se.clear();a.clear();m.clear();v.clear();
    for(int i=0; i<n; i++) {
      cin >> s;
      v.push_back(s);
      se.insert(s);
    }
    getline(cin,s);
    getline(cin,s);
    stringstream ss;
    ss << s;
    string r;
    while(ss>>r) {
      if(r[r.size()-1]=='.') r=r.substr(0,r.size()-1);
      m[r]++;
    }
    for(map<string,int>::iterator it=m.begin();it!=m.end();it++) {
      int d[26],cnt=0;memset(d,0,sizeof(d));
      r=it->first;
      for(int i=0; i<r.size(); i++) d[r[i]-'A']++;
      for(int i=0; i<26; i++) if(d[i]) cnt++;
      a.push_back(PP(cnt,it->first));
    }
    sort(a.begin(),a.end(),greater<PP>());
    memset(u,-1,sizeof(u));
    memset(uu,0,sizeof(uu));
    c=0;
    dfs(0);
    if(c==1) {
      for(int i=0; i<s.size(); i++) {
        if(isalpha(s[i])) cout << (char)(ans[s[i]-'A']+'A');
        else cout << s[i];
      }
      cout << endl;
    } else cout << "-." << endl;
  }
  return 0;
}


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

int N, H, a_max, n_attack;
vector<int> a_vec, b_vec;

bool predicate(int x) {
    return x < a_max;
}

/// @brief O(N * log(N)).
int main() {
    cin >> N >> H;

    for (int i = 1; i <= N; ++i) {
        int a, b;
        cin >> a >> b;
        a_vec.push_back(a);
        b_vec.push_back(b);
    }

    sort(a_vec.begin(), a_vec.end(), greater<int>());  // O(N * log(N)).
    a_max = a_vec.front();
    b_vec.erase(remove_if(b_vec.begin(), b_vec.end(), predicate), b_vec.end());
    sort(b_vec.begin(), b_vec.end(), greater<int>());  // O(N * log(N)).

    while (b_vec.size()) {  // O(N).
        H -= b_vec.front();
        b_vec.erase(b_vec.begin());
        ++n_attack;

        if (H <= 0) {
            cout << n_attack << endl;
            return 0;
        }
    }

    n_attack += ceil((double)H / a_max);
    cout << n_attack << endl;
}


Measured memory_bytes: 1276
int main(void){
    int i;
    double arr[12] ={0};
    double dis;
    
    while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",arr,arr+1,arr+2,arr+3,arr+4,arr+5,arr+6,arr+7,arr+8,arr+9,arr+10,arr+11)){
        // for(i = 0; i < 12; i++){
        //     printf("%d ",arr[i]);
        // }
        
       // printf("\n%d ",arr[0]);
        for(i = 1; i < 10; i++){
            arr[i] += arr[i-1]; 
            //printf("%d ",arr[i]);
        }
        
        dis = (arr[9] * arr[10]) / (arr[10] + arr[11]);
        //printf("\ndistance:%.3f\n",dis);
    
        for(i = 0; i < 10; i++){
            if(dis <= (arr[i])){
                printf("%d\n",i+1);
                break;
            }
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 2036
n,m = map(int,input().split())
hi = [0] + list(map(int,input().split()))
judge = [0]+[1]*(n)

for _ in range(m):
    a,b = map(int, input().split())
    if hi[a] >= hi[b]:
        judge[b] = 0
    if hi[a] <= hi[b]:
        judge[a] = 0
print(sum(judge))


Measured memory_bytes: 20112
x,y=map(int,input().split())
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
print(lcm(x,y))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(A > 0 && B > 0){
    C -= B;
    A -= D;
  }
  if(C > 0)cout << "No" << endl;
  else cout << "Yes" << endl;
}
    

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int h[N];
    int h_max = 0;
    for(int i=0; i<N; i++) {
        cin >> h[i];
        h_max = max(h[i], h_max); 
    }

    bool c;
    int cnt = 0;
    for(int i=1; i<=h_max; i++){
        c = false;
        for(int j=0; j<N; j++){
            if(h[j] >= i){
                if(c) ;
                else{
                    cnt++;
                    c = true;
                }
            }
            else{
                c = false;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<pll> a,b;
	rep(i,n){
		string s;
		cin>>s;
		pll p(0,0);
		rep(j,s.size()){
			if(s[j]=='(')p.fs++;
			else p.fs--;
			chmin(p.sc,p.fs);
		}
		if(p.fs>=0) a.push_back(p);
		else b.push_back(p);
	}
	sort(all(a),[](const auto &a,const auto &b){
		if(a.sc!=b.sc)return a.sc>b.sc;
		else return a.fs>b.fs;
	});
	sort(all(b),[](const auto &a,const auto &b){
		return a.fs-a.sc>b.fs-b.sc;
	});
	ll cur=0;
	bool ans=true;
	for(auto x:a){
		if(cur+x.sc<0)ans=false;
		cur+=x.fs;
	}
	for(auto x:b){
		if(cur+x.sc<0)ans=false;
		cur+=x.fs;
	}
	Yn(ans&&cur==0);
}


Measured memory_bytes: 19012
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
using namespace std;
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
int n;
int f[200001];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>f[i];
    sort(f+1,f+n+1);
	for(int i=1;i<=n;i++){
		if(f[i]!=f[i+1])continue;
		else {
	     	puts("NO");	
	     	return 0;
		}
	} 
	puts("YES");
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 55
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K;
int a[MAXN];
vector<int> v;
void Solve() {
    read(N);read(K);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    int pre = 0;
    for(int i = 1 ; i <= K + 1 ; ++i) {
        int u = 0;
        for(int j = 1 ; j <= N ; ++j) {
            if(j == pre) continue;
            if(!u) u = j;
            else if(a[j] < a[u]) u = j;
        }
        for(int j = 1 ; j <= N ; ++j) {
            if(j != pre && j != u) {
                if(!a[j]) {puts("-1");return;}
                v.pb(j);
                --a[j];
            }
        }
        if(!a[u]) {puts("-1");return;}
        v.pb(u);
        --a[u];
        pre = u;
    }
    out(v.size());enter;
    for(auto t : v) {
        out(t);space;
    }
    enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    mod = 998244353
    n,k = map(int,input().split())
    su = [0,1]
    dp = [0]+[1]+[0]*(n-1)
    ra = []
    for _ in range(k):
        ra.append(tuple(map(int,input().split())))
    for i in range(2,n+1):
        for y in ra:
            if y[0]>i:
                continue
            aa,bb = i-y[0],max(i-y[1],1)
            dp[i] += (su[aa]-su[bb-1])%mod
            dp[i] %= mod
        su.append((su[-1]+dp[i])%mod)
    print(dp[-1])


    
#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 88452
s = input()

sum = 0

if len(s) > 1:

    l = ["+"] * (len(s) - 1)

    n = 2 ** (len(s) - 1)

    for i in range(n):
        l = ["+"] * (len(s) - 1)
        for j in range(len(l)):
            ls = list(s)
            if (i >> j) & 1:
                l[j] = ""
            for x in range(len(l)):
                
                ls.insert(2*x+1,l[x])
    
        

        maped_list = map(str, ls) 
        mojiretu = ''.join(maped_list)

        sum = sum + eval(mojiretu)

    print(sum)
else:
    print(s)    



    
    
   





Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int board[1000][1000];

int min(int a,int b,int c){
	int m =0;
	if(a > b){
		m = b;
	}else{
		m = a;
	}
	if(m > c){
		m = c;
	}
	return m;
}

int main(){
	int n;
	char str;
	while(cin >> n){
		
		if(n == 0){
			return 0;
		}
		//テ、ツスツソテァツ板ィテ」ツδ愿」ツδシテ」ツδ嘉」ツつ?テ」ツ?ァテ・ツ按敕ヲツ慊淌・ツ個?
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				board[i][j] = 1;
			}
		}
		//*テ」ツ?ョテゥツδィテ・ツ按?」ツつ?1テ」ツ?ィテ」ツ?凖」ツつ?
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cin >> str;
				if(str == '*'){
					board[i][j] = -1;
				}
			}
		}
		/*
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout << board[i][j] << " ";
			}
			cout << endl;
		}*/
		
		
		for(int i=1;i<n;i++){
			for(int j=1;j<n;j++){
				if(board[i][j] != -1){
					if((board[i-1][j] != -1) &&(board[i][j-1] != -1) &&(board[i-1][j-1] != -1)){
						board[i][j] = min(board[i-1][j],board[i][j-1],board[i-1][j-1]) + 1;
					}
				}
			}
		}
		
		int max = 0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(board[i][j] >= max){
					max = board[i][j];
				}
			}
		}
	
		cout << max << endl;
	}

		return 0;
}
	

Measured memory_bytes: 5064
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

//vector<ll> a;

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

 // a.reserve(n);
  vector<int> a;
  a.reserve(n);
  for(int i=0;i<n;i++) {
    cin >> a[i];
    a[i] -= i+1;
  }

  sort(a.begin(), a.begin()+n);
  long long  b;
  if(n%2 == 0) {
    b = a[n/2 -1];
  } else {
    b = a[(n-1)/2];
  }

  long long  r = 0;

  for(int i=0;i<n;i++) {
    r += abs(a[i] - b);
  }

  cout << r << endl;
return 0;
}


Measured memory_bytes: 1024
/*input
2 2919

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vii;
#define pb push_back
#define print(a) for(auto x:a){cout<<x<<' ';}cout<<endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
    int n,r;
    cin>>r>>n;
    if(r>=10){
        cout<<n<<endl;
    }
    else{
        cout<<(n+100*(10-r))<<endl;
    }
    
}

signed main(){
    IOS
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

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

int main()
{
  long long int N, M;
  cin >> N >> M;
  long long int ans = 0;
  if (M / 2 <= N)
  {
    ans = M / 2;
  }
  else
  {
    ans = (M / 2 - N) / 2 + N;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main() {
	double r;
	cin >> r;
	cout << r * 2 * 3.1415926535;
}


Measured memory_bytes: 3792
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

int main()
{
    map<string, int> dic;
    int n;
    cin >> n;
    string op, num;
    repi(i, n, 0)
    {
        cin >> op >> num;
        if (op == "insert")
        {
            dic.insert(make_pair(num, 1));
        }
        else if (op == "find")
        {
            if (dic.count(num))
            {
                puts("yes");
            }
            else
            {
                puts("no");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 36940
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int K,N,A[200000],a,maxL=0;
	cin>>K>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	a=A[0];
	for(int i=0;i<N-1;i++){
		A[i]=A[i+1]-A[i];
		maxL=max(maxL,A[i]);
	}
	A[N-1]=K-A[N-1]+a;
	maxL=max(maxL,A[N-1]);
	cout<<K-maxL;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;	
		


int32_t main()
{   
	IOS
	int n;cin>>n;
	//int _5 = n/5;
	//int _3 = n/3;
	//int _15 = n/15;
	//cout << n*(n+1)/2 - _5*(2*5+(_5-1)*5)/2 - _3*(2*3+(_3-1)*3)/2 + _15*(2*15-(_15-1)*15)/2 <<endl;
	int sum = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				sum+=__gcd(i,__gcd(j,k));
			}
		}
	}
	cout<<sum<<endl;
}





Measured memory_bytes: 3652
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M, L = sc.nextInt
  val ABCs = Seq.fill(M)(sc.nextInt, sc.nextInt, sc.nextInt)
  val Q = sc.nextInt
  val STs = Seq.fill(Q)((sc.nextInt, sc.nextInt))

  def wf(a: Array[Array[Int]]) = {
    for(k <- 1 to N; i <- 1 to N; j <- 1 to N) if (a(i)(j) > a(i)(k) + a(k)(j)) a(i)(j) = a(i)(k) + a(k)(j)
  }

  val d = Array.fill(N + 1, N + 1)(L + 1)
  ABCs.foreach{case(a, b, c) => d(a)(b) = c; d(b)(a) = c}
  wf(d)
  val x = d.map(_.map{v => if(v <= L) 1 else L + 1})
  wf(x)
  STs.foreach{case(s, t) => println(if(x(s)(t) > L) -1 else x(s)(t) - 1)}
}

Measured memory_bytes: 114484
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;

int n, m;
int l[300010], r[300010];

VI yakusu[300010];
int ans[300010];

VI start[300010];
VI ed[300010];

struct bit
{
  int tree[300010];
  void add(int num, int val)
  {
    for(int i = num; i <= m; i += i & -i)
      tree[i] += val;
  }
  int sum(int s, int e)
  {
    int ret = 0;
    for(int i = e; i > 0; i -= i & -i)
      ret += tree[i];
    for(int i = s - 1; i > 0; i -= i & -i)
      ret -= tree[i];
    return ret;
  }
} tr;

signed main()
{
  cin >> n >> m;
  for(int i = 1; i <= n; i++)
    cin >> l[i] >> r[i];

  for(int i = 1; i <= m; i++){
    for(int j = i; j <= m; j += i)
      yakusu[j].PB(i);
  }

  for(int i = 1; i <= n; i++){
    start[l[i]].PB(l[i]);
    ed[r[i]].PB(l[i]);
  }

  for(int i = 1; i <= m; i++){
    tr.add(i, start[i].size());
    for(auto pt:yakusu[i]){
      ans[pt] += tr.sum(i - pt + 1, i);
    }
    for(auto pt:ed[i]){
      tr.add(pt, -1);
    }
  }

  for(int i = 1; i <= m; i++)
    cout << ans[i] << endl;
 
  return 0;
}


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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    class SegTree:
        def __init__(self,N,ide,segfunc=min):
            self.ide_ele = ide
            """
            ex)
             最小値のセグ木 → +inf
              和のセグ木 → 0
              積のセグ木 → 1
              gcdのセグ木 → 0
            """
            
            self.segfunc=segfunc
            
            #num:N以上の最小の2のべき乗
            self.num =2**(N-1).bit_length()
            self.seg=[self.ide_ele]*2*self.num

        #リストで初期化する
        def setL(self,init_val):
            #init_valは操作する数列
            for i in range(N):
                self.seg[i+self.num-1]=init_val[i]    
            #built
            for i in range(self.num-2,-1,-1) :
                self.seg[i]=self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 


        #k番目の値をxに更新
        def update(self,k,x):
            k += self.num-1
            self.seg[k] = x
            while k:
                k = (k-1)//2
                self.seg[k] = self.segfunc(self.seg[k*2+1],self.seg[k*2+2])


        #[p,q)の区間に対するクエリへの応答
        def query(self,p,q):
            if q<=p:
                return self.ide_ele
            p += self.num-1
            q += self.num-2
            res=self.ide_ele
            while q-p>1:
                if p&1 == 0:
                    res = self.segfunc(res,self.seg[p])
                if q&1 == 1:
                    res = self.segfunc(res,self.seg[q])
                    q -= 1
                p = p//2
                q = (q-1)//2
            if p == q:
                res = self.segfunc(res,self.seg[p])
            else:
                res = self.segfunc(self.segfunc(res,self.seg[p]),self.seg[q])
            return res

    mod=998244353
    N=I()
    X=[0]*N
    D=[0]*N
    
    for i in range(N):
        X[i],D[i]=MI()
    
    X,D=zip(*sorted(zip(X,D)))
    
    dp=[0]*(N+1)
    """
    dp[i]はi番目まで見たときと通り数，後ろから見てく．
    i番目を動かさないならば，dp[i+1]
    i番目を動かすならば，連鎖していき，影響が出ないところまで見る
    この連鎖分をセグ木で事前計算しておく．
    """
    seg=SegTree(N,0,max)
    seg.setL(range(N))
    # セグ木は，何番目まで影響するか，を持つ
    
    import bisect 
    
    for i in range(N-1,-1,-1):
        t=X[i]+D[i]
        num=bisect.bisect_left(X,t)
        l=i
        r=num
        M=seg.query(l,r)
        seg.update(i,M)
        
    dp[-1]=1
    for i in range(N-1,-1,-1):
        temp=seg.query(i,i+1)
        dp[i]=(dp[i+1]+dp[temp+1])%mod
        
    print(dp[0])
    
    # for i in range(N):
    #     print(dp[i])
        

main()


Measured memory_bytes: 117176
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n; 

ll dp[1000009][2][2];

ll solve(int idx, int a, int b) {
	if(idx == n)
		return a & b;

	if(dp[idx][a][b] != -1)
		return dp[idx][a][b];

	ll ans = 0;

	ans += solve(idx + 1, a, b) % mod;
	ans %= mod;
	ans *= 8;
	ans %= mod;
	ans += solve(idx + 1, 1, b) % mod;
	ans %= mod;
	ans += solve(idx + 1, a, 1) % mod;
	ans %= mod;

	return dp[idx][a][b] = ans;
}

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	memset(dp, -1, sizeof dp);
	
	cin >> n;
	cout << solve(0, 0, 0) % mod << endl;

	return 0;
}

Measured memory_bytes: 97144
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (h, w) = scan "%d %d" Tuple2.make
let mat = scan_matrix ~sep:' ' 10 10 0 Int.of_string
let mat2 = scan_matrix ~sep:' ' h w 0 Int.of_string

let () =
  ListL.iter (0++^10) ~f:(fun k ->
      ListL.iter (0++^10) ~f:(fun i ->
          ListL.iter (0++^10) ~f:(fun j ->
              mat.(i).(j) <- min mat.(i).(j) (mat.(i).(k)+mat.(k).(j))
            )
        ));
  ArrayL.map mat2 ~f:(fun a ->
      ArrayL.map a ~f:(fun v ->
          if v = -1 then 0
          else mat.(v).(1)
        )
      |> Array.sum
    )
  |> Array.sum
  |> Printf.printf "%d\n"


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int infint = 1e9;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e3 + 7;
ll pwr(ll a, ll b)
{
	if(b == 0)
		return 1;
	if(b == 1)
		return a;
	ll c = pwr(a, b / 2);
	c = (c * c);
	if(b % 2)
		c *= a;
	return c;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	ll A, B;
	cin >> A >> B;
	if(A == B)
		return cout << 1, 0;
	
	ll bt;
	for (int i = 0; i < 60; i++)
		if(((A >> i) & 1) != ((B >> i) & 1))
			bt = i;
	
	ll T = pwr(2, bt);
	for (int i = bt + 1; i < 60; i++)
	{
		if((A >> i) & 1)
			A -= (1LL << i);
		if((B >> i) & 1)
			B -= (1LL << i);
	}
	ll ans = T - A;
	
	ll C = B - T;
	for (int i = 60; i >= 0; i--)
		if((1LL << i) > C)
			bt = i;
	C = T + (1LL << bt) - 1;
	//second : [T, C]
	ans += C - T + 1;
	//third : [T + A, 2 * T - 1]
	ans += T - A;
	//intersection.
	ll L = T + A, R = min(C, 2 * T - 1);
	if(R >= L)
		ans -= R - L + 1;
	cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	ll a, b, n;
	while(scanf("%lld%lld%lld", &a, &b, &n)==3)
	{
		ll x=(n<b-1)?n:b-1;

		ll ans=a*x/b-a*(x/b);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll flag=0;
    int i=1;
    for( i=1;i<10001;i++)
    {
        if(int(i*0.08)==a&&int(i*0.10)==b)
        {
            flag=1;
            break;
        }
    }
    if(flag==1)
        cout<<i<<"\n";
    else cout<<-1<<"\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] s = new String[n];
        String ans = "Three";
        for(int i=0; i<n; i++) {
            s[i] = sc.next();
            if(s[i].equals("Y")) {
                ans = "Four";
                break;
            }
        }
        System.out.println(ans);
        
    }
}


Measured memory_bytes: 22100
#include <iostream>
#include <string>

using namespace std;

int main() {
    int ans = 0;
    string s1, s2;
    getline(cin, s1);
    getline(cin, s2);

    // change uppercase to lowercase
    for(int i=0; i<s1.length(); i++) {
        if (s1[i] >='A' && s1[i] <='Z') s1[i] = (char)(s1[i] - 'A' + 'a');
    }


    int line  = 1;
    while(s2!="END_OF_TEXT") {
        string tmp ="";
        for(int i=0; i<s2.length(); i++) {
            if (s2[i]!=' ') {
                if (s2[i] >='A' && s2[i] <='Z') {
                  s2[i] = s2[i] - 'A' + 'a';
                }
                tmp+=s2[i];
            } else {
                if (s1 == tmp) ans++;
                tmp = "";
            }
        }
        if (tmp.length() && s1 == tmp) {
         ans++;
        }
        tmp ="";
        line ++;
        getline(cin, s2);
    }

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


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

int main()
{
    set<string> st;

    int n;
    cin>>n;

    string last;
    bool good = true;

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

        if (i) {
            if (st.count(s) || last.back() != s[0])
                good = false;
        }
        st.insert(s);
        last = s;
    }
    cout<<(good ? "Yes" : "No")<<endl;
}


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

int main()
{
    long long n,m,ans;
    cin >> n >> m;
    if(n == 1){
        if(m == 1){
            ans = 1;
        }else{
            ans = m-2;
        }
    }else if(m == 1){
        ans = n-2;
    }else{
        ans = (n-2)*(m-2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N,K;
    cin>>N>>K;
    vector<int> h(N);
    REP(i,N){
        cin>>h[i];
    }
    int cnt = 0;
    REP(i,N){
        if(h[i]>=K){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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


int main()
{
    string s,t;
    cin >> s >> t;
    int q = s.length();
    int w = t.length();
    int lengthdp[q+1][w+1];
    for (int e = 0; e < q+1; e++)
    {
        lengthdp[e][0]=0;
    }
    for (int e = 0; e < w+1; e++)
    {
        lengthdp[0][e]=0;
    }
    for (int e = 1; e < q+1; e++)
    {
        for (int r = 1; r < w+1; r++)
        {
            if (s[e-1]==t[r-1])
            {
                lengthdp[e][r]=1+lengthdp[e-1][r-1];
            }
            else
            {
                lengthdp[e][r]=max(lengthdp[e-1][r], lengthdp[e][r-1]);
            }
            //cout << " " << lengthdp[e][r];
        }
        //cout << endl;
    }
    int curr1=q, curr2=w;
    vector<char> things;
    while (curr1 > 0 && curr2 > 0)
    {
        if (s[curr1-1]==t[curr2-1])
        {
            things.push_back(s[curr1-1]);
            //cout << s[curr1];
            curr1--;
            curr2--;
        }
        else
        {
            if (lengthdp[curr1-1][curr2] > lengthdp[curr1][curr2-1])
            {
                curr1--;
            }
            else
            {
                curr2--;
            }
        }
    }
    for (int e = things.size()-1; e >= 0; e--)
    {
        cout << things[e];
    }
    return 0;
}


Measured memory_bytes: 35456
package main

import "fmt"

func solve() {
	var X, Y string
	fmt.Scan(&X, &Y)
	if rune(X[0]) < rune(Y[0]) {
		fmt.Println("<")
	} else if rune(X[0]) == rune(Y[0]) {
		fmt.Println("=")
	} else {
		fmt.Println(">")
	}
}

func main() {
	solve()
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=0;i--)
#define rep_re(i,s,n)for(int i = n;i>=0;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

double a[101] = {};
int main() {
	ll n; cin >> n;
	double ans = 0;
	rep(i, 0, n) {
		double x; cin >> x;
		ans += 1 / x;
	}
	printf("%7f", 1 / ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	int H;
	int N;
	int sum = 0;
	int i;
	char buf[128], *ch;
	char *buf_array;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	H = atoi(ch);
	ch = strtok(NULL, " ");
	N = atoi(ch);

	buf_array = (char *)calloc(N * 8, sizeof(char));

	fgets(buf_array, N * 8, stdin);
	ch = strtok(buf_array, " ");
	sum += atoi(ch);
	for(i = 1; i < N; i += 1) {
		ch = strtok(NULL, " ");
		sum += atoi(ch);
	}

	if(H <= sum) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	free(buf_array);
	return 0;
}


Measured memory_bytes: 896
// DPで解く方法

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int DP[100005];

int main() {
  int X;
  cin >> X;
  DP[0] = 1;
  REP(i,X)
    REP(j,6)
      DP[i+100+j] = DP[i] | DP[i+100+j];

  if (DP[X]==1)
    cout << "1" << endl;
  else
    cout << "0" << endl;

}


Measured memory_bytes: 640
#include<iostream>
#include<cstdint>
#include<algorithm>
using namespace std;

const int MAX = 100000;
int main() {
	int N;
	static int A[MAX], B[MAX], C[MAX];
	int64_t paturn = 0;
	
	cin >> N;
	for (int i = 0;i < N;i ++) cin >> A[i];
	for (int i = 0;i < N;i ++) cin >> B[i];
	for (int i = 0;i < N;i ++) cin >> C[i];
	
	sort(A, A+N);
	sort(B, B+N);
	sort(C, C+N);
	
	static int64_t Br[MAX + 1];
	Br[N] = 0;
	for (int i = N - 1, j = N - 1;i >= 0;) {
		if (j < 0) {
			Br[i] = N;
			i --;
		} else {
			if (B[i] >= C[j]) {
				Br[i] = N - j - 1;
				i --;
			} else {
				j --;
			}
		}
	}
	// この時点で、あるBを決めた時のCの組み合わせが確定
	
	for (int i = N - 1;i >= 0;i --) Br[i] += Br[i + 1]; // 累積和
	
	// この時点で、あるBまでが使える時の組み合わせの数が分かる
	
	for (int i = N - 1, j = N - 1;i >= 0;) {
		if (j < 0) {
			paturn += Br[0];
			i --;
		} else {
			if (A[i] >= B[j]) {
				paturn += Br[j + 1];
				i --;
			} else {
				j --;
			}
		}
	}
	// 後はあるAに対し使える最小のBが分かれば十分
	
	cout << paturn;
	return 0;
}// O(N)

Measured memory_bytes: 2176