akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int n,k,sum=0;
  	cin>>n>>k;
  	vector<int>h(n);
  	for(long int i=0;i<n;i++){
    	cin>>h.at(i);
    }
  	sort(h.begin(),h.end());
  	if(n<=k){
    	cout<<0<<endl;
    }
  	else{
    	for(long int i=0;i<n-k;i++){
         	sum=h.at(i)+sum; 
        }
      	cout<<sum<<endl;
    }
  	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;

int main(void){
    int n;
    cin>>n;
    vector<int> cats(n);
    rep(i,n) cin>>cats[i];
    int xors=0;
    rep(i,n) xors=xors^cats[i];
    //cout<<xors<<endl;
    rep(i,n) cout<<int(xors^cats[i])<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 4048
/* AtCoder コピペ */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repEq(i, n) for (int i = 0; i <= (int)(n); i++)
#define repVector(i, v) for (auto i = v.begin(); i != v.end(); ++i)

#define ifBetween(n, a, b) if (n > a && n < b)
#define ifBetweenEq(n, a, b) if (n >= a && n <= b)

int main() {
	int n, l;
  
  	cin >> n >> l;
  	string x[n];
  
  	rep(i, n) {
    	cin >> x[i];
    }
 
  	std::vector<string> vec(x, x + sizeof x / sizeof x[0]);
    sort(vec.begin(), vec.end());
 
  	string result = "";
  	result = accumulate(vec.begin(), vec.end(), result);
  
  	cout << result << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;


ll dp[50][4];
pair<string,int> ok(int n){
    fill(*dp,*dp+50*4,INF);
    
    vector<int> p(n),t(n);
    for(int i = 0; i < n;i++) cin >> p[i] >> t[i];
    
    dp[0][0] = 0;
    for(int i = 0; i < n;i++){
        for(int j = 0; j < 4;j++){
            if(dp[i][j] == INF) continue;
            if(i == 0){
                if((j+1)*p[i] <= t[i]) dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+p[i]);
            }else{
                if((j+1)*abs(p[i]-p[i-1]) <= t[i]-t[i-1] && j <= 2){
                    dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j] + abs(p[i]-p[i-1]));
                }
                if((j+1)*p[i-1]+p[i] <= t[i]-t[i-1]){
                    dp[i+1][1] = min(dp[i+1][1],dp[i][j]+p[i]+p[i-1]);
                }
            }
        }
    }
    
    ll ret = INF;
    for(int j = 0; j < 4;j++){
        ret = min(ret,dp[n][j]+p[n-1]);
    }
    if(ret != INF) return {"OK",ret};
    
    for(int i = 0; i <= n;i++){
        if(*min_element(dp[i], dp[i]+4) == INF) return {"NG",i};
    }
    return {"",-1};
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    int n;

    while(cin >> n,n){
        string ret1; int ret2;
        tie(ret1,ret2) = ok(n);
        cout << ret1 << " " << ret2 << endl;
    }
    return 0;
}



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

using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,j;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  ll a[200005];
  ll b[200005];
  ll k,l;
  rep(i,n) cin>>a[i];
  for(j = n;j>0;j--){
    if(abs(n-j) %2 == 0){
      k = 0;
      k += abs(n-j)/2;
    } else {
      k = n-1;
      k -= abs(n-j)/2;
    }
    b[k] = a[j-1];
  }
  rep(i,n){
    if(i!=n-1) {
      cout<<b[i]<<" ";
    } else {
      cout<<b[i]<<endl;
    }
  }
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<fstream>
using namespace std;

typedef pair<int,pair<int, int> > P;

int main() {

	while (1) {
		

		int h, w;
		vector<P> pos;
		cin >> h >> w;

		if (h == 0)break;

		int X = pow(h, 2) + pow(w, 2);
		//cout << X << endl;

		
		for (int i = 1; i <= 150; i++) {
			for (int j=i+1; j <= 150; j++) {
				int x = pow(i, 2) + pow(j, 2);
				if (x > X) {
					//cout << i << ' ' << j << ' ' << x << endl;
					pos.push_back(make_pair(x, make_pair(i, j)));
				}
				else if (x == X && i > h) {
					pos.push_back(make_pair(x, make_pair(i, j)));
				}
			}
		}

		int n = 10000, m, minx=pow(X,2);
		for (int i = 0; i < pos.size(); i++) {
			if (pos[i].first < minx) {
				minx = pos[i].first;
				n = pos[i].second.first;
				m = pos[i].second.second;
			}
			else if (pos[i].first == minx && pos[i].second.first < n) {
				minx = pos[i].first;
				n = pos[i].second.first;
				m = pos[i].second.second;
			}
		}

		cout << n << ' ' << m << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
import java.util.*;

public class Main{

    boolean debug = false;

    char[][] f;
    int[] dx = {0,0,1,-1};
    int[] dy = {1,-1,0,0};
    int d;
    int rensa;

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        while(n-->0){
            f = new char[12][6];
            for(int i=0; i<12; i++){
                f[i] = sc.next().toCharArray();
            }

            rensa = 0;
            delete();
            calc();
            System.out.println(rensa);
        }
    }

    void calc(){
        d = 1;
        while(d!=0){
            d = 0;
            for(int i=0; i<12; i++){
                for(int j=0; j<6; j++){
                    if(f[i][j]!='.' && f[i][j]!='O' && f[i][j]!='x'){
                        bfs(f[i][j],j,i);
                    }
                }
            }
            
            if(d!=0){
                delete();
                rensa++;
                if(debug){
                    for(int i=0; i<12; i++){
                        System.out.println(Arrays.toString(f[i]));
                    }
                }
            }else break;
        }
    }

    void bfs(char c, int sx, int sy){
        Queue<int[]> q = new LinkedList<int[]>();
        Queue<int[]> qq = new LinkedList<int[]>();
        q.add(new int[]{sx,sy});
        qq.add(new int[]{sx,sy});
        int cnt = 0;
        boolean[][] v = new boolean[12][6];
        v[sy][sx] = true;

        while(q.size()>0){
            int[] xy = q.poll();
            int x = xy[0], y = xy[1];

            for(int i=0; i<4; i++){
                int nx = x+dx[i], ny = y+dy[i];
                if(nx>=0 && nx<6 && ny>=0 && ny<12 
                   && f[ny][nx]==c && !v[ny][nx]){
                    q.add(new int[]{nx,ny});
                    qq.add(new int[]{nx,ny});
                    v[ny][nx] = true;
                }
            }
        }

        if(debug) System.out.println(c+" "+qq.size());

        if(qq.size()>=4){
            d++;
            while(qq.size()>0){
                int[] xy = qq.poll();
                f[xy[1]][xy[0]] = 'x';
                for(int i=0; i<4; i++){
                    int nx = xy[0]+dx[i], ny = xy[1]+dy[i];
                    if(nx>=0 && nx<6 && ny>=0 && ny<12 
                       && f[ny][nx]=='O'){
                        f[ny][nx] = 'x'; 
                    }
                }
            }
        }
    }

    void delete(){
        for(int i=0; i<6; i++){
            Queue<Character> q = new LinkedList<Character>();
            for(int j=11; j>=0; j--){
                if(f[j][i]!='x' && f[j][i]!='.'){
                    q.add(f[j][i]);
                }
            }
            for(int j=11; j>=0; j--){
                if(q.size()>0) f[j][i] = q.poll();
                else f[j][i] = '.';
            }
        }
    }
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long long int a,b,x;
    cin>>a>>b>>x;
    if(a%x==0){
        cout<<b/x-a/x +1<<endl;
    }else{
        cout<<b/x-a/x<<endl;
    }
    return 0;
}

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

int main() {
	int x1, y1, x2, y2, x3, y3, x4, y4;
	cin >> x1 >> y1 >> x2 >> y2;

		x3 = x2 + (y1 - y2);
		y3 = y2 - (x1 - x2);
		x4 = x3 + (x1 - x2);
		y4 = y3 + (y1 - y2);

	cout<< x3 << " " << y3 << " " << x4 << " " << y4;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int bubbleSort(int *,int);

int main(){

  int N,j;
  int A[100];
  int sw = 0;
 

  scanf("%d",&N);

  for(j=0;j < N;j++){
    scanf("%d",&A[j]);
  }

  sw = bubbleSort(A,N);
  
 for(j=0 ;j < N;j++){
   
   if(j > 0){
     printf(" ");
   }
   
   printf("%d",A[j]);
 }
 printf("\n");
 
 
 printf("%d\n",sw);
 
 return 0;
}


int bubbleSort(int A[],int N){
  int temp = 0;
  int flag,i,j;
  int sw = 0;
  
  
  flag = 1;
  i = 0;
  
  while(flag){
    
  flag = 0;

  for(i=0 ; i<N ; i++){
  
  for(j= N - 1;j >= i + 1;j--){
    
    if(A[j] < A[j-1]){
      
      temp = A[j];
      A[j] = A[j-1];
      A[j-1] = temp;
      
      flag = 1;
      sw++;
      
    }
  }
  
  }
  
  }
  
  return sw;
}


  



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

char str[100001];

int main(){
    int n;
    scanf("%s", str);
    n = (int)strlen(str);
    if(str[0] == '0' || str[n-1] == '1'){
        printf("-1\n");
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(str[i] != str[n-2-i]){
            printf("-1\n");
            return 0;
        }
    }
    int now_root = 1;
    for(int i=2;i<=n;i++){
        printf("%d %d\n", now_root, i);
        if(str[i-2] == '1'){
            now_root = i;
        }
    }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int a[1000];
signed main(void)
{
  int n, m;
  cin >> n >> m;
  REP(i, m) cin >> a[i];
  cout << n-m-1 << endl;
  return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//using graph = vector<vector<ll>>;


int main() {
	ll n,mem=2;
	cin >> n;
	while (n >= mem) {
		mem = mem * 2;
	}
	cout << mem / 2 << endl;
	return 0;
}


Measured memory_bytes: 3104
#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++)

ll gcd(ll a, ll b){
    if(a < b) return gcd(b, a);
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    ll ret = (a * b)/gcd(a,b);
    return ret;
}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    rep(i, 0, N) cin >> a[i];
    ll g = a[0];
    rep(i, 1, N) g = gcd(g, a[i]);
    if(K % g != 0 || *max_element(a.begin(), a.end()) < K) cout << "IMPOSSIBLE" << endl;
    else cout << "POSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

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

Measured memory_bytes: 3636
<?php
fscanf(STDIN,'%d',$N);
fscanf(STDIN,'%s',$S);
$X='a';
$Y='a';
$A=[];
$B=[];
$c=0;
$max=0;
for ($i=1; $i <=$N-1 ; $i++) {
  // code...
  $X=substr($S,0,$i);
  $Y=substr($S,$i);
  $A=str_split($X);
  $B=str_split($Y);
  $c=0;
  for ($ascii=97; $ascii <=122 ; $ascii++) {
    // code...
    $W=chr($ascii);
    if(in_array($W,$A) and in_array($W,$B)){
      $c++;
    }
  }
  if($c>$max){
    $max=$c;
  }
}
echo $max;
echo "\n";
 ?>


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


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

    int m = 10000;
    for(int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if(t <= T) {
            m = min(m, c);
        }
    }
    if(m == 10000) {
        cout << "TLE";
    } else {
        cout << m;
    }
    return 0;
}


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

const int SIZE=100005;

ll dat[SIZE];
void Add(int i){
  i++;
  while(i<SIZE){
    dat[i]++;
    i+=(i&-i);
  }
}

ll Get(int i){
  i++;
  ll res=0;
  while(i){
    res+=dat[i];
    i-=(i&-i);
  }
  return res;
}

ll N,K;
ll ans=0;

vector<ll> t;
void func(ll x){
  for(ll i=1;i*i<=x;i++){
    if(x%i==0){
      Add(i);

      if(x/i!=i)Add(x/i);
    }
  }
}

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

  
  for(ll i=N;i>=K;i--){

    if(N-i>0){
      func(N-i);
    }
    
    ll x=(N-i);
    //    ll y=t.end() - upper_bound(t.begin(),t.end(),i);

    ll y=Get(SIZE-2) - Get(i);
    if(i>0){
      ans+=x;
    }
    ans+= y;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main(){
    int i,j,k;
    double N,K;
    cin >> N >> K;
    double prob=0;
    for(i=0;i<N;i++){
        int point = i+1;
        double thisprob=1.0;
        while(point < K){
            thisprob = thisprob/2.0;
            point = 2*point;
        }
        prob += thisprob;
    }
    cout << setprecision(10) << prob/N << endl;
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if(A >= 13) {
    cout << B << endl;
  } else if(6 <= A && A < 13) {
    cout << B / 2 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N;
int ans;
vector<int> p;

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

signed main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        p.push_back(a);
    }
    sort(p.begin(), p.end());
    p.erase(unique(p.begin(), p.end()), p.end());
    int n = (int)p.size();
    for(int i = 1; i < (1 << n); i++){
        int lcm = -1;
        for(int j = 0; j < n; j++){
            if((1 << j) & i){
                if(lcm < 0)lcm = p[j];
                lcm = lcm * p[j] / gcd(lcm, p[j]);
            }
        }
        int flag = 1;
        for(int j = 0; j < n; j++){
            if(!((1 << j) & i)){
                if(lcm % p[j] == 0){
                    flag = 0;
                }
            }
        }
        ans += flag;
    }
    cout << ans << endl;
    

    return 0;
}

/*

*/


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

int main()
{
	int x;
	cin >> x;
	vector<int> ans;
	for (int i = 1; i <= 10000; ++i)
	{
		for (int j = 2; j < 10000; ++j)
		{
			if (pow(i, j) > x)
			{
				break;
			}
			ans.push_back(pow(i, j));
		}
	}
	sort(ans.begin(), ans.end(), greater<int>());
	cout << ans[0] << endl;
	return 0;
}

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

int main() {

	int n;
	scanf("%d", &n);
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}
	int cnt = 0;
	int ans = 0;
	for(int i = 1; i < n; i++) {
		if(v[i] > v[i - 1]) {
			cnt = 0;
		}else {
			cnt++;
		}
		ans = max(cnt, ans);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 640
// キュー
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

//const int MAX_N = 100000;
const int STR_LEN = 10;

// キュー関連の定義
const int Max_Queue = 100000;

// キューの要素の構造体
typedef struct q_e
{
    // 配列の要素No.
    int id;
    // プロセス名
    char process_name[STR_LEN];
    // プロセスの時間
    int process_time;
}queue_element;

queue_element ary_queue[Max_Queue];

// キューの情報の構造体
typedef struct q_i
{
    int head;
    int tail;
    int count;
}queue_info;

queue_info que_info;

void create_queue(void);
int enqueue(queue_element element);
queue_element dequeue(void);

int main(void)
{

    int N, cpu_time, total_time = 0;
    char str[STR_LEN];
    queue_element que_ele;

    // キューの初期化
    create_queue();

    scanf("%d %d", &N, &cpu_time);

    for(int i = 0; i < N; i++)
    {
    	que_ele.id = i;

        scanf("%s", &str[0]);
        strcpy(&(que_ele.process_name[0]), &str[0]);

        scanf("%s", &str[0]);
        que_ele.process_time = atoi(str);

        // キューに挿入する
        enqueue(que_ele);
    }

    // cpuの時間を割り当てる
    while( que_info.count > 0 )
    {
        // キューからポップする
        que_ele = dequeue();

        if( 0 < que_ele.process_time
            && que_ele.process_time <= cpu_time )
        {
            total_time += que_ele.process_time;
            que_ele.process_time = 0;

            printf("%s %d\n", que_ele.process_name, total_time);
        }
        else
        {
            total_time += cpu_time;
            que_ele.process_time -= cpu_time;

            enqueue(que_ele);
        }
    }

    return 0;

}

// キューを作成する関数
void create_queue(void)
{
    int i;

    for(i = 0; i < Max_Queue; i++)
    {
        // キューの初期化
    	ary_queue[i].id = 0;
        ary_queue[i].process_name[0] = '\0';
        ary_queue[i].process_time = 0;
    }

    que_info.head = 0;
    que_info.tail = 0;
    que_info.count = 0;

    return;
}

// キューへプッシュする関数
int enqueue(queue_element element)
{

    if( que_info.count > Max_Queue )
    {
        // サイズオーバー
        return INT_MIN;
    }

    if( que_info.tail == Max_Queue - 1 )
    {
        // 配列をラウンド型にする
        que_info.tail = -1;
    }

    // キューに追加する
    ary_queue[que_info.tail++] = element;
    que_info.count++;

    return 0;
}

// キューからポップする関数
queue_element dequeue(void)
{
    queue_element ret;

    if( que_info.count < 0 )
    {
        // キューが空の時
        ret.id = INT_MIN;
    }
    else
    {
        if( que_info.head == Max_Queue - 1 )
        {
            // 配列をラウンド型にする
            que_info.head = -1;
        }

        ret = ary_queue[que_info.head++];
    }

    que_info.count--;

    return ret;
}



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

int main(){
    int N;
    cin >> N;
    long long a,b,minB=1000000000,sum=0;
    for(int i=0; i<N; i++){
        cin >> a >> b;
        sum+=a;
        if(a>b && minB>b)
        minB=b;
    }
    if(minB==1000000000)
    cout << 0 << endl;
    else
    cout << sum-minB << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
ans = []
while(True):
    if n <= 26:
        ans.append(chr(96+n))
        break
    n,a = divmod(n,26)
    if a == 0:
        ans.append('z')
        n -= 1
    else:
        ans.append(chr(96+a))
ans.reverse()
print(''.join(ans))

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

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if (H % h == 0 && W % w == 0) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (i % h == 0 && j % w == 0) cout << -1 * h * w * 250 + 249;
			else cout << 250;
			if (j == W) cout << endl;
			else cout << " ";
		}
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int x, y;
	cin >> x >> y;
	int a[12] = {1,3,1,2,1,2,1,1,2,1,2,1};
	string ans = (a[x-1] == a[y-1])? "Yes": "No";
	cout << ans << endl;
}


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

int main(){
    int N, M; cin >> N >> M;
    int Mat[N+1][N+1];
    memset(Mat, 0, sizeof(Mat));
    for(int i = 0; i < M; i++){
        int a, b; cin >> a >> b;
        Mat[a][b] = 1;
        Mat[b][a] = 1;
    }
    vector<int> v;
    for(int i = 1; i <= N; i++){
        v.push_back(i);
    }
    int cnt = 0;
    
    do {
        bool flag = true;
        if(v[0] != 1) continue;
        //for(auto x : v) cout << x << " "; cout << "\n";
        for(int i = 0; i < N-1; i++){
            int x = v[i];
            int y = v[i+1];
            //cout << Mat[x][y];
            if(Mat[x][y] != 1) flag = false;
        }
        //cout << endl;
        if(flag) {
            //cout << "y" << endl;
            cnt++;
        }
        //for(auto x : v) cout << x << " "; cout << "\n";
    } while( next_permutation(v.begin(), v.end()) );
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
		String s = a+b;
		int n = Integer.valueOf(s);
		String ans = "No";
		for(int i = 0; i < 320;i++) {
			if(i*i==n) {
				ans="Yes";
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    fast_io
    
    ll N;
    cin>>N;
    string ans="";
    while(N){
        if(N%26==0){
            ans+='z';
            N-=1;
        }else{
            ans+=char((N%26)+'a'-1);
        }
        N/=26;
    }
    for(int i=ans.size()-1;i>=0;i--){
        cout<<ans[i];
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MOD 1000000007

using namespace std;

int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int cnt = 0;
    int Query,F;
    char C;
    string str1,str2;
    for (int i = 0; i < Q; i++)
    {
        cin >> Query;
        if(Query == 1){
            cnt += 1;
            cnt = cnt % 2;
        }
        else{
            cin >> F >> C;
            if(F-1 == cnt){
                str1.push_back(C);
            }
            else{
                str2.push_back(C);
            }
        }
    }
    if(cnt == 0){
        for (int i = 0; i < str1.length(); i++)
        {
            cout << str1[str1.length()-i-1];
        }
        
        cout << S << str2;
    }
    else{
        for (int i = 0; i < str2.length(); i++)
        {
            cout << str2[str2.length()-i-1];
        }
        for (int i = 0; i < S.length(); i++)
        {
            cout << S[S.length()-i-1];
        }
        cout << str1 << endl;
    }

}


Measured memory_bytes: 1088
#include<iostream>

using namespace std;

int main(){
  int n,c,x,y;
  cin>>n>>c;
  
  for(x=0;x<=n;x++){
    for(y=0;y<=n-x;y++){
       if(c==x*10000+y*5000+(n-x-y)*1000){
           cout<<x<<" "<<y<<" "<<n-x-y<<endl;
           return 0;
       }
    }
  }
  cout<<-1<<" "<<-1<<" "<<-1<<endl;
  return 0;
}

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

int main()
{
	int h,w;

	while(true)
	{
	 	std::cin>>h>>w;
	 	if(h==0&&w==0)break;

	 	for(int i=0;i<h;i++)
	 	{
	 	    for(int j=0;j<w;j++)
	 	    {
	 	        std::cout<<"#";
	 	    }
	 	    std::cout<<"\n";
	 	}
	    std::cout<<"\n";
	}
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

int X,M;
string S;

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

signed main(){
  cin>>X;
  int a_,b_,b;
  bool flg=false;
  for(int b=0;-b*b*b*b*b<=X+10;b--){
    for(int a=0;a*a*a*a*a-b*b*b*b*b<=X+10;a++){
      b_=b*b*b*b*b;
      a_=a*a*a*a*a;
      // print(a_,b_);
      if(a_-b_==X){
        b_=b;
        a_=a;
        flg=true;
        break;
      }
    }
    if(flg)break;
  }
  if(flg){
    print(a_,b_);
    return 0;
  }
  for(int b=0;;b++){
    for(int a=0;a*a*a*a*a-b*b*b*b*b<X+10;a++){
      b_=b*b*b*b*b;
      a_=a*a*a*a*a;
      // print(a_,b_);
      if(a_-b_==X){
        b_=b;
        a_=a;
        flg=true;
        break;
      }
    }
    if(flg)break;
  }
  print(a_,b_);





}


Measured memory_bytes: 3656
N, M, X = [int(i) for i in input().split()]

books = {}
for i in range(N):
    hoge = list(map(int, input().split()))
    books[i] = hoge

Achievement = False

for n in range(2 ** N):
    conditions = [0 for m in range(M + 1)]  
    for i in range(N):
        if ((n >> i) & 1):
            for m in range(M + 1):
                conditions[m] += books[i][m]


    count = 0
    for m in range(1, M + 1):
        if conditions[m] < X:
            break
        count += 1
    if count == M:
        if Achievement == False:
            Achievement = True
            min = conditions[0]
        elif min > conditions[0]:
            min = conditions[0]

if Achievement == False:
    print(-1)
else:
    print(min)


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int N, M, Q;
vec(A); vec(B); vec(C); vec(D);
int ans = 0;
int nums[20];
void f(int n,int start) {
	if (n==N) {
		int sum = 0;
		fx(Q) {
			if (nums[B[x]-1]-nums[A[x]-1]==C[x]) {
				sum += D[x];
			}
		}
		ans = max(ans, sum);
		return ;
	}

	fyg(M+1,start) {
		nums[n] = y;
		f(n+1,y);
		nums[n] = 0;
	}

}

int main()
{
	cin >> N >> M >> Q;
	fx(Q) {
		vecp(A);
		vecp2(B);
		vecp2(C);
		vecp2(D);

	}

	f(0,1);
	ce(ans)
    return 0;
}



Measured memory_bytes: 3644
N,X,Y = map(int, input().split())
X,Y = X-1,Y-1

ans = [0] * N
for i in range(N):
    for j in range(i+1,N):
        dist = min(abs(i-j), abs(i-X) + 1 + abs(Y-j))
        ans[dist] += 1
print(*ans[1:], sep='\n')

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}


void solve(){
  string s;
  cin >> s;
  s = s.substr(0,s.size()-1);
  int flag = 0;
  while(1){
      if(s.size()%2==1) {
        s = s.substr(0,s.size()-1);
        continue;
      }
      else {
          int judge = 0;
          for(int i = 0; i < s.size()/2; ++i){
              if(s[i] != s[s.size()/2+i]) {
                s = s.substr(0,s.size()-1);
                judge = 1;
                break;
              }
          }
          if(!judge) flag = 1;
      }
      if(flag) {
          cout << s.size() << endl;
          return;
      }
  }
}

int main(void){
    solve();
    return 0;
}


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

int main(){
    string o, s;
    cin >> o >> s;
    int ol = o.size();
    int sl = s.size();
    for (int i=0; i<sl ; i++){
        cout << o[i] << s[i];
    }
    if (ol > sl){
        cout << o[sl];
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>
#include <regex>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
//using ll = long long;
using ll = int64_t;

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

void solve(){
    int x;
    cin >> x;
    vector<bool> expo(x+1);

    expo[1] = 1;
    for(int b = 2; b <= x; b++){
        int v = b*b;
        while(v <= x){
            expo[v] = 1;
            v *= b;
        }
    }
    for(int i = x; i >= 1; i--){
        if(expo[i]){
            cout << i << endl;
            return;
        }
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[5],t,k=0;
	for(t=0;t<5;t++){
		scanf("%d",&a[t]);
		if(a[t]<40){
			a[t]=40;
		}
	}
	for(t=0;t<5;t++){
		k+=a[t];
	}
	k=k/5;
printf("%d\n",k);
return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 1;
//-----------------------------------------------//

int N, C;
int imos[30][112345];

int main() {
	cin >> N >> C;
	REP(i, N) {
		int s, t, c;
		scanf("%d %d %d", &s, &t, &c);
		imos[c - 1][s]++;
		imos[c - 1][t + 1]--;
	}
	
	REP(i, C) REP(j, 112344) imos[i][j + 1] += imos[i][j];
	
	int cnt = 0, cur = 0; // 合計台数cnt, 空きcur
	bool used[30] = {};
	
	REP(i, 112345) {
		REP(j, C) if (used[j] && !imos[j][i]) used[j] = false, cur++;
		REP(j, C) {
			if (!imos[j][i]) continue;
			if (!used[j]) {
				used[j] = true;
				if (cur == 0) cnt++;
				else cur--;
			}
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;
typedef std::vector<std::vector<int>> graph;

bool isPath[100000] = {};
int n;

int dfs(int s, int parent, int length, const graph &g) {
  length++;
  if (s == n - 1) {
    return length;
  }
  isPath[s] = true;
  for (auto v : g[s]) {
    if (v == parent)
      continue;
    isPath[v] = true;
    int len = dfs(v, s, length, g);
    if (len != -1)
      return len;
    isPath[v] = false;
  }
  return -1;
}

int dfs2(int s, int parent, int res, const graph &g) {
  if (isPath[s] && res <= 0)
    return 0;
  if (isPath[s])
    res--;

  int val = 1;
  for (auto v : g[s]) {
    if (v == parent)
      continue;
    val += dfs2(v, s, res, g);
  }
  return val;
}

int main() {
  cin >> n;
  graph g(n);
  REP(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  int len = dfs(0, -1, 0, g);
  isPath[0] = false;
  int ans = dfs2(0, -1, (len - 1) / 2, g);
  if (2 * ans > n) {
    cout << "Fennec" << endl;
  } else {
    cout << "Snuke" << endl;
  }
}


Measured memory_bytes: 13568
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
// 詰まった入力例　S'=?b?? T=ab  ?の辞書順は英数字より前
using namespace std;

long long  X, Y;

int main(){
    cin >> X >> Y;
    int count=0;
    do{
        count++;
        X*=2;
    }while(X<=Y);
    cout << count << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, bisect
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]", u: "List[int]", v: "List[int]"):
    conns = [[] for _ in range(N)]
    for i in range(N - 1):
        conns[u[i] - 1].append(v[i] - 1)
        conns[v[i] - 1].append(u[i] - 1)

    ret = [-1] * N
    dp = []
    def dfs(idx):
        val = a[idx]
        k = -1
        if len(dp) == 0 or val > dp[-1]:
            dp.append(val)
        else:
            k = bisect.bisect_left(dp, val)
            tmp = dp[k]
            dp[k] = val
        ret[idx] = len(dp)
        for j in conns[idx]:
            if ret[j] >= 0:
                continue
            dfs(j)

        if k >= 0:
            dp[k] = tmp
        else:
            dp.pop()
        return
    dfs(0)
    for r in ret:
        print(r)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, a, u, v)

if __name__ == '__main__':
    main()


Measured memory_bytes: 383648
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (abs(a-c) <= d || (abs(a-b)<=d && abs(b-c) <= d) ? "Yes" : "No") << endl;
}


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

using namespace std;

#define rep(i, a, b)	for (int i(a); i <= (b); ++i)
#define dec(i, a, b)	for (int i(a); i >= (b); --i)
#define MP		make_pair
#define fi		first
#define se		second


typedef long long LL;

const int N = 1e5 + 10;

int f[N][11], ret[N];
int a[N], b[N], c[N];
int n, m, k;

vector <int> v[N];

void solve(int x, int y, int z){
	if (~f[x][y]) return;
	if (!ret[x]) ret[x] = z;
	if (y <= 0) return;
	for (auto u : v[x]){
		solve(u, y - 1, z);
	}
	f[x][y] = 1;
}

int main(){

	scanf("%d%d", &n, &m);
	rep(i, 1, m){
		int x, y;
		scanf("%d%d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}

	scanf("%d", &k);
	rep(i, 1, k){
		scanf("%d%d%d", a + i, b + i, c + i);
	}

	memset(f, -1, sizeof f);
	dec(i, k, 1) solve(a[i], b[i], c[i]);
	rep(i, 1, n) printf("%d\n", ret[i]);
	return 0;
}




Measured memory_bytes: 12408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
   int N,A,B;
   cin>>N>>A>>B;
   string S;
   cin>>S;
   int cnt=0;
   int abr=0;
   rep(i,S.size()){
       if(S[i]=='c'){
           cout<<"No"<<endl;
       }
       else if(S[i]=='a'){
           if(cnt<A+B){
               cout<<"Yes"<<endl;
               cnt++;
           }
           else{
               cout<<"No"<<endl;
           }
       }
       else{
           if(cnt<A+B&&abr<B){
               cout<<"Yes"<<endl;
               cnt++;
               abr++;
           }
           else{
               cout<<"No"<<endl;
           }
       }
   }
}

Measured memory_bytes: 3736
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  ll n, t;
  cin >> n >> t;
  ll s[n], ex = t, sum = t;
  if (n == 1) cout << t << endl;
  else {
    for (ll i = 0; i < n; i++) cin >> s[i];
    for (ll i = 1; i < n; i++) {
      sum += min(t, s[i] - s[i - 1]);
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

        bool is_same(int x, int y) {
            return find(x) == find(y);
        }

        // CAUTION!! : This method is heavy due to scanning linearly.
        int component_count() {
            int c = 0;
            for (const int x : parent) {
                if (x < 0) {
                    c++;
                }
            }
            return c;
        }
};

void solve() {
    int n, q;
    cin >> n >> q;
    UnionFind d(n);
    REP(i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) d.unite(u, v);
        else cout << (d.is_same(u, v) ? 1 : 0) << endl;
    }
}


Measured memory_bytes: 3980
#!/usr/bin/env python3
import sys
INF = float("inf")


def GCD(a, b):
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def solve(A: int, B: int, C: int, D: int):
    U = B-A+1
    cdivnum = B//C - (A-1)//C
    ddivnum = B//D - (A-1)//D
    cd = C*D//GCD(C, D)
    cddivnum = B//cd - (A-1)//cd
    print(U-cdivnum-ddivnum+cddivnum)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    ll D;
    cin >> N >> D;
    int ans = 0;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        if (a * a + b * b <= D * D) ans++;
    }
    output(ans);
    return 0;
}


Measured memory_bytes: 3648
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;
int D[100000];
pair<int, int> P[100000];
int U[200000], V[200000];
vector<pair<int,int>> e[100000];

string BW = "";
int ans[200000];

signed main(){
	cin >> N >> M;
	rep(i, N){
		cin >> D[i];
		P[i].first = D[i];
		P[i].second = i;
		BW += "?";
	}
	sort(P, P+N);
	rep(i, M){
		cin >> U[i] >> V[i];
		U[i]--; V[i]--;
		e[U[i]].pb({ V[i],i });
		e[V[i]].pb({ U[i],i });
		ans[i] = 1'000'000'000;
	}


	rep(i, N){
		int j = P[i].second;
		bool flg = false;
		if(BW[j] != '?') continue;
		rep(k, e[j].size()){
			if(BW[e[j][k].first] != '?'){
				flg = true;
				ans[e[j][k].second] = D[j];
				BW[j] = (BW[e[j][k].first] == 'B' ? 'W': 'B');
				break;
			}
			if(D[e[j][k].first] == D[j]){
				flg = true;
				ans[e[j][k].second] = D[j];
				BW[e[j][k].first] = 'B';
				BW[j] = 'W';
				break;
			}
		}
		if(!flg){
			cout << -1 << endl;
			return 0;
		}
	}

	cout << BW << endl;
	rep(i, M) cout << ans[i] << endl;
}

Measured memory_bytes: 14208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define N 100005
int seg[4*N];
int mul(int a, int b)
{
    return a*b%mod;
}
int mypower(int a, int b)
{
    int ans = 1;
    while(b)
    {
        if(b%2)
            ans = mul(ans, a);
        b=b/2;
        a=mul(a,a);
    }
    return ans;
}
void update(int st, int l, int r, int idx, int arr[], int val)
{
    if(l == r)
    {
        seg[st] = arr[l] = val;
        return;
    }
    int mid = (l+r)/2;
    if(idx <= mid)
        update(2*st+1, l, mid, idx, arr, val);
    else
        update(2*st+2,mid+1, r, idx, arr,val);
    seg[st] = min(seg[2*st+1],seg[2*st+2]);    
}
int query(int st, int l, int r, int ql, int qr)
{
    if(l > qr || r < ql)
    {
        return 0;
    }
    if(l >= ql && r <= qr)
        return seg[st];
    int mid = (l+r)/2;
    return min(query(2*st+1, l, mid, ql, qr), query(2*st+2, mid+1, r, ql, qr));
}

signed main() {
    char c;
    cin >> c;
    if(c >= 'A' && c <= 'Z')
        cout << 'A';
    else
        cout << 'a';
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  cin >> n;
  while(n--) {
    int m;
    cin >> m;
    int mae = 0;
    int res1 = 0, res2 = 0;
    REP(i,m) {
      int a;
      cin >> a;
      if (i) {
        int  tmp = a-mae;
        if (tmp<0) {
          res1 = max(res1,-tmp);
        }else
          res2 = max(res2,tmp);
      }
      mae = a;
    }
    cout << res2 << " "  << res1 << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    string s = to_string(N);
    int count = 0;
    for (int i = 0; i < 2; i++){
        if ((s.at(i) == s.at(i + 1)) && (s.at(i) == s.at(i + 2))){
            count++;
        }
    }
    if (count >= 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256