akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
	char toy[201],mask[201];
	int s,m,i;
	
	while(1)
	{
		scanf("%s",toy);
		strcpy(mask,toy);
		
		if(strcmp(toy,"-")==0)
			break;
		
		scanf("%d",&s);
		
		for(i=0;i<s;i++)
		{
			scanf("%d",&m);
			strcpy(toy,&mask[m]);
			strncpy(&toy[strlen(toy)],mask,m);
			strcpy(mask,toy);
		}
		
		printf("%s\n",toy);
		
	}
	
	
	return 0;
}

Measured memory_bytes: 596
N, M = map(int, input().split())
D = {i: [] for i in range(N)}
for i in range(M):
  a, b = map(int, input().split())
  D[a-1].append(b-1)
  D[b-1].append(a-1)
R = [-1 for _ in range(N)]
R[0] = 0
p = [0]
pnt = 0
cnt = 1
while cnt < N:
  n = cnt
  for i in range(pnt, cnt):
    x = D[p[i]][:]
    for k in x:
      if R[k] == -1:
        R[k] = p[i]+1
        cnt += 1
        p.append(k)
  pnt = n
print("Yes")
for i in range(1, N):
    print(R[i])

Measured memory_bytes: 44852
#include<stdio.h>
int main( void )
{
	short i ;
	short pas, juice ;
	short sum = 2001, min = 2001 ;
	for( i = 0 ; i < 3 ; i++ )
	{
		scanf( "%d", &pas ) ;
		if( sum > pas )
		{
			sum = pas ;
		}
	}
	for( i = 0 ; i < 2 ; i++ )
	{
		scanf( "%d", &juice ) ;
		if( min > juice )
		{
			min = juice ;
		}
	}
	sum += min ; 
	printf( "%d\n", sum - 50 ) ;
	return 0 ;
}

Measured memory_bytes: 592
import sys

N, K = [int(s) for s in raw_input().split()]
ws = [int(raw_input()) for _ in xrange(N)]
lo, hi = max(ws), 100000 * 10000

while lo != hi:
    p = P = (lo + hi) / 2
    k = 1
    for w in ws:
        if w > p:
            p = P
            k += 1
        p -= w
    if k <= K:
        hi = P
    else:
        lo = P + 1

print lo

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 305;
int N;
int A[MAX_N];
int B[2];

bool check(int depth) {
  bool ret = B[0] + B[1] <= A[0] + A[1] && B[0] <= A[0];

  ret &= A[0] + A[1] <= B[0] + B[1] + 2*(((LL)1 << depth)-1);

  return ret;
}

int solve(int gXor, int depth = 40) {
  if (0 <= depth) {
    int ret = INF_LL;
    if ((gXor >> depth) & 1) {
      B[0] |= ((LL)1 << depth);
      if (check(depth)) {
        ret = min(ret, solve(gXor, depth-1));
      }
      B[0] &= ~((LL)1 << depth);

      B[1] |= ((LL)1 << depth);
      if (check(depth)) {
        ret = min(ret, solve(gXor, depth-1));
      }
      B[1] &= ~((LL)1 << depth);
    } else {
      if (check(depth)) {
        ret = min(ret, solve(gXor, depth-1));
      }

      B[0] |= ((LL)1 << depth);
      B[1] |= ((LL)1 << depth);
      if (check(depth)) {
        ret = min(ret, solve(gXor, depth-1));
      }
      B[0] &= ~((LL)1 << depth);
      B[1] &= ~((LL)1 << depth);
    }
    return ret;
  } else {
    if (abs(A[0] - B[0]) == abs(A[1] - B[1]) && B[0] <= A[0] && A[1] <= B[1] && B[0] != 0) {
      return abs(A[0] - B[0]);
    } else {
      return INF_LL;
    }
  }
}

signed main()
{
  cin >> N;
  REP(n,N) {
    cin >> A[n];
  }

  int gXor = 0;
  REP(n,N) {
    gXor ^= A[n];
  }

  if (gXor == 0) {
    cout << 0 << endl;
    return 0;
  }

  gXor ^= A[0];
  gXor ^= A[1];

  int ans = solve(gXor);
  if (ans == INF_LL) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

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

    string N;
    cin >> N;

    int n = N.size();
    int prev_carry = 0;
    ll sum = 0;

    rrep(i, 0, n) {
        int ni = int(N[i] - '0');

        bool carry;
        if (i != 0 && prev_carry + ni == 5 && int(N[i - 1] - '0') >= 5) {
            carry = true;
        } else if (prev_carry + ni <= 5) {
            carry = false;
        } else {
            carry = true;
        }

        if (carry) {
            sum += 10 - (prev_carry + ni);
            prev_carry = 1;
        } else {
            sum += prev_carry + ni;
            prev_carry = 0;
        }
    }

    cout << sum + prev_carry << endl;
    return 0;
}

Measured memory_bytes: 1948
//......................................................//
//....THIS CODE IS WRITTEN BY PRATEEK MITTAL..........//
//................PDPM IIIT JABALPUR .................//

#include<bits/stdc++.h>
#define lint long long int 
using namespace std;

int main()
{
        lint n,a,b;
        cin>>n>>a>>b;
        lint diff=b-a;
        if(diff%2==0)
        cout<<"Alice"<<endl;
        else
        cout<<"Borys"<<endl;
        return 0;
}

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

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  ll sum = 0;
  rep(i,n) {
    cin >> a[i];
    sum += a[i];
  }
  sum = (sum + 4 * m - 1) / (4 * m);

  int cnt = 0;

  for (int i = 0; i < n; i++) {
    if (a[i] >= sum) cnt++; 
  }
  if (cnt >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n=0;
  cin>>n;
  if(n==0){
    cout<<2<<endl;
    return 0;
  }else if(n==1){
    cout<<1<<endl;
    return 0;
  }
  long long int prev=2;
  long long int prev2=1;
  for(int i=2;i<=n;i++){
    long long int temp=prev2;
    prev2+=prev;
    prev=temp;
  }
  cout<<prev2<<endl;
  return 0;
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int X, Y, Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}


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

using namespace std;

int v[110][2];
long long dp[110][100010];
int n,w;

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

    for (int i = 1; i <= n; ++i) 
        cin >> v[i][0] >> v[i][1];

    
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= w; ++j) {
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if(j - v[i][0] >= 0)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - v[i][0]] + v[i][1]);
        }
    }
    cout << dp[n][w] << "\n";
    return 0;
}


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

int main() {
  int A,B,C,D,x,y;
  cin>>A>>B>>C>>D;
  x=(C-1)/B+1;
  y=(A-1)/D+1;
  if(x<=y)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;
int tab[1000000];
int main()
{
    int n , m  ;
    cin >> n >> m ;
    int ans = 0 ;
    for(int i = 0 ; i< m ; i++){
        int a , b ;
        cin >> a >> b ;
        if(tab[a]) ans-- , tab[a]--;
        else tab[a]++ , ans++;
        if(tab[b]) ans-- , tab[b]--;
        else tab[b]++ , ans++;
    }
    if(!ans)cout <<"YES";
    else cout <<"NO";
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 1<<20|3, mod = 1e9+7;
int n,maxn,a[N],pre[N],s[N],s2[N],f[N];
poly v[N];

inline int Mod(int x){
	return x>=mod?x-mod:x;
}

int main(){
	n=read(),pre[0]=1;
	For(i,1,n){
		a[i]=read(),a[i]=a[i-1]^a[i],v[a[i]].pb(i);
		pre[i]=pre[i-1]+(a[i]==0);
	}
	int ans=0;
	if (a[n]==0){
		int x=1;
		For(i,1,pre[n]-2) x=x*2%mod;
		ans=Mod(ans+x);
	}
	FOR(i,1,1<<20) if (!v[i].empty()){
		f[0]=1,s[0]=1,s2[0]=pre[v[i][0]];
		FOR(j,1,siz(v[i])){
			f[j]=(1ll*s[j-1]*pre[v[i][j]]+mod-s2[j-1]+1)%mod;
			s[j]=Mod(s[j-1]+f[j]),s2[j]=(s2[j-1]+1ll*f[j]*pre[v[i][j]])%mod;
		}
		if (a[n]==0) ans=Mod(ans+s[siz(v[i])-1]);
		else if (a[n]==i) ans=Mod(ans+f[siz(v[i])-1]);
	}
	printf("%d\n",ans);
}

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

int A[1000000], n;

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

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

int main()
{
    int i, q, k, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> k;
        if (binarySearch(k)) sum++;
    }
    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 3472
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL A, B, C;
LL ans;

int main()
{
	in >> A >> B >> C;

	if (A % 2==0 && A == B && B == C)
	{
		out << -1 << std::endl;
	}
	else
	{
		while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0)
		{
			LL A_ = B / 2 + C / 2;
			LL B_ = A / 2 + C / 2;
			LL C_ = A / 2 + B / 2;
			A = A_; B = B_; C = C_;
			++ans;
		}
		out << ans << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#ceilevenoddformula
import math
from queue import PriorityQueue
import bisect
import copy
import time
from collections import Counter
#map(int,input().split())
#int(x) for x in input().split()
x=input()
if x=='RRR':
	print(3)
elif 'RR' in x:
	print(2)
elif "R" in x:
	print(1)
else:
	print(0)














 
          





























Measured memory_bytes: 68744
S = input()
N = len(S)

if list(S) == list(reversed(S)):
    if list(S[0:(N-1)//2]) == list(reversed(S[0:(N-1)//2])):
        if list(S[(N+1)//2:N]) == list(reversed(S[(N+1)//2:N])):
            print("Yes")
            exit(0)
print("No")


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner a = new Scanner(System.in);
        int x = a.nextInt();
        int y = a.nextInt();
        int z = a.nextInt();
        if(y>x && z>y)
            System.out.println("Yes");
        else
            System.out.println("No");
        }
    }

Measured memory_bytes: 17324
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int n,a,b,c,x,z,y;
int main(int argc, char const *argv[])
{
	cin >> n;
	VS strings;
	int arr[50];
	REP(i,50){
		arr[i] = 10000;
	}
	REP(i,n){
		string s;
		cin >> s;
		SORT(s);
		strings.PB(s);
	}
	int k=0;
	int a[50];
	for(char c='a'; c <= 'z'; c++){
		int cnt=0;
		REP(i,n){
			cnt=0;
			REP(j,SZ(strings[i])){
				if(c==strings[i][j]){
					cnt++;
				}
			}
			arr[k] = min(arr[k],cnt);
		}
		k++;
	}
	k=0;
	for(char c='a'; c <= 'z'; c++){
		REP(i,arr[k]){
			cout << c;
		}k++;
	}cout <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define Clear(a) a = decltype(a)()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define vec vector
typedef long long ll;
typedef pair<ll,ll> P;
//const ll big=998244353LL;
const ll big=1000000007LL;
const ll INF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
if(x<y)return x;
else return y;
}
ll expm(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (expm(x,y-1)*x)%big;
    ll t=expm(x,y/2);
    return (t*t)%big;
}
ll exp(ll x,ll y){
    if(y==0)return 1;//0^0=1
    if(x==1||y==0)return x;
    if(y%2==1)return exp(x,y-1)*x;
    ll t=exp(x,y/2);
    return t*t;
}
ll inv(ll x){
    return expm(x,big-2);
}

struct unionfind{
  vec<int> par;
  void begin(int n){
    par.resize(n,-1);
  }
  int find(int x){
    if(par[x]==-1)return x;
    return par[x]=find(par[x]);
  }
  void unite(int x,int y){
    x=find(x),y=find(y);
    if(x==y)return;
    par[x]=y;
    return;
  }
};

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/

    int n,m;cin >> n >> m;
    unionfind uf;
    uf.begin(n);
    ll ans=m;
    rep(i,m){
      int x,y,z;cin >> x >> y >> z;x--;y--;
      if(uf.find(x)==uf.find(y))ans--;
      uf.unite(x,y);
    }
    cout << max(0,n-ans) << endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  string s;
  int w;
  cin >> s >> w;

  REP(i, s.size()) {
    if(i%w==0) cout << s[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
a,b,c,x,y = map(int,input().split())
ans = a*x + b*y
for i in range(max(x,y) + 1):
	money = max(0,(x-i)*a) + max(0,(y-i)*b) + 2*i*c
	if money <= ans:
		ans = money
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for(int i= 0;i<n;i++){
      cin >> l[i];
  }
  sort(l.begin(),l.end());
  int ans = 0;
 for(int i=0;i<n;i++){
   for(int j=0;j<i;j++){
     for(int k=0;k<j;k++){
       if(l[k]!=l[j] and l[i]!=l[j] and l[k]+l[j]>l[i]){
         ans++;
       }
     }
   }
 }
  cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <queue>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fst first
#define snd second
const ll mod = 1000000007;
const ll INF = (1LL << 59);

int main(){
	int n; cin >> n;
	ll x; cin >> x;
	ll a[100010];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans = 0LL;
	if (a[0] > x) {
		ans += a[0] - x; a[0] = x;
	}
	for (int i = 1; i < n; i++) {
		int tmp;
		tmp = max(0LL, a[i]+a[i-1]-x);
		ans += tmp;
		a[i] -= tmp;
	}
	if (a[n-1] > x) {
		ans += a[n-1] - x;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    map<string, int> mp;
    cin >> n;
    rep (i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cin >> m;
    rep (i, m) {
        string s;
        cin >> s;
        mp[s]--;
    }
    int res = 0;
    for (auto m: mp) {
        res = max(res, m.second);
    }
    cout << res << endl;

    return 0;
}



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

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

    int ans = 0;
    int count = 0;
    for(int i = 0; i < 20; i++){
        ans += 2 * d + 1;
        count++;
        if(ans >= n){
            break;
        }
    }

    cout << count << endl;
}

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

int main(){
  int N;
  cin >>N;
  vector<int> card(N);
  for (int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    card.at(i) = -1*tmp;
  }
  sort(card.begin(),card.end());
  
  int Alice=0, Bob=0;
  for (int i=0; i<N; i = i +2){
    Alice += card.at(i);
  }
  
  if (N > 1){
    for (int i=1; i<N; i=i+2){
      Bob += card.at(i);
    }
  }
  
  int ans;
  ans = Bob - Alice;
  cout << ans <<endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	num, _ := strconv.Atoi(stdin.Text())
	h := num / 3600
	m := (num - (h * 3600)) / 60
	s := num - (h * 3600) - (m * 60)
	fmt.Printf("%v:%v:%v\n", h, m, s)
}



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


using namespace std;
using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
      
    int t=1;
    //cin>>t;
    while(t--){
        LL n;
        cin>>n;
        LL ans = (n/500)*1000+((n%500)/5)*5;
        cout<<ans<<'\n';
    }



return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>=13) cout<<b<<endl;
    else if(a<=5) cout<<"0"<<endl;
    else cout<<b/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n,a,tot=0;
	cin>>n;
	for(int i=sqrt(n); i>0; --i) {
		if(n%i==0) {
			a=n/i;
			break;
		}
	}
	while(a>0) {
		tot++;
		a=a/10;
	}
	cout<<tot<<"\n";
	return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
ans = []

first_U_times = ty - sy
for _ in range(first_U_times):
    ans.append('U')
first_R_times = tx - sx
for _ in range(first_R_times):
    ans.append('R')
for _ in range(first_U_times):
    ans.append('D')
for _ in range(first_R_times):
    ans.append('L')

ans.append('L')
for _ in range(first_U_times+1):
    ans.append('U')
for _ in range(first_R_times+1):
    ans.append('R')
ans.append('D')

ans.append('R')
for _ in range(first_U_times+1):
    ans.append('D')
for _ in range(first_R_times+1):
    ans.append('L')
ans.append('U')

ans = ''.join(ans)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
bool see[410][410]={};
string g[410];
Int b,w;
int d[]={1,0,-1,0,1};

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

  double x1,y1,x2,y2,x3,y3; double r,s,a,b,c;
  cin>>x1>>y1>>x2>>y2>>x3>>y3;
  a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)),b=sqrt((x3-x2)*(x3-x2)+(y2-y3)*(y2-y3)),c=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
  s=(a+b+c)/2;
  r=2*sqrt((s-a)*(s-b)*(s-c)*s)/(a+b+c);
  a=max({a,b,c});
  cout<<setprecision(10)<<r*a/(2*r+a)<<'\n';
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
    ll n,w;
    cin>>n>>w;
    vector<vector<ll>> knapsack(n);
    ll temp;
    for(ll i=0; i<n; ++i)
    {
        cin>>temp;
        knapsack[i].push_back(temp);
        cin>>temp;
        knapsack[i].push_back(temp);

    }
    sort(knapsack.begin(), knapsack.end());

    ll arr1[w+1], arr2[w+1];
    ll *ptr1;
    ll *ptr2;
    ptr1 = arr1;
    ptr2 = arr2;
    for(ll i=0; i<=w; ++i)
    {
        ptr1[i] = 0;
    }

    for(ll i=0; i<n; ++i)
    {
        ptr2[0] = 0;
        for(ll j=1; j<=w; ++j)
        {
            if(knapsack[i][0] <= j)
            {
                ptr2[j] = max(ptr1[j], knapsack[i][1] + ptr1[j-knapsack[i][0]]);
            }
            else
            {
                ptr2[j] = ptr1[j];
            }
        }
        if(i != n-1)
        {
            ll *temp = ptr1;
            ptr1 = ptr2;
            ptr2 = temp;
        }
    }
    cout<<ptr2[w];
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp {
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue() {
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {return a < b ? a : b;}

int main(){
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);
	for(i = 1; i <= n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = n + 1;
	
	while (head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if (u.t > 0) enqueue(u);
		else {
			printf("%s %d\n", u.name, elaps);
		}
	}
	
	
	return 0;
}




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

int main()
{
    int L,R,d;
    scanf("%d %d %d",&L,&R,&d);
    int a,b,c;
    a=R/d;
    b=L/d;
    c=a-b;

     if(L%d==0)
        c=c+1;

    printf("%d",c);
    return 0;
}


Measured memory_bytes: 1736
#include<iostream>
#include<stdio.h>
 
using namespace std;
 
unsigned long long int gcd(unsigned long long int x, unsigned long long int y);
unsigned long long int lcm(unsigned long long int x, unsigned long long int y);
 
	int main(void) {
		int n;
		unsigned long long int time[102];
		unsigned long long int lcm_num;
 
		cin >> n;
 
		for (int i = 1; i <= n; i++) {
			cin >> time[i];
		}
 
		lcm_num = time[1];
 
		if (n >= 2) {
			for (int t = 2; t <= n; t++) {
				if (lcm_num > time[t]) {
					lcm_num = lcm(lcm_num, time[t]);
				}
				else if (lcm_num<time[t]) {
					lcm_num = lcm(time[t], lcm_num);
				}
			}
		}
		
 
		cout << lcm_num << endl;
		return 0;
	}
	unsigned long long int gcd(unsigned long long int x, unsigned long long int y) {
		unsigned long long int r;
 
		while ((r = x % y) != 0)
		{
			x = y;
			y = r;
		}
		return y;
	}
 
	unsigned long long int lcm(unsigned long long int x, unsigned long long int y) {
		unsigned long long int p;
		p = (x / gcd(x, y))*y;
		return (p);
	}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector< ii >
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }

int gcd(int a, int b){
  if(a == 0) return b;
  else return gcd(b%a, a);
}

int32_t main(){
  DESYNC;
  int n;
  cin >> n;
  int ans = n-1;
  for(int i=1; i<=sqrt(n); i++){
    if(n%i) continue;
    int j = n/i;
    ans = min(ans, (j-1) + (i-1));
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main() {
    int cnt = 0;
    int N, M;
    cin >> N >> M;
    vector<pair<int,int>>ps(M);
    for (int i=0; i<M; i++){
        int ai, bi;
        cin >> ai >> bi;
        ps[i].first = ai-1;
        ps[i].second = bi-1;
    }
    UnionFind uf(N);
    //各辺を繋げなかった場合を全探索
    for (int i=0; i<M; i++){
        
        uf.init(N);
        //辺を貼る
        for (int j=0; j<M; j++){
            if (j==i)continue;
            else uf.merge(ps[j].first, ps[j].second);
        }
        if (uf.size(0) < N){
            //cout << i << endl;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

signed main() {
    int r;
    cin>>r;
    cout<<r*r<<endl;

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

typedef vector<ld> vld;
typedef vector<vld> vvld;

int n;
vector<vvld> dp;

ld rec(int i, int j, int k) {
	if(dp[i][j][k] >= 0.0) return dp[i][j][k];
	ld ret = 0.0;
	if(i > 0) ret += rec(i - 1, j, k) * i;
	if(j > 0) ret += rec(i + 1, j - 1, k) * j;
	if(k > 0) ret += rec(i, j + 1, k - 1) * k;
	ret += n;
	ret *= 1.0 / (i + j + k);
	return dp[i][j][k] = ret;
}

int main() {
	cout << fixed << setprecision(15);
	cin >> n;
	vi c(3);
	rep(i, n) {
		int a;
		cin >> a;
		c[a - 1]++;
	}

	dp = vector<vvld>(n+1, vvld(n+1, vld(n+1, -1.0)));
	dp[0][0][0] = 0.0;
	cout << rec(c[0], c[1], c[2]) << endl;
}


Measured memory_bytes: 431488
#include <bits/stdc++.h>
using namespace std;
int n;
int ch(int i){
    int x=0;
    for (int j = 1; j <=i/2 ; ++j) {
        if (j*j+2*j>i)break;
        for (int k = 1; k <=i/2; ++k) {
            if (k*k+j*j+k*j>i)break;
            for (int l = 1; l <=i/2; ++l) {
                if (j*j+k*k+l*l+j*k+j*l+l*k>i)break;
                if (j*j+k*k+l*l+j*k+j*l+l*k==i){
                    x++;
                }
            }
        }
    }
    return x;
}
int main() {
    cin>>n;
    for (int i = 1; i <= n; ++i) {
        printf("%d\n",ch(i));
    }
}


Measured memory_bytes: 3656
import bisect
n = int(input())
bb = [0] * (n+1)
ans = 0
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()

for i in range(1,n+1):
    bb[i] = bisect.bisect_left(a,b[i-1]) + bb[i-1]

for i in range(n):
    ans += bb[bisect.bisect_left(b,c[i])]
print(ans)

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int h, w;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
vector<string> s;
bool seen[100][100];

void dfs(int y, int x){
    for(int i = 0; i < 4; i++){
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
        if(s[ny][nx] != '#') continue;
        if(seen[ny][nx]) continue;
        seen[y][x] = true;
        seen[ny][nx] = true;
        dfs(ny, nx);
    }
}

int main() {
    cin >> h >> w;
    s.resize(h);
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    int cnt = 0;
    memset(seen, 0, sizeof(seen));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '#'){
                cnt++;
                dfs(i, j);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(seen[i][j]) ans++;
        }
    }
    if(cnt == ans) cout << "Yes"  << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
ll INF = (1 << 30);
ll MOD = 1e9 + 7;

vector<int> par;
vector<int> RANK;
void init(int n){
    for(int i = 0; i < n; i++){
        par.pb(i);
        RANK.pb(0);
    }return;
}

int FindRoot(int x){
    if(par[x] == x) return x;
    par[x] = FindRoot(par[x]);
    return par[x];
}

bool isSame(int x, int y){
    return FindRoot(x) == FindRoot(y);
}

void Union(int x, int y) {
    x = FindRoot(x);
    y = FindRoot(y);
    if (x == y) return;
    if (RANK[x] > RANK[y]) par[y] = x;
    else {
        par[x] = y;
        if (RANK[x] == RANK[y]) {
            RANK[y]++;
        }
    }
    return;
}

vector<ll> ans;

void dfs(ll x){
    if(x < 3234566668) ans.pb(x);
    if(x > 3234566667) return;

    if(x % 10 != 0 && x % 10 != 9) {
        for(int i = -1; i < 2; i++){
            dfs(10 * x + (x % 10) + i);
        }
    }else if(x % 10 == 0) {
        dfs(10 * x + 1);
        dfs(10 * x);
    }else{
        dfs(10 * x + 9);
        dfs(10 * x + 8);
    }
}

int main() {
    for(ll i = 1; i < 10; i++) dfs(i);
    sort(ans.begin(),ans.end());

    ll k; cin >> k;
    k--;
    cout << ans[k] << endl;
    //for(int i = 0; i < 1000; i++) cout << ans[i] << " ";
}

Measured memory_bytes: 4112
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int n,m;

  cin >> n >> m;

  vector<int> a(n);
  int sum = 0;
  for(ii=0;ii<n;ii++){
    cin >> a[ii];
    sum += a[ii];
  }

  double rate = (1.0d * sum) / (4*m);

  int ok = 0;
  
  for(ii=0;ii<n;ii++){
    if(a[ii] >= rate){
      ok++;
    }
  }

  if(ok >= m){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){
	/*input*/
	int a, b; 
	cin >> a >> b;
	/*culculation*/
	int max = 0;	
	for(int i = 0; i < 2; i++){
		if(a < b){
			max += b--;
		}else{
			max += a--;
		}
	}
	/*output*/
	cout << max << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		int v[] = new int[n];
		int c[] = new int[n];
		for(int i = 0; i < n; i++){
			v[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			c[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
			if(v[i] > c[i]){
				ans += v[i]-c[i];
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 22608
import Data.List
import qualified Data.ByteString.Char8 as B
import Control.Monad

main :: IO ()
main = readLn >>= flip replicateM breads >>= print . solve

solve :: [[Int]] -> Int
solve = foldl' ff 0
    where
        ff acc [l, r] = acc + r - l + 1

breads :: IO [Int]
breads = unfoldr uff <$> B.getLine
    where
        uff b = check <$> B.readInt b
        check (a, b)
            | B.null b = (a, b)
            | otherwise = (a, B.tail b)


Measured memory_bytes: 1148
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
int dc=100000;
int d[13]={},time[24]={};
void placement();
int min_diff();

int main(){
  int n;
  scanf("%d",&n);
  int i,a;
  int min=12;
  for(i=0;i<n;i++){
    dc-=df; if(dc<0){ printf("err in A\n"); break;}
    scanf("%d",&a);
    d[a]++;
    if(a<min)min=a;
    if(d[a]==3)min=0;
  }
  if(d[12]==2)min=0;
  if(min==0){
    printf("0");
    return 0;
  }

  placement();
  int x=min_diff();
  if(x<min)min=x;
  
  

  printf("%d",min);
  return 0;
}
void placement(){
  dc-=df; if(dc<0){ printf("err in placement\n"); return;}
  time[0]=1;
  int temp=1,i;
  for(i=1;i<=12;i++){
    dc-=df; if(dc<0){ printf("err in placement\n"); break;}
    if(d[i]>=2){
      time[i]=1;
      time[24-i]=1;
      temp=1;
    }else if(d[i]){
      time[12+temp*(i-12)]=1;
      temp*=-1;
    }
  }
}
int min_diff(){
  int temp=0,min=24,i;
  for(i=1;i<24;i++){
    dc-=df; if(dc<0){ printf("err in min_diff\n"); return 0;}
    if(time[i] && i-temp<min)min=i-temp;
    if(time[i])temp=i;
  }
  if(24-temp<min)min=24-temp;
  return min;
}


/// confirm df==0 ///


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int arr[N+2], n, Q, dp[2][N];

void solve()
{     
      int K;
      cin >> n >> K;
      lop(i,1,n+1) cin >> arr[i];

      dp[0][0] = 1;
      lop(i,1,n+1)
      {     
            lop(k, 0, K+1)
            {
                  int ans = dp[ (i-1)%2 ][k];
                  if(k-1>=0) ans += dp[ i%2 ][k-1], ans %=M;
                  if( k - arr[i] >= 0 ) ans -= dp[ (i-1)%2 ][ k-1-arr[i] ], ans %=M;
                  if( ans < 0 ) ans += M;
                  dp[i%2][k] = ans;
                  // bug(ans);
            }
      }

      cout << dp[n%2][K] << endl;
      
      
}


int32_t main()
{
      
      ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
      //INP(); 
      int t = 1;
      //cin >> t;
      while(t--) solve();

}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






Measured memory_bytes: 5120
from math import sqrt
Q = int(input())
que = []
for i in range(Q):
    que.append(tuple(map(int, input().split())))
for q in que:
    if q[0] == q[1]:
        print(2*q[0]-2)
    else:
        a = q[0]*q[1]
        p = int(sqrt(a))
        if p*p == a:
            p -= 1
        if a > p*(p+1):
            print(2*p-1)
        else:
            print(2*p-2)

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int x;
    cin >> x;
    int ans=x/200;
    cout << 10-ans << endl;

    return 0;
}











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

template<class T> void readin(T & x)
{
	x = 0;
	int f = 1, ch = getchar();
	while(ch < '0' || ch > '9')
	{
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9')
	{
		x = x * 10 - '0' + ch;
		ch = getchar();
	}
	x *= f;
}

int A, B, C;
long long K;

int main()
{
	readin(A), readin(B), readin(C), readin(K);
	printf("%d\n", (A - B) * (K & 1 ? -1 : 1));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cctype>
using namespace std;

int main(void){
  string s;
  getline(cin,s);
  for (int i=0;i<s.size();i++) {
    if(isalpha(s[i])){
      if(islower(s[i])) cout << (char)toupper(s[i]);
      else cout << (char)tolower(s[i]);
    } else {
      cout << (char)s[i];
    }
  }
  cout << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w, n; cin>>h>>w>>n;
	ll sr, sc; cin>>sr>>sc;
	string s, t; cin>>s>>t;

	ll left=0, right=w-1;
	ll top=0, bottom=h-1;
	for(int i=n-1; i>=0; i--){
		switch(t[i]){
			case 'L':
				right = min(right+1, w-1);
				break;
			case 'R':
				left = max(0ll, left-1);
				break;
			case 'U':
				bottom = min(bottom+1, h-1);
				break;
			case 'D':
				top = max(0ll, top-1);
				break;
		}
		switch(s[i]){
			case 'L':
				left++;
				break;
			case 'R':
				right--;
				break;
			case 'U':
				top++;
				break;
			case 'D':
				bottom--;
				break;
		}
		if (left>right || top>bottom) break;
	}

	sc--, sr--;
	if (left<=sc && sc<=right && top<=sr && sr<=bottom)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}


Measured memory_bytes: 920
#include <stdio.h>
int main(void){
    int n,i;
    int red,blue;
    red = blue = 0;
    char s[256];
    scanf("%d",&n);
    scanf("%s",s);
    for (i = 0; i < n; i++ ){
        if (s[i] == 'R'){
            red++;
        }else if (s[i] == 'B'){
            blue++;
        }
    }
    if (red > blue){
        printf("Yes");
    }else{
        printf("No");
    }
}

Measured memory_bytes: 128
N = int(input())
S = input()
T = [int(s == "o") for s in S]

def solve():
    for A in [[0, 0], [0, 1], [1, 0], [1, 1]]:
        for i in range(2, N):
            A.append(A[-2] ^ A[-1] ^ T[i - 1])
        if (T[-1] == (A[-2] ^ A[-1] ^ A[0]) and
            T[0] == (A[-1] ^ A[0] ^ A[1])):
            return A
    return []

ans = solve()
if ans:
    print("".join("S" if a else "W" for a in ans))
else:
    print(-1)


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

int main() {
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 10000; i++) {
        int a1 = floor(i * 0.08);
        int b1 = floor(i * 0.1);
        if (a1 == a && b1 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp90 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int K = st[1];

            long ans = 0;

            if (K == 1) {
                ans = (long)Math.Pow(N, 3);
                Console.WriteLine(ans);
                return;
            }

            if (K == 2) {
                ans = (long)Math.Pow(N / 2, 3) + (long)Math.Pow(N - (N / 2), 3);
                Console.WriteLine(ans);
                return;
            }

            if (K % 2 == 1) {
                ans = (long)Math.Pow(N / K, 3);
                Console.WriteLine(ans);
                return;
            } else {
                int l = K / 2;

                //全部偶数のパターンを足す
                ans += (long)Math.Pow(N / K, 3);

                //全部奇数のパターンを足す
                ans += (long)Math.Pow((N / l) - (N / K), 3);

                Console.WriteLine(ans);
                return;
            }
        }

    }
}

Measured memory_bytes: 13396
n=int(input())
x=[0]*n
L=[0]*n
lis=[]

for i in range(n):
  x[i],L[i]=map(int,input().split())
  lis.append([x[i]-L[i],x[i]+L[i]])
lis.sort(key= lambda x:x[1])
tmp=-10**18
ct=0
for x in lis:
  if x[0]>=tmp:
    ct+=1
    tmp=x[1]
    
print(ct)





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

int main(){
    int n, max=0, cnt=0; cin >> n;
    vector <int> h(n);
    for(int i = 0; i < n; i++)
        cin >> h[i];
        
    for(int i = 1; i < n; i++){
        if(h[i] <= h[i-1]) cnt++;
        else{
            if(max < cnt) max = cnt;
            cnt = 0;
        }
    }
    if(max < cnt) max = cnt;
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 640