akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            a.add(ni());
        }
        Collections.sort(a, Comparator.reverseOrder());
        Deque<Integer> aq = new ArrayDeque<>();
        for (int i = 0; i < a.size(); i++) {
            aq.addLast(a.get(i));
        }
        PriorityQueue<ArrayList<Integer>> que = new PriorityQueue<>((x,y)->y.get(0).compareTo(x.get(0)));
        int first = aq.removeFirst();
        que.add(new ArrayList<>(Arrays.asList(first, first,first)));
        long ans = 0;
        while(aq.size()>0){
            int friendly = aq.removeFirst();
            var t = que.poll();
            ans += t.get(0);
            int nei1 = t.get(1);
            int nei2 = t.get(2);
            var nextTriplet1 = new ArrayList<Integer>(Arrays.asList(Math.min(nei1,friendly), friendly,nei1));
            var nextTriplet2 = new ArrayList<Integer>(Arrays.asList(Math.min(nei2,friendly), friendly,nei2));
            que.add(nextTriplet1);
            que.add(nextTriplet2);
        }
        out.println(ans);
    }

    final int mod = 1000000007;
    int mul(int x, int y){
        return (int)((x * 1L * y) % mod);
    }
    int add(int x, int y) {
        x += y;
        return x >= mod ? (x - mod) : x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        return x >= mod ? (x - mod) : x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

using namespace std;

class UnionFind {
 public:
  explicit UnionFind(size_t n) {
    par_.resize(n);
    rank_.resize(n);
    for (size_t i = 0; i < n; i++) {
      par_[i] = i;
    }
  }

  int Find(int x) {
    if (par_[x] == x) {
      return x;
    }
    par_[x] = Find(par_[x]);
    return par_[x];
  }

  bool Same(int x, int y) { return Find(x) == Find(y); }

  void Unite(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x == y) {
      return;
    }

    if (rank_[x] < rank_[y]) {
      par_[x] = y;
    } else {
      par_[y] = x;
      if (rank_[x] == rank_[y]) rank_[x]++;
    }
  }

 private:
  std::vector<int> par_;
  std::vector<int> rank_;
};

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

  int n, q;
  cin >> n >> q;
  UnionFind u(n);

  for (int i = 0; i < q; i++) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) {
      u.Unite(x, y);
    } else {
      if (u.Same(x, y)) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    }
  }
  return 0;
}



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  string s;
  cin >> s;
  sort(ALL(s));
  char c = 'a';
  REP(i,s.size()){
    if(s[i] == c){
      c++;
    }
  }
  if(c <= 'z')cout << c << endl;
  else cout << "None" << endl;




  

  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstdlib>

using namespace std;

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int h,w;
    while (1){
        scanf("%d %d",&h,&w);
        if(h==0 && w==0){
            break;
        }else{
            for (int i=0; i<h; i++){
                for (int j=0; j<w; j++){
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
}


Measured memory_bytes: 2096
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-result"

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef long long unsigned int ull;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define REPD(i, n) for (int i = 0, i##_len = (n); i < i##_len; i--)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1000000007;

void Main()
{
    int N;
    std::cin >> N;
    std::vector<int> vec(N);
    for (auto &v : vec)
    {
        std::cin >> v;
    }

    int cnt = 0;
    bool flag = true;
    while (flag)
    {
        for (auto &v : vec)
        {
            if (v == 0 || v % 2 == 1)
            {
                flag = false;
                break;
            }
            v /= 2;
        }
        if (flag)
            cnt++;
    }

    cout << cnt << endl;
}

int main()
{
    std::ios::sync_with_stdio(false); // printf/scanf を使わない
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15); // 浮動小数点数を小数点表記

    Main();

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

typedef long long ll;

int toN(char c) {
  switch(c) {
    case 'R':
    return 0;
    case 'G':
    return 1;
    case 'B':
    return 2;
  }
}

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;

  int sum[4000][3] = {0};

  sum[0][toN(s[0])] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      sum[i][j] = sum[i-1][j];
    }
    sum[i][toN(s[i])]++;
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      if (s[i] == s[j]) continue;
      int d = j - i;
      int q = 3 - toN(s[i]) - toN(s[j]);
      
      int l = j + d - 1;
      if (l >= n) l = n-1;
      ans += sum[l][q] - sum[j][q];
      if (j+d < n) {
        ans += sum[n-1][q] - sum[j+d][q];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>

#define rep(i,n) for(int i = 0; i < n; i++)
#define rrep(i,n) for(int i = n - 1; i >= 0; i--)
#define REP(i,k,n) for(int i = k; i < n; i++)

#define vi vector<int>
#define pb push_back
using namespace std;

int main(){
    int n,r,p,c;
    vi v(51,0);
    vi t(51,0);
    while(cin >> n >> r,n != 0) {
        rep(i,n) v[i] = n - i;
        rep(i,r){
            cin >> p >> c;
            rep(j,c) t[j] = v[p - 1 + j];
            rrep(j,p) v[j + c - 1] = v[j - 1];
            rep(j,c) v[j] = t[j];
        }
        cout << v[0] << endl;
    }
    return 0;

}



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

int main(){
	
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		int f=0;
		if(i%3==0)f=1;
		for(int x=i;x;x/=10)if(x%10==3)f=1;
		if(f)cout<<" "<<i;
	}
	
	cout<<endl;
	
	return 0;
}


Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define INF (1<<21)

struct NODE{
	int to,cost,flag;
	NODE(int to,int cost,int flag) : to(to) , cost(cost) , flag(flag) {};
};
bool operator < (const NODE &a,const NODE &b){
	if(a.cost != b.cost) return a.cost > b.cost;
	else return a.flag > b.flag;
}
int main(){
	int n,m,s,t;
	while(cin >> n && n){
		cin >> s >> t >> m;
		s--,t--;
		vector<int> v[n];
		vector< pair<int,int> > e[n];
		for(int i = 0 ; i < m ; i++){
			int a,b; cin >> a >> b;
			a--,b--;
			v[a].push_back(b);
			e[b].push_back(make_pair(a,i));
		}
		bool memo[2][1000]={0};
		priority_queue<NODE> Q;
		Q.push(NODE(s,0,0));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if(memo[!!q.flag][q.to]) continue;
			else memo[!!q.flag][q.to] = true;
			if(q.to == t){
				cout << q.cost << " " << q.flag << endl;
				break;
			}
			for(int i = 0 ; i < v[q.to].size() ; i++) Q.push(NODE(v[q.to][i],q.cost+1,q.flag));
			if(!q.flag) for(int i = 0 ; i < e[q.to].size() ; i++) Q.push(NODE(e[q.to][i].first,q.cost+1,e[q.to][i].second+1));
		}
	}
}

Measured memory_bytes: 1248
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int D = scan.nextInt();
        if (C < A) {
            int t1 = A;
            int t2 = B;
            A = C;
            B = D;
            C = t1;
            D = t2;
        }
        if (B <= C) {
            System.out.println(0);
            return;
        }
        List<Integer> data = new ArrayList<Integer>();
        data.add(A);
        data.add(B);
        data.add(C);
        data.add(D);
        data.sort(Comparator.naturalOrder());
        int answer = data.get(2)-data.get(1);
        System.out.println(answer);
    }
}


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

int N, K;
string S;

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

  char k = S.at(K-1);

  if( k == 'A'){
    S.at(K-1) = 'a';
  }else if( k == 'B'){
    S.at(K-1) = 'b';
  }else if( k == 'C'){
    S.at(K-1) = 'c';
  }
  
  cout << S << endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 079_abc_c / Link: https://abc079.contest.atcoder.jp/tasks/abc079_c?lang=en  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VI a(4);
	FOR(i, 0, 4) {
		a[i] = N / (int)pow(10, 3 - i);
		a[i] %= 10;
	}
	string OP = "+-";
	FOR(op, 0, 1<<3) {
		int ret =a[0];
		FOR(i, 1, 4) {
			if (op&(1 << (i - 1))) {
				ret -= a[i];
			}
			else ret += a[i];
		}
		if (ret == 7) {
			cout << a[0];
			FOR(i, 1, 4) {
				cout << OP[(op&(1 << (i - 1))) ? 1 : 0];
				cout << a[i];
			}
			cout << "=7" << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  S = '#' + S;
  if(C < D || C < B){
    for(int i=A; i<=C; i++){
      if(S[i] == '#' && S[i+1] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
    for(int i=B; i<=D; i++){
      if(S[i] == '#' && S[i+1] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
  }else{
    for(int i=A; i<=C; i++){
      if(S[i] == '#' && S[i+1] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
    bool can = false;
    for(int i=B; i<=D; i++){
      if(S[i-1]!='#' && S[i]!='#' && S[i+1]!='#'){
        can = true;
      }
    }
    if(!can){
      cout << "No" << endl;
      return 0;
    }
  }
  cout<< "Yes" << endl;
  return 0;
}


Measured memory_bytes: 772
N = int(input())
W = [int(i) for i in input().split()] 
a = 0
b = sum(W)
S1 = 0
S2 = b
for i in range(N):
  S1 += W[i]
  S2 -= W[i]
  a = abs(S1-S2)
  if a < b:
    b = a
print(b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,m,a[51][51],ans=0;
int u[2501],v[2501],f[51];
inline int find(int p)
{
    if(f[p]==p)
        return p;
    return f[p]=find(f[p]);
}//并查集
int main(){
	cin>>n>>m;
	for(register int i=1;i<=m;i++){
		cin>>u[i]>>v[i];
		a[u[i]][v[i]]=1;
		a[v[i]][u[i]]=1;
	}
	for(register int i=1;i<=m;i++){
		a[u[i]][v[i]]=0;
		a[v[i]][u[i]]=0;
		for(register int j=1;j<=n;j++)f[j]=j;
		for(int k=1;k<=n;k++)
            {
                for(int l=k+1;l<=n;l++)
               if(a[k][l]){
                        f[find(l)]=find(k);
                }
            }
//		for(register int j=1;j<=n;j++)cout<<f[j]<<" ";
//		cout<<endl;
		for(register int j=2;j<=n;j++)
		if(find(j)!=find(j-1)){
//			cout<<i<<" "<<j<<":"<<f[j]<<" "<<j-1<<":"<<f[j-1]<<endl;
			ans++;
			break;
		}
		a[u[i]][v[i]]=1;
		a[v[i]][u[i]]=1;
	}
	cout<<ans<<endl;
	return 0;
}

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

namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      int N=int.Parse(Console.ReadLine());
int[][] arr = new int[N][];
      int ans=0;
      int tmp=0;
      for(int i=0;i<N;i++){
      arr[i]=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

      }
      for(int j=0;j<N;j++){
        if(arr[j][0]==arr[j][1]){
          tmp++;
          if(tmp>=3){
            ans=tmp;
        }
        }else{
          tmp=0;
        }
        
      }
      if(ans>=3){
        Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");
      }
    }
    
  }

}

Measured memory_bytes: 28260
#include <bits/stdc++.h>
using namespace std;
#define fx(x) fixed<<setprecision(x)
//give up
int main(){
	int a,b,x,y; cin>>a>>b>>x>>y;
	if(x+x==a&&y+y==b) cout<<fx(6)<<double(a)*double(b)/2<<" "<<1<<endl;
	else cout<<fx(6)<<double(a)*double(b)/2<<" "<<0<<endl;
}

Measured memory_bytes: 3760
'use strict';
var Main = function(stdin) {
  var line = stdin.split('\n');
  var param = line[0].split(' ').map(Number);
  var result = (function(height,width) {
    return [
    	height * width
    	,(height + width) * 2
    ].join(' ');
  }(
    param[0]
    ,param[1]
  ));
  console.log(result);
};

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7384
n, k, c = map(int, input().split())
s = input()
work = [1]*n

rest = 0
for i in range(n):
    if rest:
        rest -= 1
        work[i] = 0
        continue

    if s[i] == 'x':
        work[i] = 0
    elif s[i] == 'o':
        rest = c


rest = 0
for i in reversed(range(n)):
    if rest:
        rest -= 1
        work[i] = 0
        continue
    if s[i] == 'o':
        rest = c


if k < sum(work):
    print()
else:
    for idx, bl in enumerate(work):
        if bl:
            print(idx+1)


Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(true){
    int n,x;
    cin>>n>>x;
    if(n==0 and x==0)return 0;
    int cnt=0;
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            for(int k=j+1; k<=n; k++){
                if(i+j+k==x)cnt++;
            }
        }
    }
    cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <cstdio>
#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <complex>

using namespace std;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
#define PB push_back
#define MP make_pair
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef struct{
	int to, dist, cost;
}edge;

vector<vector<edge> > g;
vector<bool> visit;

int main(){
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0)return 0;
		g.clear();
		g=vector<vector<edge> >(n);
		visit=vector<bool>(n,false);
		REP(i,m){
			int u,v,d,c;
			scanf("%d%d%d%d", &u,&v,&d,&c);
			u--,v--;
			edge e1 = {v,d,c};
			edge e2 = {u,d,c};
			g[u].PB(e1);
			g[v].PB(e2);
		}
		priority_queue<TIII, vector<TIII>, greater<TIII> > q;
		q.push(MT(0,0,0));
		int ret = 0;
		while(!q.empty()){
			TIII tmp = q.top();
			q.pop();
			if(visit[tmp.T3])continue;
			ret += tmp.T2;
			visit[tmp.T3] = true;
			n--;
			if(n==0)break;
			REP(i,g[tmp.T3].size())q.push(MT(tmp.T1+g[tmp.T3][i].dist, g[tmp.T3][i].cost, g[tmp.T3][i].to));
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 2924
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val H = input.nextInt()
    val N = input.nextInt()
    var sumA = 0
    
    for (i in 1..N) {
      sumA += input.nextInt()
    }
    
    if (sumA >= H) {
      println("Yes")
    } else {
      println("No")
    }
  }
}

Measured memory_bytes: 59544
using System;

class main{
	static void Main(){
		string[] str = Console.ReadLine().Trim().Split(' ');
		int a = int.Parse(str[0]);
		int b = int.Parse(str[1]);
		int c = int.Parse(str[2]);
		int d = int.Parse(str[3]);
		if(Math.Abs(a - c) <= d){
			Console.WriteLine("Yes");
		}else if(Math.Abs(a - b) <= d && Math.Abs(b - c) <= d){
			Console.WriteLine("Yes");
		}else{
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 13140
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>
#include <fstream>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, a, b; cin >> n >> a >> b;
	string s; cin >> s;
	int q = 0;
	int f = 0;
	for (char c : s)
	{
		if (c == 'a' && q < a + b)
		{
			cout << "Yes" << endl;
			++q;
		}
		else if (c == 'b' && q < a + b && f < b)
		{
			cout << "Yes" << endl;
			++q;
			++f;
		}
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 3760
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(){
  int i,j,n,m,ans;
  string str;
  vector<int> v;
  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> m;
    cin >> str;

    v.push_back(0);
    v.push_back(0);
    for(i=2;i<m;i++){
      if(str[i] == 'I' && str[i-1] == 'O' && str[i-2] == 'I') v.push_back(v[i-2]+1);
      else v.push_back(0);
    }

    ans = 0;
    for(i=2;i<m;i++){
      if(v[i] >= n) ans++;
    }

    cout << ans << endl;
    v.clear();
  }
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> x(n);
    rep(i,n) cin >> a[i];
    rep(i,n) x[i] = a[i];
    sort(x.rbegin(),x.rend());
    rep(i,n){
        if(x[0] == a[i]){
            cout << x[1] << endl;
        } else {
            cout << x[0] << endl;
        }
    }

 
    return 0;
}

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

int main() {
  char a , b , c , d , e , f , g , h , i;
  cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
      cout << 'A' << h << 'C' << endl;
    
    

  // ここにプログラムを追記
  
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int room[4][3][10]={0};
    int n,b,f,r,v;
    int i,j,k;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d%d%d",&b,&f,&r,&v);
        room[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<=3;i++){
        for(j=0;j<=2;j++){
            for(k=0;k<=9;k++){
                printf(" %d",room[i][j][k]);
            }printf("\n");
        }if(i!=3){
            printf("####################\n");
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<functional>

using namespace std;

int main() {
	int n[3], ans = 0;
	for (int i = 0; i < 3; i++) { cin >> n[i]; }
	for (int i = n[0]; i <= n[1]; i += n[0]) {
		ans++;
	}
	if (ans >= n[2])cout << n[2] << endl;
	else { cout << ans << endl;; }
	return 0;
}

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


public class Main {


	public static void main(String[] args) throws Exception{
		BufferedReader  jk =  new BufferedReader(new InputStreamReader( System.in))  ; 
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)) ; 
		StringTokenizer ana = new StringTokenizer(jk.readLine()) ;
		int n = Integer.parseInt(ana.nextToken()) ; 
		int k = Integer.parseInt(ana.nextToken()) ;
		int t[]= new int[n] ; 
		ana = new StringTokenizer(jk.readLine()) ;
		for(int i=0 ; i<n ;i++)
		{
			t[i]= Integer.parseInt(ana.nextToken()) ; 
		}
		int cost[]=new int[n] ; 
		cost[0]=0 ; cost[1]= Math.abs(t[1]-t[0]) ; 
		for(int i=2 ;i<n ;i++)
		{
			int res = -1 ; 
			for(int j=Integer.max(0, i-k) ;j<i ;j++)
			{
				int y =cost[j]+Math.abs(t[i]-t[j]) ; 
				if(res==-1) res =  y  ;
				else res= Integer.min(res,y) ;
			}
			cost[i] =res  ;
		}
		out.println(cost[n-1]);
		














		out.flush();
	}
}



Measured memory_bytes: 32904
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;


int main(){
	ll a,b;
	cin>>a>>b;
    bool p=true;
    ll ans=0;
    rep(i,a,b+1){
        string t=to_string(i);
        rep(i,0,2){
            if(t[i]!=t[4-i]) p=false;
        }
        if(p)ans++;
        p=true;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long n,ans=1;
    cin >> n;
    long a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i=0;i<n;i++){
        if(ans<=long(1e18)/a[i]) ans *= a[i];
        else{
            cout << -1 << endl;
            return 0;
        } 
    } 
    cout << ans << endl;
}


Measured memory_bytes: 4388
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  int H,W,cnt=0;
  cin>>H>>W;
  char A[H][W];
  
  REP(i,H){
    REP(j,W){
      cin>>A[i][j];
      if(A[i][j]=='#') cnt++;
    }
  }
  
  if(cnt!=H+W-1) CAN=false;
  
  if(CAN) co("Possible");
  else co("Impossible");
  return 0;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    ostr << p.first << " " << p.second;
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll a, b = 0;
    cin >> a >> b;
    if(a-b*2 > 0) cout << a-b*2 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
s=input()
if (s[1]==s[0] and s[2]==s[3] and s[0]!=s[2]):
  print('Yes')
elif (s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]):
  print('Yes')
elif (s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]):
  print('Yes')
else:
  print('No')
  

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

int main()
{
	char c;
	cin >> c;
	switch(c)
	{
	case 'A':
		cout << "T";
		break;
	case 'C':
		cout << "G";
		break;
	case 'G':
		cout << "C";
		break;
	case 'T':
		cout << "A";
		break;
	}
	cout << "\n";
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
    int r,d,xtwo;
    scanf("%d %d %d",&r,&d,&xtwo);
    long x[11];
    x[0] = xtwo;
    for (int i = 1; i < 11; i++)    {
        x[i] = x[i-1] * r - d;
        printf("%ld\n",x[i]);
    }
    return 0;
}


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

int x[200], n;
int main() {
	//freopen("in.txt", "r", stdin);
	cin >> n; n *= 2;
	for (int i = 0; i < n; i ++) cin >> x[i];
	sort(x, x + n);
	int res = 0;
	for (int i = n % 2; i < n; i += 2) res += x[i];
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define DIVCEIL(A,B) ((A+(B-1))/B)
using namespace std;


void solve(long long N){
    long long a=1ll;
    long long ans=LONG_LONG_MAX;
    while(a*a<=N){
        if(N%a == 0){
            auto b=N/a;
            ans = min(ans, (long long)to_string(b).length());
        }
        a++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))

static const char INC = 0;
static const char DEC = 1;
static const char NONE = -1;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //freopen("debug.txt", "w", stderr);

    cin.tie(0);
    ios::sync_with_stdio(false);

    long N;
    ll A, prevA;
    ll ans = 0;
    char isInc = -1;

    cin >> N;

    if (N == 1) {
        cout << 1 << endl;

        return 0;
    }

    long i;

    cin >> prevA;
    for (i = 1; i < N; i++) {
        cin >> A;

        if (isInc == NONE) {
            if (A < prevA) isInc = DEC;
            else if (prevA < A) isInc = INC;
        } else {
            if (isInc == DEC) {
                if (prevA < A) {
                    isInc = NONE;

                    ans++;
                }
            } else if (isInc == INC) {
                if (A < prevA) {
                    isInc = NONE;

                    ans++;
                }
            }
        }

        prevA = A;
    }

    ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月07日 星期日 22时32分53秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

int dp[2005][20005];
int ans[3],cost[3]={1,5,10};

void fuck(int i,int x){
	if(!x) return ;
	ans[dp[i][x]]++;
	fuck(i-1,x-cost[dp[i][x]]);
}

void solve(){

	mem(dp,-1);
	int n,Y;
	scanf("%d%d",&n,&Y);

	dp[0][0]=10000;
	Y/=1000;

	for(int i=1;i<=n;i++){
		for(int j=1;j<=Y;j++){
			if(j>=1 && dp[i-1][j-1]!=-1) dp[i][j]=0;
			else if(j>=5 && dp[i-1][j-5]!=-1) dp[i][j]=1;
			else if(j>=10 && dp[i-1][j-10]!=-1) dp[i][j]=2;
		}
	}

	if(dp[n][Y]==-1){
		printf("-1 -1 -1\n");
		return ;
	}
	fuck(n,Y);
	printf("%d %d %d\n",ans[2],ans[1],ans[0]);
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 156928
#include<stdio.h>
int main(){
  int i,n,p[20],cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
    if(i<2)
      continue;
    if(p[i-1]<p[i] && p[i-1]>p[i-2])
      cnt++;
    else if(p[i-1]<p[i-2] && p[i-1]>p[i])
      cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const int N = 18;


void solve(int t)
{
	ll d, tt, s;
	cin >> d >> tt >> s;

	if (s * tt < d)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}



}


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





	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3644
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// 枝定義
struct Edge
{
	int	from;
	int	to;
	Edge(){}
	Edge(int a, int b): from(a), to(b){}
};

// dfs
int N, M;
int ans = 0;
vector<vector<int>>	G;
vector<bool>		isUsed;
void dfs(int from, int to)
{
	// 到達してないところがないか
	bool isFin = true;
	for (int j = 0; j < N; j++) {
		if (!isUsed[j]) {
			isFin = false;
			break;
		}
	}
	if (isFin) {
		ans++;
		return;
	}

	for (auto nextTo : G[to]) {
		if (from != nextTo) {
			if (!isUsed[nextTo]) {
				isUsed[nextTo] = true;
				dfs(to, nextTo);
				isUsed[nextTo] = false;
			}
		}
	}
}

// メイン
int main()
{
	cin >> N >> M;
	vector<Edge>	edgeList;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		edgeList.emplace_back(a, b);
	}
	G.resize(N);
	for (int j = 0; j < M; j++) {
		const auto &edgeOne = edgeList[j];
		G[edgeOne.from].emplace_back(edgeOne.to);
		G[edgeOne.to].emplace_back(edgeOne.from);
	}

	int startPos = 0;
	isUsed.clear();
	isUsed.resize(N, false);
	isUsed[startPos] = true;
	dfs(-1, startPos);

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


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

int main() { /* ここに書く */
  
  int X,N,q,P,M,ans,j;
  j = 0;
  ans = 0;
  
  cin >> X >> N;
  vector<bool>vec(101);
  
  for(int i = 0; i<N ; i++){
    
    cin >> q;
    vec.at(q) = true;
    
  }
  
  bool p,m;
  
  while(ans == 0){
    
    P = X + j;
    M = X - j;
    
    if(P < 101){
      
      p = vec.at(P);
      
      if(p == false){
        
      ans = P;
        
       
      }
    }
    
    else{
      ans = 101;
      
    }
    
    //cout << p << ' ' << P << ' ' << ans <<endl;
    
    if(M > 0){
      
      m = vec.at(M);
      
      if(m == false){
        
      ans = M;
        
      }
    }
    
    else{
      ans = 0;
      break;
    }
    
    //cout << m << ' ' << M << ' ' << ans << endl;
    
    j++;
    
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m; cin >> n >> m;
    vector<vi> G(n);
    rep(i, m){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    string res = "IMPOSSIBLE";
    for(auto& v : G[0]){
        for(auto& t : G[v]){
            if(t == n - 1){
                res = "POSSIBLE";
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 12016
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

ll n;
vector<char> ans;

int main() {
	cin >> n;
	while (n) {
		ans.pb((char)((n - 1) % 26 + 'a'));
		if (n % 26 == 0) n--;
		n /= 26;
	}
	for (auto it = ans.rbegin(); it != ans.rend(); ++it) {
		cout << *it;
	}
}

Measured memory_bytes: 3632
#include<stdio.h>

	int main(void){
	
		int n,i;
		scanf("%d",&n);
		int x[1000],y[1000],z[1000];
		
		for(i=0;i<n;i++){
			scanf("%d%d%d",&x[i],&y[i],&z[i]);
			x[i]=x[i]*x[i];
			y[i]=y[i]*y[i];
			z[i]=z[i]*z[i];
		}
		
		for(i=0;i<n;i++){
			if(x[i]==y[i]+z[i] || y[i]==x[i]+z[i] || z[i]==x[i]+y[i]){
				printf("YES\n");
			}else{
				printf("NO\n");
			}
		}
	
	return 0;
}

Measured memory_bytes: 588
#include <iostream>

int main()
{
	int K, S, c123 = 0, c112 = 0, c122 = 0, c111 = 0;
	std::cin >> K >> S;
	for (int x = 0; x <= K; x++)
	{
		if (x + 0 + 0 > S) break;
		if (x + K + K < S) continue;
		for (int y = 0; y < x; y++)
		{
			if (x + y + 0 > S) break;
			if (x + y + K < S) continue;
			for (int z = 0; z < y; z++)
			{
				if (x + y + z > S) break;
				if (x + y + z == S) c123++;
			}
		}
	}
	for (int x = 0; x <= K; x++)
	{
		if (x + x + 0 > S) break;
		if (x + x + K < S) continue;
		for (int z = 0; z < x; z++)
		{
			if (x + x + z > S) break;
			if (x + x + z == S) c112++;
		}
	}
	for (int x = 0; x <= K; x++)
	{
		if (x + 0 + 0 > S) break;
		if (x + K + K < S) continue;
		for (int z = 0; z < x; z++)
		{
			if (x + z + z > S) break;
			if (x + z + z == S) c122++;
		}
	}
	for (int x = 0; x <= K; x++)
	{
		if (x + x + x > S) break;
		if (x + x + x == S) c111++;
	}
	std::cout << c123 * 6 + c112 * 3 + c122 * 3 + c111 << std::endl;
	return 0;
}


Measured memory_bytes: 256
import math

n, k = map(int, input().split())
x, y, c = zip(*[map(int, input().split()) for _ in range(n)])
que = [(0, 0, 1000)]
res = 1e9
i = 0
while i < len(que):
    px, py, r = que[i]
    i += 1
    lb = [c[j] * math.hypot(max(abs(px - x[j]) - r, 0), max(abs(py - y[j]) - r, 0)) for j in range(n)]
    if res * (1 - 5e-7) > sorted(lb)[k - 1]:
        dis = [c[j] * math.hypot(px - x[j], py - y[j]) for j in range(n)]
        res = min(res, sorted(dis)[k - 1])
        for dx in (-0.5, 0.5):
            for dy in (-0.5, 0.5):
                que.append((px + dx * r, py + dy * r, r / 2))
print(res)

Measured memory_bytes: 5876
#include <algorithm>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int32_t main() {
  while (true) {
    uint32_t n, l;
    cin >> n >> l;
    if (n == 0 && l == 0)
      break;

    vector<uint32_t> nums;
    nums.push_back(n);

    for (uint32_t i = 0; i < 20; i++) {
      ostringstream os;
      os << setfill('0') << setw(l);
      os << n;
      string str = os.str();
      sort(str.begin(), str.end());
      uint32_t min_val = stoi(str);
      reverse(str.begin(), str.end());
      uint32_t max_val = stoi(str);
      n = max_val - min_val;
      nums.push_back(n);
    }

    for (uint32_t j = 0; j < nums.size(); j++) {
      for (uint32_t i = j + 1; i < nums.size(); i++) {
        if (nums[j] == nums[i]) {
          cout << j << " " << nums[i] << " " << i - j << endl;
          goto end;
        }
      }
    }

  end:
    continue;
  }

  return 0;
}

Measured memory_bytes: 3184
from math import gcd
from decimal import Decimal as dec 
a, b, c, d = map(dec,input().split())
if a % c ==0:
    c_explicit = b // c - a // c + 1
else:
    c_explicit = b // c - a // c 
if a % d ==0:
    d_explicit = b // d - a // d + 1
else:
    d_explicit = b // d - a // d 
e = gcd(int(c), int(d))
e = dec(e)
gcl = (c / e) * (d / e) * e
if a % gcl ==0:
    e_explicit = b // gcl - a // gcl + 1
else:
    e_explicit = b // gcl - a // gcl 
g = b - a + 1 - c_explicit - d_explicit + e_explicit
print(g)

Measured memory_bytes: 9904
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = 0x3f3f3f3f;

ll a[300001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("C.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    cout << a[n/2] - a[n/2-1];
}



Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int m = scan.nextInt();
			int[] dis = new int[n];
			for(int i = 0;i < n-1;i++){
				dis[i+1] = dis[i] + scan.nextInt();
			}
			long sum = 0;
			int now = 0;
			int a;
			for(int i = 0;i < m;i++){
				a = scan.nextInt();
				sum += dis[now+((a > 0)?a:0)] - dis[now+((a > 0)?0:a)];
				now += a;
			}
			System.out.println((sum>=100000)?sum%100000:sum);
		}
	}
}

Measured memory_bytes: 94644
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans=10000000;
	for(int i=1;i<n;i++){
		int j=n-i;
		int sum=0;
		int a=i,b=j;
		while(a!=0){
			sum=sum+a%10;
			a/=10;
		}
		while(b!=0){
			sum=sum+b%10;
			b/=10;
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#define MAX 1000000000
using namespace std;
typedef long long ll;
int main(){
  ll s,x,ex,about_sq;
  cin >> s;
  if(s<=MAX){
    cout << "0 0 "<<s<<" 0 0 1\n";
    return 0;
  }
  ll i;
  i = MAX;
  ll tmp;
  for(ll i=0;i<=MAX;i++){
    tmp = s+i;
    if(tmp%MAX==0){
      cout << "0 0 "<<MAX<<" 1 "<<i<<" "<<tmp/MAX<<endl;
      break;
    }
  }
}



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


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

	vector<int> d(n);
	rep(i,n) cin >> d[i];
	sort(d.begin(), d.end());
	int arc_first=d[n/2], abc_end=d[n/2-1];
	int cases = arc_first-abc_end;
	cout << cases << endl;


	return 0;

}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	long double a, b, c;
	cin >> a >> b >> c;
	long double eps = 1.0E-14;
	if (sqrt(a) + sqrt(b) + eps < sqrt(c))  cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}

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

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	cout << fixed << setprecision(9) << sqrt(a*a+b*b-2*a*b*cos(2*M_PI*11*(60*h+m)/720));
}

Measured memory_bytes: 4248
package main

import (
	"fmt"
	"math"
	// "strconv"
)

func main() {
	var A,B,H,M int
	fmt.Scan(&A,&B,&H,&M)

	s := float64(60 * H + M) / 2
	l := float64(6*M)
	angle := math.Abs(l - s)
	if angle > float64(180){
		angle = float64(360) - angle
	}

	lh := A
	sh := B
	if B > A{
		lh = B
		sh = A
	}

	cos := math.Cos((angle * math.Pi) /180)
	sin := math.Sin((angle * math.Pi) /180)
	a := float64(sh) * sin
	b := float64(lh) - float64(sh) * cos
	res := math.Sqrt(a*a + b*b)

	fmt.Println(res)
	
	// x := fmt.Sprintf("%g",res)
	// y, _ := strconv.ParseFloat(x, 64)
	// fmt.Println(y)

	
}


Measured memory_bytes: 1824
// Work.cpp : This file contains the 'main' function. Program execution begins and ends there.


/*
ID: your_id_here
LANG: C++
TASK: greed
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;


int main() {
	int a, b;
	cin >> a >> b; 

	cout << a * b;

	}



Measured memory_bytes: 3612
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long cnt = 0, i = 0, a, c, b, j, x, y, r, H, W;
	double z;
	cin >> a >> b;
	x = a / b;
	y = a%b;
	z = (double)a / b;
	printf("%ld %ld %1.5f\n", x, y, z);
}

Measured memory_bytes: 3156