akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
   public static void main(String[]args){
   
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();

      if(a<b && b<c){
         System.out.println("Yes");
      }else{
         System.out.println("No");
      }

   }
}

Measured memory_bytes: 26056
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int mod = 2019;
long long modpow(long long a, long long n){
  long long r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %mod;
    a = a * a % mod;
    n >>= 1;
  }
  return r;
}

int main(void){
    string s;cin>>s;
    reverse(s.begin(),s.end());
    ll res=0,now=0;
    map<ll,ll> mp;
    rep(i,s.size()){
        ll t=modpow(10,i);
        ll d=s[i]-'0';
        d*=t;
        d+=now;
        d%=2019;
        mp[d]++;
        now=d;
    }
    for(auto& p:mp){
        ll x=p.first,y=p.second;
        if(x==0){
            res+=(y+1)*y/2;
        }else{
            y--;
            res+=(y+1)*y/2;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << endl;
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << endl;
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  ll N;
  cin >> N;
  vector<ll> X(N);
  vector<ll> X_buf(N);
  rep(i, 0, N){
    cin >> X[i];
    X_buf[i] = X[i];
  }
  sort(X_buf.begin(), X_buf.end());

  rep(i, 0, N){
    if(X[i] <= X_buf[N/2-1]){
      cout << X_buf[N/2] << endl;
    }else{
      cout << X_buf[N/2-1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5376
import sys
x,y = map(int,input().split())
flg = 0

for i in range(x+1):
    for j in range(x+1):
        if x == (i+j) and y == (2*i + 4*j):
            print('Yes')
            flg = 0
            sys.exit()
        else:
            flg = 1
if flg:
    print('No')


Measured memory_bytes: 9056
! https://beta.atcoder.jp/contests/abc097/submissions/3768108

module UnionFind
    implicit none
    public
        type :: Union_Find
            integer(8),allocatable,dimension(:) :: par,g
        end type Union_Find
    contains
        subroutine init(p,n)
            implicit none
            type(Union_Find)  p
            integer(8) n,i
            allocate( p%par(n) )
            allocate( p%g(n) )
            do i=1,n
                p%par(i) = i
                p%g(i) = 1
            enddo
        end subroutine init
        recursive function root(p,n) result(ret)
            implicit none
            type(Union_Find) p
            integer(8) ret,n
            if(p%par(n)==n)then
                ret = n
                return
            else
                p%par(n) = root(p,p%par(n))
                ret = p%par(n)
                return
            endif
        end
        function gsize(p,x) result(a)
            implicit none
            integer(8) x,a
            type(Union_Find) p
            a = p%g(root(p,x))
        end
        subroutine unite(p,a,b)
            implicit none
            type(Union_Find) p
            integer(8) a,b
            a = root(p,a)
            b = root(p,b)
            if(a/=b)then
                p%par(a) = b
                p%g(b) = p%g(b) + p%g(a)
                p%g(a) = 0
            endif
        end
end module UnionFind

program atcoder_abc97d
    use UnionFind
    implicit none
    type(Union_Find) uf
    integer(8) n,m,i
    integer(8) ans,x,y
    integer(8),allocatable,dimension(:) :: a,b
    integer(8),allocatable,dimension(:) :: c
    read*,n,m
    allocate( a(m) , b(m) , c(m) )
    call init(uf,n+1)
    do i = 1,m
        read*,a(i),b(i)
    enddo
    ans = (n-1)*n/2
    do i=m,1,-1
        c(i) = ans
        x = gsize(uf,a(i))
        y = gsize(uf,b(i))
        if(root(uf,a(i)) /= root(uf,b(i)))then
            ans = ans - x*y
        endif
        call unite(uf,a(i),b(i))
    enddo
    do i=1,M
        write(*,'(I0)')c(i)
    enddo
!----------------------functions--------------------------
contains
end program atcoder_abc97d

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

int main() {
	int k;
	cin >> k;
	int a,b;
	cin >> a >> b;
	int count = 0;
	for (int i = a; i <= b; i++) {
      if (i % k == 0) {
        count++;
        break;
      }
	}
  
	if (count == 1) {
		cout << "OK" << endl;
	} else {
		cout<<"NG"<<endl;
	}
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VLL x(n);
  rep(i, n) cin >> x[i];
  ll ans = 1000000000;
  rep(xx, 100) {
    ll tmp = 0;
    rep(i, n) { tmp += (x[i] - xx) * (x[i] - xx); }
    chmin(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


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

int n;

bool repeat(string s) {
    if (n % 2 == 1) {
        return false;
    }

    int mid = n / 2;
    for (int i = 0; i < mid; i++) {
        if (s.at(i) != s.at(mid + i)) {
            return false;
        }
    }

    return true;
}

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

    cout << (repeat(s) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, D;
  while (cin >> N >> D) {
    int L = 2 * D + 1;
    int res = (N + L - 1) / L;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define INF 100000000
#define ll long long

int dp[1 << 16];
int main()
{
	int N, M, K;
	int D[16], nxt[100];
	int v[100][100];
	cin >> N >> M >> K;
	REP(i, 0, N) nxt[i] = -1;
	REP(i, 0, M) {
		cin >> D[i];
		D[i]--;
		nxt[D[i]] = i;
	}
	REP(i, 0, N) REP(j, 0, K) {
		cin >> v[i][j];
		v[i][j]--;
	}
	REP(i, 0, 1 << M) dp[i] = INF;

	dp[(1 << M) - 1] = 0;
	queue<int> q;
	q.push((1 << M) - 1);
	while (!q.empty()) {
		int qu = q.front();
		q.pop();
		REP(i, 0, K) {
			int next = 0;
			REP(j, 0, M) {
				if((qu >> j) & 1){
					if (nxt[v[D[j]][i]] != -1) {
						next = next | (1 << nxt[v[D[j]][i]]);
					}
				}
			}
			if (dp[next] != INF) continue;
			dp[next] = dp[qu] + 1;
			q.push(next);
		}
	}

	cout << dp[0] << endl;
	return 0;
}

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

struct node {
	int l, r;
};

char s[100];
int len;
node ans[100][100];

node max(node n1, node n2) {
	if (n1.l < 0 && n1.r < 0) return n2;
	if (n2.l < 0 && n2.r < 0) return n1;
	if (n1.r - n1.l > n2.r - n2.l) return n1;
	if (n2.r - n2.l > n1.r - n1.l) return n2;
	int i, j;
	for (i = n1.l, j = n2.l; i <= n1.r && j <= n2.r; i++, j++) {
		if (s[i] != '?' && s[j] != '?') {
			if (s[i] < s[j]) return n2;
			if (s[i] > s[j]) return n1;
		} else if (s[i] == '?') {
			if (s[j] != '9' && s[j] != '?') return n1;
		} else if (s[j] == '?') {
			if (s[i] != '9' && s[i] != '?') return n2;
		}
	} 
	return n1;
}

node dfs(int l, int r) {
	if (ans[l][r].l != -2 && ans[l][r].r != -2) return ans[l][r];

	bool b = true;
	for (int i = l; i <= r && b; i++) if (s[i] == 'L' || s[i] == 'R' || s[i] == ',' || s[i] == '(' || s[i] == ')') b = false;
	if (b) {
		if (l != r && s[l] == '0') return ans[l][r] = {-1, -1};
		return ans[l][r] = {l, r};
	}
	
	if (s[l] != 'L' && s[l] != 'R' && s[l] != '?') return ans[l][r] = {-1, -1};
	if (s[l + 1] != '(' && s[l + 1] != '?') return ans[l][r] = {-1, -1};
	if (s[r] != ')' && s[r] != '?') return ans[l][r] = {-1, -1};
	node maxl = {-1, -1};
	node maxr = {-1, -1};
	for (int i = l + 3; i <= r - 2; i++) {
		if (s[i] == '?' || s[i] == ',') {
			node ll = dfs(l + 2, i - 1), rr = dfs(i + 1, r - 1);
			if (ll.l != -1 && ll.r != -1 && rr.l != -1 && rr.r != -1)
				maxl = max(maxl, ll), maxr = max(maxr, rr);
		}
	}
	if (s[l] == 'L') return ans[l][r] = maxl;
	else if (s[l] == 'R') return ans[l][r] = maxr;
	else if (s[l] == '?') return ans[l][r] = max(maxl, maxr);
	return ans[l][r] = {-1, -1};
}

int main() {
	scanf("%s", s);
	len = strlen(s);

	for (int i = 0; i < len; i++) for (int j = 0; j < len; j++) ans[i][j].l = ans[i][j].r = -2;

	dfs(0, len - 1);

	if (ans[0][len - 1].l == -1 && ans[0][len - 1].r == -1) printf("invalid");
	else 
		for (int i = ans[0][len - 1].l; i <= ans[0][len - 1].r; i++) 
			if (s[i] == '?') printf("9"); else printf("%c", s[i]);
	printf("\n");
	return 0;
}

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

int main() {
  int n, k;
  int r, s, p;
  string T;
  map<int, bool> win;
  ll ans;
  ans = 0;
  cin >> n >> k;
  cin >> r >> s >> p;
  cin >> T;
  for (int i = 1; i <= T.size(); i++){
    char te;
    te = T[i-1];
    if (k < i && te == T[i-1-k]) {
      if (win[i-k] == false) {
        if (te == 'r') ans += p;
        if (te == 's') ans += r;
        if (te == 'p') ans += s;
        win[i] = true;
      } else {
        win[i] = false;
      }
    } else {
      if (te == 'r') ans += p;
      if (te == 's') ans += r;
      if (te == 'p') ans += s;
      win[i] = true;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8376
#include<bits/stdc++.h>
using namespace std;
double xp1,yp1,xp2,yp2,x,y,l1,r1,l2,r2,sum;
int n;
int main(){
	scanf("%lf%lf%lf%lf",&xp1,&yp1,&xp2,&yp2);
	l1=xp2-xp1;
	r1=yp2-yp1;
	scanf("%d",&n);
	for(int i=1; i<=n; i++){
		scanf("%lf%lf",&x,&y);
		l2=x-xp1;
		r2=y-yp1;
		sum=l1*l2+r1*r2;
		printf("%.8lf %.8lf\n",xp1+l1*sum/((l1*l1)+(r1*r1)),yp1+r1*sum/((l1*l1)+(r1*r1)));
	}
} 


Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
/* #pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
typedef long long ll;
const ll MAXN = 1e3 + 2;
const ll MAXD = 1e3 + 5;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-4;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}




int main(){

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


ll x;
cin >> x;
cout << (ceil(x / 1000.0) * 1000  - x);

 
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
const long long MODUL = 1e9 + 7;
vector<vector<long long>> dp(1000, vector<long long>(1000, 0));
vector<vector<bool>> visited(1000, vector<bool>(1000, 0));
void dfs(int x, int y, vector<vector<int>>& matrix){
    visited[x][y] = true;
    int u = x - 1;
    int v = y;
    if (u >= 0 && v >= 0 && matrix[u][v] == 0){
        if (!visited[u][v])
            dfs(u, v, matrix);
        dp[x][y] = (dp[x][y] + dp[u][v]) % MODUL;
       // cout << dp[u][v] << " " << dp[x][y] << endl;
    }

    u = x;
    v = y - 1;
    if (u >= 0 && v >= 0 && matrix[u][v] == 0){
        if (!visited[u][v])
            dfs(u, v, matrix);
        dp[x][y] = (dp[x][y] + dp[u][v]) % MODUL;
        //cout << dp[u][v] << " " << dp[x][y] << endl;
    }
}

int main(){
    int h, w;
    scanf("%d %d\n", &h, &w);
    vector<vector<int>> matrix(h, vector<int>(w));
    for (int i = 0; i < h; i++){
        char c;
        for (int j = 0; j < w; j++){
            scanf("%c", &c);
            if (c == '.') matrix[i][j] = 0;
            else matrix[i][j] = 1;
        }
        scanf("%c", &c);
    }
    dp[0][0] = 1;

    dfs(h - 1, w - 1, matrix);

    cout << dp[h - 1][w - 1];
}


Measured memory_bytes: 12416
#include<stdio.h>
#include<math.h>
#define EPS 1e-4
/*
  ax + by = c
  dx + ey = f
*/

int
main(int argc, char *argv[])
{
        char buf[64];
        int a, b, c, d, e, f;
        double inv_d, x, y;
        
        while (fgets(buf, 64, stdin)) {
                sscanf(buf, "%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
                inv_d = 1 / (double)(a * e - b * d);
                x = inv_d * (e * c - b * f);
                y = inv_d * (a * f - d * c);
                if (-EPS < x && x < EPS) x = 0.000;
                if (-EPS < y && y < EPS) y = 0.000;
                printf("%.3f %.3f\n", x, y);
        }

        return 0;
}

Measured memory_bytes: 644
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    a[i]--;
  }

  vector<int> result;

  for (int step = 0; step < n; ++step) {
    int i = n - 1 - step;
    while (i >= 0 && a[i] != i) i--;
    if (i == -1) {
      cout << -1 << endl;
      return 0;
    }

    result.push_back(a[i] + 1);
    a.erase(a.begin() + i);
  }

  reverse(result.begin(), result.end());

  for (int i = 0; i < n; ++i) {
    cout << result[i] << endl;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
def bubbleSort(A, N):
      ctn = 0
      for i in range(0,N):
            for j in range(0,N-i-1):
                  if int(A[j]) > int(A[j+1]):
                        t = A[j]
                        A[j] = A[j+1]
                        A[j+1] = t
                        ctn = ctn + 1
      for i in range(0,N):
            if i < N-1:
                  print(A[i],end=' ')
            else:
                  print(A[i])
      print(ctn)

if __name__ == "__main__":
      N = int(input())
      A = input()
      A = A.split()
      bubbleSort(A, N)

Measured memory_bytes: 7764
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  const L=input[1].split(' ').map(e=>{
    return e-0;
  }).sort((a,b)=>{
    return a-b;
  });
  var tL,giri;
  var ret=0;
  for(var i=0;i<L.length-2;i++){
    for(var j=i+1;j<L.length-1;j++){
      if(L[L.length-1]<L[i]+L[j]){
        ret+=L.length-1-j;
        continue;
      }
      if(L[j+1]>=L[i]+L[j]){
        continue;
      }
      tL=L.length-1;
      giri=j+1;
      while(tL-giri>1){
        if(L[Math.ceil((tL+giri)/2)]<L[i]+L[j]){
          giri=Math.ceil((tL+giri)/2);
        }else{
          tL=Math.ceil((tL+giri)/2);
        }
      }
      ret+=giri-j;
    }
  }
  console.log(ret);

}




//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int K;
  cin >> K;
  vector<long> ans;
  function<void(long)> dfs = [&](long n) -> void {
    if (n > 3234566667) return;
    ans.push_back(n);
    for (int next = max(0L, n % 10 - 1); next <= min(9L, n % 10 + 1); next++) {
      dfs(n * 10 + next);
    }
  };
  for (int i = 1; i <= 9; i++) dfs(i);
  sort(ans.begin(), ans.end());
  cout << ans.at(K - 1) << "\n";
}

Measured memory_bytes: 4300
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
struct Point
{
	double x;
	double y;
};
const double D_TO_R = M_PI / 180;
void cochCurve(Point p1, Point p2, int n)
{
	if (n <= 0)
		return;
	Point s, t, u;
	s.x = (2 * p1.x + p2.x) / 3;
	s.y = (2 * p1.y + p2.y) / 3;
	t.x = (p1.x + 2 * p2.x) / 3;
	t.y = (p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x)*cos(60 * D_TO_R) - (t.y - s.y)*sin(60 * D_TO_R) + s.x;
	u.y = (t.x - s.x)*sin(60 * D_TO_R) + (t.y - s.y)*cos(60 * D_TO_R) + s.y;
	cochCurve(p1, s, n - 1);
	printf("%.8f %.8f\n", s.x, s.y);
	cochCurve(s, u, n - 1);
	printf("%.8f %.8f\n", u.x, u.y);
	cochCurve(u, t, n - 1);
	printf("%.8f %.8f\n", t.x, t.y);
	cochCurve(t, p2, n - 1);
}
int main()
{
	int n;
	cin >> n;
	Point p1{ 0,0 };
	Point p2{ 100,0 };
	printf("%.8f %.8f\n", p1.x, p1.y);
	cochCurve(p1, p2, n);
	printf("%.8f %.8f\n", p2.x, p2.y);
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int n,m,a[500],b[500],cost[500],node[100],size[100],sum;
	int i,j,k;
	while(1) {
		cin>>n>>m;
		sum=0;
		if(n==0&&m==0) break;
		for(i=0;i<m;i++) cin>>a[i]>>b[i]>>cost[i];
		for(i=0;i<m-1;i++) {
			for(j=i+1;j<m;j++) {
				if(cost[i]>cost[j]) {
					swap(cost[i],cost[j]);
					swap(a[i],a[j]);
					swap(b[i],b[j]);
				}
			}
		}
		for(i=0;i<n;i++) size[i]=1,node[i]=i;
		for(i=0;i<m;i++) {
			int x,y,va;
			x=a[i],y=b[i],va=cost[i];
			while(x!=node[x]) x=node[x];
			while(y!=node[y]) y=node[y];
			if(x!=y) {
				sum+=va;
				if(size[x]>=size[y]) node[y]=x;
				else node[x]=y;
			}
		}
		cout<<sum<<endl;
	}
}

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

int main() {
  int a, b, n, i;
  
  while(cin >> a >> b >> n) {
    int sum = 0;
    
    for(i = 1; i < n+1; i++) {
      a = a % b * 10;
      sum += (int)a/b;
    }

    cout << sum << endl;
  }

  return 0;
}
      
  

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int a,b,c,k;cin>>a>>b>>c>>k;

  cout << (k%2==0 ? a-b : b-a) << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;	
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

ll rep_power_modM(ll a, ll n, ll M){
    if(n == 0)return 1;
    if(n%2 == 0){ll tmp = rep_power_modM(a,n/2,M); return tmp*tmp%M;}
    return a*rep_power_modM(a,n-1,M)%M;
}

ll comb(ll n, ll r, ll M = MOD){
    ll ans = 1; rep(i,r){ans *= (n-i)%M; ans%=M;}
    ll divisor = 1; rep(i,r){divisor *= (i+1)%MOD; divisor %=M;}
    ans = ans * rep_power_modM(divisor,M-2,M)%M; if(ans<0)ans+=M;
    return ans;
}

int main(){
	int x,y;
	cin>>x>>y;
	int ans = 0;
	if((x+y) % 3 != 0){ cout<< ans<<endl; return 0;}
	int r_base = (x+y)/3;
	if(r_base <= x && x <= r_base*2){
		ans = comb(r_base, x%r_base);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 200000
#define SNT 2000000000
typedef long long int llong;



int L[MAX / 2 + 2], R[MAX / 2 + 2];


llong merge(int*, int, int, int, int);
llong mergeS(int*, int, int, int);

llong merge(int A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1, n2;
  llong c = 0;
  n1 = mid - left;
  n2 = right - mid;
  for( i = 0 ; i < n1 ; i++){
    L[i] = A[left + i];
  }
  for( i = 0 ; i < n2 ; i++){
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SNT;
  i = j = 0;
  for( k = left ; k < right ; k++){
    if( L[i] <= R[j] ){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
      c += n1 - i;
    }
  }
  return c;
}

llong mergeS(int A[], int n, int left, int right){
  int mid;
  llong v1, v2, v3;
  if( left + 1 < right){
    mid = (left + right) / 2;
    v1 = mergeS(A, n, left, mid);
    v2 = mergeS(A, n, mid, right);
    v3 = merge(A, n, left, mid, right);
    return v1 + v2 + v3;
  }
  else return 0;
}

int main(){
  int A[MAX], n, i;
  llong ans;

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

  ans = mergeS(A, n, 0, n);
  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 3332
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
              Scanner sc = new Scanner(System.in);
        boolean flag = true;
        while(flag) {

            //7
            int a = sc.nextInt();
            if (a == 0) {
                break;
            }
            int aa[] = new int[a];
            int sum = 0;
            for (int i = 0; i < a; i++) {
                aa[i] = sc.nextInt();
                
                sum += aa[i];
            }
           
                int av = sum / a;
            

            int answer=0;
            for (int k = 0; k < a; k++) {
                if (aa[k] <= av) {
                    answer++;
                }
            }
            System.out.println(answer);


        }
    }
}


Measured memory_bytes: 58992
#include <stdio.h>

int main(void){
    char suit[] = "SHCD";
    int card[52] = {0};
    int n;
    int i;
    int s;
    char buf[2];
    int cnum;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%s %d", buf, &cnum);
        switch (buf[0])
        {
            case 'S':
                s = 0;
                break;
            case 'H':
                s = 1;
                break;
            case 'C':
                s = 2;
                break;
            case 'D':
                s = 3;
                break;
        }
        card[s * 13 + cnum - 1] = 1;
    }
    for (i = 0; i < 52; i++)
    {
        if (card[i] == 0)
        {
            printf("%c %d\n", suit[i / 13], (i % 13) + 1);
        }
    }

    return 0;
}


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

const int p=1000000007,inv2=(p+1)/2; 
int qpow(int a,int k){
	int ans=1;
	while(k){
		if(k&1) ans=1LL*ans*a%p;
		a=1LL*a*a%p;
		k>>=1;
	}
	return ans;
}

int N,Q;
int A[3005];
int F[3005][3005];

int main(){
	scanf("%d%d",&N,&Q);
	for(int i=1;i<=N;i++) scanf("%d",&A[i]);
	for(int i=1;i<=N;i++)
	for(int j=1;j<=N;j++)
		F[i][j]=(A[i]>A[j]);
	for(int i=1;i<=Q;i++){
		int x,y;scanf("%d%d",&x,&y);
		F[x][y]=F[y][x]=1LL*(F[x][y]+F[y][x])%p*inv2%p;
		for(int j=1;j<=N;j++)if(j!=x&&j!=y){
			F[j][x]=F[j][y]=1LL*(F[j][x]+F[j][y])%p*inv2%p;
			F[x][j]=F[y][j]=1LL*(F[x][j]+F[y][j])%p*inv2%p;
		}
	}
	int ans=0;
	for(int i=1;i<=N;i++)
	for(int j=i+1;j<=N;j++)
		ans=(ans+F[i][j])%p;
	printf("%d\n",1LL*ans*qpow(2,Q)%p);
}

Measured memory_bytes: 39028
def selection(A,N):
    count = 0
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i],A[minj]=A[minj],A[i]
            count += 1
    return count 

n = int(input())
a = list(map(int,input().split()))
count=selection(a,n)
print(' '.join(map(str,a)))
print(count)


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

using namespace std;

int main(){
    long long n;
    cin >> n;
    string ans;

    while(n){
        n--;
        ans += 'a'+n%26;
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int A[6], k;
int main(void){
    for (int i=0;i<5;i++)
      cin >> A[i];
    cin >> k;
    for (int i=0;i<5;i++){
      for (int j=i+1;j<5;j++){
        if (abs(A[j]-A[i])>k) {
          cout << ":(" << endl;
          exit(0);
        }
      }
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
XL = [list(map(int, input().split())) for i in range(N)]
LR = [[x - l, x + l] for x, l in XL]

LR.sort(key=lambda x: x[1])

ans = 0
prev = -float("INF")
for l, r in LR:
    if prev <= l:
        ans += 1
        prev = r

print(ans)

Measured memory_bytes: 43636
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int n;
   cin >> n;
   int ans = 0;
   if(n%2==0) ans = n;
   else{
      ans = 2*n;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
while True:
    a,b=map(int,input().split())

    if a==0:
        break
    else :
        if a<=b:
                X,Y = b,a
        else :
            X,Y = a,b
            
        s=0
                
        def c(X, Y, s) :
            while Y != 0 :
                s += 1
                X %= Y
                X, Y = Y, X
                
            return X, s
            
        print(c(X, Y, s)[0], c(X, Y, s)[1])




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

using namespace std;

using int64 = long long;

constexpr int64 P = 1000000007;

// Verified: ABC133E, ABC132D, ABC130E
struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 x) : x(x) {}
  FiniteField() : x(0) {}
  int64 Value() { return x; }
  inline FiniteField operator+(FiniteField o) {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  int n, k;
  cin >> n >> k;
  cout << Power(FiniteField(k), n).Value() << endl;
}



Measured memory_bytes: 3204
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5+3;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;cin>>n;
	vector<bool> dp;
	rep(i,100*n+1){
		dp.push_back(false);
	}
	dp[0] = true;
	rep(i,n){
		int s;cin>>s;
		vector<bool> dp2(dp);
		rep(i,100*n+1){
			if(i+s > dp.size()) break;
			if(dp[i]) dp2[i+s] = true;
		}
		dp = dp2;
	}
	REP(i,dp.size()){
		if(dp[i] && i%10 != 0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int n,a,b;
cin >> n >> a >> b;
if(n*a>=b){
	cout << b << endl;
}
else{
	cout << n*a << endl;
}
///////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
n = int(input())
i = 1
t,h = 0,0
while i <= n:
    s1,s2 = map(str,input().split())
    if s1 < s2 :
        h += 3
    elif s1 > s2 :
        t += 3
    else:
        t += 1
        h += 1
    i += 1
print(t,h)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	int n;
	cin >> n;
	vector<int> b(n + 1), s(n + 2);
	inc1(i, n) { int a; cin >> a; b[a]++; }
	inc1(i, n) { s[1]++; s[b[i] + 1]--; }
	inc1(i, n) { s[i + 1] += s[i]; }
	inc1(i, n) { s[i + 1] += s[i]; }
	
	vector<int> ans(n + 2);
	inc1(i, n) { ans[s[i] / i] = i; }
	dec1(i, n) { setmax(ans[i], ans[i + 1]); }
	
	inc1(i, n) { cout << ans[i] << "\n"; }
	
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int keta(int n){
	int a = 0; 
	while(n > 0){
		a ++; 
		n /= 10; 
	}
	return a; 
}
int main(){
	int N, M; 
	cin >> N >> M; 
	pair<int, pair<int, int>> A[100010]; // pair<県, pair<年, 市番号>>
	for(int i = 0; i < M; i++){
		A[i].second.second = i + 1; 
		cin >> A[i].first >> A[i].second.first; 
	}
	sort(A, A+M); 
	int count = 1; 
	for(int i = 0; i < M; i++){ // これで年を番号に上書き
		A[i].second.first = count; 
		if(A[i].first == A[i+1].first){count ++;}
		else{count = 1;}
	}
    pair<pair<int, int>, int> B[100010]; // pair<pair<市番号, 県内で生まれた順番>, 県>
	for(int i = 0; i < M; i++){ 
		B[i].first.first = A[i].second.second; 
        B[i].first.second = A[i].second.first; 
        B[i].second = A[i].first; 
	}
	sort(B, B+M); 
	for(int i = 0; i < M; i++){ 
		for(int j = 0; j < 6 - keta(B[i].second); j++){
			cout << 0;  
		}
		cout << B[i].second; 
		for(int j = 0; j < 6 - keta(B[i].first.second); j++){
			cout << 0;  
		}
		cout << B[i].first.second << endl; 
	}	
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int k = scan.nextInt();
		int n = scan.nextInt();

		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}

		int min = a[n - 1] - a[0];
		for (int i = 1; i < n; i++) {
			min = Math.min(min, k - a[i] + a[i - 1]);
		}

		System.out.println(min);

		scan.close();
	}

}


Measured memory_bytes: 84692
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *right, *left, *parent;
};

struct Node *root, *NIL;

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

 z = (struct Node *)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(struct Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

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

int main(){
  int n,i,x;
  char com[1000];

  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%s",com);
    if(!strcmp(com,"insert")){
      scanf("%d",&x);
      insert(x);
    }
    else if(!strcmp(com,"print")){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 25296
N = int(input())
a = list(map(int,input().split()))
a.sort()
if a[0] == a[-1]:
    if a[0] == N-1 or a[0] <= N//2:
        print("Yes")
    else:
        print("No")
    exit()

if a[0] < a[-1]-1:
    print("No")
    exit()

o = 0
t = 0
for i in range(N):
    if a[i] != a[0]:
        o = i
        t = N-i
        break

if t//2 + o >= a[-1] > o:
    print("Yes")
else:
    print("No")



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

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    int ans = 0;
    for (char c : s) {
        if (c == '+')
            ++ans;
        else if (c == '-')
            --ans;
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#include<cmath>
#include<queue>
#include<stack>

#include<stdio.h>
#include<stdlib.h>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}

using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	long Array[100010] = { 0 };
	ll N;
	ll sum = 0;
	cin >> N;
	rep(i, N) {
		long A;
		cin >> A;
		sum += A;
		Array[A]++;
	}
	ll Q;
	cin >> Q;

	vector<ll> ans;

	rep(i, Q) {
		ll B, C;
		cin >> B >> C;

		ll diff = C - B;
		sum += Array[B] * diff;
		ans.push_back(sum);

		Array[C] += Array[B];
		Array[B] = 0;
	}

	for (auto x : ans) {
		cout << x << endl;
	}

EndPoint:;

	//Program End
#ifndef DEBUG
	system("pause");
#endif // !DEBUG

	return 0;
}




Measured memory_bytes: 5032
#include<iostream>
using namespace std;
int main(){
    long long  n,k;
    static long long _1,_2;
    cin>>n>>k;
    for(long long i=1;i<=n;i++){
        if(!(k%2)) {
            if(i%k == k/2) _2++;
        }
        if(i%k==0) _1++;
    }
    if(k%2 == 0) cout<<_1*_1*_1+_2*_2*_2;
    else cout<<_1*_1*_1;
}

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

int N, K;
int l[50];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> l[i];
	}
	sort(l, l + N);
	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += l[N - i - 1];
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n,a,b;
  std::cin >> n>>a>>b;
  if(a*n>b){std::cout << b<< '\n';}
  else std::cout << a*n << '\n';


  return 0;
}


Measured memory_bytes: 256
s = input()
cand1 = '10' * (len(s)//2) + '1' * (len(s)%2)
cand2 = '01' * (len(s)//2) + '0' * (len(s)%2)

print(min(sum([x != y for x, y in zip(s, cand1)]), sum([x != y for x, y in zip(s, cand2)])))

Measured memory_bytes: 4212
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define LL long long
#define ULL unsigned long long
#define P 1000000007
#define H 10007
#define mod(a,b) a-a/b*b
#define debug(x) cerr<<#x<<"="<<x<<endl
using namespace std;

int n,m,tmp1,tmp2;
int a[500];

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&tmp1,&tmp2);
		a[tmp1]++;
		a[tmp2]++;
	}
	for(int i=1;i<=n;i++)
	{
		printf("%d\n",a[i]);
	}
	return 0;
}


Measured memory_bytes: 256
x1,x2,x3,x4,x5 = (int(x) for x in input().split())
if x1 == 0:
  print(1)
if x2 == 0:
  print(2)
if x3 == 0:
  print(3)
if x4 == 0:
  print(4)
if x5 == 0:
  print(5)

Measured memory_bytes: 9128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int h, w;
  while (cin >> h >> w) {
    if (!h && !w)
      break;
    rep(i, 0, h) {
      rep(j, 0, w) {
        if ((i + j) & 1)
          cout << ".";
        else
          cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;

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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,A,B; cin >> N >> A >> B;
    cout << N/(A+B)*A+min(N%(A+B),A) << '\n';
}

Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
	int a,b,c,d;
	
	scanf("%d %d %d",&a,&b,&c);
	if(b < a){
		d=a;
		a=b;
		b=d;
	}
	else{
	} 
	
	if(c < b){
		d=c;
		c=b;
		b=d;
	}
	else{ 
	}
	if(b < a){
		d=a;
		a=b;
		b=d;
	}
	else{
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}


Measured memory_bytes: 2140
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //int answer = 0;
        String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        String S=sc.next();
        String s[]=new String[4];
        String ss="";
        String sss="";
        int count1=0;
        int count2=0;
        for (int i=0;i<4;++i)
        {
            s[i]=S.substring(i,i+1);
            if (i==0){ss=s[i]; ++count1;}
            else
            {
                if (ss.equals(s[i])) {++count1;}
                else if(sss.equals("")) { sss=s[i]; ++count2;}
                else if (sss.equals(s[i])) {++count2;}
            }
        }

        if (count1==2 && count2==2) {answer="Yes";}

        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}

Measured memory_bytes: 23764
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	weights := ScanNums(n)

	sum := 0
	for _, weight := range weights {
		sum += weight
	}

	minAbs := float64(sum)
	firstSum := 0
	for _, weight := range weights {
		firstSum += weight
		gapAbs := math.Abs(float64(sum-firstSum) - float64(firstSum))
		if gapAbs < minAbs {
			minAbs = gapAbs
		}
	}

	fmt.Println(int(minAbs))
}

func ScanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 512
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=50+5;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 1000000007
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,f[N][N],c[N][N];

inline int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
inline int mul(int x,int y) {return 1ll*x*y%maxd;}

int main()
{
    n=read();
    rep(i,0,n)
    {
        c[i][0]=1;
        rep(j,1,i) c[i][j]=add(c[i-1][j],c[i-1][j-1]);
    }
    f[1][0]=f[1][1]=n;
    rep(i,1,n-1) rep(j,0,i)
    {
        rep(k,j,n-i)
        {
            if ((!k) || (k-j)&1) continue;
            int y=(k-j)/2;
            rep(x,0,k)
            {
                f[i+k][abs(x-y)]=add(f[i+k][abs(x-y)],mul(f[i][j],mul(c[n-i][k],c[k][x])));
            }
        }
    }
    printf("%d\n",f[n][0]);
    return 0;
}

Measured memory_bytes: 256