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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define mod 1e9 +7;

typedef long long ll;
typedef vector<ll> vll;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    bool ans = true;
    string s, s_inv;
    cin >> s;

    int n = s.size();
    s_inv = s;
    reverse(all(s_inv));
    if(s != s_inv)ans = false;
    string t1, t1_inv, t2, t2_inv;
    t1 = s.substr(0, (n-1)/2);
    t1_inv = t1;
    reverse(all(t1_inv));

    t2 = s.substr((n+3)/2 - 1);
    t2_inv = t2;
    reverse(all(t2_inv));

    if(t1 != t1_inv || t2 != t2_inv)ans = false;

    cout << ((ans)? "Yes" : "No") << endl;
    return 0;
} 

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())

ans_water, ans_sugar = 100 * a, 0
for i in range(f // (100 * a) + 1):
  water = 100 * a * i
  if water > f:
    break
  for j in range(((f - water) // (100 * b)) + 1):
    water = 100 * a * i + 100 * b * j
    if water == 0 or water > f:
      break
    for k in range(((f - water) // c) + 1):
      sugar = c * k
      if water + sugar > f or sugar > e * water // 100:
        break
      for l in range(((f - water - sugar) // d) + 1):
        sugar = c * k + d * l
        if water + sugar > f or sugar > e * water // 100:
          break
        if sugar / (water + sugar + 1) > ans_sugar / (ans_water + ans_sugar):
          ans_water, ans_sugar = water, sugar

print(ans_water + ans_sugar, ans_sugar)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.StringTokenizer;

public class Main  implements Runnable {
	int[][] ta = new int[16][4096];
	int ptr = 0;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 64 * 1024 * 1024).start();
    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		int k = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		//long a = Long.parseLong(sc.next());
		//String s = sc.next();
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//ArrayList<Str_4> lists = new ArrayList<Str_4>();
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		//int[] ra = new int[r];
		//ArrayList<ArrayList<Integer>> lists = new ArrayList<>();

		for(int i = x-k+1; i < x+k; i++)
		{
			out.print(i);
			out.print(" ");
		}
		

		out.println();
		out.flush();
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

    }
}

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

const ll Mod = 1e9+7; 
const int MAX = 1e5+5;
ll sec[MAX], tri[MAX];
int cntl[MAX], cntr[MAX];
int Lint[MAX];
string L;
int n;

void init() {
  rep(i, n) Lint[i] = (L[i] == '1') ? 1 : 0;
  sec[0] = tri[0] = 1;
  rep(i, n+1) sec[i+1] = sec[i]*2 % Mod;
  rep(i, n+1) tri[i+1] = tri[i]*3 % Mod;
  cntl[0] = Lint[0]; cntr[n-1] = Lint[n-1];
  for (int i = 1; i < n; ++i) cntl[i] = cntl[i-1] + Lint[i];
  for (int i = n-2; i >= 0; --i) cntr[i] = cntr[i+1] + Lint[i];
}

void solve() {
  init();
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (Lint[i]) {
      if (i == 0) ans = (ans + tri[n-1]) % Mod;
      else if (i == n-1) ans = (ans + sec[cntl[i-1]]) % Mod;
      else ans = (ans + sec[cntl[i-1]]*tri[n-(i+1)]) % Mod;
    }
  }
  ans = (ans + sec[cntl[n-1]]) % Mod;
  cout << ans << endl;
}


int main() {
  cin >> L;
  n = L.length();
  solve();
  return 0;
}

Measured memory_bytes: 3200
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int h, w;

		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			// h??¨w???0????????£?????¨???????????????
			if ((h == 0) & (w == 0)) {
				break;
			}

			// ????????????????????????
			for (int count = 0; count < h; count++) {
				// ?¨??????????????????????
				for (int count2 = 0; count2 < w; count2++) {
					// ???????????????????????¨????????????True???#??????????????????????????¶???
					if ((count == 0) | (count == (h - 1))) {
						sb.append("#");
					} else {
						// ?¨?????????????????????¨?????????True???#?????????)??????????????¶???
						if ((count2 == 0) | (count2 == (w - 1))) {
							sb.append("#");
						} else {
							sb.append(".");
						}
					}
				}
				sb.append("\n");
			}

			System.out.println(new String(sb));
			// StringBuilder???????????????
			sb.delete(0, sb.length());

		}

	}
}

Measured memory_bytes: 27572
// #includes {{{
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <cmath>
using namespace std;
// }}}
// pre-written code {{{
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

const int INF=0x3f3f3f3f;

typedef long long Int;
typedef unsigned long long uInt;
#ifdef __MINGW32__
typedef double rn;
#else
typedef long double rn;
#endif

typedef pair<int,int> pii;

/*
#ifdef MYDEBUG
#include"debug.h"
#include"print.h"
#endif
*/
// }}}

char s[100010];

bool judge(int i,int l){
	map<int,int> m;
	REP(j,l)m[s[i+j]-'a']++;
	FOR(it,m)if(it->second*2>l)return true;
	return false;
}

int main(){
	scanf("%s",s);
	int l = strlen(s);
	REP(i,l-3+1){
		if(judge(i,3)){
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	REP(i,l-2+1){
		if(judge(i,2)){
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
	}
	printf("-1 -1\n");
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			long n = scanner.nextLong();
			long a = scanner.nextLong();
			long b = scanner.nextLong();
			System.out.println(n / (a + b) * a + Math.min(n % (a + b), a));
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

ll dp[200200][2]; // dp[i][j]:i番目のグループで(j==0:左、j==1:右)を取った時の最大値
ll dp2[200200][2][2]; // dp2[i][j][k]:i番目のグループで(j==0:左、j==1:右)を取った時の最大値
                      // kは既に1グループ飛ばしたかどうか

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<=n;i++){
        // 初期化
        dp[i][0]=dp[i][1]=-1e18;
        dp2[i][0][0]=dp2[i][0][1]=dp2[i][1][0]=dp2[i][1][1]=-1e18;
    }
    int m=n/2;
    if(n%2==0){
        dp[1][0]=a[0],dp[1][1]=a[1];
        for(int i=1;i<m;i++){
            for(int j=0;j<2;j++){
                if(j==0){
                    dp[i+1][0]=max(dp[i+1][0],dp[i][j]+a[2*i]);
                }
                dp[i+1][1]=max(dp[i+1][1],dp[i][j]+a[2*i+1]);
            }
        }
        cout << max(dp[m][0],dp[m][1]) << endl;
    }
    else{
        // a[n-1]を使わない場合　上の偶数の場合と一緒
        dp[1][0]=a[0],dp[1][1]=a[1];
        for(int i=1;i<m;i++){
            for(int j=0;j<2;j++){
                if(j==0){
                    dp[i+1][0]=max(dp[i+1][0],dp[i][j]+a[2*i]);
                }
                dp[i+1][1]=max(dp[i+1][1],dp[i][j]+a[2*i+1]);
            }
        }
        // a[n-1]を使う場合
        dp2[1][0][0]=a[n-1]+a[0],dp2[1][1][0]=a[n-1]+a[1];
        dp2[1][0][1]=a[n-1];
        for(int i=1;i<m;i++){
            for(int j=0;j<2;j++){
                for(int k=0;k<2;k++){
                    if(k==0){
                        dp2[i+1][0][1]=max(dp2[i+1][0][1],dp2[i][j][k]);
                    }
                    if(j==0){
                        dp2[i+1][0][k]=max(dp2[i+1][0][k],dp2[i][j][k]+a[i*2]);
                    }
                    // a[n-2]は使えない事に注意！
                    if(i!=m-1)dp2[i+1][1][k]=max(dp2[i+1][1][k],dp2[i][j][k]+a[i*2+1]);
                }
            }
        }
        cout << max({dp[m][0],dp[m][1],dp2[m][0][1],dp2[m][1][1]}) << endl;
    }
}

Measured memory_bytes: 14252
counter = [0] * 1001
(1..499).each do |i|
  counter[i + (i + 1)] += 1
end

(3..50).each do |i|
  (1..1000/i).each do |s|
    k = s
    num = 0
    i.times{ num += k; k += 1}
    break if num > 1000
    counter[num] += 1
  end
end

while n = gets.to_i
  break if n == 0
  p counter[n]
end

Measured memory_bytes: 8644
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const ll INF=100000000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
int main() {
	int c[3][3];
	int a[3][2],b[2][3];
	rep(i,0,3){
		rep(j,0,3){
			cin>>c[i][j];
		}
	}
	rep(i,0,3){
		rep(j,1,3){
			a[i][j-1]=c[i][j]-c[i][j-1];
			b[j-1][i]=c[j][i]-c[j-1][i];
		}
	}
	bool d=false;
	rep(i,0,2){
		if(a[0][i]!=a[1][i]||a[2][i]!=a[1][i])d=true;
		if(b[i][0]!=b[i][1]||b[i][1]!=b[i][2]){
			d=true;
		}
	}
	yesno(!d);
	return 0;
}


Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,L,T;
int ar[100005],br[100005];

int dst[100005];
int main(){
  cin>>n>>L>>T;

  lint sum=0;
  REP(i,n){
    scanf("%d%d",&ar[i],&br[i]);
    dst[i]=(br[i]==1?(ar[i]+T)%L:((ar[i]-T)%L+L)%L);
    sum+=(br[i]==1?ar[i]+T:ar[i]-T);
  }
  sort(dst,dst+n);
  lint sum2=0;
  REP(i,n){
    sum2+=dst[i];
  }
  REP(i,n){
    if(abs(sum2-sum)%(n*(lint)L)==0){
      REP(j,n) printf("%d\n",dst[(i+j)%n]);
      exit(0);
    }
    sum2+=L;
  }
  return 0;
}





Measured memory_bytes: 2304
#include<stdio.h>
#include<math.h>
double d,r,s,z[6];
int n,i,j,a[50];
int main(){
	for(scanf("%d",&n);n--;){
		for(i=0;i<6;i++)
			scanf("%lf",z+i);
		r=z[2];
		s=z[5];
		d=hypot(*z-z[3],z[1]-z[4]);
		printf("%d\n",a[j++]=d>r+s?0:r>d+s?2:s>d+r?-2:1);
	}
	
	i=a[3];
	if(i==2)puts("");
	else if(i==-2)while(1);
	else if(i==1)return 1;
	return 0;
}

Measured memory_bytes: 0
n = input()
l = input().split() 
l = [int(x) for x in l]
e =[]
f =[int(x) for x in l if x%2==0]
for i in range(len(l)):
    if l[i] % 2 == 0 and (l[i]%3 ==0 or l[i]%5==0):
        e.append(l[i])
if (len(e)==len(f)):
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<map>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {

	int n;
	string s;
	ull m = 0, a = 0, r = 0, c = 0, h = 0,ans=0;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		switch (s[0]) {
		case 'M':m++; break;
		case 'A':a++; break;
		case 'R':r++; break;
		case 'C':c++; break;
		case 'H':h++; break;
		}
	}

	ans = m * a*r + m * a*c + m * a*h + m * r*c + m * r*h + m * c*h + a * r*c + a * r*h + a * c*h + r * c*h;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 100
#define INF 10000000

int min(int i,int j){
  if(i<j) return i;
  else return j;
}

int main(){
  int n,i,j,l,k,t;
  int p[N+1];
  int m[N+1][N+1];

  scanf("%d",&n);
  for(i=1 ; i<=n ; i++) scanf("%d%d",&p[i-1],&p[i]);

  for(i=1 ; i<=n ; i++) m[i][i] = 0;
  for(l=2 ; l<=n ; l++){
    for(i=1 ; i<=n-l+1 ; i++){
      j = i + l - 1;
      m[i][j] = INF;
      for(k=i ; k<=j-1 ; k++){
        t = m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
        m[i][j] = min(m[i][j],t);
      }
    }
  }
  printf("%d\n",m[1][j]);
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>
#include <string.h>
#include <vector>

#define pb push_back

using namespace std;

int banyak[30], memo[30][80];

int dp(int id, int sisa) {
	int ret = 0;
	if (id == 25)
		return 0;
	if (sisa == 1)
		return 1;
	if (memo[id][sisa] != -1)
		return memo[id][sisa];
	for (int j = 0; j <= banyak[id]; j++) {
		if (j == sisa)
			break;
		if (sisa % (j + 1) == 0)
			ret += dp(id + 1, sisa / (j + 1));
	}
	memo[id][sisa] = ret;
	return ret;
}

int main() {
	int n, temp, angka, cnt, ans;
	bool valid[110];
	vector<int> prima;
	scanf("%d", &n);
	memset(valid, true, sizeof valid);
	for (int i = 2; i < 98; i++)
		if (valid[i]) {
			prima.pb(i);
			temp = i * i;
			while (temp < 98) {
				valid[temp] = false;
				temp += i;
			}
		}
	memset(banyak, 0, sizeof banyak);
	for (int i = 2; i <= n; i++) {
		temp = 0;
		angka = i;
		while (angka > 1) {
			cnt = 0;
			while (angka % prima[temp] == 0) {
				cnt++;
				angka /= prima[temp];
			}
			banyak[temp] += cnt;
			temp++;
		}
	}
	memset(memo, -1, sizeof memo);
	ans = dp(0, 75);
	printf("%d\n", ans);
	return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

int a[100];
int cells[100][100]; // r * c

int main() {
  string S;
  cin >> S;

  string ans = "Sunny";
  if (S == "Sunny") ans = "Cloudy";
  else if (S == "Cloudy") ans = "Rainy";

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
a= int(input())
cand = [a]
index = 0
while True:
    if cand[index] % 2 ==0:
        last= int(cand[index]/2)
    else:
        last= int(cand[index]*3+1)
        
    if last in cand:
        cand.append(last)
        print(index+2) #リストの最後はindex+1番目で、そこに新たに一つ加えるため
        break
    else:
        cand.append(last)
        index +=1

Measured memory_bytes: 3060
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

master_l, master_r = -1, N
for l, r in LR:
	master_l = max(master_l, l)
	master_r = min(master_r, r)

print(max(0, master_r - master_l + 1))


Measured memory_bytes: 27332
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    //b:pi面体のカウント用バケツ
    int N,K,p[200010]={},b[1010]={},s;

    //１から添字までの合計格納(期待値計算用)
    long long sum[1010]={};

    //v:各サイコロの期待値格納,ans:答え,temp:累積和用
    double v[200010]={},ans=0,temp=0;

    cin >> N >> K;
    for(int i=0;i<N;i++)
    {
        cin >> p[i];
        b[p[i]]+=1;
    }
    sum[1]=1;
    for(int i=1;i<=1000;i++)
    {
        sum[i]=sum[i-1]+i;

        double tempv = 0;

        //i面サイコロがあるとき
        if(b[i]>=1)
        {
            //期待値計算
            tempv = (double)sum[i] / (double)i;

            //N個のサイコロをループ
            for(int k=0;k<N;k++)
            {
                //i面サイコロであれば、期待値を格納
                if(p[k]==i)
                {
                    v[k] = tempv;
                }
            }
        }
    }

    //0~K-1までの期待値合計を計算して一旦答えに
    for(int i=0;i<K;i++)
    {
        ans += v[i];
    }

    s = 0;

    temp=ans;

    //0~(K-1)→1~Kと範囲を１ずつずらして期待値合計が大きくなれば答えを更新
    for(int i=K;i<N;i++)
    {
        temp -=v[i-K];
        temp +=v[i];
        if(temp>ans)
        {
            ans = temp;
        }
    }

    cout<<setprecision(10)<<fixed;
    cout<<ans<<endl;

}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(0);

    int n, x, t; cin >> n >> x>> t;
    cout<<ceil(n/(ld)x)*t<<endl;
}

Measured memory_bytes: 3784
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var AB = ReadSplitInt();
            var A = AB[0];
            var B = AB[1];
            Println(Max(Max(A - B, A + B), A * B));
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 11604
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(input_line):
    """Test Case
    >>> print_ans("2 3 1")
    3 1 2
    >>> print_ans("1 2 3 4 5")
    1 2 3 4 5
    >>> print_ans("8 2 7 3 4 5 6 1")
    8 2 4 5 6 7 3 1
    """
    arr = np.array(list(map(int,input_line.split())))
    arr_sort = np.argsort(arr) + 1
    arr_str = list(map(str,arr_sort.tolist()))
    print(" ".join(arr_str))

if __name__ == '__main__':
    N = int(input())
    input_line = input()
    print_ans(input_line)

Measured memory_bytes: 24916
#include <stdio.h>

int A[1000000],n;

int B_search(int key){
  int left = 0;
  int right = n;
  int mid;

  while(left < right){
    mid = (left + right) / 2;
    if(key == A[mid])return 1;
    if(key > A[mid])left = mid + 1;
    if(key < A[mid])right = mid;
  }
  return 0;
}

int main(){
  int i, q, key, sum = 0;

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

  scanf("%d", &q);
  for(i = 0; i < q; i++){
    scanf("%d", &key);
    if(B_search(key))sum++;
  }
  printf("%d\n", sum);
}



Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int N,M,Q,B,C,D;
int A[100010];
std::string S;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b>=c-a&&a<=c){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	x,y,z,k=map(int,input().split())
	ABC=np.array(read().split(),np.int64)
	A=ABC[:x]
	B=ABC[x:-z]
	C=ABC[-z:]
	AB=np.add.outer(A,B)
	AB=AB.ravel()
	AB.sort()
	AB=AB[-3000:]
	
	ans=np.add.outer(AB,C)
	ans=ans.ravel()
	ans.sort()
	
	for i in range(k):
		print(ans[-i-1])
	
if __name__ == '__main__':
	main()

Measured memory_bytes: 44112
#include<iostream>
#include<cstring>
#include<cstdlib>

using namespace std;
int main(){
  //char s[100100];
  int k;
  char *s = (char *)malloc(1000000);
  cin >> s;
  cin >> k;
  int len = strlen(s);
  for(int i = 0; i < len; i++){
    if(s[i] == 'a'){
      continue;
    }
    int diff = 'z' - s[i] + 1;
    if(diff <= k){
      s[i] = 'a';
      k -= diff;
    }
  }
  k %= 26;
  s[len-1] += k;
  if(s[len-1] > 'z'){
    s[len-1] = s[len-1] - 'z' + 'a' - 1;
  }
  cout << s << endl;
  free(s);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
     int p=0;

if (N<=599){p=8;}
else if(N<=799){p=7; }
else if(N<=999){p=6; }
else if(N<=1199){p=5; }
else if(N<=1399){p=4; }
else if(N<=1599){p=3; }
else if(N<=1799){p=2; }
else if(N<=1999){p=1; }
     
System.out.println(p);
}
    }


Measured memory_bytes: 27000
from collections import deque, Counter
N, M, K = list(map(int, input().split()))
F = [[] for _ in range(N)]
B = [[] for _ in range(N)]

for _ in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    F[a].append(b)
    F[b].append(a)

for _ in range(K):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    B[a].append(b)
    B[b].append(a)

# まだ探索済みでない頂点からdfs
# どの頂点がどの連結成分に属するかを管理
connect_group = {}

for i in range(N):
    if connect_group.get(i) is not None:
        continue
    stack = deque()
    stack.append(i)
    connect_group[i] = i
    p = -1    
    while len(stack):
        j = stack.pop()
        connect_group[j] = i
        for k in F[j]:
            if connect_group.get(k) is None:
                stack.append(k)
                connect_group[k] = i


ans = []
connect_len = Counter(connect_group.values())
for i in range(N):
    g = connect_group[i]
    l = connect_len[g]
    x = 0
    for j in set(F[i]).union(set(B[i])):
        if g == connect_group[j]:
            x += 1
    ans.append(str(l - x - 1))

print(' '.join(ans))

Measured memory_bytes: 116128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int s, w;
  cin >> s >> w;
  if(w>=s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  return 0;
}

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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    int H, W;
    vector<string> F;
    void input() {
        cin >> H >> W;
        H += 2;
        W += 2;
        F.resize(H);
        F[0] = string(W, '#');
        for (int i = 1; i < H - 1; i++) {
            string s; cin >> s;
            F[i] = string("#") + s + "#";
        }
        F[H - 1] = string(W, '#');
    }

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

    int sy, sx, sdir;
    void init() {
        string s = "^>v<";
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (find(s.begin(), s.end(), F[i][j]) != s.end()) {
                    sy = i;
                    sx = j;
                    sdir = find(s.begin(), s.end(), F[i][j]) - s.begin();
                    return;
                }
            }
        }
    }

    struct State {
        int y, x;
        int dir;
        State(int y, int x, int dir) :
            y(y), x(x), dir(dir) {}
    };

    const int INF = 1<<28;

    void solve() {
        init();
        bool V[H][W];
        bool D[H][W][4];
        memset(V, false, sizeof(V));
        memset(D, false, sizeof(D));
        queue<State> Q;
        Q.push(State(sy, sx, sdir));
        V[sy][sx] = true;
        D[sy][sx][sdir] = true;
        while (not Q.empty()) {
            State c = Q.front(); Q.pop();
            if (F[c.y][c.x] == 'G') {
                break;
            }
            for (int i = 0; i < 4; i++) {
                int ndir = (c.dir + 5 - i) % 4;
                int ny = c.y + dy[ndir];
                int nx = c.x + dx[ndir];
                if (F[ny][nx] == '#') continue;
                if (D[ny][nx][ndir]) {
                    cout << -1 << endl;
                    return;
                }
                V[ny][nx] = true;
                D[ny][nx][ndir] = true;
                Q.push(State(ny, nx, ndir));
                break;
            }
        }
        int ans = 0;
        for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) if (V[i][j]) ans++;
        //for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { cout << V[i][j] << " "; } cout << endl; }
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 1260
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007

llint memo[87];

llint ryuka(int x) {
	if (memo[x] != 0)return memo[x];
	if (x == 0)return 2;
	if (x == 1)return 1;
	memo[x] = ryuka(x - 1) + ryuka(x - 2);
	return memo[x];
}

int main() {
	int n;
	cin >> n;
	cout << ryuka(n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;

ll mod_pow(ll x,ll n,ll mod){
  if(n==0)return 1;
  ll res=mod_pow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}

ll rev[111111];
ll inr[111111];

void make_comb(void){
  rev[0]=1;
  for(ll i=1;i<111111;i++){
    rev[i]=rev[i-1]*i;
    rev[i]%=MOD;
  }
  for(ll i=0;i<111111;i++){
    inr[i]=mod_pow(rev[i],MOD-2,MOD);
  }
}

ll ncm(ll a,ll b){
  if(a == 0 && b == 0)return 1;
  if(a < b || a < 0)return 0;
  ll tmp = inr[a-b]* inr[b] % MOD;
  return tmp * rev[a] % MOD; 
}

int main(){
  ll n,m;
  cin >> n >> m;
  make_comb();
  vector<ll> v;
  for(ll i = 2;i <= m;i++){
    if( m % i )continue;
    ll cnt = 0;
    while(m%i==0){
      m/=i;
      cnt++;
    }
    v.push_back(ncm(cnt+n-1,cnt));
  }
  ll ans=1;
  for(int i=0;i<v.size();i++){
    ans*=v[i];
    ans%=MOD;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1920
#include <chrono>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std::chrono;
using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define maxn 300001
#define M   1000000007
#define int long long
#define inf 1e18
#define ninf -1e17
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;


int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  float ans=0.0;
  ans=a[0];
  for(int i=1;i<n;i++){
    ans=(ans+a[i])/2;
  }
  cout<<ans;

}


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



int main(void) {

	int N, M, L, R, nit, l = 0, r = 100010;
	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		cin >> L >> R;
		l = max(l, L - 1);
		r = min(R, r);
	}

	nit = r - l;
	if (nit < 0) nit = 0;
	
	cout << nit << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int solve(long long x){
    int ans=0;
    while (x>0){
    	ans+=x%10;
    	x/=10;
    }
    return ans;
}
int main(){
    int k;
    cin>>k;
    ll n=0,m,y;
    int x;
    for(int i=0;i<k;i++){
        n++;
        m=n;
        for(int d=0;d<15;d++){
            if (pow(10, d)>n) break;
            x=(ll)(n/pow(10, d))%10;
            y=(ll)(n/pow(10, d))-x;
            for (int s=1;s<=10;s++){
                if (x>=s) continue;
                if (1.0f*((ll)((y+s)*pow(10,d))-1)/solve((ll)((y+s)*pow(10, d))-1)<1.0f*m/solve(m)){
                    m=(ll)((y+s)*pow(10,d))-1;
                }
            }
        }
        n=m;
        cout<<n<<'\n';
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
const int mod = 1e9+7;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

long long int kaijyo(long long n){
    if(n==1) return 1;
    else return ((n % mod) * (kaijyo(n-1)%mod)) % mod;
}

int main()
{
    long long int n,m;cin >> n >> m;

    if(n==m){
        p((kaijyo(n)*kaijyo(m)*2)%mod)
    } else if(n==m+1 || m==n+1) {
        p((kaijyo(n)*kaijyo(m))%mod)
    } else {
        p(0)
    }
}

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

short table[1000][1000];



int main(){

    int c,n,ans=0,N,count=0;
    char cha;

    cin >> c >> n;

    N = n-1;

    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
          cin >> cha;
          table[i][j] = (cha=='0') ? 0 : 1;
      }
    }

    for(int i=0; i<n/2; i++){
      for(int j=0; j<n/2; j++){
          /*int tmp = (table[i][j] + table[i][N-j] + table[N-i][j] + table[N-i][N-j]);
          cout << tmp << endl;*/
          if( (table[i][j] + table[i][N-j] + table[N-i][j] + table[N-i][N-j]) % 4 != 0){
            count++;
          }
      }
    }

    if(count==0){
      ans++;
    }

    int d,w,h;

    while(--c){

      bool beforeok;

      cin >> d;

      if(d!=0){

        for(int i=0;i<d;i++){
          cin >> w >> h;
          w--;
          h--;
          /*cout << w*N+h << endl;
          cout << w*N+(N-h) << endl;
          cout << (N-w)*N+h << endl;
          cout << (N-w)*N+(N-h) << endl;*/
          /*cout << table[w][h] << endl;
          cout << table[w][N-h] << endl;
          cout << table[N-w][h] << endl;
          cout << table[N-w][N-h] << endl;    */
          //cout << (table[w][h] + table[w][N-h] + table[N-w][h] + table[N-w][N-h]) % 4 << endl;
          if( (table[w][h] + table[w][N-h] + table[N-w][h] + table[N-w][N-h]) % 4 != 0){
            beforeok = false;
          }else{
            beforeok = true;
          }
          table[w][h] = (table[w][h] == 0) ? 1 : 0;

          if( (table[w][h] + table[w][N-h] + table[N-w][h] + table[N-w][N-h]) % 4 != 0){
            if(beforeok){
              count++;
            }
          }else{
            count--;
          }

        }


      }

      //cout << "count = " << count << endl;

      if(count==0){
        //cout << "ok" << endl;
        ans++;
      }

      /*for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cout << table[i][j];
        }
        cout << endl;
      }*/

    }

    cout << ans << endl;





    return 0;
}

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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	cout << 3 * n * n;
	

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    string S;
    cin >> S;
    int N = S.length();
    int ans = 0;
    REP(i, N / 2){
        if(S[i] != S[N - 1 - i]) ans++;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; 
	cin >> N; 
	int A[200010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; 
	}
	int k = N - 1; 
	while(k >= 0){
		cout << A[k] << " "; 
		k -= 2; 
	}
	k = N % 2; 
	while(k < N){
		cout << A[k] << " "; 
		k += 2;
	}
	cout << endl; 
}

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

typedef pair<int, int> ii;

vector<int> AdjList[200005];
int dist[200005];
int dist2[200005];
int ans[200005];

int dp[200005][4];
int fc[200005];

int dist3Cnt[200005];
int p[200005];

ii dist3Cnt2[200005];

int dfs(int u, int k){
    if(k < 0){return 0;}
    if(dp[u][k] != -1){return dp[u][k];}
    if(k == 0){return dp[u][k] = 1;}

    dp[u][k] = 0;
    for(int v: AdjList[u]){
        if(v != p[u]){
            //printf("u=%d v=%d k=%d\n", u, v, k-1);
            dp[u][k] += dfs(v, k-1);
        }
    }

    //printf("dp[%d][%d]=%d\n", u, k, dp[u][k]);
    return dp[u][k];
}

void dfs2(int u, int p2 = -1, int fc2 = -1){
    fc[u] = fc2;
    p[u] = p2;
    //printf("dfs2: %d %d %d\n", u, p, fc2);
    for(int v: AdjList[u]){
        if(v != p2){
            //printf("u=%d v=%d\n", u, v);
            int fc3 = (fc2 == -1)?v:fc2;
            dfs2(v, u, fc3);
        }
    }
}

int main(){
    int N;
    scanf("%d", &N);
    for(int i = 1; i < N; i ++){
        int a, b;
        scanf("%d%d", &a, &b);
        AdjList[a].push_back(b);
        AdjList[b].push_back(a);
    }

    memset(dist, -1, sizeof(dist));
    queue<int> q;
    q.push(1);
    dist[1] = 0;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v: AdjList[u]){
            if(dist[v] == -1){
                dist[v] = dist[u]+1;
                q.push(v);
            }
        }
    }

    int cnt0 = 0;
    int cnt1 = 0;
    for(int i = 1; i <= N; i ++){
        cnt0 += (dist[i]%2 == 0);
        cnt1 += (dist[i]%2 == 1);
    }

    if(cnt0 <= N/3){
        int cnt3 = 3;
        int cnt1 = 1;
        for(int i = 1; i <= N; i ++){
            if(dist[i]%2 == 0){
                ans[i] = cnt3;
                cnt3 += 3;
            }else if(dist[i]%2 == 1){
                ans[i] = cnt1;
                cnt1 ++;
                if(cnt1%3 == 0 && cnt1 <= 3*cnt0){cnt1++;}
            }
        }
    }else if(cnt1 <= N/3){
        int cnt3 = 3;
        int cnt1 = 1;
        for(int i = 1; i <= N; i ++){
            if(dist[i]%2 == 1){
                ans[i] = cnt3;
                cnt3 += 3;
            }else if(dist[i]%2 == 0){
                ans[i] = cnt1;
                cnt1 ++;
                if(cnt1%3 == 0 && cnt1 <= 3*(N-cnt0)){cnt1++;}
            }
        }
    }else{
        int cnt1 = 1;
        int cnt2 = 2;
        int cnt3 = 3;
        for(int i = 1; i <= N; i ++){
            if(dist[i]%2 == 1){
                if(cnt1 <= N){
                    ans[i] = cnt1;
                    cnt1 += 3;
                }else{
                    ans[i] = cnt3;
                    cnt3 += 3;
                }
            }else if(dist[i]%2 == 0){
                if(cnt2 <= N){
                    ans[i] = cnt2;
                    cnt2 += 3;
                }else{
                    ans[i] = cnt3;
                    cnt3 += 3;
                }
            }
        }
    }

    for(int i = 1; i <= N; i ++){
        printf("%d ", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 17012
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push
#define fi first
#define se second
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) x.begin(), x.end()
#define endl '\n'
typedef long long int unsigned lliu;
typedef long long int lli;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

bool miOrdenMamador(const pi &a, const pi &b){
	return a.first < b.first || (a.first==b.first && a.second > b.second);
}

int main(){__
	int n, m;
	lli suma=0;
	cin>>n>>m;
	vpi v(n);
	forn(i, n){
		cin>>v[i].first>>v[i].second;
	}
	sort(all(v), miOrdenMamador);
	int j=1;
	int i=0;
	priority_queue<int> pq;
	while(j<=m){
		while(i<n && v[i].first<=j){
			pq.push(v[i].second);
			i++;
		}
		if(!pq.empty()){
			suma+=pq.top();
			pq.pop();
		}
		j++;
	}
	cout<<suma<<endl;

}

Measured memory_bytes: 1660
package main

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

func main() {
	read := bufio.NewReader(os.Stdin)
	write := bufio.NewWriter(os.Stdout)
	defer write.Flush()
	var l, r, d int
	fmt.Fscan(read, &l, &r, &d)
	sum := 0
	for i := l; i <= r; i++ {
		if i%d == 0 {
			sum++
		}
	}
	fmt.Fprintln(write, sum)
}

Measured memory_bytes: 1844
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I] * (N * 2)
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()

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

int main(void){
  string s;
  int n=1000;
  while(n--){
    cin>>s;
    bool ans = true;
    for(int i=0;i<s.size()-1;i++){
      if((s[i]-'A')/3 == (s[i+1]-'A')/3 && abs(s[i]-s[i+1])==1){
	continue;
      }
      if(abs(s[i]-s[i+1])==3)continue;
      ans=false;
      break;
    }
    if(ans)cout<<s<<endl;
  }
}

Measured memory_bytes: 1172
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long long int n=0;
	long long int ans=1;
	cin>>n;
	long long int N=n;
	if((n%2)==0){
		N=2;
	}
	for(int i=3;i<=sqrt(n);i+=2){
		if((n%i)==0){
			N=i;
		}
	}
	if(N<(n/N)){
		N=n/N;
	}
	int i=2;
	for(;;i++){
		ans*=10;
			if(N<ans){
				break;
			}
	}
	cout<<i-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){

	long long l,i=0,in[2];
	while(std::cin >> l){
		in[i]=l;
		i++;
		if(i>=2)break;
	}

	long int wh = in[0]*in[1];

	long int out = (wh+(2-1))/2;

	if(in[0] == 1 || in[1] == 1)out = 1;
	std::cout << out <<std::endl;
	return 0;
}



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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,t;cin >> n >> t;
	vector<ll> a(n);
	rep(i,n) cin >> a.at(i);
	ll min=1000000000,max=0,ans=0;
	rep(i,n){
		if(a.at(i)-min>max) max=a.at(i)-min;
		if(a.at(i)<min) min=a.at(i);
	}
	min=1000000000;
	rep(i,n){
		if(a.at(i)-min==max) ans++;
		if(a.at(i)<min) min=a.at(i);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1152
S = input()
mid = len(S)//2 + 1
first = S[0:mid-1]
last = S[mid:]
first_ = ''.join(list(reversed(first))) 
last_ = ''.join(list(reversed(last))) 
a = ((first_ == first) and (last == last_) and (first == last_))
if a:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;
// Not for Rating """"""""""I'm in Love with Experience :)""""""""""""""""""
void solve()
{
    ll K,X;cin>>K>>X;
  	if(K*500>=X)cout<<"Yes";
  	else cout<<"No";
}
int main(void)
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int T=1;while(T--){solve();}return 0;
}/*Solved By:- RITIK AGARWAL*/

Measured memory_bytes: 3676
#include <stdio.h>
#define C 4
#define D 7

int main(void)
{
	int N,i,j,NUM,judge;
	
	scanf("%d", &N);
	
	judge = 0;
	
	for(i = 0; i < 100; i++)
	{
		for(j = 0; j < 100; j++)
		{
			NUM = i*C + j*D;
			
			if(NUM == N){
				printf("Yes");
				judge = 1;
				goto loopend;
			}
		}
	}
	
	loopend:
	if(judge != 1){
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128