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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    map<char, int> cnt;
    cnt['a'] = cnt['b'] = cnt['c'] = 0;
    for(int i = 0; i < n; i++){
        cnt[s[i]]++;
    }
    int ma = -1;
    int mi = 1e5+7;
    for(auto p : cnt){
        ma = max(ma, p.second);
        mi = min(mi, p.second);
    }
    if(ma-mi <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private boolean nakayoshi(int[] p, int[] q) {
		return p[0] < q[0] && p[1] < q[1];
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		int[][] red = new int[N][2];
		int[][] blue = new int[N][2];

		for (int i = 0; i < N; i++) {
			red[i] = new int[] { sc.nextInt(), sc.nextInt() };
		}
		for (int i = 0; i < N; i++) {
			blue[i] = new int[] { sc.nextInt(), sc.nextInt() };
		}

		sc.close();

		Comparator<int[]> cmp = (o1, o2) -> Integer.compare(o2[0], o1[0]);
		cmp = cmp.thenComparing((o1, o2) -> Integer.compare(o2[1], o1[1]));
		Arrays.sort(red, cmp);

		Arrays.sort(blue, (o1, o2) -> Integer.compare(o1[1], o2[1]));

		boolean[] used = new boolean[N];

		int ans = 0;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (used[j])
					continue;

				if (nakayoshi(red[i], blue[j])) {
					ans++;
					used[j] = true;
					break;
				}
			}
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 28244
//RUPC-C
#include<stdio.h>
#include<string.h>
char map[1005][1005];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
typedef struct pair{
	int x,y;
}PAIR;
PAIR q[100005],sq[100005];
int bfs(int y,int x){
	int i,j,qn,sqn,nx,ny,f;
	q[0].y=y;q[0].x=x;
	qn=1;f=0;
	while(qn!=0){
		sqn=0;
		for(i=0;i<qn;i++){
			/*if(map[q[i].y][q[i].x]=='t'){
				f=1;
				goto nex;
			}*/
			map[q[i].y][q[i].x]='1';
			for(j=0;j<4;j++){
				nx=q[i].x+dx[j];
				ny=q[i].y+dy[j];
				if(map[ny][nx]=='t'){
					f=1;
					goto nex;
				}
				if(map[ny][nx]=='.' || map[ny][nx]=='t'){
					sq[sqn].x=nx;
					sq[sqn].y=ny;
					map[ny][nx]='1';
					sqn++;
				}
			}
		}
		//memcpy(q,sq,sizeof(PAIR)*sqn);
		for(i=0;i<sqn;i++){
			q[i].x=sq[i].x;
			q[i].y=sq[i].y;
		}
		qn=sqn;
	}
	nex:
	if(f==1)return 1;
	else return 0;
}
int main(){
	int i,j,w,h,n,ans=0,f=0;
	int x,y,sx,sy;
	char ss[1005];
	scanf("%d%d",&w,&h);
	for(i=0;i<=w+1;i++)map[0][i]=map[h+1][i]='#';
	for(i=1;i<=h;i++){
		scanf("%s",ss);
		strcpy(map[i]+1,ss);
		map[i][0]=map[i][w+1]='#';
	}
	//for(i=0;i<=h+1;i++)printf("%s\n",map[i]);
	map[1][1]='1';
	if(bfs(1,1)==1)f=1;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	//while(scanf("%d%d",&x,&y)!=EOF){
		if(f==0)ans++;
		scanf("%d%d",&x,&y);
		x++;y++;
		map[y][x]='.';
		sx=sy=1;
		for(j=0;j<4;j++)
			if(map[y+dy[j]][x+dx[j]]=='1')break;
		if(j<4)sx=x,sy=y;
		map[sy][sx]='1';
		if(f==0 && j<4 && bfs(sy,sx)==1)f=1;
		
		//printf("%d:%d %d\n",i+1,sx,sy);
		//for(j=0;j<=h+1;j++)printf("%s\n",map[j]);
		//printf("\n");
	}
	if(f==0)printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N,z[5]; cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++)cin >> S[i];
	long long ans=0;
	bool k = 0;
	map<char, int> x;
	for (int i = 0; i < N; i++) { x[S[i][0]]++; }
	z[0] = x['M'], z[1] = x['A'], z[2] = x['R'], z[3] = x['C'], z[4] = x['H'];
	for (int i = 0; i<(1<<5); i++) {
		if (((i >> 0) & 1) + ((i >> 1) & 1) + ((i >> 2) & 1) + ((i >> 3) & 1) + ((i >> 4) & 1) == 3) {
			long long y=1;
			for (int j = 0; j < (1 << 5); j++) {
				if (i >> j & 1) y *= z[j];
			}
			if (y != 0) {
				ans += y; k = 1;
			}
		}
	}
	if(k)cout << ans;
	else cout << 0;
}



Measured memory_bytes: 6144
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <array>
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
//#define MOD 998244353
#define MOD 1000000007
#define PI 3.14159265358979
using ll = long long;
using namespace std;

int main(){
    int h,w,k;
    int black = 0;
    int ans = 0;
    array<array<char, 6>, 6> map;
    cin >> h >> w >> k;
    rep(i,h){
        rep(j,w){
            cin >> map[i][j];
            if(map[i][j]=='#')
                black++;
        }
    }

    rep(i,(1<<h)){
        rep(j,(1<<w)){
            array<array<char, 6>, 6> cp = map;
            int count = 0;

            rep(k, h)
            {
                if(i&(1<<k)){
                    rep(l,w){
                        if(cp[k][l]=='#'){
                            count++;
                            cp[k][l] = '.';
                        }
                    }
                }
            }

            rep(k, w)
            {
                if(j&(1<<k)){
                    rep(l,h){
                        if(cp[l][k]=='#'){
                            count++;
                            cp[l][k] = '.';
                        }
                    }
                }
            }

            if(black-count==k)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#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 INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k; cin >> n >> k;
  if(k==1){
      cout << 0 << endl;
  }else{
      cout << n - k << endl;
  }

}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;cin>>n>>k;
   // / vector<int> a[n+1];
    set<int>s;
    for(int i=0;i<k;++i)
    {
        int x;
        cin>>x;
       // s.insert(x);
        for(int j=0;j<x;++j)
        {
            int y;cin>>y;
            //a[x].push_back(y);
            s.insert(y);
        }
    }
    cout<<n-(int)s.size()<<"\n";
    return 0;
}

Measured memory_bytes: 3652
n=int(input())
l=[int(i) for i in input().split()]
s=abs(l[0])
for i in range(1,n):
    s+=abs(l[i]-l[i-1])
s+=abs(l[-1])
#print(s)
for i in range(n):
    if i==0: 
        loss=abs(l[1]-l[0]) 
        loss+=abs(l[0])
        gain=abs(l[1])
        print(s-loss+gain)
    elif i==n-1:
        loss=abs(l[-1])
        loss+=abs(l[-1]-l[-2])
        gain=abs(l[-2])
        print(s-loss+gain)
    else: 
        loss=abs(l[i]-l[i-1])
        loss+=abs(l[i]-l[i+1])
        gain=abs(l[i-1]-l[i+1])
        print(s-loss+gain)

Measured memory_bytes: 64364
import java.util.*;
import static java.lang.Math.*;

public class Main {
	static int A, B, C, N;
	static int[] L;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N= sc.nextInt();
		L = new int[N];
		A= sc.nextInt();
		B= sc.nextInt();
		C= sc.nextInt();
		int i;
		for(i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		sc.close();
		sc = null;
		System.out.println(calmp(0,0,0,0));
	}
	static int calmp(int n, int a, int b, int c) {
		if(n == N) {
		    return (min(min(a,b),c) > 0) ? (abs(A-a)+abs(B-b)+abs(C-c)-30) : 3000;}
		int mp0 = calmp(n+1, a, b, c);
		int mp1 = calmp(n+1, a+L[n], b, c) + 10;
		int mp2 = calmp(n+1, a, b+L[n], c) + 10;
		int mp3 = calmp(n+1, a, b, c+L[n]) + 10;
		return min(min(mp0, mp1),min(mp2, mp3));
	}
}


Measured memory_bytes: 23364
package main

import (
	"fmt"
	"strconv"
	"log"
)

func main(){
	var a,b string
	fmt.Scan(&a, &b)
	t:=a+b
	x,e:=strconv.Atoi(t)
	if e !=nil{
		log.Fatal(e)
	}
	fmt.Print(foo(x))
}
func foo(x int)string{
	for n:=1;n*n<=100000;n++{
		if n * n ==x {
			return "Yes"
		}
	}
	return "No"
}

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

int main(){
    
    int N,M;cin>>N>>M;
    vector<long long int> T1(N),T2(N),T3(N),T4(N),T5(N),T6(N),T7(N),T8(N);
    for(int i=0;i<N;i++){
        long long int a,b,c;cin>>a>>b>>c;
        T1[i]=a+b+c;
        T2[i]=a+b-c;
        T3[i]=a-b+c;
        T4[i]=a-b-c;
        T5[i]=-a+b+c;
        T6[i]=-a+b-c;
        T7[i]=-a-b+c;
        T8[i]=-a-b-c;
    }
    sort(T1.rbegin(),T1.rend());
    sort(T2.rbegin(),T2.rend());
    sort(T3.rbegin(),T3.rend());
    sort(T4.rbegin(),T4.rend());
    sort(T5.rbegin(),T5.rend());
    sort(T6.rbegin(),T6.rend());
    sort(T7.rbegin(),T7.rend());
    sort(T8.rbegin(),T8.rend());
    long long int ans=0;
    long long int sum=0;
    for(int i=0;i<M;i++){
        sum+=T1[i];
    }
    ans=max(ans,sum);
    sum=0;
    for(int i=0;i<M;i++){
        sum+=T2[i];
    }
    ans=max(ans,sum);
    sum=0;
    for(int i=0;i<M;i++){
        sum+=T3[i];
    }
    ans=max(ans,sum);
    sum=0;
    for(int i=0;i<M;i++){
        sum+=T4[i];
    }
    ans=max(ans,sum);
    sum=0;
    for(int i=0;i<M;i++){
        sum+=T5[i];
    }
    ans=max(ans,sum);
    sum=0;
    for(int i=0;i<M;i++){
        sum+=T6[i];
    }
    ans=max(ans,sum);
    sum=0;
    for(int i=0;i<M;i++){
        sum+=T7[i];
    }
    ans=max(ans,sum);
    sum=0;
    for(int i=0;i<M;i++){
        sum+=T8[i];
    }
    ans=max(ans,sum);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N, K;
    in2(N, K);

    vi H(N);
    inN(H, N);

    sort(all(H));

    ll sum = 0;
    rep(i, N - K) sum += H[i];

    outl(sum);

    return 0;
}

Measured memory_bytes: 3900
#include<cstdio>

int main()
{
	int a, b, y;
	scanf("%d %d", &a, &b);
    float x;
    y = (a + b) / 2;
    x = (a + b) / 2.0;
    if(x == y)
		printf("%d\n", y);
	else
		printf("%d\n", y + 1);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];

    for(int loop = 0; loop < min(k, 100); ++loop){
        vector<int> S(n + 1, 0);
        for(int i = 0; i < n; ++i){
            int l = max(0, i - a[i]);
            int r = i;
            ++S[l], --S[r];
            l = i + 1;
            r = min(n, i + a[i] + 1);
            ++S[l], --S[r];
        }
        for(int i = 0; i < n; ++i)  S[i + 1] += S[i], a[i] = S[i] + 1;
    }
    for(int i = 0; i < n; ++i){
        cout << a[i];
        cout << ((i == n - 1) ? '\n' : ' ');
    }
}


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

#define MAX 100000

int N;
typedef pair<int, int> P;
P xs[MAX];
P ys[MAX];

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
};

int main()
{
	cin >> N;
	for( int i = 0; i < N; i++ ) {
		int x, y;
		cin >> x >> y;
		xs[i] = make_pair( x, i );
		ys[i] = make_pair( y, i );
	}

	sort( xs, xs + N );
	sort( ys, ys + N );
	vector< vector<int> > vec;
	for( int i = 0; i < N - 1; i++ ) {
		int s = xs[i].second;
		int t = xs[i + 1].second;
		int d = abs( xs[i + 1].first - xs[i].first );
		vec.push_back( { d, s, t } );
	}
	for( int i = 0; i < N - 1; i++ ) {
		int s = ys[i].second;
		int t = ys[i + 1].second;
		int d = abs( ys[i + 1].first - ys[i].first );
		vec.push_back( { d, s, t } );
	}
	sort( vec.begin(), vec.end() );
	UnionFind uf(N);
	int ans = 0;
	for( auto e : vec ) {
		int d = e[0];
		int s = e[1];
		int t = e[2];
		if( uf.findSet( s, t ) ) {
			continue;
		}
		uf.unionSet(s, t);
		ans += d;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14128
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    printf("%ld\n", n*(n+1)/2);

    return 0;
}


Measured memory_bytes: 128
import math

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

n = int(input())

for i in range(0,10**5):
  if is_prime(n+i)==True:
    print(n+i)
    exit()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){	
	int n;
	cin>>n;int flag=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				flag=1;
				break;
			}
		}
		if(flag){
			break;
		}
	}
	if(flag){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
} 

Measured memory_bytes: 256
ans = []
n = input()
p = 0
while p != n:
    score = raw_input()
    length = len(score)
    flag = 0
    for i in range(length-1):
        if score[i] == score[i+1]:
            flag = 1
    if flag == 0:
        ans.append("Yes")
    else:
        ans.append("No")
    p += 1
for i in ans:
    print i

Measured memory_bytes: 7480
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	if strings.Repeat(string(s[0]), 3) == s[0:3] || strings.Repeat(string(s[1]), 3) == s[1:4] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main()
{
  cin.tie(0);
  double t, x;
  cin >> t >> x;
  double ans;
  ans = t / x;
  printf("%.12f\n", ans);
}

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

int find(vector<vector<int>> &frnd, vector<int> &state, int u){
    for (int i = 0; i < frnd[u].size(); i++){
        if (state[frnd[u][i]] == 0){
            return frnd[u][i];
        }
    }
    return -1;
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> frnd(n);
    int s, t;
    for (int i = 0; i < m; i++){
        cin >> s >> t;
        frnd[s].push_back(t);
        frnd[t].push_back(s);
    }
    vector<int> color(n, 0);
    int cl = 1;
    for (int i = 0; i < n; i++){
        stack<int> s;
        //vector<int> state(n, 0);
        if (color[i] == 0){
            s.push(i);
            color[i] = cl;
            //state[i]++;
            while(!s.empty()){
                int v = s.top();

                s.pop();
                for (int j = 0; j < frnd[v].size(); j++){
                    int u = frnd[v][j];
                    if (color[u] == 0){
                        color[u] = cl;
                        s.push(u);
                    }
                }
                /*int nxt = find(frnd, state, v);
                if (nxt != -1){
                    s.push(nxt);
                    color[nxt] = cl;
                    state[nxt]++;
                }
                else{
                    state[v]++;
                    s.pop();
                }*/
            }
        }
        cl++;
    }
    int q;
    cin >> q;
    int a, b;
    for (int i = 0; i < q; i++){
        cin >> a >> b;
        if (color[a] == color[b])
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 8616
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define re return
#define pb emplace_back
#define em emplace
#define er erase
#define all(x) (x).begin(), (x).end()
#define in(v); { for (auto &i : v) cin >> i; }
#define out(v); { for (auto &i : v) cout << i << ' '; cout << endl; }

#define int long long

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;

const long long INFll = 1e18;



void solve() {
    int n, d, a;
    cin >> n >> d >> a;
    vector <pair <int, int>> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i].fi >> v[i].se;
    sort(all(v));
    int il = 0, ifar = 0;
    int psh = 0;
    vector <int> u(n);
    while (il < n) {
        while (v[ifar].fi + 2 * d < v[il].fi) {
            psh -= u[ifar];
            ifar++;
        }

        u[il] = max(v[il].se / a + (v[il].se % a != 0) - psh, 0ll);
        psh += u[il];
        il++;

    }
    cout << accumulate(all(u), 0ll);
}

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

    solve();
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
const int MAXN=200000+10;
int N;
long long D;
long long x[MAXN],y[MAXN];

int main(){
    cin>>N>>D;
    for(int i=1;i<=N;i++){
        cin>>x[i]>>y[i];
    }
    int ans=0;
    for(int i=1;i<=N;i++)
        ans+=(x[i]*x[i]+y[i]*y[i]<=D*D);
    cout<<ans;
}


Measured memory_bytes: 6752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll r;
    cin>>r;
    cout<<3*r*r<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n,mod=1000000000,sum=0,m;
  cin>>n;
  m=n;
  for(int i=0;i<10;++i){
    sum+=n/mod;
    n%=mod;
    mod/=10;
  }
  if(m%sum==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3528
s = gets.strip.split('')
q = gets.to_i
is_reverse = false

q.times do
  query = gets.split("\s")
  
  if query[0] == '1'
    is_reverse = ! is_reverse
    next
  end
  
  if (! is_reverse && query[1] == '1') || (is_reverse && query[1] == '2')
    s.unshift(query[2])
    next
  end
  
  s.push(query[2])
end
s = s.join
print is_reverse ? s.reverse! : s

Measured memory_bytes: 28668
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,c=MI()
cal1=[]
dis1=[]
for i in range(n):
    a,b=MI()
    cal1.append(b)
    dis1.append(a)
cal2=list(reversed(cal1))
dis2=[0 for i in range(n)]
for i in range(n):
    dis2[i]=c-dis1[i]
dis2=list(reversed(dis2))
#print(cal1)
#print(dis1)
#print(cal2)
#print(dis2)
u1=list(accumulate(cal1))
v1=list(accumulate(cal1))
u2=list(accumulate(cal2))
v2=list(accumulate(cal2))
for i in range(n):
    u1[i]-=dis1[i]
    v1[i]-=2*dis1[i]
    u2[i]-=dis2[i]
    v2[i]-=2*dis2[i]
'''print("u1")
print(u1)
print("u2")
print(u2)
print("v1")
print(v1)
print("v2")
print(v2)'''
ans=[]
ans.append(max(u1))
ans.append(max(u2))
#print(ans)
mxv1=[0 for i in range(n)]
mxv2=[0 for i in range(n)]
mxv1[0]=max(0,v1[0])
mxv2[0]=max(0,v2[0])
for i in range(n-1):
    mxv1[i+1]=max(v1[i+1],mxv1[i])
    mxv2[i+1]=max(v2[i+1],mxv2[i])
'''print("mxv1")
print(mxv1)
print("mxv2")
print(mxv2)'''
mxa=0
for i in range(n-1):
    sm=u1[i]+mxv2[n-i-2]
    #print(sm)
    if sm>mxa:
        mxa=sm
ans.append(mxa)
mxb=0
for i in range(n-1):
    sm=u2[i]+mxv1[n-i-2]
    #print(sm)
    if sm>mxb:
        mxb=sm
ans.append(mxb)
#print(ans)
print(max(ans))

    
    


    
    

        
        
    



Measured memory_bytes: 123096
N = gets.to_i
as = gets.split.map(&:to_i)
sum = as.reduce(&:+)
sums = Array.new(N)
current = 0
as.each.with_index do |a, i|
  current += a
  sums[i] = current
end

ans = 1 << 60
sums[0...-1].each.with_index do |psum, i|
  # c = i + 1
  b = (sum - psum).abs
  diff = (psum - b).abs
  ans = diff if diff < ans
end
puts ans


Measured memory_bytes: 17668
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int64 dis[101][101];

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

  int V, E; cin >> V >> E;
  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (i == j) {
        dis[i][j] = 0;
      } else {
        dis[i][j] = INF64;
      }
    }
  }

  for (int i = 0; i < E; ++i) {
    int s, t, d; cin >> s >> t >> d;
    dis[s][t] = (int64)d;
  }

  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j) {
        if (dis[i][k] == INF64 || dis[k][j] == INF64) continue;
        chmin(dis[i][j], dis[i][k] + dis[k][j]);
      }
    }
  }

  for (int i = 0; i < V; ++i) {
    if (dis[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << '\n';
      return 0;
    }
  }

  for (int i = 0; i < V; ++i) {
    for (int j = 0; j < V; ++j) {
      if (dis[i][j] == INF64) {
        cout << "INF";
      } else {
        cout << dis[i][j];
      }
      if (j != V - 1) cout << " ";
    }
    cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 3304
#include<bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int n, ans = 0; string s,t="810";
vector<char> c = { '0','1','2','3','4','5','6','7','8','9' };
void dfs(int i) {
    if (i == 3) {
        int id = 0;
        rep(l, n) {
            if (s[l] == t[id]) id++;
            if (id > 2) {
                ans++; break;
            }
        }
    }
    else {
        rep(j, 10) {
            t[i] = c[j];dfs(i+1);
        }
    }
}
int main() {
    cin >>n >>s; dfs(0); cout << ans << endl;
}

Measured memory_bytes: 3608
#pragma GCC optimize("O3")
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200010


int main() {
	char s[N];
	f(i, N)s[i] = 0;
	int n;
	int ans[N];
	int fians[N];
	int a[N];
	int b[N];
	int c[N];
	int aa, bb, cc;
	int ka, kb, kc;
	int x, y, z;
	ans[0] = 0;
	f(i, N-1) {
		x = 0;
		y = i + 1;
		while (y > 0) {
			if (y % 2 == 1)x++;
			y /= 2;
		}
		x = (i + 1) % x;
		ans[i + 1] = ans[x] + 1;
	}
	scanf("%d", &n);
	scanf("%s", s);
	ka = 0;
	f(i, n) {
		if (s[i] == '1')ka++;
	}
	kb = ka - 1;
	kc = ka + 1;
	if (kb > 0) {
		x = 1 % kb;
		bb = 0;
		f(i, n) {
			b[i] = x;
			if (s[n - i - 1] == '1')bb = (bb + x) % kb;
			x = (x * 2) % kb;
		}
	}
	if (kc > 0) {
		x = 1 % kc;
		cc = 0;
		f(i, n) {
			c[i] = x;
			if (s[n - i - 1] == '1')cc = (cc + x) % kc;
			x = (x * 2) % kc;
		}
	}
	f(i, n) {
		if (s[n-i-1] == '1') {
			if (kb <= 0)fians[n - i - 1] = 0;
			else {
				x = bb + (kb - b[i]);
				x = x % kb;
				fians[n - i - 1] = ans[x] + 1;
			}

		}
		else {
			x = cc + c[i];
			x = x % kc;
			fians[n - i - 1] = ans[x] + 1;
		}

	}
	f(i,n)printf("%d\n", fians[i]);


	return 0;
}

Measured memory_bytes: 5004
using System;
using System.Linq;

class D
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var M = 998244353;
		var h = Read();
		var n = h[0];
		var lrs = new int[h[1]].Select(_ => Read()).ToArray();

		var s = 0L;
		var d = new long[n + 1];
		d[1] = 1;
		d[2] = -1;

		for (int i = 1; i <= n; i++)
		{
			s = (s + d[i]) % M;
			foreach (var lr in lrs)
			{
				int l = i + lr[0], r = i + lr[1] + 1;
				if (l <= n) d[l] = (d[l] + s) % M;
				if (r <= n) d[r] = (d[r] - s + M) % M;
			}
		}
		Console.WriteLine(s);
	}
}


Measured memory_bytes: 29744
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;

bool isOddString(string s){
    if(s.size() % 2 == 1) return false;
    for(int i = 0; i < s.size() / 2; i++){
        if(s[i] != s[i + s.size() / 2]) return false;
    }
    return true;
}

int main(){

    string s;
    cin >> s;
    
    int size = s.size();
    for(int i = 0; i < size; i++){
        s.erase(s.end()-1);
        if(isOddString(s) ){
            cout << s.size() << endl;
            return 0;
        } 
    }

}

Measured memory_bytes: 256
n, m = map(int, input().split())
H = list(map(int, input().split()))
p = [1] * n
for _ in range(m):
    a,b = map(int, input().split())
    if H[a-1] == H[b-1]:
        p[a-1] = 0
        p[b-1] = 0
    elif H[a-1] > H[b-1]:
        p[b-1] = 0
    else:
        p[a-1] = 0
print(sum(p))

Measured memory_bytes: 20112
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#include <cmath>
using namespace std;

int main()
{
    int n, temp, i, cnt=0;
    cin >> n;
    int p[n];
    for (i=0; i<n; i++)
    {
        cin >> p[i];
    }
    temp=p[0];
    for (i=0; i<n; i++)
    {
        if (temp>p[i])
        {
            temp=p[i];
            cnt++;
        }
    }
    cout << cnt+1 << endl;

    return 0;
}


Measured memory_bytes: 4332
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int h,w,n;
    cin >> h >> w >> n;
    int tmp;
    //cout << h << w << n << endl;

    vector<int> a(h*w,0);
    int count1 = 0;//配列
    int count2 = 0;//ループ
    for(int i = 0;i < n;i++){
        cin >> tmp;
        //cout << "a" << endl;
        while(count2 < tmp){
            //cout << "b" << endl;
            a[count1]=i+1;
            count1++;
            count2++;
        }
        count2 = 0;
    }
   /* REP(h*w){
        cout << a[i];
    }
    cout << endl;
*/
    int b[h][w];
   

    int count = 0;
    for(int i = 0;i < h;i++){

        int tmp2 = 0;
        if(i%2 == 0){
            for(int j = i*w;j < (i+1)*w;j++){

                b[i][tmp2]=a[j];
                tmp2++;

            }
            //cout << endl;
        }else{

            for(int j = (i+1)*w-1;j >= i*w; j--){

                b[i][tmp2]=a[j];
                tmp2++;

            }
            //cout << endl;
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(j <=w-2){
                cout << b[i][j] << " "; 
            }else{
                cout << b[i][j];
            }        
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    vector<int> ver(N);
    for (int i = 0; i < N; i++)
        cin >> ver.at(i);
    sort(ver.begin(), ver.end());
    int point;
    point = 0;
    for (int i = 0; i < N; i++)
    {
        if (i > 0 && ver.at(i) == ver.at(i - 1))
            continue;
        point++;
    }
    cout << point << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from itertools import*\n"
"n,a,b,c,*l=map(int,open(0).read().split())\n"
"a=a,b,c\n"
"m=10**18\n"
"for s in product(*[range(4)]*n):\n"
"  if all(i in s for i in(0,1,2)):\n"
"    t,c=[0]*4,[0]*4\n"
"    for i,v in zip(s,l):\n"
"      t[i]+=v\n"
"      c[i]+=1\n"
"    m=min(m,sum(abs(x-y)+~-z*10for x,y,z in zip(a,t,c)))\n"
"print(m)\n"
"\"";
  system(s);
  return 0;
}            

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, t;
    cin >> n >> t;
    akari<int> as(t + 1);
    while (n--)
    {
        int l, r;
        cin >> l >> r;
        as[l]++;
        as[r]--;
    }
    for (int i = 0; i < t; i++)
    {
        as[i + 1] += as[i];
    }
    cout << *max_element(as.begin(), as.end()) << endl;
}

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



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

using namespace std;



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

    int n, k, q, a;
    cin>>n>>k>>q;
    int ans[n]= {0};
    for(int i=0; i<q; i++)
    {
        cin>>a;
        ans[a-1]++;
    }
    if(k>q)
    {
        while(n--)
            cout<<"Yes"<<endl;
        return 0;
    }
    for(int j=0; j<n; j++)
    {
        if(ans[j]>q-k) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
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; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

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

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n); inv(n, a);
    sort(a.begin(), a.end(), greater<int>());
    int g = gcd(a[0], a[1]);
    for(int i = 2; i < n; i++){
        g = gcd(g, a[i]);
    }
    if(k <= a[0] && k % g == 0){
        cout << "POSSIBLE" << endl;
    }else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;


int main()
{
    string S;
    cin >> S;
    ll tmp=0;
    for(int i=0; i<S.size(); i++){
        ll a=ll(S[i])-ll('0');
        tmp+=a;
        tmp%=9;
    }
    if(tmp%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;




    return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a - (2 * b) > 0 ? a - (2 * b) : 0) << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
const int MOD = 998244353;

int ks[3001];

int main() {
    int N, S;
    cin >> N >> S;
    vector<int> As(N);
    for (auto& A : As) {
        cin >> A;
    }
    ll s = 0;
    memset(ks, 0, sizeof(ks));
    ks[0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = S; j >= As[i]; j--) {
            ks[j] = (ks[j] + ks[j - As[i]]) % MOD;
        }
        s = (s + ks[S]) % MOD;
        ks[0]++;
    }
    cout << s << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var dp [100][2]int

const MAX_DIGIT = 50

func main() {
	sc.Split(bufio.ScanWords)

	N, K := nextInt(), nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	for i := 0; i < 100; i++ {
		for j := 0; j < 2; j++ {
			dp[i][j] = -1
		}
	}
	dp[0][0] = 0
	for d := 0; d < MAX_DIGIT; d++ {
		mask := 1 << uint((MAX_DIGIT - d - 1))

		num := 0
		for i := 0; i < N; i++ {
			if (A[i] & mask) == mask {
				num++
			}
		}

		cost0 := mask * num
		cost1 := mask * (N - num)

		if dp[d][1] != -1 {
			chmax(&dp[d+1][1], dp[d][1]+max(cost0, cost1))
		}

		if dp[d][0] != -1 {
			if (K & mask) == mask {
				chmax(&dp[d+1][1], dp[d][0]+cost0)
			}
		}

		if dp[d][0] != -1 {
			if (K & mask) == mask {
				chmax(&dp[d+1][0], dp[d][0]+cost1)
			} else {
				chmax(&dp[d+1][0], dp[d][0]+cost0)
			}
		}
	}

	fmt.Println(max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]))

}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


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

long long cnt;
int l;
int A[1000000];
int n;
std::vector<int> G;

void insertionSort(int g) {
    int v, j;
    for (int i = g; i < n; i++) {
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j +g] = v;
    }
}

void shellSort() {
    for (int h = 1; ;) {
        if (h > n) break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size()-1; i >= 0; i--) {
        insertionSort(G[i]);
    }
}


int main()
{
    std::scanf("%d", &n);
    for (int i = 0; i < n; i++) std::scanf("%d", &A[i]);
    cnt = 0;
    shellSort();

    std::printf("%d\n", G.size());
    for (int i = G.size()-1; i >= 0; i--) {
        std::printf("%d", G[i]);
        if (i) std::printf(" ");
    }
    std::printf("\n");
    std::printf("%d\n", cnt);
    for (int i = 0; i < n; i++) std::printf("%d\n", A[i]);

    return 0;
}



Measured memory_bytes: 7132
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm> 
#include <functional>	
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int A = max(a + b, a - b);
	int B = max(A, a*b);
	cout << B << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
  int main(void){
    int n,i;
    double sum = 0;
    double A[101];

    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%lf",&A[i]);
      sum = sum+(1/A[i]);
    }

    printf("%lf",1/sum);

    return 0;
  }




Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N, X, T; cin >> N >> X >> T;
  int n = (N+X-1)/X;
  cout << n*T << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}

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

int main() {
  long long A, B, N; 
  cin >> A >> B >> N;
  if (N < B) {
    cout << (long long)floor(A * N / B) << endl;
    return 0;
  } 
  cout << (long long)floor(A * (B - 1) / B) - A * (long long)floor((B - 1) / B) << endl;
}

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

using namespace std;

int main()
{
	string s;
	long long n;
	cin >> s >> n;
	
	int i = 0;
	for (; i < s.length() && s[i] == '1'; i++) {
		;
	}
	if (!(i < s.length())) {
		cout << 1 << endl;
	}
	else if (i + 1 > n) {
		cout << 1 << endl;
	}
	else {
		cout << s[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
x = int(input())
bs = [input() for i in range(x)]
bt = []
for q in ["S ","H ","C ","D "]:
    for qq in range(13):
        bt.append(q+str(qq+1))
aaa = list(set(bt) - set(bs))
aaa.sort(key=lambda x: (int(x[2:])))
for ii in ["S","H","C","D"]:
    for i in aaa:
        if (i.find(ii) != -1):
            print(i)


Measured memory_bytes: 5608
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	// 全体の数
	totalNum := b - a + 1

	// 最小公倍数
	lcm := c * d / gcd(c, d)

	var cNum, dNum, eNum int
	if a%c == 0 {
		cNum = a/c - 1
	} else {
		cNum = a / c
	}
	if a%d == 0 {
		dNum = a/d - 1
	} else {
		dNum = a / d
	}
	if a%lcm == 0 {
		eNum = a/lcm - 1
	} else {
		eNum = a / lcm
	}

	// Cの倍数の数
	C := (b/c - cNum)
	// Dの倍数の数
	D := (b/d - dNum)
	// C,Dの公倍数の数
	CD := (b/lcm - eNum)

	ans := totalNum - (C + D - CD)
	fmt.Println(ans)
}

func gcd(x, y int) int {
	tmp := x % y
	if tmp > 0 {
		return gcd(y, tmp)
	} else {
		return y
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int psg[MAXN];
int rpsg[MAXN];
char S[MAXN];

int mygcd(ll a,ll b){
    return a?mygcd(b%a,a):b;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>A[i];

    for(int i=1;i<=n;i++)
        psg[i] = mygcd(psg[i-1],A[i]);

    for(int i=n;i>=1;i--)
        rpsg[i] = mygcd(rpsg[i+1],A[i]);

    for(int i=1;i<=n;i++){
        x = psg[i-1];
        y = rpsg[i+1];
        mx = max(mx,mygcd(x,y));
    }

    cout<<mx<<"\n";

    return 0;
}


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

int main(){
    int H, W;
    cin >> H >> W;
    int m[H+2][W+2] = {};
    char tmp;
    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
            cin >> tmp;
            if (tmp=='#'){
                m[i-1][j]++;
                m[i-1][j+1]++;
                m[i-1][j-1]++;
                m[i][j-1]++;
                m[i][j+1]++;
                m[i+1][j]++;
                m[i+1][j+1]++;
                m[i+1][j-1]++;
                m[i][j] = -100;
            }
        }
    }
    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
            if (m[i][j] < 0) cout << '#';
            else cout << m[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
  val a = sc.nextInt
  val b = sc.nextInt
  val h = sc.nextInt
//  val list = List.fill(3)(sc.nextInt)

  val ans = (a + b) * h / 2

  println(ans)


  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }
}

Measured memory_bytes: 27328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define sz(a)			a.size()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD1			998244353
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const int tam = 100010;
const int MOD = 1e9+7;
const double EPS = 1e-9;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	cin>>n;
	int ar[n];
	ll sad = 0;
	fore(i, 0, n)
	{
		cin>>ar[i];
		ar[i] -= i+1;
	}
	sort(ar, ar + n);
	int med = ar[n / 2];
	fore(i, 0, n) sad += abs(ar[i] - med);
	cout<<sad<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 1024
INF = float('inf')
MAX_N = 110
MAX_V = 100100

# input
N, W = map(int, input().split())
weight, value = [0]*N, [0]*N

for i in range(N):
    tmp_w, tmp_v = map(int, input().split())
    weight[i] = tmp_w
    value[i] = tmp_v

dp = [[INF for _ in range(MAX_V)] for _ in range(MAX_N)]
dp[0][0] = 0


for i in range(N):
    for sum_v in range(MAX_V):
        # i番目の品物を選ぶ場合
        if sum_v - value[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i])
        # i番目の品物を選ばない場合
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])


answer = 0
for sum_v in range(MAX_V):
    if dp[N][sum_v] <= W:
        answer = sum_v

print(answer)

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

int main() {
  int N = 0;
  cin >> N;
 
  int n1000 = N / 1000;
  int n100 = N % 1000 / 100;
  int n10 = N % 100 / 10;
  int n1 = N % 10;
  
  if( n1000 == n100 && n100 == n10 || n100 == n10 && n10 == n1 )
	cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256