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

#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)

#define X() real()
#define Y() imag()
#define x(p) (p).X()
#define y(p) (p).Y()
#define SZ(R) (int)(R).size()
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%SZ(P)]
#define prev(P, i) P[(i-1+SZ(P)%SZ(P)]

using D = double;
using P = complex<D>;
namespace std {
  bool operator < (const P& a, const P& b) {
    return x(a) != x(b) ? x(a) < x(b) : y(a) < y(b);
  }
}
D dot(const P& a, const P& b) {
  return x(conj(a)*b);
}
D cross(const P& a, const P& b) {
  return y(conj(a)*b);
}
int ccw(P a, P b, P c) {
  b -= a;
  c -= a;
  if(cross(b, c) > 0) return +1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}
struct L : public vector<P> {
  L(){}
  L(const P& a, const P& b) {
    push_back(a);
    push_back(b);
  }
};

using G = vector<P>;
const D EPS = 1e-8;
const D PI = acos(-1);

P makeP(D arg, D r = 1.0) {
  return r * P{cos(arg), sin(arg)};
}
P rotP(const P& p, D arg) {
  return p * makeP(arg);
}
D getArgP(const P& p) {
  return atan2(y(p), x(p));
}
D toRad(D deg) {
  return PI * deg / 180.0;
}

G makeStar(const P& p, D arg, D r) {
  G ret;
  P v{0.0, r};
  rep(i, 5) {
    ret.push_back(p + rotP(v, 2*PI/5*i+arg));
  }
  return ret;
}

bool interSP(const L& s, const P& p) {
  return abs(s[0] - p) + abs(s[1] - p) - abs(s[0]-s[1]) < EPS;
}
bool interSS(const L& s, const L& t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
    ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
P proj(const L& l, const P& p) {
  P v = l[0]-l[1];
  D t = dot(p - l[0], v) / norm(v);
  return l[0] + t*(v);
}
D distSP(const L& s, const P& p) {
  P r = proj(s, p);
  if(interSP(s, r)) return abs(r-p);
  return min(abs(s[0]-p), abs(s[1]-p));
}
D distSS(const L& s, const L& t) {
  if(interSS(s, t)) return 0.0;
  return min({distSP(s, t[0]), distSP(s, t[1]), distSP(t, s[0]), distSP(t, s[1])});
}

int main() {
  cout << fixed << setprecision(20);
  int n, a, b;
  while(cin >> n >> a >> b) {
    if(n == 0 && a == 0 && b  == 0) break;
    a--;
    b--;
    vector<G> gs;
    rep(i, n) {
      D x, y, a, r;
      cin >> x >> y >> a >> r;
      gs.push_back(makeStar(P{x, y}, toRad(a), r));
    }
    const D INF = 1e18;
    vector<vector<D>> d(n, vector<D>(n, INF));
    rep(i, n) d[i][i] = 0.0;
    using Ls = vector<L>;
    vector<Ls> v(n);
    rep(i, n) {
      rep(j, 5) {
	v[i].push_back(L{curr(gs[i], j), next(gs[i], j+1)});
      }
    }
    rep(i, n) rep(j, i) {
      double dist = INF;
      rep(k, 5) rep(l, 5) {
	dist = min(dist, distSS(v[i][k], v[j][l]));
      }
      d[i][j] = d[j][i] = min(d[i][j], dist);
    }

    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    cout << d[a][b] << endl;
  }
  return 0;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	LL a, b, k;
	cin >> a >> b >> k;
	if (a >= k) cout << a - k << ' ' << b << endl;
	else cout << 0 << ' ' << max(0LL, b - (k - a));
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[100005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int v[100005];
	for (i = 0; i <= n; i++)
		v[i] = 0;
	v[1] = 1;
	int now = 1;
	int ans = 0;
	while (now != 2)
	{
		now = a[now - 1];
		ans++;
		if (v[now] > 0)
		{
			printf("-1\n");
			return 0;
		}
		v[now]++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    reverse(sa.begin(), sa.end());
    reverse(sb.begin(), sb.end());
    reverse(sc.begin(), sc.end());

    char now=sa.back();
    sa.pop_back();
    while(1){
        if(now=='a'){
            if(sa.size()==0){
                cout<<'A'<<endl;
                break;
            }
            now=sa.back();
            sa.pop_back();
        }else if(now=='b'){
            if(sb.size()==0){
                cout<<'B'<<endl;
                break;
            }
            now=sb.back();
            sb.pop_back();
        }else{
            if(sc.size()==0){
                cout<<'C'<<endl;
                break;
            }
            now=sc.back();
            sc.pop_back();
        }
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int N, C; 
  cin >> N >> C;

  vector<int> x(N), v(N);
  REP(i, N) cin >> x[i] >> v[i];

  vector<int> sum(N+1, 0);
  REP(i, N) sum[i+1] += sum[i]+v[i];

  vector<int> R(N+1, 0);
  REP(i, N){
    chmax(R[i+1], max(R[i], sum[i+1]-x[i]));
  }

  vector<int> L(N+1, 0);
  RFOR(i, 1, N+1){
    chmax(L[i-1], max(L[i], sum[N]-sum[i-1]-(C-x[i-1])));
  }

  int ans = max(R[N], L[0]);
  REP(i, N){
    chmax(ans, R[i+1]-x[i]+L[i+1]);
    chmax(ans, L[i]-(C-x[i])+R[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin>>n;
    long long int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    long long int sum=0;
    for(int i=0;i<n;i++){
        sum=sum+b[i]-a[i];
    }
    bool jud=true;
    if(sum<0){
        jud=false;
    }
    long long int asum=0;
    long long int bsum=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            bsum=bsum+a[i]-b[i];
        }else if(a[i]<b[i]){
            if((a[i]-b[i])%2==0){
                asum=asum+(b[i]-a[i])/2;
            }else{
                asum=asum+(b[i]-a[i]+1)/2;
                bsum++;
            }
        }
    }
    if(2*asum-bsum-sum==0&&asum<=sum&&bsum<=sum){
        jud=true;
    }else{
        jud=false;
    }
    if(jud==true){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 384
from itertools import accumulate
n = int(input())
a = list(map(int,input().split()))
b = list(accumulate(a))
a_sum = sum(a)
dn = float("inf")


for i in range(n-1):
    dn = min(abs(a_sum - 2*b[i]) ,dn)
print(dn)

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

int main() {
  int N;
  cin >> N;
  
  rep (i, N) {
    string S;
    cin >> S;
    
    if (S == "Y") {  //黄色があったとき4種類
      cout << "Four" << endl;
      break;
    }
    if (i == (N - 1)) {  //全部確認して黄色がなかった場合 i=0だからN-1
      cout << "Three" << endl;
    }

  }
}


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

int main() {
	ll n;
	cin >> n;
	vector<pair<ll, ll>>ta(n);
	for (int i = 0; i < n; i++)cin >> ta.at(i).first >> ta.at(i).second;
	ll t = ta.at(0).first;
	ll a = ta.at(0).second;
	for (int i = 1; i < n; i++) {
		//tに合わせる場合
		ll t_t, a_t;
		if (t % ta.at(i).first == 0) {
			t_t = t;
			a_t = t_t / ta.at(i).first * ta.at(i).second;
		}
		else {
			t_t = ((t / ta.at(i).first) + 1) * ta.at(i).first;
			a_t = t_t / ta.at(i).first * ta.at(i).second;
		}
		//aに合わせる場合
		ll t_a, a_a;
		if (a % ta.at(i).second == 0) {
			a_a = a;
			t_a = a_a / ta.at(i).second * ta.at(i).first;
		}
		else {
			a_a = ((a / ta.at(i).second) + 1) * ta.at(i).second;
			t_a = a_a / ta.at(i).second * ta.at(i).first;
		}
		if (a_t < a) {t = t_a; a = a_a;}
		else if (t_a < t) { t = t_t; a = a_t; }
		else { t = min(t_t, t_a); a = min(a_t, a_a); }
	}
	cout << t+a << endl;
}

Measured memory_bytes: 256
#import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

S = input()

ans = 'x' * len(S)

print(ans)



Measured memory_bytes: 5104
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll INF = (ll)1e18;
const int N = 100100;
ll dist[N];
vector<pli> g[N];
int n, m;
set<pli> setik;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d%d", &n, &m);
	for (int i = 1; i < n; i++)
		g[i].push_back(mp(0, i - 1));
	while(m--) {
		int v, u;
		ll w;
		scanf("%d%d%lld", &v, &u, &w);
		v--;u--;
		g[v].push_back(mp(w, u));
	}
	for (int i = 0; i < n; i++)
		dist[i] = INF;
	dist[0] = 0;
	for (int i = 0; i < n; i++)
		setik.insert(mp(dist[i], i));
	while(!setik.empty()) {
		int v = setik.begin()->second;
		setik.erase(setik.begin());
		for (pli e : g[v]) {
			int u = e.second;
			ll w = dist[v] + e.first;
			if (w >= dist[u]) continue;
			setik.erase(mp(dist[u], u));
			dist[u] = w;
			setik.insert(mp(dist[u], u));
		}
	}
	if (dist[n - 1] == INF)
		printf("-1\n");
	else
		printf("%lld\n", dist[n - 1]);

	return 0;
}


Measured memory_bytes: 14848
#include <stdio.h>

struct Node { int o, p, q;};
struct Node x[10000];
int n;
void pre( int u) {
	if ( u == -1) {
		return ;
	}
	printf(" %d", u);
	pre( x[u].p);
	pre( x[u].q);
	
}

void in( int u) {
	if ( u == -1) {
		return ;
	}
	in( x[u].p);
	printf(" %d", u);
	in( x[u].q);
	
}

void post( int u) {

	if ( u == -1){
		return ;
	}
	post( x[u].p);
	post( x[u].q);
	printf(" %d", u);
	
}

int main() {
	int i, v, p, q, way;
	
	scanf("%d", &n);
	for ( i = 0; i < n; i++) {
		x[i].o = -1;
	}
	
	for ( i = 0; i < n; i++) {
		scanf("%d %d %d", &v, &p, &q);
		x[v].p = p;
		x[v].q = q;
		if ( p != -1) {
			x[p].o = v;
		}
		if ( q != -1) {
			x[q].o = v;
		}
	}
	
	for ( i = 0; i < n; i++) {
		if ( x[i].o == -1) {
			way = i;
		}
	}
	printf("Preorder\n");
	pre(way);
	printf("\n");
	printf("Inorder\n");
	in(way);
	printf("\n");
	printf("Postorder\n");
	post(way);
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 1808
#include <stdio.h>

int main(){
  int i,j,k,h,w,n,m,l,o,p[11],t,u,c[11][2],a[1005],e,f,g;
  char s[1001];
  scanf("%d",&h);
  scanf("%d",&w);
  scanf("%d",&k);
  m=h*w;
  for(i=0;i<w;i++) a[i]=0;
  for(i=0;i<h;i++){
    scanf("%s",s);
    for(j=0;j<w;j++){
      a[j]<<=1;
      a[j]|=s[j]-'0';
    }
  }
  for(l=0;l<(1<<(h-1));l++){
    o=l;
    u=0;
    for(i=0;i<h-1;i++){
      p[i]=(o&1);
      if(p[i]){
        c[u][0]=0;
        c[u][1]=0;
        u++;
      }
      o>>=1;
    }
    c[u][0]=0;
    c[u][1]=0;
    f=0;
    g=u;
    for(i=0;(i<w)&&(f==0);i++){
      t=0;
      for(j=0;j<h;j++){
        c[t][1]+=(a[i]>>j)&1;
        if(c[t][1]>k){
          f=1;
          break;
        }
        if(p[j]||(j==h-1)){
          c[t][0]+=c[t][1];
          if(c[t][0]>k){
            for(o=0;o<=u;o++){
              c[o][0]=c[o][1];
            }
            g++;
          }
          t++;
        }
      }
      for(j=0;j<=u;j++){
        c[j][1]=0;
      }
    }
    if(f==0){
      if(g<m) m=g;
    }
  }
  printf("%d",m);
  return(0);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;


int N;

bool check(const vector<pair<ld, ld>>&cs, const ld amid) {
	map<ld, int>mp;
	for (auto c : cs) {
		ld r = c.second;
		ld x = c.first;
		if (r < amid)continue;
		else if (r > amid) {
			ld dis = sqrt(r*r - amid*amid);
			mp[x - dis]++;
			mp[x + dis]--;
		}
	}
	ld pre = -1;
	int num = 0;
	ld len = 0;
	bool preok = false;
	for (auto m : mp) {
		num += m.second;
		if (num) {
			if (!preok) {
				pre = m.first;
			}
			len = max(len, m.first - pre);
			preok = true;
			
			
		}
		else {
			if (num < 0)assert(false);
			if (preok) {
				len = max(len, m.first - pre);
				pre = -1;
			}
			preok = false;
		}
	}
	return amid*2 < len;
}
int main() { 
	while (1) {
		cin >> N;
		if (!N)break;
		vector<pair<ld, ld>>cs;
		for (int i = 0; i < N; ++i) {
			int x, r; cin >> x >> r;
			cs.push_back(make_pair(x, r));
		}
		ld amin = 0;
		ld amax = 2e6;
		int atime = 40;
		while (atime--) {
			ld amid = (amin + amax) / 2;
			if (check(cs, amid)) {
				amin = amid;

			}
			else {
				amax = amid;
			}
		}
		cout << setprecision(22) << fixed << amin*2 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 12516
#include<stdio.h>

int max(int a,int b){
        int z;
        if(a>b){
            z = a;
            if(z-1>b){
              z = z+(z-1);   
            }else{
                z = z+b;
            }
        }else{
            z=b;
            if(z-1>a){
                z = z+(z-1);
            }else{
                z = z+a;
            }
        }
        return z;
}
    

int main(void){
    int a;
    int b;
    int z;
    scanf("%d %d", &a,&b);
    z = max(a,b);
    printf("%d",z);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var X = ReadLong();
            switch (X)
            {
                case 7:
                case 5:
                case 3:
                    return "YES";
                default:
                    return "NO";
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27484
#include<iostream>
using namespace std;
int main(){
	string n;
	while(cin >> n){
		for(int i = 0; i < 9; i++){
			string ans = "";
			for(int j = 1; j < n.size(); j++){
				int a = n[j-1]-'0',b = n[j]-'0';
				ans += ((a + b) % 10) + '0';
			}
			n = ans;
		}
		cout << n << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
# 24
# ALDS_11_B - 深さ優先探索

from collections import deque

n = int(input())
u_l = []
k_l = []
v_l = []
for i in range(n):
    _in = input()
    _v_l = []
    for j,_ in enumerate(_in.split()):
        if j == 0:
            u_l.append(int(_))
        elif j == 1:
            k_l.append(int(_))
        else:
            _v_l.append(int(_))
    v_l.append(_v_l)

def dfs(v):
    global count
    c_l[v] = True
    d_l[v] = count
    count += 1
    for i in range(k_l[v]):
        _v = v_l[v][i]-1
        if not c_l[_v]:
            dfs(_v)
    f_l[v] = count
    count += 1

d_l = [None]*n
f_l = [None]*n
c_l = [False]*n
count = 1
while False in c_l:
    dfs(c_l.index(False))

for idx, d, f in zip(list(range(1,n+1)), d_l, f_l):
    print(idx, d, f)


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

int main(){
    int x, n;
    cin >> x >> n;
    if(n == 0){
        cout << x;
        return 0;
    }
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];

    sort(p.begin(), p.end());

    int idx = 0;
    int ans = 0;
    for(int i = 0; i <= 101; i++){
        if(p[idx] == i){
            idx++;
            continue;
        }
        if(abs(i-x) < abs(ans-x)) ans = i;
    }
    cout << ans;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
const ll MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll K,N=50;
  cin>>K;
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    a[i]=i;
  }
  for(int i=0;i<N;i++){
    a[i]+=K/N;
  }
  for(int i=0;i<K%N;i++){
    a[i]+=N+1;
    for(int j=0;j<N;j++){
      a[j]--;
    }
  }

  cout<<N<<endl;
  for(int i=0;i<N-1;i++){
    cout<<a[i]<<' ';
  }
  cout<<a[N-1]<<endl;
}


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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair <int,int>
#define piii pair < pii, int>
#define pll pair <long long , long long>
#define plll pair <pll , long long>
#define y11 y1
typedef long long ll;

int n,ans,l[500];

int main()
{
	ios:: sync_with_stdio(false);
	cin >> n;
	for(int i=0;i<2*n;i++)
		cin >> l[i];
	sort(l,l+2*n);
	for(int i=0;i<2*n;i+=2)
		ans+=l[i];
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import heapq

n, k = map(int, input().split())
h = []
d = [0 for _ in range(n)]
ans = float('inf')

for _ in range(n):
    # h.append(int(input()))
    heapq.heappush(h, int(input()))

h = [heapq.heappop(h) for _ in range(n)]

for i in range(n - k + 1):
    diff = h[i + k - 1] - h[i]
    ans = min(ans, diff)

print(ans)

Measured memory_bytes: 8248
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ca=Counter(a)
cb=Counter(b)
for k in cb:
    if k in ca:
        if cb[k]+ca[k]>n:
            print('No')
            exit()
tmpc=0
tmpd=0
c=[0]
d=[0]
for i in range(1,n+1):
    if i in ca:tmpc+=ca[i]
    if i in cb:tmpd+=cb[i]
    c.append(tmpc)
    d.append(tmpd)
x=0
for i in range(n+1):
    x=max(x,c[i]-d[i-1])
ans=b[-x:]+b[:-x]
print('Yes')
print(*ans,sep=' ')
exit()
print(c)
print(d)

Measured memory_bytes: 173780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

    public static void main(String[] args) throws IOException {
        // write your code here

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(reader.readLine());

        System.out.println(2*3.14*n);

    }
}


Measured memory_bytes: 33304
def int2char(i):
    return chr(ord("a") + i - 1)

N = int(input())

ans = ""
while (True):
    N_lsb_int = ((N - 1) % 26) + 1
    N_next = int((N - N_lsb_int)/26)
    ans = int2char(N_lsb_int) + ans
    if N_next == 0:
        break
    N = N_next

print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   int a,b,c;
   cin>>a>>b>>c;
   a*=10;
   a+=b;
   a*=10;
   a+=c;
   if(a%4==0)
    cout<<"YES"<<endl;
   else
    cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define vi vector<int>
#define MAX_N 200005
#define i197 1000000007

using namespace std;


typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,P1> P2;
const int inf=1000000000;
P1 xy[MAX_N]={};

int main() {
	int a[12];
	rep(i,12)cin>>a[i];
	sort(a,a+12);
	bool flg=true;
	rep(i,3){
		rep(k,3){
			if(a[i*4+k]!=a[i*4+k+1])flg=false;
		}
	}
	yesno(flg);
	return 0;
}



Measured memory_bytes: 6212
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
s = S()

tmp = ""
ans = 0
for i in range(n):
    if s[i] != tmp:
        ans += 1
    tmp = s[i]
print(ans)

Measured memory_bytes: 39408
#include <stdio.h>
 
#define INF 1e9
#define MAX 101

int min(int a,int b){
  if(a<b) return a;
  return b;
}
 
int main(){
  int n,i,u,k,j,v,c;
  int d[MAX][MAX];
 
  for(i = 0 ; i < MAX ; i++){
    for(j = 0 ; j < MAX ; j++){
      d[i][j] = INF;
    }
    d[i][i] = 0;
  }
 
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%d%d" ,&u ,&k);
    
    for(j = 0 ; j < k ; j++){
      scanf("%d%d" ,&v ,&c);
      d[u][v] = c;
    }
  }
 
  for(k = 0 ; k < n ; k++){
    for(i = 0 ; i < n ; i++){
      for(j = 0 ; j < n ; j++){
    d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
 
  for(i = 0 ; i < n ; i++){
    printf("%d %d\n" ,i ,d[0][i]);
  }
 
  return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod=1000000007;
//head

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

    int n, m;
    cin >> n >> m;
    const int nax = 1e5+2;
    vi adj[nax];

    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    queue<int> q;
    vector<int> prev(n+1,1 << 30);
    q.push(1);
    prev[1] = 0;
    vector<bool> vis(n+1,false);
    vector<int> dist(n+1,1<<30);
    dist[1] = 0;
    while(!q.empty()) {
        int u = q.front(); q.pop();
        vis[u] = true;

        trav(v,adj[u]) {
            if(!vis[v] && dist[u] + 1 < dist[v]) {
                dist[v] = dist[u] + 1;
                prev[v] = u;
                q.push(v);
            }
        }
    }
    bool ok = true;
    for(int i = 1; i <= n; i++) {
        if(prev[i] == (1 << 30)) ok = false;
    }
    if(ok) {
        cout << "Yes" << endl;
        for(int i = 2; i <= n; i++) {
            cout << prev[i] << endl;
        }
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 10544
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;

class LowLink{
public:
	int n, cnt1;
	vector<vector<int> > G, G2;	//G2は作ったグラフ(木)
	vector<int> pre, low, cmp, used;	//cmpは作成後のindex
	void init(int m){
		n = m;cnt1 = 0;
		pre.resize(n);low.resize(n);used.resize(n);
		G.resize(n);G2.resize(n);cmp.resize(n);
		fill(all(pre), -1);
	}
	void add_edge(int x, int y){
		G[x].pb(y);G[y].pb(x);
	}
	int dfs(int v = 0, int par = -1){	//橋の検出
		if(pre[v] >= 0)return pre[v];
		pre[v] = low[v] = cnt1++;
		rep(i,G[v].size())if(par != G[v][i]){
			int res = dfs(G[v][i], v);
			low[v] = min(low[v], res);
		}
		return low[v];
	}
	int build(int v = 0, int x = 0){	//橋のみを残した木の構築
		int mx = x;cmp[v] = x;
		used[v] = 1;
		rep(i,G[v].size())if(!used[G[v][i]]){
			if(pre[G[v][i]] == low[G[v][i]]){			//橋
				G2[cmp[v]].pb(x+1);G2[x+1].pb(cmp[v]);
				chmax(mx, build(G[v][i], x+1));x++;
			}else chmax(mx, build(G[v][i], cmp[v]));
		}
		return mx;
	}
	int lowlink(){
		rep(i,n)if(!used[i])dfs(i);
		fill(all(used), 0);
		int k = 0;
		rep(i,n)if(!used[i])k += (build(i, k)-k)+1;
		return k;
	}
};

vector<vector<int> > ans;
vector<vector<int> > G, G2;
signed main(){
	LowLink low;
	int n, m;
	scanf("%lld%lld", &n, &m);
	G.resize(n);
	low.init(n);
	ans.resize(n);
	rep(i,m){
		int v, u;
		scanf("%lld%lld", &v, &u);
		low.add_edge(v, u);
		G[v].pb(u);G[u].pb(v);
	}
	int size = low.lowlink();
	vector<vector<int> > G2 = low.G2;
	vector<int> cmp = low.cmp;
	rep(i,n){
		rep(j,G[i].size()){
			int from = cmp[i], to = cmp[G[i][j]];
			if(from != to and i < G[i][j])ans[i].pb(G[i][j]);
		}
	}
	rep(i,n){
		ZIP(ans[i]);
		rep(j,ans[i].size())printf("%lld %lld\n", i, ans[i][j]);
	}
	//ZIP(ans);
	//size = ans.size();
	//rep(i,size)printf("%lld %lld\n", ans[i].fi, ans[i].se);
	return 0;
}







Measured memory_bytes: 7604
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	ll a, b;
	int k;
	cin >> a >> b >> k;
	for(int i=0; i<k; i++){
		if(i%2==0){
			if(a%2==1) a--;
			a/=2;
			b+=a;
		}else{
			if(b%2==1) b--;
			b/=2;
			a+=b;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}


#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  ll N;
  vector<pair<ll, ll>> r, b;
  cin >> N;
  rep(i, N){
    ll x, y;
    cin >> x >> y;
    r.push_back(make_pair(x, y));
  }
  rep(i, N){
    ll x, y;
    cin >> x >> y;
    b.push_back(make_pair(x, y));
  }

  sort(all(r));
  sort(all(b));
  // dump(r);
  // dump(b);

  ll res = 0;
  rep(i, b.size()){
    vector<pair<ll, ll>> cands;
    rep(j, r.size()){
      if(b[i].first > r[j].first && b[i].second > r[j].second){
        cands.push_back(r[j]);
      }
    }
    sort(all(cands), [](auto && lhs, auto && rhs){return lhs.second < rhs.second;});
    if(cands.size()){
      // dump(b[i]);
      // dump(cands);
      // b.erase(b.begin() + i);
      r.erase(find(all(r), cands[cands.size() - 1]));
      res++;
    }
  }
  // dump(r);
  // dump(b);
  cout << res;
}
#endif


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int a[5];
int main ()
{
	int x,y,z,ans=0;
	cin>>x>>y>>z;
	a[0]=x,a[1]=y,a[2]=z;
	sort(a,a+3);
	while(a[0]!=a[2])
	{
		if(a[0]!=a[1])
		{
			a[0]+=2;
			ans++;
		}
		else
		{
			a[1]++;
			a[0]++;
			ans++;
		}
		sort(a,a+3);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=100010;
int a[maxn],n;
ll ans=1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int t=0;
	for(int i=n;i>=2;i--)
		if(a[i]==a[i-1]) 
		{
			ans=ans*a[i];
			t++;
			i--;
			if(t==2) break;
		}	
	if(t<2) puts("0");
	else printf("%lld",ans);	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    ll n, b, r; cin >> n >> b >> r;
    ll unit = b + r;
    ll ans = n / unit * b;
    if(n % unit <= b) ans += n % unit;
    else ans += b;
    cout << ans << endl; 
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> done(n + 1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        done[a] ^= 1;
        done[b] ^= 1;
    }

    bool check = 0;
    for (int i = 1; i <= n; i++) {
        check |= done[i];
    }

    if (!check) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn = int(input())
    stdOut = solve(stdIn)
    print(stdOut)

"""
方針


"""

def solve(stdIn):
    if stdIn == 0:
        return 1
    return 0

if __name__ == "__main__":
    main()


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

int main()
{
    int N;
    cin >> N;  
    vector<vector<int>> G(N);
    vector<pair<int, int>> vp;
    for (int i=1; i<N; ++i) {
        int a, b;
        cin >> a >> b;
        G[--a].emplace_back(--b);
        G[b].emplace_back(a);
        vp.emplace_back(a, b);
    }

    int K = 0;
    map<pair<int, int>, int> I;
    vector<int> cs(N, 0);

    vector<int> used(N, 0);
    queue<int> que;
    used[0] = 1;
    que.emplace(0);
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        if (K < (int)G[v].size()) K = G[v].size();
        int cur = 1;
        for (int u: G[v]) {
            if (used[u]) continue;
            if (cur == cs[v]) cur++;
            cs[u] = I[make_pair(u, v)] = I[make_pair(v, u)] = cur++;
            used[u] = 1;
            que.emplace(u);
        }
    }

    cout << K << endl;
    for (auto p:vp) cout << I[p] << endl;
}

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

int main(){
	char a,b;
	cin>>b;
	for(int i=0;i<3;++i){
		a=b;cin>>b;
		if(a==b){
			printf("Bad");
			return 0;
		}
	}
	printf("Good");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int a[5];
  	for(int i=0;i<5;i++){
    	cin>>a[i];
    }
  int j=0,c;
  	for(j=0;j<5;j++){
    	if(a[j]==0){
          c=j+1;
          break;
        }}
  cout<<c;
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
int main(){int n,i;
cin>>n;
int h[n+3],dp[n+3];
for(i=1;i<=n;i++){cin>>h[i];}
dp[1]=0;dp[2]=abs(h[2]-h[1]);
for(i=3;i<=n;i++){dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));}
cout<<dp[n];
    return  0;}

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

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl

using namespace std;

int main(){
    string s;
    cin >> s;
    Yes((s.at(0) != s.at(1)) && (s.at(1) != s.at(2)) && (s.at(2) != s.at(0)));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int solve(int n) {
  int i = 0;
  while(n>0) {
    n/=10;
    i++;
  }
  return i;
}
int main() {
  int n; cin>>n;
  int ans=0;
  for (int i = 1; i <= n; i++) {
    if (solve(i)%2==1) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


char pr[100];

main(){
	double d;
	while(cin>>d){
		if(d<0)break;
		
		
		memset(pr,0,sizeof(pr));
		
		for(int i=0;i<13;i++){
			if(i<8){
				if(d>=pow(2,7-i)){
					d-=pow(2,7-i);
					pr[i]='1';
				}else{
					pr[i]='0';
				}
			}else if(i==8){
				pr[i]='.';
			}else{
				if(d>=pow(2,8-i)){
					d-=pow(2,8-i);
					pr[i]='1';
				}else{
					pr[i]='0';
				}
			}
		}
		
		if(d!=0)puts("NA");
		else puts(pr);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if((a-b)>c){
    printf("%d\n",0);
    return 0;
  }
  printf("%d\n",c-(a-b));  
  return 0;
}


Measured memory_bytes: 128
#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() {
  string S;
  cin >> S;
  if ((S[2] == S[3]) && (S[4] == S[5])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b, c;
	cin >> a >> b >> c;
	if(c >= a && c <= b) cout <<"Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
  int x,a,b;cin>>x>>a>>b;
  if (b <= a) cout << "delicious";
  else if (b <= a + x) cout << "safe";
  else cout << "dangerous";
}


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

typedef long long ll;
using namespace std;

int main() {
  int N, a[100010], cnt = 0;
  ll ans = 1;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }

  sort(a, a + N, greater<int>());
  int pre = a[0], pos = 1;
  do {
    if (pre == a[pos]) {
      ans *= pre;
      cnt++;
      pre = a[pos + 1];
      pos += 2;
    } else {
      pre = a[pos];
      pos++;
    }
  } while(pos <= N + 1 && cnt < 2);

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


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

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

    int n; cin >> n;
    vi a(n+1); forn(i,n) cin >> a[i+1];
    sort(all(a));
    for (int i = 1; i < si(a); i += 2) a[i] = 24-a[i];
    sort(all(a)); a.pb(24);

    int ans = 24;
    forn(i,si(a)-1) ans = min(ans, a[i+1] - a[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

c = (len(s)-1) // 2

l = s[:c]
r = s[-c::][::-1]

ss = s[(n+3)//2-1:]
nn = len(ss)
cc = (nn-1) // 2
ll = ss[:cc]
rr = ss[-cc::][::-1]

if n == 3:
    if s[0] == s[-1]:
        print('Yes')
    else:
        print('No')
elif l == r and ll == rr:
    print('Yes')
else:
    print('No')




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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<bool> c(8, false);
  for(int i=0; i<n; i++) {
    cin >> a.at(i);
  }
  int r1 = 0;
  int r2 = 400;
  int o = 0;
  for(int i=0; i<8; i++) {
    for(int j=0; j<n; j++) {
      if(a.at(j) >= r1 && a.at(j) < r2) {
        c.at(i) = true;
      }
    }
    r1 += 400;
    r2 += 400;
  }
  for(int i=0; i<n; i++) {
    if(a.at(i) >= 3200) {
      o++;
    }
  }
  int ans = 0;
  for(int i=0; i<8; i++) {
    if(c.at(i)) {
      ans++;
    }
  }
  int ans1 = ans;
  if(ans1 == 0) {
    ans1++;
  }
  int ans2 = ans+o;
  cout << ans1 << " " << ans2 << endl;
}

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

int main() {
    int N;
    cin >> N;
    int ans, p;
    for (int i = 1; i <= N; i++) {
        ans = i * (1 + i) / 2;
        if (ans >= N) {
            p = i;
            break;
        }
    }
    for (int i = 1; i <= p; i++) {
        if (i == ans - N) continue;
        cout << i << endl;
    }
}

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

int compare(std::string a, std::string b)
{
    for(int i = 0; i < a.size() && b.size(); ++i){
        if(a[i] > b[i]) return 1;
        if(a[i] < b[i]) return -1;
    }
    if(a.size() == b.size()) return 0;
    if(a.size() >  b.size()) return 1;
    return -1;
}

int main()
{
    int taro = 0;
    int hana = 0;
    int n;
    std::cin >> n;
    for(int i = 0; i < n; i++){
        std::string t;
        std::string h;
        std::cin >> t >> h;
        // if(compare(t,h) < 0){
        if(t.compare(h) < 0){
            hana += 3;
        }else
        // if(compare(t,h) > 0){
        if(t.compare(h) > 0){
            taro += 3;
        }else{
            hana += 1;
            taro += 1;
        }
    }
    std::cout << taro << " " << hana << std::endl;
    return 0;
}

Measured memory_bytes: 3164
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []
for i in range(M):
  a, b = (map(int, input().split()))
  A.append(a)
  B.append(b)

flg = [1] * N
for i in range(M):
  if flg[A[i]-1] == 1 and H[A[i]-1] <= H[B[i]-1]:
    flg[A[i]-1] = 0

for i in range(M):
  if flg[B[i]-1] == 1 and H[A[i]-1] >= H[B[i]-1]:
    flg[B[i]-1] = 0

print(sum(flg))

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

int main() {
	// your code goes here
	long long int a,b;
	long long int miner,maxer;
	while(cin >> a >> b){
		int a2=a,b2=b;
		while(max(a2,b2)%min(a2,b2)!=0){
			if(a2>b2)
			a2=a2-b2;
			else
			b2=b2-a2;
		}
		miner =min(a2,b2);
		cout << miner << " " ;
		cout << a/miner*b << endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      	int max = 0;
      	int count = 0;
      	for(int i=0;i<s.length();i++){
          if( s.charAt(i) == 'R' ){
            count++;
          }else{
            count = 0;
          }
          if( max < count ){
            max = count;
          }
        }
      System.out.println(max);
	}
}

Measured memory_bytes: 26896
#include <iostream>
using namespace std;
int main() {
  int A[100][100];
  int b[100];
  long c[100] = {};
  int i, j, n, m;
  cin >> n >> m;
  for(i = 0; i < n; i++) {
	for(j = 0; j < m; j++) {
	  cin >> A[i][j];
	}
  }
  for(j = 0; j < m; j++) {
	cin >> b[j];
  }

  for(i = 0; i < n; i++) {
	for(j = 0; j < m; j++) {
	  c[i] += A[i][j] * b[j];
	}
	cout << c[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
def divisors(N):
    U = int(N ** 0.5) + 1
    L = [i for i in range(1, U) if N % i == 0]
    return L + [N // i for i in reversed(L) if N != i * i]

N, K = map(int,input().split())
A = list(map(int,input().split()))
for d in reversed(divisors(sum(A))):
    R = sorted(a % d for a in A)
    # print(d,R,-sum(R) // d,sum(R[:-sum(R) // d]))
    if sum(R[:-sum(R) // d]) <= K:
        print(d)
        quit()



Measured memory_bytes: 41692
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<set>

int main(){
  int x,y;
  cin>>x>>y;
  if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
    cout<<"Yes"<<endl;
    return 0;
  }

  if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
    cout<<"Yes"<<endl;
    return 0;
  }

  if(x==2&&y==2){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

vector<int> tree[200000];
int color[200000];

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

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    queue<PII> que;
    que.push(make_pair(0, 1));
    color[0] = 1;
    que.push(make_pair(N - 1, -1));
    color[N - 1] = -1;

    while (!que.empty()) {
        auto res = que.front(); que.pop();
        int v = res.first,
            c = res.second;
        for (int to : tree[v]) {
            if (color[to] != 0) continue;
            que.push(make_pair(to, c));
            color[to] = c;
        }
    }
    int w = 0, b = 0;
    for (int v = 0; v < N; v++) {
        if (color[v] == 1) b++;
        else w++;
    }
    if (b > w) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }

    return 0;
}


Measured memory_bytes: 8704
#include <iostream> // cout, endl, cin
#include <vector> // vector
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
    }
    int a,counter,counter_min;
     for(int i=0;i<N;i++){
        a=A.at(i);
        counter=0;
        while(a%2==0){
            a=a/2;
            counter++;
        }
        if(counter<counter_min) counter_min=counter;
    }
    cout<<counter_min<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int fdepth[100000], sdepth[100000];
vector<int> tree[100000];
void dfs1(int v, int p) {
  for(int i = 0; i < tree[v].size(); i++) {
    int to = tree[v][i];
    if (to != p) {
       fdepth[to] = fdepth[v] + 1;
       dfs1(to, v);
    }
  }
}
void dfs2(int v, int p) {
  for(int i = 0; i < tree[v].size(); i++) {
    int to = tree[v][i];
    if (to != p) {
       sdepth[to] = sdepth[v] + 1;
       dfs2(to, v);
    }
  }
}
int main(void) {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  fdepth[0] = 0;
  sdepth[n - 1] = 0;
  dfs1(0, -1);
  dfs2(n - 1, -1);
  int f = 0, s = 0;
  for (int i = 0; i < n; i++) {
    if (fdepth[i] <= sdepth[i]) f++;
    else s++;
  }
  cout << (f > s ? "Fennec" : "Snuke") << endl;
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<long> h(n);
    for(auto& i : h) cin >> i;
    int c = 0;
    int mc = 0;
    for(int i = n-1; i > 0; i--){
        if(h.at(i) <= h.at(i-1)) c++;
        else mc=max(mc, c), c=0;
    }
    mc=max(mc, c);
    cout << mc << endl;
    return 0;
}


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

int main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i) cin>>a[i];
    
    sort(a,a+n,greater<int>());
    int A=0,B=0;
    for(int i=0;i<n;i+=2){
        A+=a[i];
    }
    for(int j=1;j<n;j+=2){
        B+=a[j];
    }
    cout<<(A-B)<<endl;
    
    return 0;
}

Measured memory_bytes: 256