akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int x = sc.nextInt();
    int t = sc.nextInt();

    int kaisuu = 0;
    int nn = n;
    while(nn > 0) {
      nn = nn - x;
      kaisuu++;
    }
    
    System.out.println(kaisuu*t);
  }
}


Measured memory_bytes: 35596
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#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 vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	int count4 = 0;
	int count2 = 0;
	int count = 0;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 4 == 0) {
			count4++;
		}
		else if (a % 2 == 0) {
			count2++;
		}
		else {
			count++;
		}
	}
	bool flag = true;
	count4++;
	if( (count > count4)or
		(count2 > 0&&count == count4) ){
		flag = false;
	}
	
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define stdi(in) freopen(in, "r", stdin)
#define stdo(out) freopen(out, "w", stdout)
#define stdio(in, out) stdi(in); stdo(out)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define MAX 1000007
#define MOD 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
//typedef int ittt;
//#define int ll


using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const ll inf = 1e18;

ll hit[MAX];
ll dp[MAX];
int n;

ll solve(int i){
	if(i<=1){
		return 0;
	}

	if(dp[i]!=-1) return dp[i];

	ll ans = solve(i-1)+abs(hit[i]-hit[i-1]);

	if(i-2>0){
		ans = min(ans, solve(i-2)+abs(hit[i]-hit[i-2]));
	}

	return dp[i] = ans;

}

int main(){
    /*#ifndef ONLINE_JUDGE
        stdio("in", "out");
    #endif*/
    fast;
    cin>>n;

    for(int i=1;i<=n;i++){
    	cin>>hit[i];
    	dp[i] = -1;
    }

    ll ans = solve(n);
    cout<<ans<<'\n';
    
    return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int a[105],b[105];
int ans;
int main(void){
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>b[i];
    }
    a[0]=b[0]; a[n-1]=b[n-2];
    ans=a[0]+a[n-1];
    for(int i=1;i<n-1;i++){
        a[i]=min(b[i-1],b[i]);
        ans+=a[i];
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
r=range;x,y,z,k=map(int,input().split())
a,b,c=eval("list(map(int,input().split())), "*3)
ab=sorted([a[i]+b[j]for i in r(x)for j in r(y)],reverse=True)
abc=sorted([ab[i]+c[j]for i in r(min(3000,x*y))for j in r(z)],reverse=True)
print(*[abc[i]for i in r(k)])

Measured memory_bytes: 141000
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>

#define nl '\n'

using namespace std;

int n;
double x, t;
string u;


int main(){

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x >> u;
        if(u == "JPY"){
            t = t + x;
        } else if(u == "BTC"){
            t = t + (x*380000);
        }
    }

    cout << t;



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

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

int main() {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if (r>x){
    cout << "No" << endl;
  }
  else if (r>y){
    cout << "No" << endl;
  }
  else if (W<x+r){
    cout << "No" << endl;
  }
  else if (H<y+r){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}




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

int main()
{
    long long int X, count, val;
    cin>>X;
    count=0;
    val=100;
    double p;
    while(val<X)
    {
        p=val*1.0;
        p=p*(1.01);
        val=floor(p);
        count+=1;
    }
    cout<<count;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define INF 2000000000
#define pb push_back 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define double long double
 
using namespace std;

int main()
{
    IOS;
    ll h,n;
    cin >> h >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
    {
        ll x;
        cin >> x;
        sum += x;
    }
    if(sum >= h)
        cout << "Yes";
    else
        cout << "No";
}   

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[200000], inv[200000];

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i), --a[i];
    forn(i, n) inv[a[i]] = i;
    int cur = 1, mx = 1;
    for (int i = 1; i < n; ++i) {
        if (inv[i] > inv[i - 1]) {
            ++cur;
            mx = max(mx, cur);
        } else {
            cur = 1;
        }
    }
    cout << n - mx << endl;
    return 0;
}


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

int main(){
  long long H;
  cin >> H;
  long long div=0;
  long long temp=H;
  while(temp>0){
    temp=temp/2;
    div++;
  }
  long long ans=0;
  for(int i=0; i<div; i++){
    ans+=pow(2,i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0){break;}
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || i==H-1 || j==0 || j==W-1){cout << "#";}
                else{cout << ".";}
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int i;
string s;
int main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>s;
    for(i=s.length()-2;i>=0;i-=2)if(s.substr(0,i/2)==s.substr(i/2,i/2))rc(i);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w == 0) break;
            String s = "";
            String t = "";
            for(int i = 0; i < w; i++) {
                s += ((i%2) == 0) ? "#" : ".";
                t += ((i%2) == 1) ? "#" : ".";
            }
            for(int i = 0; i < h; i++) {
                System.out.println((i % 2) == 0 ? s : t);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 21252
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

void dout() { cerr << '\n'; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << " " << H;
    dout(T...);
}

#ifdef LOCAL
    #define dbg(...) cerr << #__VA_ARGS__, dout(__VA_ARGS__)
#else
    #define dbg(...) ;
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 200007, alph = 26;
int n, suf[N];
vector <int> vec[alph];
string s;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif

    cin >> s;
    n = s.size();

    int mask = 0;
    for (int i = n; i >= 1; i--) {
        int ch = (s[i - 1] - 'a');
        vec[ch].pb(i);

        suf[i] = suf[i + 1];
        mask |= (1 << ch);
        if (mask == (1 << alph) - 1) {
            mask = 0;
            suf[i]++;
        }
    }
    int len = suf[1] + 1, cur = 1;
    string ans = "";
    for (int i = 1; i <= len; i++) {
        for (int j = 0; j < alph; j++) {
            if (vec[j].empty()) {
                if (len == i) {
                    ans += char('a' + j);
                    break;
                }
            }
            int nxt = vec[j].back() + 1;
            if (len - i > suf[nxt]) {
                for (int k = cur; k < nxt; k++) {
                    int ch = (s[k - 1] - 'a');
                    vec[ch].ppb();
                }
                cur = nxt;
                ans += char('a' + j);
                break;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 2196
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100010
using namespace std;
int n,a[N],u[N];
vector<int> adj[N];
int dfs(int p = 1,int fa = 0)
{
    int tot = 0;
    for (int i = 0;i < adj[p].size();i++)
    {
        int x = adj[p][i];
        if (x == fa) continue;
        if (!dfs(x,p)) return 0;
        tot += u[x];
        if (adj[p].size() >= 2)
        {
            if (u[x] > a[p]) return 0;
        }
    }
    if (p != 1)
    {
        if (adj[p].size() == 1)
        {
            u[p] = a[p];
            return 1;
        } else {
            u[p] = 2*a[p]-tot;
            if (u[p] < 0) return 0;
            if (u[p] > a[p]) return 0;
            else return 1;
        }
    } else {
        if (adj[p].size() == 1)
        {
            if (tot != a[p]) return 0;
            return 1;
        } else {
            if (tot != a[p]*2) return 0;
            return 1;
        }
    }
}
int main()
{
    cin >> n;
    for (int i = 1;i <= n;i++) scanf("%d",&a[i]);
    for (int i = 1;i <= n-1;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    if (dfs()) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 13184
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int main() {
    int n;
    scanf("%d",&n);
 
    LL a=1,b=1;
    for(int i=1;i<=n;i++){
        LL x,y;
        scanf("%lld%lld",&x,&y);
        LL percent=max(a/x,b/y);
        while(true){
            if(percent*x>=a&&percent*y>=b)
                break;
            percent++;
        }
        a=percent*x;
        b=percent*y;
    }
    printf("%lld\n",a+b);
 
    return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1)a += 20;
	if (b == 1)b += 20;
	if (a == b)cout << "Draw";
	else if (a > b)cout << "Alice";
	else cout << "Bob";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
    long int n,ans,b,p;
    cin>>n;
    int a[n],prm[11]={1,2,6,24,120,720,5040,40320,362880,3628800,39916800};
    REP(i,n)cin>>a[i];
    REP(i,n){
        b=a[i];
        while(1){
            if(b%2==0){
                b=b/2;
                ans++;
            }
            if(b%2!=0)break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
  vector<int>K;
  int sum=0;
  for(int i=0;i<n;i++){
      int x;
      cin>>x;
      sum=sum+x;
      K.push_back(x);
      
  }
 
  int y=0;
  int c=0;
  int min=sum;
  for(int j=0;j<n-1;j++){
     y=y+K[j];
     c =sum-y;
     int x=y-c;
     if(x<0){
         x=-x;
     }
     if(x<min){
         min=x;
     }

     
  }


   cout<<min; 
}

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

int mem[50];

long long fib(int n){
  if(mem[n]!=-1)
    return mem[n];
  
  if(n==0||n==1)
    return mem[n]=1;

  return mem[n]=fib(n-1)+fib(n-2);
}

main()
{

  int n;
  
  cin >> n;
  
  for(int i=0;i<50;i++){
    mem[i]=-1;
  }

  cout << fib(n) << endl;

  return (0);
}



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

int main(){
    long A, B, K;
    cin>>A>>B>>K;
    if(A<=K){
        if(A+B-K>0)cout<<0<<" "<<A+B-K<<endl;
        else cout<<0<<" "<<0<<endl;
    }
    else cout<<A-K<<" "<<B<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, m, c[1009], s[510009], t[510009], cnt[1027], sum[1027];
int main() {
	while (scanf("%d%d", &n, &m), n) {
		for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
		sort(c, c + n);
		int b = 0;
		for (int i = 0; i <= n; i++) {
			for (int j = i; j <= n && c[i] + c[j] <= m; j++) {
				s[b++] = c[i] + c[j];
			}
		}
		for (int i = 0; i < 30; i += 10) {
			fill(cnt, cnt + 1024, 0); sum[0] = 0;
			for (int j = 0; j < b; j++) cnt[(s[j] >> i) & 1023]++;
			for (int j = 0; j < 1024; j++) sum[j + 1] = sum[j] + cnt[j];
			for (int j = 0; j < b; j++) t[sum[(s[j] >> i) & 1023]++] = s[j];
			for (int j = 0; j < b; j++) s[j] = t[j];
		}
		int r = b - 1, ret = 0;
		for (int i = 0; i < b && i <= r; i++) {
			while (r > 0 && s[i] + s[r] > m) r--;
			ret = max(ret, s[i] + s[r]);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 6664
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

ll fix[13], pre[13];

signed main() {
    IO;
    ll n;
    cin >> n;
    vector<char> pr;

    while(n > 0) {
    	if(n % 26 > 0) {
    		pr.push_back(char((n % 26) + 'a' - 1));
    	}
    	else {
    		pr.push_back('z');
			--n;
		}
    	n /= 26;
    }
    reverse(pr.begin(), pr.end());
    for(auto it: pr) cout << it;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

int main(){
	int n,c;
	cin>>n>>c;
	vector<vector<int>> D(c+1,vector<int>(c+1)),C(n+1,vector<int>(n+1));
	vector<vector<int>> tab(3,vector<int>());
	vector<pair<int,int>> c1,c2,c3;
	vector<int> ans;
	for(int i=1;i<c+1;i++){
		for(int j=1;j<c+1;j++){
			cin>>D[i][j];
		}
	}
	for(int i=1;i<n+1;i++){
		for(int j=1;j<n+1;j++){
			cin>>C[i][j];
			if((i+j)%3==0) tab[0].push_back(C[i][j]);
			if((i+j)%3==1) tab[1].push_back(C[i][j]);
			if((i+j)%3==2) tab[2].push_back(C[i][j]);
		}
	}
	for(int i=0;i<3;i++){
		for(int j=1;j<=c;j++){
			int tmp=0;
			for(int l=0;l<tab[i].size();l++){
				tmp+=D[ tab[i][l] ][j];
			}
			if(i==0) c1.push_back(make_pair(tmp,j));
			if(i==1) c2.push_back(make_pair(tmp,j));
			if(i==2) c3.push_back(make_pair(tmp,j));
		}
	}
	sort(c1.begin(),c1.end());
	sort(c2.begin(),c2.end());
	sort(c3.begin(),c3.end());
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			for(int l=0;l<3;l++){
				int a=c1[i].second,b=c2[j].second,c=c3[l].second;
				if(a==b || b==c || c==a) continue;
				else ans.push_back(c1[i].first+c2[j].first+c3[l].first);
			}
		}
	}
	sort(ans.begin(),ans.end());
	cout<<ans[0]<<endl;
}


Measured memory_bytes: 2544
//#define _XCODE_DEBUG

#include <iostream>

#ifdef _XCODE_DEBUG
    #include <fstream>
#endif

int main() {
    #ifdef _XCODE_DEBUG
        std::ifstream in("input.txt");
        std::cin.rdbuf(in.rdbuf());
    #endif
    
    int K, S;
    std::cin >> K >> S;
    
    int ans = 0;
    for (int i=0; i<=K; ++i) {
        for (int j=0; j<=K; ++j) {
            if (S-i-j>=0 && S-i-j<=K) ++ans;
        }
    }
    
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using PPl = pair<ll, pair<ll, ll>>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--; cw--; dh--; dw--;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

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

  int ddy[20] = {-2, -2, -2, -2, -2, -1, -1, -1, -1,  0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};
  int ddx[20] = {-2, -1,  0,  1,  2, -2, -1,  1,  2, -2, 2,-2,-1, 1, 2,-2,-1, 0, 1, 2};

  ll cost[h][w];
  rep(i, h) {
    rep(j, w) {
      cost[i][j] = INF;
    }
  }
  cost[ch][cw] = 0;

  queue<P> q;
  q.push(P(ch, cw));
  priority_queue<PPl, vector<PPl>, greater<PPl>> pq;
  pq.push(PPl(0, Pl(ch, cw)));

  // int cnt = 1;
  // int ans = 0;

  while(! pq.empty()) {
    int yy = pq.top().second.first;
    int xx = pq.top().second.second;
    pq.pop();

    ll wallnum = 0;

    rep(i, 4) {
      int ny, nx;
      ny = yy + dy[i]; nx = xx + dx[i];

      // cout << ny << " " << nx << " " << m[ny][nx] <<  endl;

      if (ny < 0 || ny >= h || nx < 0 || nx >= w) {
        wallnum++;
        continue;
      }
      // if (cost[ny][nx] != INF) continue;
      if (s[ny][nx] == '#') {
        wallnum++;
        continue;
      }
      if (cost[ny][nx] <= cost[yy][xx]) continue;
      pq.push(PPl(cost[yy][xx], Pl(ny, nx)));
      cost[ny][nx] = cost[yy][xx];

      if (ny == dh && nx == dw) {
        cout << cost[dh][dw] << endl;
        return 0;
      }
    }

    if (wallnum >= 2) {
      rep(i, 20) {
        int ny, nx;
        ny = yy + ddy[i]; nx = xx + ddx[i];

        // cout << ny << " " << nx << " " << m[ny][nx] <<  endl;

        if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
        // if (cost[ny][nx] != INF) continue;
        if (s[ny][nx] == '#') continue;
        if (cost[ny][nx] <= cost[yy][xx] + 1) continue;
        pq.push(PPl(cost[yy][xx]+1, Pl(ny, nx)));
        cost[ny][nx] = cost[yy][xx] + 1;
      }
    }

  }
  if (cost[dh][dw] == INF) cout << -1 << endl;
  else cout << cost[dh][dw] << endl;

  return 0;
}


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

int main(){

    string s,t;
    cin >> s >> t;
    
    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}

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

using namespace std;

int x[200000];
int t[200000];

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

	int n;
	cin >> n;
	for( int i = 0; i < n; i++ )cin >> x[i];
	for( int i = 0; i < n; i++ )t[i] = x[i];
	sort(x, x + n);
	int s = x[( n + 1 ) / 2];
	int c[2] = { x[( n + 1 ) / 2],x[( n + 1 ) / 2 - 1] };
	for( int i = 0; i < n; i++ )
	{
		if( s > t[i] )cout << c[0] << endl;
		else cout << c[1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3712
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    println!("{}", (n - 1) / 2);
}


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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	
	int N, A, B; cin >> N;
	vector<pair<int, int>> ver;
	rep(i, N) {
		cin >> A >> B;
		ver.emplace_back(B,A);
	}
	
	sort(ver.begin(), ver.end());
	int sum = 0;
	bool X = true;
	for (auto v:ver) {
		sum += v.second;
		if (sum>v.first) {
			X = false;
			break;
		}
	}
	cout << (X ? "Yes" : "No") << endl;
}

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

int main(){
  string s;
  cin>>s;
  
  int tt=0,ss=0,st=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='S') ss++;
    else if(s[i]=='T'&&tt<ss){
      tt++;
      st++;
    }
  }
  cout<<s.size()-2*st<<endl;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void cMin(T* a, T* b)  {if(*a>*b) *a=*b;}
template<typename T> inline void chMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  div(T a, T b)     {return ((a+b-1)/b);}
template<typename T> inline bool eoVerify(T a)     {return (!(a&1)? true : false );}

int main(){
    string s, t; cin >> s >> t;
    int ans = 1e8;
    rep(0,s.length()){
        int ret=0;
        if(t.length() + i > s.length()) break;
        rep2(0,t.length()){
            if(s[i+j] != t[j]) ret++;
        }
        ans = min(ans, ret);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a,b;
    char op;
    while (cin>>a>>op>>b,op!='?')
    {
        switch (op)
        {
            case '+':
                cout<<a+b<<endl;
                break;
            case '-':
                cout<<a-b<<endl;
                break;
            case '*':
                cout<<a*b<<endl;
                break;
            case '/':
                cout<<a/b<<endl;
                break;
            default:break;
        }
    }
    return 0;
}


Measured memory_bytes: 3092
//My life was going great until I stumble upon this question ); ):

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

long long MOD = 1000000007; //1e9+7
long long INF = 1e18;
typedef long long ll;
typedef long double ld;
#define pii		pair<int, int>
#define pll		pair<long long, long long>
#define fi 		first
#define se 		second
#define fr(i,a,b) 	for(int i=a;i<b;i++)
#define out2(a,b) 	cout<<a<<" "<<b<<"\n";
#define all(v) 		v.begin(), v.end()
#define pb          	emplace_back

void solve()
{
    ll n, ans, d;
    cin>>n;
    ans = n-1;
    for(int i=2;i<=n-1;i++){
        d = n/i;
        ans+=(d);
        if(n%i==0) ans--;
    }
    cout<<ans;
}

int main() {
	FIO;
	//freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int test;
	//cin>>test;
	test=1;
	for(int t=1;t<=test;t++){
        //cout<<"Case #"<<t<<": ";
        solve();
        //cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3616
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
import sys,bisect,math
sys.setrecursionlimit(15000)

s = sys.stdin.readline().rstrip()
if s == "ABC":
    print("ARC")
    exit()
print("ABC")


Measured memory_bytes: 9088
N, K = map(int, input().split())
R, S, P = map(int, input().split())
scoredict = {'r':P, 's':R, 'p':S}
T = input()

score = 0
for i in range(K):
    score += scoredict[T[i]]
    last = T[i]
    while True:
        i += K
        if i >= N:
            break
        if T[i] == last:
            last = None
            continue
        else:
            score += scoredict[T[i]]
            last = T[i]

print(score)

Measured memory_bytes: 3316
import copy
from collections import Counter

l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
c = Counter

def nC2(n):
    if n < 2:
        return 0
    else:
        return n*(n-1)//2

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

count = 0
C = Counter(A)
for num in C.values():
    count += num*(num-1)//2
#print(count)

for a in A:
    print(count - (C[a] - 1))

Measured memory_bytes: 86984
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, x, t, w = 0, ans = 0, count = 0;
  vector<pair<lli, lli>> pr;
  map<lli, lli> ma;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> x >> t;
  while (n > count)
  {
    count += x;
    ans += t;
  }
  out(ans);
  // if ()
  // {
  //   out("Yes");
  // }
  // else
  // {
  //   out("No");
  // }
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}

Measured memory_bytes: 3644
li = lambda: list(map(int, input().split()))

n = int(input())
p = li()
count = 0
for i in range(n-2):
    i_n = p[i]
    ni = p[i+1]
    n_i = p[i+2]
    if (i_n < ni < n_i) or (i_n > ni > n_i):
        count += 1
print(count)

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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, m;
    cin>>n>>m;
    int ans[n];
    REP(i, n){
        ans[i]=0;
    }
    REP(i, m){
        int a, b;
        cin>>a>>b;
        ans[a-1]++;
        ans[b-1]++;
    }
    REP(i, n){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var A, B, C, K int
	fmt.Scanf("%d %d %d", &A, &B, &C)
	fmt.Scanf("%d", &K)

	var flag int = 0
	for i := 0; i < K; i++ {
		if A >= B {
			B = B * 2
		} else {
			C = C * 2
		}

		if B > A && C > B {
			flag = 1
			break
		}
	}

	if flag == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1832
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

// const int INF = 200000000;
const ll INF = 1e13;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    int A, B, Q;
    cin >> A >> B >> Q;
    auto s = make_vec<ll>(A);
    auto t = make_vec<ll>(B);
    auto x = make_vec<ll>(Q);
    REP(i, A) { cin >> s.at(i); }
    REP(i, B) { cin >> t.at(i); }
    REP(i, Q) { cin >> x.at(i); }

    REP(i, Q) {
        int s_i = lower_bound(ALL(s), x[i]) - s.begin();
        int t_i = lower_bound(ALL(t), x[i]) - t.begin();

        vector<ll> s_can, t_can;
        if (s_i == A) {
            s_can.push_back(s[s_i - 1]);
        } else if (s_i == 0) {
            s_can.push_back(s[s_i]);
        } else {
            s_can.push_back(s[s_i]);
            s_can.push_back(s[s_i - 1]);
        }

        if (t_i == B) {
            t_can.push_back(t[t_i - 1]);
        } else if (t_i == 0) {
            t_can.push_back(t[t_i]);
        } else {
            t_can.push_back(t[t_i]);
            t_can.push_back(t[t_i - 1]);
        }

        ll ret = INF;
        for (auto a : s_can) {
            for (auto b : t_can) {
                ret = min(ret, abs(x[i] - a) + abs(a - b));
                ret = min(ret, abs(x[i] - b) + abs(a - b));
            }
        }
        cout << ret << "\n";
    }

    return 0;
}


Measured memory_bytes: 3712
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] agrs) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

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

        print(a);
        for (int i = 1; i < n; i++) {
            int v = a[i];
            int j = i - 1;
            while (j >= 0 && a[j] > v) {
                a[j+1] = a[j];
                j--;
            }
            a[j + 1] = v;
            print(a);
        }
    }

    private static void print(int[] a) {
        System.out.println(Arrays.stream(a).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
    }
}



Measured memory_bytes: 34472
#include "bits/stdc++.h"
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
typedef long long int ll;
const ll N = 1e6+6,inf = 1e9+7;

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


    int n,res=0;cin>>n;
    int Arr[n+2];
    double sum = 0;
    double num = n;
    for(int i=1;i<=n;i++)
    {
        int x;cin>>x;
        Arr[i] = x;
        sum += x;
    }
    double mn = 1e9;
    sum /= num;
    for(int i=1;i<=n;i++)
    {
        double nw = fabs((double)Arr[i]-sum);
        if(nw<mn)res=i,mn=nw;
    }
    cout<<res-1<< "\n";






    return 0;
}


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

int main(){
  int a, b;
  string op;
  while(1){
    cin >> a >> op >> b;
    if (op == "+")
      cout << a + b << endl;
    if (op == "-")
      cout << a - b << endl;
    if (op == "*")
      cout << a * b << endl;
    if (op == "/")
      cout << a / b << endl;
    if (op == "?")
      break;
  }
  return 0;
}



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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i=0; i<N; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  
  
  int s=N;
  for (int i=0; i<N-1; i++) {
    if (vec.at(i)==vec.at(i+1)) s--;
  }
  
  cout << s << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int x = b*10;
  for(int i=x;i<x+10;i++){
    if(a==i*2/25){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int r[10500];
int n, q;

void init()
{
	for (int i = 0; i < n; i++) {
		r[i] = i;
	}
}

int find(int x)
{
	if (r[x] == x)return x;
	else {
		r[x] = find(r[x]);
		return r[x];
	}

}

void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	r[x] = y;
}

int same(int x, int y)
{
	if (find(x) == find(y))return 1;
	else return 0;
}

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

	int a, x, y;
	for (int i = 0; i < q; i++) {
		cin >> a >> x >> y;
		if (a == 0) unite(x, y);
		if (a == 1)cout << same(x, y) << endl;
	}

	return 0;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
LL a, b;
inline LL gcd(LL a, LL b){
	return b ? gcd(b, a % b) : a;
}
int main(){
	scanf("%lld%lld", &a, &b);
	printf("%lld\n", a / gcd(a, b) * b);
}

Measured memory_bytes: 256
'use strict'

function main(input) {
	input = input.split('\n').map(v => v.split(' '))
	const n = input[0][0]
	const nums = input[1]

	let ans = nums.slice(0, 1).toString()

	for (let i = 1; i < n; i++) {
		if (i % 2 == n % 2) {
			ans = ans + ' ' + nums[i]
		} else {
			ans = nums[i] + ' ' + ans
		}
	}

	console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

signed main()
{
  string s;
  int end;

  cin >> s;

  while (true) {
    s.pop_back();
    int h = s.size();
    if (h % 2 == 1) continue;
    if (s.substr(0, h / 2) == s.substr(h / 2, h - 1)) {
      cout << h << endl;
      break;
    }
  }

  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int A[10],f,i,j,k,l,a,b;
main(){
    for(auto& c:A)cin>>c;
    for(;j<A[9];j++){
        cin>>b;
        for(k=0;k<9;++k)A[k]*=A[k]!=b;
    }
    string s="012345678036147258048246";
    for(auto c:s){
        a+=A[c-'0'];
        if((++l)%3==0){
            f+=a==0;
            a=0;
        }
    }
    cout<<(f?"Yes":"No");
}

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

int main(){
    ll a, b, x;
    cin >> a >> b >> x;
    ll bt, up;
    bt = (a + x - 1)/ x;
    up = b / x;
    cerr << up << endl;
    cerr << bt << endl;
    if(up < bt) cout << 0 << endl;
    else cout << up - bt + 1 << endl;
    return 0;
}

Measured memory_bytes: 384
from collections import Counter, defaultdict
N = int(input())
d = defaultdict(int)
ans = 0
for i in range(N):
    l = list(input())
    l.sort()
    l = ''.join(l)
    d[l] += 1
for x in d.values():
    ans += x*(x-1)//2
print(ans)

Measured memory_bytes: 22440
n, k = map(int,input().split())
w_in = list()

for i in range(n):
    w_in.append(int(input()))


def alloc(p):
    load = 0
    track = 1
    for w in w_in:
        if w > p:
            return False
        if load + w <= p:
           load += w
        else:
            load = w
            track += 1
            if track > k:
                return False
    return True


def binsearch():
    upper = sum(w_in)
    lower = max(w_in)
    while(upper != lower):
        mid = int((upper + lower) / 2)
        if alloc(mid):
            upper = mid
        else:
            lower = mid + 1
    return upper
print(binsearch())

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

int main() {
	// your code goes here
	int a[4];
	for(int i=0 ; i<4 ; i++){
		cin>>a[i];
	}
	sort(a,a+4);
	if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9)cout<<"YES";
	else cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    unsigned long n, a, b, max, min;
    scanf("%lu%lu%lu", &n, &a, &b);

    if (a < b) max = a;
    else max = b;

    if (a+b > n) min = (a+b) - n;
    else min = 0;

    printf("%lu %lu", max, min);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

int n;
int x, y, z;
string dp[55][55][55];
string ans;

bool check(string s)
{
	while(s.size() < n) s += 'a';
	
	for(int i = 0; i <= x; i++){
		for(int j = 0; j <= y; j++){
			for(int k = 0; k <= z; k++){
				dp[i][j][k] = "";
			}
		}
	}
	dp[0][0][0] = s;
	
	for(int i = 0; i <= x; i++){
		for(int j = 0; j <= y; j++){
			for(int k = 0; k <= z; k++){
				if(dp[i][j][k] < s) continue;
				if(i+1 <= x) dp[i+1][j][k] = max(dp[i+1][j][k], ('a' + dp[i][j][k]).substr(0, n));
				if(j+1 <= y) dp[i][j+1][k] = max(dp[i][j+1][k], ('b' + dp[i][j][k]).substr(0, n));
				if(k+1 <= z) dp[i][j][k+1] = max(dp[i][j][k+1], ('c' + dp[i][j][k]).substr(0, n));
			}
		}
	}
	return (dp[x][y][z] >= s);
}

int main(void)
{
	cin >> x >> y >> z;
	n = x + y + z;
	
	for(int i = 0; i < n; i++){
		for(int j = 2; j >= 0; j--){
			string s = ans + ((char)('a'+j));
			if(check(s)){
				ans = s;
				break;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
const int MD=1000000000;
int pr[1005],co[1005];
int k;
void prime()
{
	k=0;
	for (int i=2;i<=1000;i++)
	{
		int f=1;
		for (int j=2;j*j<=i;j++)
		{
			if (i%j==0)
			{
				f=0;
				break;
			}
		}
		if (f==1)
		{
			pr[k]=i;
			k++;
		}
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	prime();
/*	for (int i=0;i<k;i++)
	{
		printf("%d ",pr[i]);
	}*/
	for (int i=0;i<k;i++)
	{
		co[i]=0;
	}
	for (int i=2;i<=n;i++)
	{
		int t=i;
		for (int j=0;j<k;j++)
		{
			if (t<pr[j])
			{
				break;
			}
			while (t%pr[j]==0)
			{
				t/=pr[j];
				co[j]++;
//				printf("%d ",pr[j]);	
			}
		}
	}
	long long res=1;
	for (int i=0;i<k;i++)
	{
		if (co[i]==0 || n<pr[i])
		{
			continue;
		}
		res=(res*(long long)(co[i]+1))%(MD+7);
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

int main()
{
IOS
int n;
cin>>n;
auto compare=[](pair<ll,ll> a,pair<ll,ll> b) {
  return a.second<b.second;
    
};
vector<pair<ll,ll>> task;
ll x,y;
fo(i,n){
    cin>>x>>y;
    task.emplace_back(x,y);
    if(x>y) {cout<<"No"; return 0;}
}
sort(all(task),compare);
ll time=0;
fo(i,n){
    time=time+task[i].first;
    if(time<=task[i].second) ;
    else{cout<<"No"; return 0;}
}
cout<<"Yes";

}



Measured memory_bytes: 6256
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[110000];
int sum[110000];
int db[18][110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
	}
	for(int i=0;i<a;i++)c[a+i]=c[i];
	for(int i=0;i<a*2;i++)sum[i+1]=sum[i]+c[i];
	sum[a*2+1]=999999999;
	int left=0;
	int right=100000000;
	while(left+1<right){
		int M=(left+right)/2;
		for(int i=0;i<a*2;i++){
			db[0][i]=upper_bound(sum,sum+a*2+1,sum[i]+M)-sum-1;
		}
	//	printf("%d\n",M);
	//	for(int i=0;i<a*2;i++)printf("%d ",db[0][i]);printf("\n");
		db[0][a*2]=a*2;
		for(int i=1;i<18;i++){
			for(int j=0;j<=a*2;j++){
				db[i][j]=db[i-1][db[i-1][j]];
			}
		}
		bool ok=false;
		for(int i=0;i<a;i++){
			int at=i;
			for(int j=0;j<18;j++){
				if(b&(1<<j)){
					at=db[j][at];
				}
			}
			if(at>=i+a)ok=true;
		}
		if(ok)right=M;else left=M;
	}
	printf("%d\n",right);
}

Measured memory_bytes: 9440
def calc(x,y):
	if y==0:
		return x
	elif x==r:
		return r+y
	elif y==c:
		return r*2+c-x
	elif x==0:
		return r*2+c*2-y
	else:
		return -1
r,c,n=map(int,input().split())
pts=[]
for i in range(n):
	x1,y1,x2,y2=map(int,input().split())
	u,v=calc(x1,y1),calc(x2,y2)
	if u>=0 and v>=0:
		pts.append((u,i))
		pts.append((v,i))
pts=sorted(pts)
stk=[]
for a,b in pts:
	if len(stk)==0 or stk[-1]!=b:
		stk.append(b)
	else:
		stk.pop()
if len(stk):
	print("NO")
else:
	print("YES")

Measured memory_bytes: 29284
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair < ll, int > PLI;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e5 + 6;

int n, K;
int a[N], pos[N];

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

    #ifdef krauch
        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    cin >> n >> K;
    int ans = 0, ok = 0;
    set < int > st;
    forn(i, 1, n) {
        cin >> a[i];

        if (i > 1 && a[i] > a[i - 1]) pos[i] = pos[i - 1];
        else pos[i] = i;
        if (pos[i] <= i - K + 1) ok = 1;

        st.insert(a[i]);
//        cerr << a[i] << "\n";
        if (i == K) ans += (pos[i] > 1);
        if (sz(st) != K + 1) continue;
        if (pos[i] > i - K + 1 && (a[i - K] != *st.begin() || a[i] != *st.rbegin())) {
            ++ans;
//            cerr << i << "\n";
        }
        st.erase(a[i - K]);
    }

    cout << ans + ok << "\n";

    return 0;
}


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


int main()
{
  int n,t;
  cin >> n;
  set<int> d;
  for(int i = 0;i < n;i++){
    cin >> t;
    d.insert(t);
  }
  cout << d.size() << endl;
  return 0;
  
}


Measured memory_bytes: 256
#include <stdio.h>
long long solvegcd(long long a,long long b){
  if (a%b==0){
    return(b);
  }
  else{
    return(solvegcd(b,a%b));
  }
}
long long judgeprime(long long n){
  for(long long i=2; i*i<=n; i++){
    if(n%i==0){
      return 0;
    }
  }
  return 1;
}
int main() {
  long long A,B,count=0;
  scanf("%lld%lld", &A,&B);
  long long gcd = solvegcd(A,B);
  for(long long i=1; i*i<=gcd; i++){
    if(gcd%i==0){
      if(judgeprime(i)==1){
	count++;
      }
      if(i*i!=gcd){
	if(judgeprime(gcd/i)==1){
	  count++;
	}
      }
    }
  }
  printf("%lld\n",count);
  
  return 0;
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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;
}

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    string s;
    in(s);
    int len = 0;
    int ans = 0;
    rep(i, s.size())
    {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
        {
            len++;
        }
        else
        {
            chmax(ans, len);
            len = 0;
        }
    }
    chmax(ans, len);
    out(ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line;
        List<String> inputs = new ArrayList<>();
        while ((line = br.readLine()) != null && !line.isEmpty()) {
            int len = line.split(" ").length;
            if(len != 1) {
                inputs.add(line);
            }
        }
        output(inputs); //最後に出力する場合
    }

    public static void output(List<String> inputs) {
        inputs.stream().forEach(line->{
            List<Integer> numbers = Arrays.stream(line.split(" ")).map(Integer::parseInt).collect(Collectors.toList());
            System.out.println(yesNo(numbers.get(0), numbers.get(1), numbers.get(2)));
        });
    }

    public static String yesNo(int a, int b, int c) {
        if(a * a + b * b == c * c || a * a == b * b + c * c || b * b == a * a + c * c) return "YES";
        else return "NO";
    }
}


Measured memory_bytes: 32808