akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define x first
#define y second
#define int int long long // 2e9 & 9e18
using namespace std; const int inf = numeric_limits<int>::max();
struct __io{__io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}} __io; // fast I/O
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<", "<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif

int n, k;

bool opeation(vector<int> &a) {
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        d[max(0ll, i-a[i])]++;
        if (i+a[i]+1 < n) {
            d[i+a[i]+1]--;
        }
    }
    a[0] = d[0];
    bool done = a[0] == n;
    for (int i = 1; i < n; ++i) {
        a[i] = a[i-1] + d[i];
        if (a[i] < n) done = false;
    }
    return done;
}

signed main() {
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < k; ++i) {
        if (opeation(a)) break;
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 6356
#include<cstdio>
using namespace std;
const int maxn=100+2;
const int ABC=26;
int n,m;
int num[ABC];
char str[maxn];
int change(char ch){return ch-'a';}
int main(){
	scanf("%d%d",&n,&m);
	int one=(n>>1)*(m>>1),two=(n&1)*(m>>1)+(m&1)*(n>>1),three=m&n&1;
	for (int i=1;i<=n;i++){
		scanf("%s",str+1);
		for (int j=1;j<=m;j++) num[change(str[j])]++;
	}
	bool flag=true;
	for (int i=0;i<ABC;i++){
		while (num[i]>=4&&one){
			num[i]-=4;
			one--;
		}
		while (num[i]>=2&&two){
			num[i]-=2;
			two--;
		}
		while (num[i]&&three){
			num[i]--;
			three--;
		}
		if (num[i]){
			flag=false;
			break;
		}
	}
	if (flag) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;i++)
int main()
{
	ios_base::sync_with_stdio(false);
	string s;
	cin>>s;
	if(s[s.size()-1]=='s')
		cout<<s+"es"<<endl;
	else
		cout<<s+"s"<<endl;
	return 0;
}

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

int main(){
  int n,k,s;
  cin >> n >> k >> s;
  int count=0;
  for(int i=0;i<n;i++){
    if(count<k){
      cout << s << " ";
      count++;
    }
    else{
      if(s==1000000000) cout << 1 << " ";
      else cout << 1000000000 << " ";
    }
  }
 return 0; 
}



Measured memory_bytes: 1280
import numpy as np
import sys

x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
p = np.array(list(map(int, input().split())))
diff = set(p - x)
for i in range(102):
    if -i not in diff:
        print(x-i)
        break
    elif i not in diff:
        print(x+i)
        break

Measured memory_bytes: 27200
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
    int N;//かっている数//最大100
    cin >> N;
    vector<int> a(N, 0);
    for (int i = 0; i < N; i++) { //0からn-1まで
        cin >> a[i];
    }

    //色は0-9999まである
    int col = -1;
    int count = 1;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        // cout << count <<endl;
        if (a[i] != col) {
            if (count >= 2) {
                ans += count / 2;
            }
            count = 1;
            col = a[i];
        } else if (a[i] == col) {
            count++;
        }
    }
    if (count >= 2) {
        ans += count / 2;
    }


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


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

int main() {
	int n;
	cin >> n;
	vector<double> x(n), y(n);
	for (auto &e : x) cin >> e;
	for (auto &e : y) cin >> e;
	double a = 0, b = 0, c = 0, d = 0;
	for (int i = 0; i < n; i++) {
		a += abs(x[i] - y[i]);
		b += pow(abs(x[i] - y[i]), 2);
		c += pow(abs(x[i] - y[i]), 3);
		d = max(abs(x[i] - y[i]), d);
	}
	cout << setprecision(10) << a << endl;
	cout << setprecision(10) << sqrt(b) << endl;
	cout << setprecision(10) << pow(c, 1.0 / 3) << endl;
	cout << setprecision(10) << d << endl;
}


Measured memory_bytes: 3480
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string S;
  std::cin >> S;
  S[3] = '8';

  print(S);
  return 0;
}


Measured memory_bytes: 256
// Link : https://atcoder.jp/contests/abc147/tasks/abc147_b
#include <iostream>
#include <string>
using namespace std;

int sisa(string an)
{
    int len = an.length();

    if (len == 0 || len == 1)
    {
        return 0;
    }

    else if (an[0] == an[len - 1])
    {
        string sub = an.substr(1, len - 2);
        // cout<<len<<"\n";

        return 0 + sisa(sub);
    }

    string sub = an.substr(1, len - 2);
    return 1 + sisa(sub);
}

int main()
{
    string a;
    cin >> a;
    int hasil = sisa(a);
    cout << hasil;

    return 0;
}


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

int main(void){
    int N;
    scanf("%d", &N);

    int A[100];
    int sum = 0;
    int count = 1;
    scanf("%d", &A[0]);

    for(int i = 1; i < N; i++){
       scanf("%d", &A[i]);
       if(A[i] == A[i - 1]){
           count++;
       }else{
           sum += count / 2;
           count = 1;
       }
    }
    sum += count / 2;

    printf("%d\n", sum);

    return 0;
}



Measured memory_bytes: 888
#include"bits/stdc++.h"

#define MOD 1000000007
#define rep(i, N) for(int i = 0;i < N;i++)
#define ll long long
#define int long long

using namespace std;


signed main(void) {
	int N; cin >> N;
	vector<int> A(N), cnt(N);
	int totComb = 0;
	rep(i, N) {
		cin >> A[i];
		A[i]--;
		cnt[A[i]]++;
	}

	rep(i, N)if (cnt[i] >= 2)totComb += (cnt[i] * (cnt[i] - 1)) / 2;

	rep(i, N) {
		cout << totComb - (cnt[A[i]] - 1) << endl;
	}

	return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include <vector> // vector
using namespace std;
 
int main(){
  int N;
  cin>>N;
  vector<int>data(N-1);
  vector<int>sum(N,0);
  for(int i = 0;i<N-1;i++){
    cin>>data.at(i);
    sum.at(data.at(i)-1)++;
  }
  for(int i = 0;i<N;i++){
    cout<<sum.at(i)<<endl;
  }
}

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

int main()
{
    int r,i,j;
    cin>>r;
    int arr[r][3];
    long long dp_table[r][3];
    for(i=0;i<r;i++){
        for(j=0;j<3;j++){
            cin>>arr[i][j];
            dp_table[i][j]=-1;
        }
    }
    dp_table[r-1][0]=(long long)(arr[r-1][0]);
    dp_table[r-1][1]=(long long)(arr[r-1][1]);
    dp_table[r-1][2]=(long long)(arr[r-1][2]);
    for(i=r-2;i>=0;i--){
        for(j=0;j<3;j++){
            if(j==0){
                dp_table[i][j]=(long long)(arr[i][j]+max(dp_table[i+1][1],dp_table[i+1][2]));
            }
            else if(j==1){
                dp_table[i][j]=(long long)(arr[i][j]+max(dp_table[i+1][0],dp_table[i+1][2]));
            }
            else{
                dp_table[i][j]=(long long)(arr[i][j]+max(dp_table[i+1][0],dp_table[i+1][1]));
            }
        }
    }
    //cout<<endl;
    long long t1=max(dp_table[0][0],dp_table[0][1]);
    t1=max(t1,dp_table[0][2]);
    cout<<t1;

}


Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//const int mod = 998244353;
const int N = 2000005;
const int K = 1000000;
vector < int > ls[N], rs[N];
int s[N], n;
int check(int A, int delta){
    int m = (n - A - 1) / delta;
    if (delta >= A) return -1;
    if (A % delta == 0){
        if (A / delta <= m) return -1;
        return ls[delta][m] + rs[delta][m];
    }
    return ls[delta][m] + rs[delta][m];
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 1; i < n; i++){
        ls[i].pb(0);
        rs[i].pb(0);
        for (int j = i; j < n; j += i){
            int x = ls[i].back();
            ls[i].pb(x + s[j]);
        }
        for (int j = n - 1 - i; j >= 0; j -= i){
            int x = rs[i].back();
            rs[i].pb(x + s[j]);
        }
    }
    int ans = 0;
    for (int i = 1; i < n; i++){
        int d = n - i - 1;
        for (int j = 1; j * j <= d; j++){
            if (d % j != 0) continue;
            ans = max(ans, check(i, j));
            ans = max(ans, check(i, d / j));
        }
    }
    cout << ans;
}


Measured memory_bytes: 123764
#include<iostream>
using namespace std;
int main(){
  int A,B,X;
  cin>>X>>A>>B;
  
  if(A-B >= 0){
    cout<<"delicious"<<endl;
  }
  else  if(B-A <= X ){
    cout<<"safe"<<endl;
  }
  else if(A-B <= X+1 ){
    cout<<"dangerous"<<endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
def con(var):
    var=str(var)
    while(len(var)<6):
        var="0"+var
    return var
 
 
def run():
    N,M=map(int,input().split())
    P=[-1]*M
    Y=[-1]*M
    arr=[]
    for i in range(M):
        P[i],Y[i]=input().split()
        P[i]=int(P[i])-1
        Y[i]=int(Y[i])
        arr.append([P[i],Y[i],i])
    arr=sorted(arr,key=lambda x:x[1])
    ans=[0]*M
    cnt=[0]*N
    for i in range(M):
        cnt[arr[i][0]]=cnt[arr[i][0]]+1
        ans[arr[i][2]]=con(arr[i][0]+1)+con(cnt[arr[i][0]])
    for i in range(M):
        print(ans[i])
run()

Measured memory_bytes: 33672
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();

		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N;
  string S;
  cin>>N>>S;
  int cnt=0;
  for(int i=0;i<N;i++){
    if(S.substr(i,3)=="ABC"){cnt++;}
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3580
n=int(input())
arr=[int(x) for x in input().split()]

arr.sort()
flag=0
pdt=1
for i in range(n):
  pdt=pdt*arr[i]
  if(pdt>1000000000000000000):
    flag=1
    break

if(flag==1):
  print(-1)
else:
  print(pdt)

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> v;
  load(v, n);

  int c = 0;
  for (int i = 0; i < n - 2; ++i) {
    if ((v[i] < v[i + 1] && v[i + 1] < v[i + 2])
        || (v[i] > v[i + 1] && v[i + 1] > v[i + 2])) {
      c++;
    }
  }
  p(c);
}

Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define                          ll                          long long int
ll gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

#define                          in(x)                       scanf("%lld",&x)
#define                          in2(x,y)                    scanf("%lld %lld",&x,&y)
#define                          in3(x,y,z)                  scanf("%lld %lld %lld",&x,&y,&z)
#define                          out(x)                      printf("%lld\n",x)
#define                          cy                          printf("YES\n")
#define                          cn                          printf("NO\n")
#define                          inf                         1e18
#define                          neg                         -1e18
#define                          mx                          200009
#define                          fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                          fi                          first
#define                          si                          second
#define                          ce                          cout<<endl
#define                          pb                          push_back
#define                          vc(x)                       x.begin(),x.end()
#define                          pb                          push_back
#define                          pi                          pair<ll,ll>
#define                          debug                       printf("ok\n");
#define                          pg                          pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> >
#define                          mod                         1000000007
vector<ll>vt[mx];
bool vis[mx]={false},vertex,edge;
ll coun=0;
void dfs(ll u){
   coun++;
   vis[u]=1;
   for(auto x:vt[u]){
     if(!vis[x]){


            dfs(x);
     }
   }
}

int main(){

     ll i,n,j,ans=0,m,s=0,sum=0,x=0,u,v;

     cin>>m>>n;
     for(i=0;i<n;i++){
      cin>>u>>v;
        vt[u].pb(v);
        vt[v].pb(u);

     }

     for(i=1;i<m;i++){

         if(!vis[i]){
           dfs(i);
         }
         ans=max(ans,coun);
         coun=0;
     }
     cout<<ans;


}



Measured memory_bytes: 21012
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define out(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> m;
    REP(i,n) {
        int x; cin >> x;
        m[x]++;
    }

    int ans = 0;
    for(auto x:m) {
        if (x.second - x.first >= 0) ans += x.second-x.first;
        else ans += x.second;
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A*B}) << endl;
    return 0;
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
using ll = long long;

constexpr int SZ = 100000, prs = 10;
ll pre[1 << prs][SZ + 1];

int main() {
  int N;
  cin >> N;
  vector<int> V(N + 1), W(N + 1);
  REP(i, N) cin >> V[i + 1] >> W[i + 1];
  FOR(i, 1, min(N + 1, 1 << prs)) {
    if (i != 1) copy(pre[i / 2], pre[i / 2] + SZ + 1, pre[i]);
    for (int j = SZ; j >= W[i]; --j)
      pre[i][j] = max(pre[i][j], pre[i][j - W[i]] + V[i]);
    REP(j, SZ) pre[i][j + 1] = max(pre[i][j + 1], pre[i][j]);
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    if (v < (1 << prs)) {
      cout << pre[v][L] << "\n";
    } else {
      int lvl = 32 - __builtin_clz(v) - prs;
      ll ans = 0;
      REP(b, 1 << lvl) {
        int w = 0;
        ll va = 0;
        REP(i, lvl) {
          if ((b >> i) & 1) {
            w += W[v >> i];
            va += V[v >> i];
          }
          if (w > L) break;
        }
        if (w <= L) ans = max(ans, pre[v >> lvl][L - w] + va);
      }
      cout << ans << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 804452
NN = 18
MA = [-1] * ((1<<NN+1)-1)
MI = [1<<100] * ((1<<NN+1)-1)
 
def update(a, x):
    i = (1<<NN) - 1 + a
    MI[i] = x
    MA[i] = x
    while True:
        i = (i-1) // 2
        MI[i] = min(MI[2*i+1], MI[2*i+2])
        MA[i] = max(MA[2*i+1], MA[2*i+2])
        if i == 0:
            break
def rangemin(a, b):
    l = a + (1<<NN)
    r = b + (1<<NN)
    mi = 1<<100
    while l < r:
        if l%2:
            mi = min(mi, MI[l-1])
            l += 1
        if r%2:
            r -= 1
            mi = min(mi, MI[r-1])
        l >>= 1
        r >>= 1
    return mi
def rangemax(a, b):
    l = a + (1<<NN)
    r = b + (1<<NN)
    ma = -1
    while l < r:
        if l%2:
            ma = max(ma, MA[l-1])
            l += 1
        if r%2:
            r -= 1
            ma = max(ma, MA[r-1])
        l >>= 1
        r >>= 1
    return ma

N, K = map(int, input().split())
A = [int(a) for a in input().split()]
a = 0
l = -1
cnt = 0
for i in range(1, N):
    if A[i-1] > A[i]:
        a = i
    if i >= K-1 and a <= i - K + 1:
        if i - l > 1:
            cnt += 1
        l = i
ans = 1 - max(cnt-1, 0)
for i in range(N):
    update(i, A[i])
    if i >= K:
        mi = rangemin(i-K, i)
        ma = rangemax(i-K+1, i+1)
        if mi != A[i-K] or ma != A[i]:
            ans += 1

print(ans)

Measured memory_bytes: 128764
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        m: usize,
        e: [[Usize1;2];m],
    }

    let mut graph: Vec<Vec<usize>> = vec![vec![]; n];
    for v in e {
        let (from, to) = (v[0], v[1]);
        graph[from].push(to);
        graph[to].push(from);
    }

    let mut seen: Vec<Option<usize>> = vec![None; n];
    seen[0] = Some(0);
    let mut q: VecDeque<usize> = VecDeque::new();
    q.push_back(0);

    while let Some(n) = q.pop_front() {
        // なんらかの処理
        for &next in &graph[n] {
            if seen[next].is_some() {
                continue;
            }
            q.push_back(next);
            seen[next] = Some(n);
        }
    }

    println!("Yes");
    for i in 1..n {
        if let Some(n) = seen[i] {
            println!("{}", n + 1);
        }
    }
}


Measured memory_bytes: 19212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//codell here
	ll n,a,b;

	cin >> n >> a>>b;
	ll d = (n /(a+b))*a;
	ll p = n % (a+b);
	if(p<a){
		d+=p;
	} else {
		d+=a;
	}
	cout << d;
}

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

#define int long long

signed main(){
    string s;
    int k;
    cin >> s >> k;

    int n = s.size();

    for(int i = 0;i < n;i++){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }else{
            if(i+1 == k){
                break;
            }
        }
    }

    cout << 1 << endl;
    return 0;
}




Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**9)

def main():
    N,M,K = map(int,input().split())
    MOD = 998244353

    def get_fact(maxim,mod):
        maxim += 1
        fact = [0]*maxim

        fact[0] = 1
        for i in range(1,maxim):
            fact[i] = fact[i-1] * i % mod

        invfact = [0]*maxim
        invfact[maxim-1] =  pow(fact[maxim-1],mod-2,mod)

        for i in reversed(range(maxim-1)):
            invfact[i] = invfact[i+1] * (i+1) % mod

        return fact, invfact

    def powerful_comb(n,r,mod,fact,invfact):
        return fact[n] * invfact[r] * invfact[n-r] % mod

    ans = 0
    fact, invfact = get_fact(N+1,MOD)
    for i in range(K+1):
        ans += (M*pow(M-1,N-i-1,MOD) * powerful_comb(N-1,i,MOD,fact,invfact)) % MOD

    print(ans % MOD)

if __name__ == "__main__":
  main()

Measured memory_bytes: 70944
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            String s = sc.nextLine();
            if (s.equals("0")) {
                return;
            }
            List<Integer> ns;
            try {
                ns = Stream.of(s.split(""))
                        .map(Integer::parseInt)
                        .collect(Collectors.toList());
            } catch (NumberFormatException e) {
                System.out.println(e);
                return;
            }
            System.out.println(ns.stream().mapToInt(Integer::intValue).sum());
        }
    }
}




Measured memory_bytes: 33524
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		
		int divisor = 0;
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 2 != 1) {
				continue;
			}
			for (int j = 1; j <= n; j++) {
				if (i % j == 0) {
					divisor++;
				}
			}
			if (divisor == 8) {
				ans++;
			}
			
			divisor = 0;
		}
		System.out.println(ans);
	}
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e3 + 10;
const int MOD = 1e9 + 7;

int n;

int32_t main(){
    boost;

    //code
    cin >> n;
    int x , y;
    vector<int> xx , yy;

    for(int i = 0 ; i < n ; ++i){
    	cin >> x >> y;
    	xx.push_back(x);
    	yy.push_back(y);
    }
    int a = 1 , b  = 1;
    for(int i = 0 ; i < n ; ++i){
    	x = xx[i];
    	y = yy[i];
    	int m = max( (a-1)/x , (b-1)/y ) + 1;
    	a = m*x;
    	b = m*y;
    }
    cout << a + b;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int count = 0;

void sum(int A[],int left,int mid,int right)
{
    
  int n1=mid-left,n2=right-mid;
  int L[n1],R[n2];
  int i,j,k;
  
    for(i=0;i<=n1-1;i++)L[i]=A[left + i];
    for(i=0;i<=n2-1;i++)R[i]=A[mid + i];
    L[n1]=1000000000;
    R[n2]=1000000000;
    i=0;j=0;

    for(k=left;k<=right-1;k++){
      if(L[i]<= R[j]){
            A[k] = L[i];
            i++;
        }
	else{
            A[k] = R[j];
            j++;
        }
        count++;
    }
}
void num(int A[],int left,int right){
  if(left+1<right){
        int mid=(left + right)/2;
        num(A,left,mid);
	num(A,mid,right);
        sum(A,left,mid,right);
    }
}
int main()
{
    int n,S[1000000],i;
    
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&S[i]);
    
    num(S,0,n);
    
    for(i=0;i<n-1;i++)printf("%d ",S[i]);
    printf("%d\n",S[i]);
    printf("%d\n",count);
    
    return 0;
}



Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<int,int> P;

const int INF = 100000000;

char a[50][50];
int H,W;
int d[50][50];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int bfs(int x,int y){
	queue<P> que;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			d[i][j]=INF;
		}
	}
	que.push(P(x,y));
		d[x][y]=0;
		while(que.size()){
			P p=que.front();
			//cout << p.first << " " << p.second << endl;
			que.pop();
			//if(p.first==(H-1) && p.second==(W-1))break;
			for(int i=0;i<4;i++){
				int nx = p.first+dx[i], ny =p.second+dy[i];
				if (0<=nx && nx < H && 0 <= ny && ny < W && a[nx][ny]!='#' && d[nx][ny]==INF){
					que.push(P(nx,ny));
					d[nx][ny]=d[p.first][p.second]+1;
				}
			}
		}
		//return d[H-1][W-1];
	int ans = 0;
	rep(i,H)rep(j,W){
		if(d[i][j]!=INF)chmax(ans,d[i][j]);
		//cout << d[i][j] << endl;
		//d[i][j]=INF;
	}
	return ans;
}

int main(){
		cin>>H>>W;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				cin>>a[i][j];
			}
		}
	int ans = 0;
	rep(i,H)rep(j,W){
		if(a[i][j]=='.')chmax(ans,bfs(i,j));
		//cout << bfs(i,j) << endl;
	}
	cout << ans << endl;
	return 0;
  }


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

using namespace std;

int main() {
    int N,W;
    cin >> N >> W;
    vector<pair<int,int>> tresure(N+1);
    for ( int i = 0; i < N; ++i ) {
        cin >> tresure[i].first >> tresure[i].second;
    }
    //vector<vector<int>> dp(N);
    int dp[10001];

    for ( int w = 0; w <= W; ++w ) {
        dp[w] = 0;
    } 

    for ( int w = 0; w <= W; ++w ) {
        for ( int j = 0; j < N; ++j ) {
            if  (w >= tresure[j].second )dp[w] = max(dp[w], dp[w-tresure[j].second]+tresure[j].first);
        }
    }

    cout << dp[W] << endl;
}


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int[][] a = new int[3][3];

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		int n = sc.nextInt();
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}

		boolean[][] c = new boolean[3][3];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (b[i] == a[j][k]) {
						c[j][k] = true;
						break;
					}
				}
			}
		}

		boolean k = false;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (!c[i][j]) {
					k = false;
					break;
				} else {
					k = true;
				}
			}
			if (k) {
				System.out.println("Yes");
				return;
			}
		}


		for (int j = 0; j < 3; j++) {
			for (int i = 0; i < 3; i++) {
				if (!c[i][j]) {
					k = false;
					break;
				} else {
					k = true;
				}
			}
			if (k) {
				System.out.println("Yes");
				return;
			}
		}


		if ( (c[0][0] && c[1][1] && c[2][2]) || c[0][2] && c[1][1] && c[2][0] ) {
			System.out.println("Yes");
			return;
		}

		System.out.println("No");
		return;

	}

}


Measured memory_bytes: 35848
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second
int main() {
    ll x,y;
    cin>>x>>y;
    vi v;
    v.pb(x+y);
    v.pb(x-y);
    v.pb(x*y);
    sort(v.begin(),v.end());
    cout<<v[2]<<endl;
}


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

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

    string ans;

    if (d == 25) {
        ans = "Christmas";
    } else if (d == 24) {
        ans = "Christmas Eve";
    } else if (d == 23) {
        ans = "Christmas Eve Eve";
    } else if (d == 22) {
        ans = "Christmas Eve Eve Eve";
    }

    cout << ans << endl;
}


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

int main() {
	int n;cin>>n;
	double x[100],y[100],a[100];
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=0;i<n;i++)cin>>y[i];
	for(int i=0;i<n;i++)a[i]=abs(x[i]-y[i]);
	double p1,p2,p3,p4;p1=p2=p3=p4=0.0;
	for(int i=0;i<n;i++)p1+=a[i];
	for(int i=0;i<n;i++)p2+=a[i]*a[i];
	p2=sqrt(p2);
	for(int i=0;i<n;i++)p3+=a[i]*a[i]*a[i];
	p3=cbrt(p3);
	for(int i=0;i<n;i++)p4=p4<a[i]?a[i]:p4;
	cout<<fixed<<setprecision(5)<<p1<<endl<<p2<<endl<<p3<<endl<<p4<<endl;
	return 0;
}

Measured memory_bytes: 3424
using System;

namespace SoundHound2018C
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long[] inp = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            long n = inp[0];
            long m = inp[1];
            long d = inp[2];

            double rate;
            if (d == 0 || d == n)
            {
                rate = (double)1 / n;
            }
            else
            {
                rate = (double)2 * (n - d) / (n * n);
            }
            Console.WriteLine(rate * (m - 1));
        }
    }
}

Measured memory_bytes: 11220
N = int(input())
INF = float('inf')

L = []
R = []
for _ in range(N):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

maxL = max(L)
minR = min(R)

LR = [(minR - l + 1, r - maxL + 1) for l, r in zip(L, R)]
LR.sort()

ans = 0
S = INF
for (_, b), (a, _) in zip(LR, LR[1:]):
    S = min(S, b)
    ans = max(ans, a + S)

# minLとmaxRを一緒にする
for l, r in zip(L, R):
    now = r - l + 1
    now += max(0, minR - maxL + 1)
    ans = max(ans, now)

print(ans)

Measured memory_bytes: 25312
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 13 September 2020 05:56:14 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

const int Mod = 1e9+7;

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<Mod>;
class Solver{
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        void solve(){
            int n;
            cin >> n;
            if(n == 1){
                cout<<0<<endl;
                return;
            }
            mint ans = 1; 
            for(int i=0; i<n; ++i){
                ans *= 8;
            }
            mint a=1;
            for(int i=0; i<n; ++i){
                a*=9;
            }
            mint k = 1;
            for(int i=0; i<n; ++i){
                k*=10;
            }
            cout<<(k-a*2+ans)<<endl;
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int c[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    int jud1=false;
    int jud2=false;
    int jud3=false;
    int jud4=false;
    if(c[0][0]-c[0][1]==c[1][0]-c[1][1] && c[0][0]-c[0][1]==c[2][0]-c[2][1]) jud1=true;
    if(c[0][1]-c[0][2]==c[1][1]-c[1][2] && c[0][1]-c[0][2]==c[2][1]-c[2][2]) jud2=true;
    if(c[0][0]-c[1][0]==c[0][1]-c[1][1] && c[0][0]-c[1][0]==c[0][2]-c[1][2]) jud3=true;
    if(c[1][0]-c[2][0]==c[1][1]-c[2][1] && c[1][0]-c[2][0]==c[1][2]-c[2][2]) jud4=true;
    if(jud1*jud2*jud3*jud4) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}


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

    int N;
    string str;
    char s[200];
    memset(s, -1, sizeof(s));

    cin >> str;
    N = str.length();

    for (int i = 1; i <= N; ++i) {
        s[i*2] = str[i-1];
    }

    for (int i = 2; i <= 2*N; i += 2) {
        switch(s[i]) {
        case 'H': case 'B': case 'R':
            if (s[i+2] != 'A') s[i+1] = 'A';
            break;
        case 'K':
            if (s[i-2] != 'A') s[i-1] = 'A';
            break;
        }
    }

    string ans;
    for (int i = 0; i <= 2*N + 2; ++i) {
        if (~s[i]) ans += s[i];
    }

    cout << ((ans == "AKIHABARA") ? "YES" : "NO") << endl;


    return 0;
}


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

int main()
{
    long long int a,b,k;
    cin>>a>>b>>k;
    if(a>k)
        a-=k;
    else{
        b-=k-a;
        a=0;
    }
    if(b<0)
        b=0;
    cout<<a<<' '<<b;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

dp = [-1] * N

dp[0] = 0
dp[1] = dp[0] + abs(h[1] - h[0])

for x in range(2, N):
    dp[x] = min(dp[x - 1] + abs(h[x] - h[x - 1]),
                dp[x - 2] + abs(h[x] - h[x - 2]))
print(dp[N - 1])

Measured memory_bytes: 85092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

int main() {
	
	int n, k;
	cin >> n >> k;
	
	if (k > (n - 1) * (n - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	
	V<P> ans;
	int now = 0;

	rep1(i, n - 1) {
		int u = 1;
		ans.push_back(P(u, i + 1));
		now += i - 1;
		while (now > k) {
			u++;
			ans.push_back(P(u, i + 1));
			now--;
		}
	}

	cout << ans.size() << endl;
	for (auto p : ans)cout << p.first << " " << p.second << endl;

}

Measured memory_bytes: 384
INF = 10**11


def binary_search(array, value):
    start = 0
    end = len(array) - 1
    while end - start >= 2:
        tmp = (start + end) // 2
        # print(start, end, tmp)
        if array[tmp] <= value:
            start = tmp
        else:
            end = tmp
        # print(start, end, tmp)
    return start


A, B, Q = map(int, input().split())
s_array = [int(input()) if i != 0 else -INF for i in range(A + 1)]
s_array.append(INF)
t_array = [int(input()) if i != 0 else -INF for i in range(B + 1)]
t_array.append(INF)
q_array = [int(input()) for i in range(Q)]

# print(s_array, t_array, q_array)

ans_array = []
for q in q_array:
    s_index = binary_search(s_array, q)
    t_index = binary_search(t_array, q)
    method_a = q - min(s_array[s_index], t_array[t_index])
    method_b = max(s_array[s_index + 1], t_array[t_index + 1]) - q
    method_c = (q - s_array[s_index]) + (t_array[t_index + 1] - q) + min(
        (q - s_array[s_index]), (t_array[t_index + 1] - q))
    method_d = (q - t_array[t_index]) + (s_array[s_index + 1] - q) + min(
        (q - t_array[t_index]), (s_array[s_index + 1] - q))
    ans_array.append(min(method_a, method_b, method_c, method_d))

for ans in ans_array:
    print(ans)

Measured memory_bytes: 107228
#include <stdio.h>
int main (){
  int k=0,t=0;
char s[101];
scanf ("%s",s);
  for (int i=0;s[i]!=0;i++){
    t++;
  }
  printf ("%c%d%c",s[0],t-2,s[t-1]);
  return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int x = in.nextInt();
			int y = in.nextInt();
			int[] a = {1, 3, 5, 7, 8, 10, 12};
			int[] b = {4, 6, 9, 11};
			int[] c = {2};
			
			for(int i = 0; i < a.length; i++) {
				if(a[i] == x) {
					x = 100;
				}
				if(a[i] == y) {
					y = 100;
				}
			}
			
			for(int i = 0; i < b.length; i++) {
				if(b[i] == x) {
					x = 200;
				}
				if(b[i] == y) {
					y = 200;
				}
			}
			
			for(int i = 0; i < c.length; i++) {
				if(c[i] == x) {
					x = 300;
				}
				if(c[i] == y) {
					y = 300;
				}
			}
			out.println(x == y ? "Yes" : "No");
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 22996
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! flush {
    () => {
        std::io::stdout().flush().unwrap();
    };
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut xs: Vec<u64> = sc.vec(n);
    xs.sort();
    put!((1..n).map(|i| xs[n - 1 - i / 2]).sum::<u64>());
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 14988
/*    Don’t Quit
    
    When things go wrong as they sometimes will;
        When the road you’re trudging seems all uphill;
            When the funds are low, and the debts are high;
                And you want to smile, but you have to sigh;
                    When care is pressing you down a bit
                        Rest if you must, but don’t you quit.
*/
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=2e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
vector<int>vp[N];

int32_t main()
{
    IOS;
    string s,t;
    cin>>s>>t;
    int sum=0;
    for(int i=0;i<min(s.size(),t.size());i++)
    {
        sum+=(s[i]==t[i]);
    }
    cout<<sum<<endl;
    
    
    

        
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt(), b = s.nextInt();
		int c = a/b;
		if (a - b*c <= 0) {
			System.out.println(c);
		}else {
			if (a - b*(c+1) <= 0)
			System.out.println(c+1);
		}

	}
}


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

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

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
inline void putint(int X) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int keta = 0;
	char C[6];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
const int bm = 500001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A < bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
int L[500001], R[500001], C[500001], ne[500001];
int are[500001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), Q = getint();
	rep1(i, N) C[i] = getint();
	rep1(i, Q) {
		L[i] = getint();
		int r = getint();
		ne[i] = R[r];
		R[r] = i;
	}
	rep1(i, N) {
		if (are[C[i]]) add(are[C[i]]);
		are[C[i]] = i;
		
		for (int r = R[i]; r; r = ne[r]) {
			L[r] = i - L[r] - query(L[r]) + 1;
		}
	}

	rep1(i, Q) putint(L[i]);
	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 14988
#include <iostream>
#include <assert.h>

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int64_t X,Y;
  std::cin >> X >> Y;
  int64_t cnt = 0;
  for(int64_t i = X; i <= Y; i+=i){
    cnt++;
  }
  std::cout << cnt << std::endl;

  return 0;
}


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


int main(){
    int N;
    cin >> N;
    vector<int> P(N),Q(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    int a = 0,b = 0;
    while(next_permutation(P.begin(),P.end())) ++a;
    while(next_permutation(Q.begin(),Q.end())) ++b;
    cout << abs(b-a) << endl;

}

Measured memory_bytes: 256