akhauriyash/Code-Regression huggingface dataset:
//ツ単ツ渉δづ可嘉ーツつッツづ篠つ「ツつ「ツつセツつッツつセツつェ, ツ板?湘」ツ額ツつェintツづ可偲サツづ慊づァツづ按つ「ツ嘉つ能ツ青ォツつェツつ?づゥツづ個づ?陳債暗督つオツづ按つッツづェツづ篠づ按づァツづ按つ「
//ツ姪「ツ妥ィツ閉カツづ可渉堕つゥツづェツづ?つ「ツづゥツ「100ツ鳴?* 10ツ鳴慊」ツづ個湘ーツ個渉づ?づ? intツづ可偲サツづ慊づァツづ按つ「
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int main(){
  int n;
  ll sum[4002], num[4002];

  while(cin >> n, n){
    //ツ催?渉? ツ全ツ暗オツ板?湘」ツづ?
    fill(sum, sum + 4002, 0);

    //ツ全ツ暗オツづ慊つセツ禿シツ療債つウツづェツづ?つ「ツづ按つ「
    fill(num, num + 4002, -1);

    //ツ渉?氾板づ可湘ョツ陛アツづーツ禿シツ療?
    for(int i = 0; i < n; i++){
      ll m, a, b;
      cin >> m >> a >> b;

      //ツ板?湘」ツづーツ堕ォツつオツつアツづ?
      sum[m] += a * b;

      //ツ渉可づ淞づ?禿シツ療債つウツづェツつスツ偲青暗オツ氾板債?づ按づァツづ? ツ可スツ氾板姪堋づ可禿シツ療債つウツづェツつスツつゥツ記ツ可ッツつオツづ?つィツつュ
      if(num[m] == -1){
        num[m] = i;
      }
    }

    //ツ板?湘」ツつェ100ツ鳴慊暗按湘」ツづ個人ツづーツ療アツ仰督つキツづゥ
    //ツつアツづ個づ?つォ, ツ可スツ氾板姪堋づ可禿シツ療債つウツづェツつスツ人ツづ?つ?づゥツつゥツづ?つ「ツつ、ツ湘ョツ陛アツづ?暗ェツ渉渉づ英ush
    vector<P> ans;

    for(int i = 0; i < 4002; i++){
      if(1000000 <= sum[i]){
        ans.push_back(P(num[i], i));
      }
    }

    //ツ禿シツ療債渉?づ可陛?づ堕妥鳴つヲ
    sort(ans.begin(), ans.end());

    //ツ督堋つヲツ出ツ療?
    for(int i = 0; i < ans.size(); i++){
      cout << ans[i].second << endl;
    }

    //1ツ人ツづ?該ツ督鳴偲陳つェツつ「ツづ按つッツづェツづ晒A
    if(ans.size() == 0){
      cout << "NA\n";
    }
  }
}

Measured memory_bytes: 1292
import heapq
from collections import defaultdict

N, M = map(int, input().split())
salary = defaultdict(list)
for i in range(N):
    a, b = map(int, input().split())
    salary[a].append(-b)

sv = []
heapq.heapify(sv)
ans = 0
for i in range(1, M+1):
    for j in range(len(salary[i])):
        heapq.heappush(sv, salary[i][j])
    if(len(sv)):
        ans -= heapq.heappop(sv)
print(ans)

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

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

    int a;
    string ans="APPROVED";
    for (int i=0; i<n; i++) {
        cin >> a;
        if (a%2 == 0) {
            if (a%3 != 0 && a%5 != 0) ans = "DENIED";
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

long long x;

long long find(long long val){
	if(val == 0) return 0;
	else if(val < 0){
		for(long long i = 1; i * i * i * i * i <= -val; i++)
			if(i * i * i * i * i == -val) return -i;
	}else
		for(long long i = 1; i * i * i * i * i <= val; i++)
				if(i * i * i * i * i == val) return i;
	return LLONG_MAX;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x;
	long long res = LLONG_MAX, i = 0;
	while(res == LLONG_MAX){
		long long dif = -x + i * i * i * i * i, opp = find(dif);
		if(opp != LLONG_MAX) res = opp;
		i++;
	}
	cout << i - 1 << " " << res << "\n";
	return 0;
}

Measured memory_bytes: 3540
object Main{
    def main(args: Array[String]): Unit ={
        var in = scala.io.StdIn.readLine().split(" ").map(_.toInt)
        val a = in(0) / in(1)
        val b = in(0) - a * in(1)
        val c = in(0).toDouble / in(1)
        println(a + " " + b + " " +f"$c%.5f")
    }
}

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

using ll = long long;

const int INF = 1001001001;

int main(void){
  string s; cin >> s;
  if(s[0] == 'A' && s[1] == 'A' && s[2] == 'A') cout << "No" << endl;
  else if(s[0] == 'B' && s[1] == 'B' && s[2] == 'B') cout << "No" << endl;
  else cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#MLE注意！ not は使わず !=

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    import math
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = math.pi
    print(2*n*a)

if __name__ == '__main__':
    main()

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

int main(){
    int n, k;
    long sum = 0;
    std::cin >> n >> k;

    std::vector<int> h(n);
    for(auto i = 0; i < n; i++){
        std::cin >> h.at(i);
    }

    std::sort(h.begin(), h.end());
    for(int i = 0; i < n - k; i++){
        sum += h.at(i);
    }

    std::cout << sum << std::endl;

    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


int main(){
    
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    H = min(2 * Q, H);
    S = min(2 * H, S);
    D = min(2 * S, D);
    ll ans = 0;
    if(N % 2){
        N--;
        ans += S;
    }
    N /= 2;
    ans += N * D;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    string s,t;
    cin >> s >> t;
    string ts = t.substr(0, s.size());

    if ((s.size()+1)==t.size()&&ts==s) {
        print("Yes");
    } else {
        print("No");
    }
    return 0;
}


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

int main(){
	int x,y,sum=0;
  cin >> x >> y;
  if(x == 1 && y == 1) sum = 1000000;
  else{
    for(int i=0; i<2; i++){
    	if(x == 1) sum += 300000;
      if(x == 2) sum += 200000;
      if(x == 3) sum += 100000;
      x = y;
    }
    }
  cout << sum;
}


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

int n;
int g[101][101];
char c[101];
int visit[101];
int finish[101];
int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int v;
            cin >> v;
            g[u][v] = 1;
        }

    }

   stack<int> s;
    for (int l = 1; l <= n; ++l) {
        c[l] = 'w';

    }
    int time = 0;
    int start = 0;
    int v;
    while(true) {
        start++;
        if(start == n) break;
        if(c[start] == 'w') {
            time++;
            s.push(start);
            c[start] = 'g';
            visit[start] = time;
            while (s.size() != 0) {
                time++;
                v = s.top();
                int next = -1;
                for (int i = 1; i <= n ; ++i) {
                    if(i == v) {
                        continue;
                    }
                    if(g[v][i] && c[i] == 'w') {
                        next = i;
                        break;
                    }
                }
                if(next == -1) {
                    c[v] = 'b';
                    finish[v] = time;
                    s.pop();
                } else {
                    c[next] = 'g';
                    visit[next] = time;
                    s.push(next);
                }
            }
        }
    }

    for (int m = 1; m <= n; ++m) {
        cout << m << " " << visit[m ] << " " << finish[m] << endl;

    }



    return 0;
}



Measured memory_bytes: 3112
#include <stdio.h>
#include <math.h>

int main(void){
  int n,i,j,k,x[10000],ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  for(i=0;i<n;i++){
    k=sqrt(x[i]);
    if(x[i]==2) ans++;
    else if(x[i]%2!=0){
      for(j=3;j<=k;j++){
	if(x[i]%j==0) break;
      }
      if(j>k) ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2708
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int,int>
#define ll                long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

static ll int inf = 1e9;
const int cont = 10e5+10;
using namespace std;

void solve(){
   ll a, b,c,d,n,k;
   string s;
   cin>>s;
   ll sum = 0;
   for(int i=0;i<s.size();i++){
    sum += (s[i]-'0');
   }
   if(sum%9 ==0)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}

int main(){
    Fast;

    solve();

	return Okay;
}



Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

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

  LINT a[N];
  REP(i, N) cin >> a[i];
  LINT ans=0;

  REP(i, N){
    while(a[i]%2 == 0){
      a[i] = a[i]/2;
      ++ans;
    }
  }

  cout << ans;




  return 0;
}


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

int main(){
  int K,S;
  cin >> K >> S;
  int c=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      int k = S-i-j;
      if(k < 0 || k > K) continue;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

const max = 100000000000

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

	sc := bufio.NewScanner(os.Stdin)
	s := make([]int, a+2)
	s[0], s[len(s)-1] = -max, max
	for i := 1; i < len(s)-1; i++ {
		sc.Scan()
		s[i], _ = strconv.Atoi(sc.Text())
	}
	t := make([]int, b+2)
	t[0], t[len(t)-1] = -max, max
	for i := 1; i < len(t)-1; i++ {
		sc.Scan()
		t[i], _ = strconv.Atoi(sc.Text())
	}
	x := make([]int, q)
	for i := range x {
		sc.Scan()
		x[i], _ = strconv.Atoi(sc.Text())
	}

	wr := bufio.NewWriter(os.Stdout)
	for _, vx := range x {
		ss := sort.SearchInts(s, vx)
		st := sort.SearchInts(t, vx)
		ans := max * 2
		for _, vs := range s[ss-1 : ss+1] {
			for _, vt := range t[st-1 : st+1] {
				if d := abs(vx-vs) + abs(vs-vt); d < ans {
					ans = d
				}
				if d := abs(vx-vt) + abs(vs-vt); d < ans {
					ans = d
				}
			}
		}
		wr.WriteString(strconv.Itoa(ans) + "\n")
	}
	wr.Flush()
}


Measured memory_bytes: 7552
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, M, ans = 0, check = 0 ;
  long long int K, past = 0 ;
  cin >> N >> M >> K ;
  long long int A[N+2], SumA[N+2], B[M+2], SumB[M+2], last ;
  SumA[0] = 0 ;
  SumB[0] = 0 ;
  A[N+1] = K ;
  B[M+1] = K ;
  for(int i=1;i<(N+1);i++){
    cin >> A[i] ;
    SumA[i] = SumA[i-1] + A[i] ;
  }
  for(int i=1;i<(M+1);i++){
    cin >> B[i] ;
    SumB[i] = SumB[i-1] + B[i] ;
  }
  SumA[N+1] = SumA[N] + A[N+1] ;
  SumB[M+1] = SumB[M] + B[M+1] ;
  for(int i=0;i<(N+1);i++){
    if(K < SumA[i]) break ;
    while(K >= SumA[i] + SumB[ans-i+1]){
      ans++ ;
    }
  }
  cout << ans << endl ;
  return 0 ;
}  

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

using namespace std;

int main() {
  double w;
  while (cin >> w) {
    string msg = (w <= 48.) ? "light fly" :
                 (w <= 51.) ? "fly" :
                 (w <= 54)  ? "bantam" :
                 (w <= 57.) ? "feather" :
                 (w <= 60.) ? "light" :
                 (w <= 64.) ? "light welter" :
                 (w <= 69.) ? "welter" :
                 (w <= 75.) ? "light middle" :
                 (w <= 81.) ? "middle" :
                 (w <= 91.) ? "light heavy" : "heavy";
    cout << msg << endl;
  }
}


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        vector<vector<pii>> input(N);
        rep(i, N) {
            int a; cin >> a;
            input[i].resize(a);
            rep(j, a) {
                cin >> input[i][j].first >> input[i][j].second;
                input[i][j].first--;
            }
        }

        int ans = 0;
        for(int flg = 0; flg < (1 << N); flg++) {
            bool ok = true;
            // vector<int> is_ok(N, -1);
            rep(i, N) if(flg & (1 << i)) {
                rep(j, input[i].size()) {
                    if(flg & (1 << input[i][j].first)) {
                        if(input[i][j].second == 0) ok = false;
                    } else {
                        if(input[i][j].second == 1) ok = false;
                    }
                }
            }
            if(ok) ans = max<int>(__builtin_popcount(flg), ans);
      FAIL:;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <stack>

using namespace std;

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

typedef long long LL;
typedef pair<int, int> PII;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repl(i, n) for(LL i = 0; i < (LL)(n); i++)

int main(void){
  int n, k;
  cin >> n >> k;

  int d;
  vector<int> total(n);
  int target = n;

  for (int i = 0; i < n; i++) {
    total[i] = 0;
  }

  int num;
  for (int i = 0; i < k; i++) {
    cin >> d;
    for (int j = 0; j < d; j++) {
      cin >> num;
      if (total[num-1] == 0) {
        total[num-1] ++;
        target --;
      }
    }
  }

  cout << target << endl;

  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string.h>
#define ll long long int
using namespace std;

int main()
{
    int n;
    cin>>n;
    
    int a[n],b[n],i,c=0;
    
    for(i=0;i<n;i++)
    {
    cin>>a[i]>>b[i];
    }
    
    for(i=0;i<n;i++)
    {
    if(a[i]==b[i])
    {
    if(a[i+1]==b[i+1]&&a[i+2]==b[i+2])
    c++;
    }
    
    }
    
    if(c>0)
    cout<<"Yes";
    else
    cout<<"No";
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
#include <iomanip>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    long long int n;
    cin >> n;
    vector<int> v(n);
    REP(i,n){
        cin >> v[i];

    }
    long long int q;
    cin >> q;
    int result = 0,tmp;
    REP(i,q){
        cin >> tmp;
        result+=(int)binary_search(v.begin(), v.end(), tmp);
    }
    cout << result << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int x,y;
    cin>>x>>y;
    cout<<((x%y)?x:-1);
    
    
  
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;

}

Node treeMaximum(Node x){
 while(x->right!=NIL)
    x=x->right;
  return x;


}

Node treeSearch(Node u, int k){
  if(u==NIL||k==u->key)
    return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  if(x->right!=NIL)
    return treeMinimum(x->right);
  
  Node y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)
    y=z;
  else
    y=treeSuccessor(z);

  if(y->left!=NIL)
    x=y->left;
  else
    x=y->right;

  if(x!=NIL)
    x->parent=y->parent;

  if(y->parent==NIL)
    root=x;
  else if(y==y->parent->left)
    y->parent->left=x;
  else
    y->parent->right=x;
  
  if(y!=z)
    z->key=y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;

  if(y==NIL)
    root=z;
  else if(z->key<y->key)
    y->left=z;
  else
    y->right=z;
    
}

void inorder(Node u){
  if(u==NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20460
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int h,w;
ll K;
int dp[1403][1403];
int T[1403][1403];

int main()
{
	scanf("%d %d",&h,&w);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			scanf("%d",&T[i][j]);
		}
	}
	for(int i=0;i<=h;i++)dp[i][0]=0;
	for(int i=0;i<=w;i++)dp[0][i]=0;

	int maxv = 0;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(T[i][j]==1)dp[i][j]=0;
			else dp[i][j] = min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;

			//printf("%d*",dp[i][j]);
			maxv = max(maxv,dp[i][j]);
		}
	}
	printf("%lld\n",maxv*maxv);
	return 0;
}



Measured memory_bytes: 18096
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    if (a == 0) {
        cout << 1 << endl;
    } else if (b == 0) {
        cout << 2 << endl;
    } else if (c == 0) {
        cout << 3 << endl;
    } else if (d == 0) {
        cout << 4 << endl;
    } else if (e == 0) {
        cout << 5 << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int main() 
{
	int n; cin >> n;
	n *= -1;
	while(n < 0) {
		n += 1000;
	}
	cout << n;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using namespace atcoder;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, d;
    cin >> n >> d;
    auto x = make_vec<int>({n, 2});
    rep(i, n) cin >> x[i][0] >> x[i][1];
    two_sat ts(n);

    auto ng = [&](int a, int b) { return abs(a - b) < d; };
    rep(i, n) for (int j = i+1; j < n; ++j) {
        rep(k, 2) rep(l, 2) {
            if (ng(x[i][k], x[j][l])) {
                ts.add_clause(i, 1-k, j, 1-l);
            }
        }
    }
    bool ans = ts.satisfiable();
    if (ans) {
        cout << "Yes\n";
        auto v = ts.answer();
        rep(i, n) cout << x[i][v[i]] << '\n';
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 3832
a = [int(input()) for i in range(5)]
if all(n%10==0 for n in a):
    b = sum([((k//10)+1)*10 for k in a if k%10 != 0])
    b += sum([l for l in a if l%10 ==0])
    print(b)
else:
    A = min([j%10 for j in a if j%10 != 0])
    b = sum([((k//10)+1)*10 for k in a if k%10 != 0])
    b += sum([l for l in a if l%10 ==0])
    print(b-(10-A))

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,K;
    string S;
    cin >> N >>K;
    vector<ll> vec(N);
    REP(i, N)
        cin >> vec.at(i);

        double m = K / 2.0;
        ll ans = 0;

        REP(i, N)
        {
            if (m >= vec.at(i))
            {
                ans += vec.at(i);
            }
            else{
            ans += K - vec.at(i);
        }
    }
    cout << 2*ans << endl;

}


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

string repeat(string s, int n)
{
	string s1 = s;
	for (int i=1; i<n;i++)
		s += s1;

	return s;
}
int main()
{
	string s = "ACL";
	int n ;
	cin>>n;
	cout << repeat(s, n) << endl;;
	return 0;
}



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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

string s;
int l;

void init()
{
	cin >> s;
	sort(all(s));
	l = s.length();
}

void solve()
{
	if (l % 2) {
		PRINT(false);
		return;
	}
	l /= 2;
	rep(i, l) {
		if (s[i*2] != s[i*2+1]) {
			PRINT(false);
			return;
		}
	}
	PRINT(true);
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c)
    cout << 1;
  if((a == b && a != c) || (b == c && a != c) || (a == c && a != b))
    cout << 2;
  if(a != b && b != c && a != c)
    cout << 3;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;

ll N;
vector<ll> A;

void input() {
    cin >> N;
    A.resize(N);
    for (auto& a : A)
        cin >> a;
}

void solve() {
    auto maxi = max_element(A.begin(), A.end());
    auto mini = min_element(A.begin(), A.end());
    auto put_ans = [](ll l, ll r) {
        cout << l + 1 << ' ' << r + 1 << endl;
    };
    cout << (N - 1) * 2 << endl;
    if (abs(*maxi) >= abs(*mini)) {
        for (auto it = A.begin(); it != A.end(); ++it) {
            if (it != maxi)
                put_ans(maxi - A.begin(), it - A.begin());
        }
        for (ll i = 0; i < N - 1; i++)
            put_ans(i, i + 1);
    } else {
        for (auto it = A.begin(); it != A.end(); ++it) {
            if (it != mini)
                put_ans(mini - A.begin(), it - A.begin());
        }
        for (ll i = N - 1; i > 0; i--)
            put_ans(i, i - 1);
    }
}


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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
#define ff(x) cerr << #x << " is " << x << '\n'
#define FL freopen("in", "r", stdin),freopen("out", "w", stdout);
#define time cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b) 
int main(){
    //FL;
    fin;
    int n;
    cin >> n;
    int v[n + 2];
    fore(i, 1, n + 1)cin >> v[i];
    int cur = 0;
    fore(i, 1, n + 1)
        if(v[i] != i)
            cur++;
    if(cur <= 2)cout << "YES\n";
    else cout << "NO\n";
    time;
    return 0;
}   

Measured memory_bytes: 256
S = input()
Q = int(input())

order = 'f'
front, back = [], []
for i in range(Q):
    q = input().split()
    if q[0] == '1':
        order = 'r' if order == 'f' else 'f'
        continue

    _, f, c = q
    if order == 'f':
        if f == '1':
            front.append(c)
        else:
            back.append(c)
    else:
        if f == '1':
            back.append(c)
        else:
            front.append(c)


front.reverse()
joined_s = ''.join(front) + S + ''.join(back)
print(joined_s if order == 'f' else ''.join(list(reversed(joined_s))))


Measured memory_bytes: 7408
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
int n;
int main()
{
	cin>>n;
	if(n<1200)
		puts("ABC");
	else if(n>=1200&&n<2800)
		puts("ARC");
	else
		puts("AGC");
	return 0;
}


Measured memory_bytes: 256
L, R = map(int, input().split())
if R-L+1>=2019:
    print(0)
else:
    a=2018
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            a=min(a, ((i%2019)*(j%2019)%2019))
    print(a)

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

int main()
{
    int h, w;
    cin >> h >> w;
    int a[h][w] = {};
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }
    
    stringstream ss;
    int count = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j] %2 ==1){
                if(j != w-1){
                    ss << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << endl;
                    count++;
                    a[i][j+1]++;
                }else if(i != h-1){
                    ss << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
                    count++;
                    a[i+1][j]++;
                }
            }
        }
    }
    
    cout << count << endl;
    cout << ss.str() << endl;
    return 0;
}

Measured memory_bytes: 7044
#include<string.h>
#include<stdio.h>
int main(void)
{
	char a[100];
	int A,i;
	scanf("%s",a);
	A=strlen(a);
	for(i=A-1;i>=0;i--){
		printf("%c",a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
struct str{
    int a,b,c,d ;
}tt[60] ;
vector<int>v ;
int n,m,q,ans ;
void fun(int k)
{
    //cout<<k<<" "<<m<<endl ;
    if(v.size()==n)
    {
        //for(int i = 0 ; i < v.size() ; i++) cout<<v[i]<<" " ; cout<<endl ;
        int sm=0 ;
        for(int i = 0 ; i < q ; i++)
        {
            int p=tt[i].a,qq=tt[i].b,r=tt[i].c,s=tt[i].d ;
            if(v[qq-1]-v[p-1]==r) sm+=s ;
        }
        //cout<<sm<<endl ;
        ans=max(ans,sm) ;
        return ;
    }
    if(k>m) return ;
    for(int i = k ; i <= m ; i++)
    {
        v.push_back(i) ;
        fun(i) ;
        v.pop_back() ;
    }
}
int main()
{
    cin>>n>>m>>q ; ans=0 ;
    for(int i = 0 ; i < q ; i++) cin>>tt[i].a>>tt[i].b>>tt[i].c>>tt[i].d ;
    fun(1) ;
    cout<<ans<<endl ;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long int lli;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    lli a[5];
    for(int i=0;i<5;i++) cin>>a[i];
    for(int i=0;i<5;i++) if(a[i]==0) cout<<i+1;
    return 0;
}

Measured memory_bytes: 3616
N, X, Y = [int(x) for x in input().split()]

ans = [0] * N

for i in range(1, N):
    for j in range(i + 1, N + 1):
        dist = min( j - i, abs(i - X) + 1 + abs(j - Y) )
        ans[dist] += 1

for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 46300
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    int N = S.size();

    bool E[1 << 8];
    for (int i = 0; i < N; ++i) {
        E[S[i]] = true;
    }

    cout << (!(E['N'] ^ E['S']) && !(E['W'] ^ E['E']) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int a, b;
	cin >> a;
	cin >> b;


	if (a > b) {
		cout << "a > b" << endl;
	}
	else if(a == b){
		cout << "a == b" << endl;
	}
	else {
		cout << "a < b" << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
// pactice
 
#pragma warning(disable:4996)
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define MAX_NUMBER 100000
#define MAX_STRING 1000000

	int anNumber[MAX_NUMBER];
	int anMinusNumber[MAX_NUMBER];
	char sInput[MAX_STRING+1]="";

int main() {
 
	char* psInput=NULL;
	int nNumberOfNumber=0;
	int nTargetNumber=0;
	int nBlockNumber=0;
	int i=0;
	int nCount=0;

	for(i=0;i<MAX_NUMBER;i++){
		anNumber[i]=0;
	}
	// read line 1
	gets(sInput);
	psInput = strtok(sInput," ");
	nNumberOfNumber=atoi(psInput);
	psInput = strtok(NULL," ");
	nBlockNumber=atoi(psInput);

	// read line 2
	gets(sInput);
	psInput = strtok(sInput," ");
	for (i=0;i<nNumberOfNumber;i++){
		anNumber[i]=atoi(psInput);
		psInput = strtok(NULL," ");
	}
	nTargetNumber=nNumberOfNumber;
	while(nTargetNumber>1){
		nTargetNumber=nTargetNumber-(nBlockNumber-1);
		nCount++;
	}
	printf("%d\n",nCount);

	return 0;
}

Measured memory_bytes: 1152
solve :: [[Float]] -> (Int, Int)
solve = foldl f (0, 0)
  where
    f r@(r1, r2) (ai:bi:ci:_)
      | ai == bi                = (r1, r2 + 1) -- ????????¢
      | ai^2 + bi^2 == ci ^ 2   = (r1 + 1, r2) -- ????????¢
      | otherwise               = r            -- ?????????

main :: IO ()
main = getContents >>= printResult . solve . parseInput
  where
    parseInput = map (map read . words) . lines . map c2s
    c2s ',' = ' '
    c2s c   = c
    printResult (r1, r2) = print r1 >> print r2

Measured memory_bytes: 3952
def p(n):
    l = [1]*(n+1)
    l[0] = l[1] = 0
    for i in range(2,int(n ** 0.5) + 1):
        if l[i]:
            for j in range(2*i, n+1, i):
                l[j] = 0
    return l
n = input()
l = []
l += [str(n)+":"]
from itertools import compress
P = p(int(n ** 0.5))
for i in compress(xrange(0,n), P):
    while n % i == 0:
        n /= i
        l += [i]
if n != 1: l += [n]
print " ".join(map(str,l))

Measured memory_bytes: 7272
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            var k = cin.nextInt();

            var list = new List<int>();
            for (int i = a; i < a+k && i <= b; i++)
            {
                list.Add(i);
            }

            for (int i = b; i >= a && i > b-k; i--)
            {
                list.Add(i);
            }

            list = list.OrderBy(i => i).Distinct().ToList();
            foreach (var item in list)
            {
                Console.WriteLine(item);
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13396
fn main() {
    let mut reader = acio::Reader::new();
    let n = reader.read::<usize>();
    let x = reader.read::<u32>();
    let l = reader.read_by::<u32>(n);
    let mut p = 0;
    let mut i = 0;
    while p <= x && i < n {
        p += l[i];
        i += 1;
    }
    if p <= x {
        println!("{}", n + 1);
    } else {
        println!("{}", i);
    }
}

/// IO Module for AtCoder
#[allow(dead_code)]
mod acio {
    use std::fmt::Debug;
    use std::io::{stdin, Stdin};
    use std::str::FromStr;

    pub struct Reader {
        input: Stdin,
        stack: Vec<String>,
    }

    impl Reader {
        pub fn new() -> Self {
            Reader {
                input: stdin(),
                stack: vec![],
            }
        }

        pub fn read_by<F>(&mut self, count: usize) -> Vec<F>
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            let mut v = vec![];
            for _ in 0..count {
                v.push(self.read());
            }
            return v;
        }

        pub fn read<F>(&mut self) -> F
        where
            F: FromStr,
            <F as FromStr>::Err: Debug,
        {
            if self.stack.is_empty() {
                let mut line = self.read_line();
                self.stack.append(&mut line);
                self.stack.reverse();
            }
            self.stack.pop().unwrap().parse().unwrap()
        }

        fn read_line(&mut self) -> Vec<String> {
            let mut buf = String::new();
            self.input.read_line(&mut buf).unwrap();
            buf.split_whitespace().map(|s| s.to_string()).collect()
        }
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
  int n,k,d,a[105]={},b,m=0;
  scanf("%d",&n);
  scanf("%d",&k);
  for(;k>0;k--){
    for(scanf("%d",&d);d>0;d--){
      scanf("%d",&b);
      a[b-1]++;
    }
  }
  for(k=0;k<n;k++){
    if(a[k]!=0) m++;
  }
  printf("%d",n-m);
  return(0);
}

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

int main(void){
	int N;
	cin >> N;
	int A[N];
	vector<int> cnt(N+1);
	int maxcnt = 1;
	rep(i,N) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	int B[N];
	rep(i,N) {
		cin >> B[N-1-i];
		cnt[B[N-1-i]]++;
	}
	sort(cnt.begin(),cnt.end());
	maxcnt = cnt[N];

	if (maxcnt > N) {
		cout << "No" << endl;
		return 0;
	}

	int j = 0;
	rep(i,N) {
		while (A[i] == B[i]) {
			swap(B[i], B[j]);
			j++;
		}
	}
	j = N-1;
	rep(i,N) {
		while (A[i] == B[i]) {
			swap(B[i], B[j]);
			j--;
		}
	}

	cout << "Yes" << endl;
	rep(i,N) cout << B[i] << " ";
	cout << endl;

	return 0;
}


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

void solve(string& s){
	for(int i = 1; i < 26; i+=2){
		if(i == 13)continue;
		for(int j = 0; j < 26; ++j){
			string ss = s;
			for(int k = 0; k < (int)s.size(); ++k){
				if('a' <= ss[k] && ss[k] <= 'z'){
					ss[k] = (i * (ss[k] - 'a') + j) % 26 + 'a';
				}
			}
			if(ss.find("this") != string::npos || ss.find("that") != string::npos){
				cout << ss << endl;
				return;
			}
		}
	}
}

int main()
{
	int n;
	string s;
	cin >> n; cin.ignore();
	for(int i = 0; i < n; ++i){
		getline(cin,s);
		solve(s);
	}
}

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

int main(){
  int n, w;
  cin >> n >> w;
  vector<int> W(n), V(n);
  for(int i = 0; i < n; i++) cin >> W.at(i) >> V.at(i);
  
  vector<vector<long long>> dp(n+1, vector<long long>(w+1, 0));
  
  for(int i = 1; i < n+1; i++){
    for(int j = 0; j < w+1; j++){
      if(j-W.at(i-1) >= 0)
        dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-1).at(j-W.at(i-1))+V.at(i-1));
      dp.at(i).at(j) = max(dp.at(i).at(j), dp.at(i-1).at(j));
    }
  }
  cout << dp.at(n).at(w) << endl;
}

Measured memory_bytes: 83044
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #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;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  ll ans = 0;
  for(int i=0; i<N; i++){
    if(i+1<N && A[i]%2 && A[i+1]){
      ans++;
      A[i+1]--;
    }
    ans += A[i]/2;
  }
  cout << ans << endl;
  return 0;
}


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

long long gcd(long long a,long long b){
    return b ? gcd(b,a % b) : a;
}

int n,k,a[100100],dif[100100],g;

int main(){
    cin >> n >> k;
    for(int i = 1;i <= n;++i) scanf("%d",&a[i]);
    if(n == 1){
        if(k == a[1]) puts("POSSIBLE");
        else puts("IMPOSSIBLE");
        return 0;
    }
    sort(a+1,a+1+n);
    for(int i = 1;i < n;++i) dif[i] = a[i+1] - a[i];
    sort(dif+1,dif+n,greater<int>());
    if(dif[1] == 0){
        if(k == a[1]) puts("POSSIBLE");
        else puts("IMPOSSIBLE");
        return 0;
    }
    g = dif[1];
    for(int i = 2;i < n;++i)
        if(dif[i]) g = gcd(g,dif[i]);
    for(int i = 1;i <= n;++i)
        if(a[i] >= k && (a[i] - k) % g == 0){
            puts("POSSIBLE");
            return 0;
        }
    puts("IMPOSSIBLE");

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b;
    scanf("%d %d %d",&x,&a,&b);
    int disa,disb;
    disa=fabs(x-a);
    disb=fabs(x-b);
    if(disa<disb)
    {
        printf("A");
    }
    else
    {
        printf("B");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n,k,d;
int x;
map<int,int> cnt;
int main() {
    ios::sync_with_stdio(false);
    cin>>n>>k;
    while(k--){
        cin>>d;
         while(d--){
             cin>>x;
              cnt[x]++;
         }
    }
    int res=0;
    for(int i=1;i<=n;++i){
        if(cnt[i]==0) res++;
    }
    printf("%d\n",res);

    return 0;
}

Measured memory_bytes: 3800
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();//3
        int box = a;
        int b = sc.nextInt();//5
        double t = sc.nextInt();//7
        int count = 1;
        int c = a;
        t += 0.5;//t=8
        ArrayList<Integer> time = new ArrayList<>();
        while(count <= 20){//3,6,9,...
            time.add(c);//
            ++count;
            c = a * count;
        }//time=3,6
        int countTime = 0;

        for(int x : time){//3>7F,6>7F,9>7T,
            if(x > t){
                break;
            }else{
                ++countTime;
            }
        }
        if(a < t){
            System.out.println(countTime * b);
        }else{
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
int pa[MAX];
int ra[MAX];
void init(){
  for(int i=0;i<MAX;i++){
    pa[i]=i;
    ra[i]=0;
  }
}
 
int find(int x){
  if(pa[x]==x)return x;
  else return pa[x]=find(pa[x]);
}
 
void unite(int x,int y){
  x=find(x),y=find(y);
  if(x==y)return;
  if(ra[x]<ra[y])swap(x,y);
  pa[y]=x;
  if(ra[x]==ra[y])ra[x]++;
}
 
bool same(int x,int y){
  return (find(x)==find(y));
}
 
int n,m,q,a,b;
int main(){
  init();
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    unite(a,b);
  }
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d %d",&a,&b);
    cout<<(same(a,b)?"yes":"no")<<endl;
  }
  return 0;
}

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


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

    int N;
    cin >> N;
    int A[N-1];
    rep(i,N-1) cin >> A[i];
    int B[N];
    rep(i,N) B[i]=0;
    rep(i,N-1){
        B[A[i]-1]++;
    }

    rep(i,N) cout << B[i] << endl;
}

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

int Na, Nq, A[20], Q[200];

bool mySolve(int ix, int m) {
	//cout << "mySolve (ix:" << ix << " m:" << m << " A[ix]:" << A[ix] << ")" << endl;
	int ans;
	if (m == 0) {
		return true;
	}
	else if ((m < 0) || (ix >= Na)) {
		return false;
	}
	ans = mySolve(ix + 1, m) || mySolve(ix + 1, m - A[ix]);
	return ans;
}

int main() {
	cin >> Na;
	for (int i = 0; i < Na; i++) cin >> A[i];

	cin >> Nq;
	for (int i = 0; i < Nq; i++) cin >> Q[i];

	for (int i = 0; i < Nq; i++) {
		if (mySolve(0, Q[i])) cout << "yes" << endl;
		else cout << "no" << endl;
	}

	return 0;
}

Measured memory_bytes: 3100