akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <unordered_map>
#include <assert.h>
using namespace std;

#define ran(i, a, b) for ((i) = (a); (i) < (b); (i)++)
#define rep(i, a) ran ((i), 0, (a))
#define rep1(i, a) ran ((i), 1, (a)+1)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
#define _0 first
#define _1 second
#define _pb(x) push_back(x)
#define _mp(x, y) make_pair(x, y)
#if defined(SHIROKO1_LOCAL) && !defined(NDEBUG)
#define DEBUG(...) fprintf(stderr, "[DEBUG] " __VA_ARGS__)
#else
#define DEBUG(...) ((void)0)
#endif



int main()
{
	ll n;
	static ll s[3][100100];
	static ll d[3][100100];
	cin >> n;
	ll i, j;
	rep (j, 3) {
		rep (i, n)
			cin >> s[j][i];
		sort(s[j], s[j]+n);
	}
	
	rep (i, n)
		d[0][i] = 1;

	ran (j, 1, 3) {
		ll sum = 0;
		ll k = 0;
		rep (i, n) {
			while (k < n && s[j-1][k] < s[j][i])
				sum += d[j-1][k++];
			//DEBUG("D %i %i = %i\n", j, i, sum);
			d[j][i] = sum;
		}
	}
	ll ans = 0;
	rep (i, n)
		ans += d[2][i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
using namespace std;
int main(void){
   int i,l,x,h;
cin>>i>>l>>x;
  if ( x % 500 != 0 ) x += 500 - x%500;
  int a = 0;
  int b = 0;
h=l*2;
  if ( i < l ) {
    a = x/1000 + ((x%1000>0)?1:0);
  } else if ( i > h ){
    b = x/500;
  } else {
    a = x/1000; 
    b = x%1000/500;
  }

  cout << i*a + l*b << endl;
}



Measured memory_bytes: 3092
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll X=0;
    cin >> X;

    //vll X(N);
    //REP(i,N) cin >> X[i];


    //本文
    bool ok = true;
    ll a = 1,ans = 0;
    while(ok){
    ans = 360*a/X;
    if((360*a)%X==0){ok = false;}
    else{a++;}
    }
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3580
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,A,B;
  cin>>N>>A>>B;
  if(N+A+B>=22)
    cout<<"bust"<<endl;
  else
    cout<<"win"<<endl;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    uint64_t *H = new uint64_t[N];
    for(int n=0; n<N; n++){
        cin >> H[n];
    }
    sort(H, H+N);
    uint64_t s=0;
    for(int n=K; n<N; n++){
         s += H[N-n-1];
    }
    cout << s << endl;
	return 0;
}


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

using namespace std;

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

  int n, k;
  cin >> n >> k;

  bool digits[10] = {false};

  for (int i = 0; i < k; ++i) {
    int x; cin >> x;
    digits[x] = true;
  }

  while (n <= INT_MAX) {
    int tmp = n;

    while (tmp) {
      int d = tmp % 10;
      if (digits[d]) break;
      else tmp /= 10;
    }

    if (tmp == 0) break;
    else n++;
  }

  cout << n << "\n";
}


Measured memory_bytes: 3632
N = int(input())
S = list(input())
a = [chr(i) for i in range(65, 65+26)]

for i in range(len(S)):
    current_i = a.index(S[i])
    next_i = (current_i + N) % 26
    S[i] = a[next_i]

print(''.join(S))

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

typedef long long int ll;

ll power(ll a,ll b,ll p)
{
    ll r = 1;
    while(b>0){
        if(b%2 == 1){
            r = (r*a)%p;
        }
        a = (a*a)%p;
        b = b/2;
    }
    return r;
}

ll mod = ll(1e9)+7;
ll cost[2005][2005];

ll solve(ll u,ll k)
{
    if(k==0){
        if(u==0){
            return 1;
        }
        return 0;
    }



    if(cost[u][k]==-1){
        ll val = 0;
        for(ll i=1;i<=u;i++){
            val = (val+solve(u-i,k-1))%mod;
        }
        cost[u][k] = val;
    }
    return cost[u][k];
}



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

    ll n,k;
    cin>>n>>k;
    ll fact[n+2*k+1];

    ll val = 1;
    fact[0] = 1;
    for(ll i=1;i<=n+k;i++){
        fact[i] = (i*fact[i-1])%mod;
    }

    //cout<<"io"<<endl;
    for(ll i=1;i<=k;i++){
        if((n-k+1)>=i and (k-1)>=(i-1)){
        ll val = (((fact[n-k+1]*power((fact[i]*fact[n-k+1-i] + mod)%mod,mod-2,mod)+mod)%mod))%mod;

        ll val2 = (((fact[k-1]*power((fact[i-1]*fact[k-1-i+1] + mod)%mod,mod-2,mod)+mod)%mod))%mod;
       cout<<(val*(val2)+mod)%mod<<endl;
       //cout<<(val2)<<endl;
        }
        else{
            cout<<0<<endl;
        }

    }


}


Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 210000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};


void solve() {

	LL result = 0;
	int n;
	int h, w;
	cin >>h>>w>> n;
	result = h;
	vector<int> zb(h+1, w+1);
	for (int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		zb[x] = min(zb[x], y);
	} 
	int nx = 1, ny = 1;

	for (int i = 2; i <= h; ++i) {
		if (zb[i] <= ny) {
			result = i - 1;
			break;
		}
		nx += 1;
		if (ny +1 < zb[i]) ny += 1;

	}
	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()
	l := scanInt()

	ans := (l+l+n-1)*n/2

	if l <= 0 && l+n-1 >= 0 {
		fmt.Println(ans)
	} else {
		if abs(l) < abs(l+n-1) {
			fmt.Println(ans-l)
		} else {
			fmt.Println(ans-(l+n-1))
		}
	}
}


Measured memory_bytes: 640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> d(n);

    for(int i = 0;i < n;++i){

        cin >> d[i];

    }

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

    for(int i = 1; i < n; ++i){

        if(d[i] == d[i-1]){
            d.erase(d.begin() + i);
            --i;
            --n;
        }

    }

    cout << d.size() << endl;

    return 0;
}

Measured memory_bytes: 256
n=input()
N=int(n)
S=N
ans=0
for i in range(0,9):
  if N//(10**(8-i)) !=0:
    a=N//(10**(8-i))
    ans+=N//(10**(8-i))
    N-=a*(10**(8-i))
if int(S/ans)==S/ans:
  print("Yes")
else:
  print("No")

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

#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define mod         (ll)1000000007
//#define mod         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll hell;
// ll expo(ll base, ll exponent, ll mod) {                                //return base^exponent modulo modulus
//     ll ans = 1;
//     while(exponent !=0 ) {
//         if((exponent&1) == 1) {
//             ans = ans*base ;
//             ans = ans%mod;
//         }
//         base = base*base;
//         base %= mod;
//         exponent>>= 1;
//     }
//     return ans%mod;
// }

ll solve(){ 
    ll n,m,sum=0; cin>>n>>m;
    vl a(n); lp(i,0,n) cin>>a[i],sum+=a[i];
    sort(all(a),greater<ll>());
    lp(i,0,m){
        if(a[i]*4*m < sum){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}   

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
while True:
    n,k=[int(s)for s in input().split(" ")]
    if n==k==0:break
    card=sorted([int(input())for i in range(k)])
    blank=card[0]==0
    if blank:card.pop(0)
    lens=[]
    con=[]
    tl=1
    i=0
    while i<len(card)-1:
        if card[i+1]==card[i]+1:tl+=1
        else:
            if card[i+1]==card[i]+2:con.append(True)
            else:con.append(False)
            lens.append(tl)
            tl=1
        i+=1
    lens.append(tl)
    if not blank:print(max(lens))
    else:
        l=0
        for i in range(len(con)):
            if con[i]:
                l=max((l,lens[i]+lens[i+1]+1))
        print(l)

Measured memory_bytes: 11876
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)

//小文字=大文字+32
int main() {
	int X;
	cin >> X;
	if (X < 30) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
}
	



Measured memory_bytes: 3620
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

static class Program
{
    static void Main()
    {

        int[] input = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        Point startPoint = new Point(input[0], input[1]);
        Point goalPoint = new Point(input[2], input[3]);

        //スタート上からゴール左へ
        Write("U");
        Point.Move(startPoint.GetArroundPoint(Point.Direction.U), goalPoint.GetArroundPoint(Point.Direction.L));
        Write("R");

        //ゴール下からスタート右へ
        Write("D");
        Point.Move(goalPoint.GetArroundPoint(Point.Direction.D), startPoint.GetArroundPoint(Point.Direction.R));
        Write("L");

        //スタート左からゴール上へ
        Write("L");
        Point.Move(startPoint.GetArroundPoint(Point.Direction.L), goalPoint.GetArroundPoint(Point.Direction.U));
        Write("D");

        //ゴール右からスタート下へ
        Write("R");
        Point.Move(goalPoint.GetArroundPoint(Point.Direction.R), startPoint.GetArroundPoint(Point.Direction.D));
        Write("U");

        ReadKey();
    }

    struct Point
    {
        public Point(int x, int y) : this()
        {
            X = x;
            Y = y;
        }

        public int X { get; set; }
        public int Y { get; set; }

        public Point GetArroundPoint(Direction direction)
        {
            switch (direction)
            {
                case Direction.U:
                    return new Point(X, Y + 1);
                case Direction.D:
                    return new Point(X, Y - 1);
                case Direction.L:
                    return new Point(X - 1, Y);
                case Direction.R:
                    return new Point(X + 1, Y);
                default:
                    throw new Exception();
            }
        }

        public enum Direction
        {
            U,
            D,
            L,
            R
        }

        public static void Move(Point a, Point b)
        {
            if (a.Y > b.Y)
            {
                while (a.Y > b.Y)
                {
                    Write("D");
                    --a.Y;
                }
            }
            else if (a.Y < b.Y)
            {
                while (a.Y < b.Y)
                {
                    Write("U");
                    ++a.Y;
                }
            }

            if (a.X > b.X)
            {
                while (a.X > b.X)
                {
                    Write("L");
                    --a.X;
                }
            }
            else if (a.X < b.X)
            {
                while (a.X < b.X)
                {
                    Write("R");
                    ++a.X;
                }
            }
        }
    }
}

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

void compute(string line){
    char buffer[2100];
    int p = 1025;
    int l = p, r = p;
    buffer[p] = line[0];
    for ( int i = 3; i < line.size(); i+=3 ){
	if ( line[i-1] == '>' ) p++;
	else p--;
	buffer[p] = line[i];
	l = min(l, p); r = max(r, p);
    }
    for ( int i = l; i <= r; i++ ) cout << buffer[i];
    cout << endl;
}

main(){
    int tcase; cin >> tcase;
    string line;
    for ( int i = 0; i < tcase; i++ ) { cin >> line; compute(line); }
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    string s;
    cin >> n >> s;

    string RGB = "RGB";
    forn (i, 0, sz(s))
        forn (j, 0, 3)
            if (s[i] == RGB[j])
                s[i] = j;

    vector <vector <int>> suf(n + 1, vector <int> (3));
    for (int i = n - 1; i >= 0; --i)
        forn (j, 0, 3)
            suf[i][j] = suf[i + 1][j] + (s[i] == j);
    
    long long ans = 0;
    forn (i, 0, n) {
        forn (j, i + 1, n) {
            if (s[i] == s[j])
                continue;
            ans += suf[j][3 - s[i] - s[j]];
            if (j + (j - i) < n && s[j + (j - i)] == 3 - s[i] - s[j])
                ans--;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
 
 
int main() {
 
    int a;
    int count=0;
    cin>>a;

    vector<int>vec;

    int j;
    for(int i=0;i<a;i++) {
        cin>>j;
        vec.push_back(j);
    }

    for(int i=1;i<a-1;i++) {
        if ((vec[i - 1] < vec[i] && vec[i] < vec[i + 1]) || (vec[i + 1] < vec[i] && vec[i] < vec[i - 1])) {
            count++;
        }
    }

    cout << count;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int main() {
	ll N;
	cin >> N;
	ll mina=MOD,cnt;
	FOR(i,1,sqrt(N)+1){
		if(N%i==0){
			cnt=max((int)to_string(N/i).length(),(int)to_string(i).length());
          	if(cnt>mina) break;
			mina = min(mina, cnt);
		}
	}
	cout << mina << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> supervise;
    REP(i, N-1) {
        cin >> A[i];
        supervise[A[i]]++;
    }

    FOR(i, 1, N) {
        cout << supervise[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13552
package main
import "fmt"

func main() {

  var input string
  fmt.Scan(&input)
  var en rune = 0
  var count = 0
  for _,element := range input {
    if en == element {
      count += 1
      if count >= 3 {
        break
      }
    } else {
      en = element
      count = 1
    }
  }
  
  if count >= 3 {
    fmt.Printf("Yes")
  } else {
    fmt.Printf("No")
  }
}


Measured memory_bytes: 512
a, b = map(int, input().split()) 

if(a < b):
  if (a < b-1):
    print(b+(b-1))
    exit()
  else:
    print(b+a)
    exit()
if(a > b):
  if (a-1 > b):
    print(a+(a-1))
    exit()
  else:
    print(b+a)
    exit()
else:
  print(2*a)


Measured memory_bytes: 3060
fun main(args: Array<String>) {

    var (N,W) = readLine()!!.split(" ").map{it.toInt()}


    var dp = Array(N){LongArray(W+1){0}}
    var w = IntArray(N)
    var v = IntArray(N)

    for(i in 0 until N){
        val(wi,vi) = readLine()!!.split(" ").map{it.toInt()}
        w[i] = wi;
        v[i] = vi;
    }

    for(j in 0..W){
        if(w[0]  <= j){
            dp[0][j] = v[0].toLong()
        }
    }

    for(i in 1 until N){
        for(j in 0..W){
            if(w[i] > j) {
                dp[i][j] = dp[i-1][j]
            } else {
                dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-w[i]] + v[i])
            }
        }
    }

    println(dp[N-1][W])

}


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


//二項係数　MAXは適宜変更
//COMinit()で初期化忘れないこと


const ll MAX = 4000010;
const ll MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
 
 
void COMinit() {
 fac[0] = fac[1] = 1;
 finv[0] = finv[1] = 1;
 inv[1] = 1;
  for (ll i = 2; i < MAX; i++){
  fac[i] = fac[i - 1] * i % MOD;
  inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
       finv[i] = finv[i - 1] * inv[i] % MOD;
        }
      }
 
   long long COM(ll n, ll k){
  if (n < k){ return 0;}
  if (n < 0 || k < 0) {return 0;}
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
     }

ll g(ll r, ll c){ 
  
  ll res = 0;
  
  for(ll x = 0; x <= r; x++){ 
    res += COM(x+c+1,x+1);
    res %= MOD;
  }
  
  return res;
}

int main(){ 
  ll r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
  
  
  COMinit();
  
  ll ans = 0;
  
  ans += g(r2,c2);
  ans -= g(r1-1,c2);
  ans = (ans+MOD)%MOD;
  ans -= g(r2,c1-1);
  ans = (ans+MOD)%MOD;
  ans += g(r1-1,c1-1);
  ans %= MOD;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 93952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n;
  cin >> n;
  vector<int> a(n), g_wo_i(n, 1);
  // vector<vector<int>> factor(n);
  vector<queue<int>> factor2(n);
  vector<pair<int, int>> prime;
  // srand((unsigned int)time(NULL));
  for (auto &x : a) {
    cin >> x;
    // x = rand()%1000000000;
  }

  // g1は全要素の最大公約数
  int g1 = a.at(0);
  for (auto &x : a) {
    g1 = __gcd(g1, x);
  }
  for (auto &x : a) {
    x /= g1;
  }

  //√max(a)までの素数を生成
  int check_num = (int)sqrt(*max_element(ALL(a)));
  vector<bool> is_prime(check_num + 1, true);
  for (int i = 0; i <= check_num; i++) {
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (int j = i + 1; j <= check_num; j++) {
        if (j % i == 0) is_prime.at(j) = false;
      }
    }
  }
  REP(i, check_num + 1) {
    if (is_prime.at(i)) prime.push_back(make_pair(i, 0));
  }

  // aを素因数分解,素因数をfactorに格納
  REP(i, n) {
    for (auto &y : prime) {
      int cnt = 0;
      while (a.at(i) % y.first == 0) {
        cnt++;
        factor2.at(i).push(y.first);
        // factor.at(i).push_back(y.first);
        a.at(i) /= y.first;
      }
      y.second = max(y.second, cnt);
      if (a.at(i) == 1) break;
    }
    if (a.at(i) != 1) {
      factor2.at(i).push(a.at(i));
      prime.push_back(make_pair(a.at(i), 0));
      // factor.at(i).push_back(a.at(i));
    }
  }
  sort(ALL(prime));

  // DEBUGS(is_prime);
  // DEBUG(check_num);
  // REP(i, n) { DEBUGS(factor.at(i)); }

  //一つを除いた最大公約数を求める
  for (auto y : prime) {
    int p = y.first;
    int p_n = y.second;
    REP(i, p_n) {
      int cnt = 0;
      int tmp;
      REP(j, n) {
        // if (factor.at(j).size() == 0) {
        if (factor2.at(j).empty()) {
          cnt++;
          tmp = j;
        } else {
          // if (factor.at(j).at(0) == p) {
          if (factor2.at(j).front() == p) {
            // factor.at(j).erase(factor.at(j).begin());
            factor2.at(j).pop();
          } else {
            cnt++;
            tmp = j;
          }
        }
      }
      if (cnt == 1) {
        g_wo_i.at(tmp) *= p;
      }
    }
  }

  // DEBUGS(g_wo_i);
  //  DEBUG(g1);
  // DEBUGS(prime);
  cout << g1 * *max_element(ALL(g_wo_i)) << "\n";
  return 0;
}


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

using namespace std;

bool hantei(int x, int y, int h, int w) {
	if (0 <= x && x < w && 0 <= y && y < h) {
		return true;
	}
	else {
		return false;
	}
}

int main() {
	int h, w;
	cin >> h >> w;

	string no = "0123456789";

	vector< vector<char> > mp(h, vector<char>(w));

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

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> mp[i][j];
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (mp[i][j] == '.') {
				int cc = 0;
				for (int k = 0; k < 9; k++) {
					if (hantei(j + dx[k], i + dy[k], h, w) && mp[i+dy[k]][j+dx[k]] == '#') {
						cc++;
					}
				}
				mp[i][j] = no[cc];
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << mp[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( ll i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

ll ans;
vector<ll> sa, sb;
ll a[200005], b[200005];


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

    rep(i, 1, n+1) cin >> a[i];
    rep(i, 1, m+1) cin >> b[i];

    sa.pb(0);
    sb.pb(0);
    rep(i, 1, n+1) sa.pb(sa[i-1]+a[i]);  
    rep(i, 1, m+1) sb.pb(sb[i-1]+b[i]);  

    for (ll i=0; i<=n; i++) {
        ll sum = sa[i];
        if (sum>k) break;
        int l = 0, r = sz(sb);
        while (r-l>1) {
          int m = (r+l)/2;
          if (sb[m]<=k-sum) l = m;
          else r = m;
        }
        ans = max(ans, i+l);
        
        
    }

  
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 11060
#include<bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
using namespace std;

const int N = 5e3 + 3;

int dp[N][N];
int n, m;

inline void upd(int &x, int y) {
    x += y;
    if(x >= m) x -= m;
}

main() {
    cin >> n >> m;
    dp[1][0] = 1;
    int tec = 0;
    for(int i = 1; i <= n - 1; ++i) {
        tec = i <= (n + 1) / 2 ? i : 2*(n + 1) / 2 - i;
        for(int j = 0; j <= n; ++j) {
            for(int k = 0; k <= n - j; k += tec) {
                upd(dp[i + 1][j + k], dp[i][j]);
            }
        }
    }
    int ans = 0;
    for(int j = 0; j < n; ++j) {
        int res = (dp[n][j] * 1ll * (n - j)) % m;
        upd(ans, res);
    }
    cout << ans;
}


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

int main(){
  int N,M,X,Y,x[101],y[101],i;
  x[100]=-1000;y[100]=1000;
  cin>>N>>M>>X>>Y;
  for(i=0;i<N;i++){
  	cin>>x[i];
    if(x[i]>=x[100])x[100]=x[i];
  }
  for(i=0;i<M;i++){
  	cin>>y[i];
    if(y[i]<=y[100])y[100]=y[i];
  }
  
  for(i=x[100]+1;i<=y[100];i++){
  	if(i>X && i<=Y){
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

void test();

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n;
    cin >> n;
    vector<pii> a(n);
    for(auto &i : a){
        cin >> i.F;
    }
    for(auto &i : a){
        cin >> i.S;
    }
    ll ans = 0;
    for(auto &i : a){
        if(i.F>i.S){
            ans += (i.F-i.S);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pcont(x) for(auto i: x){cout << i << " ";} cout << "\n";

int main(){
    IOS;
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    map<int, int> m;
    for(int i = 0; i<n; i++){
        cin >> a[i];
        sum += a[i];
        m[a[i]]++;
    }

    int q;
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        ll changed = (ll)m[b];
        sum += changed*((ll)(c-b));
        m[b] -= changed;
        m[c] += changed;
        cout << sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 8404
import java.util.*;

public class Main{
  public static void main(String[] args){
	Scanner s=new Scanner (System.in);
    int m1 = s.nextInt();
    int d1 =s.nextInt();
    int m2 = s.nextInt();
    int d2 =s.nextInt();
    if(d2>d1){
    	System.out.println(0);
    }else{
    	System.out.println(1);
    }
  }
}

Measured memory_bytes: 24276
<?php
list($n) = ints();
$a = ints();
for ($i = 0; $i < $n; ++$i) {
    if (isset($cnt[$a[$i]])) $cnt[$a[$i]]++;
    else $cnt[$a[$i]] = 1;
}
if (isset($cnt[1])) {
    if ($cnt[1] > 1) exit('0');
    else exit('1');
}
$max = max($a);
ksort($cnt);
$isPrime = isPrimeArr($max);
$ans = 0;
foreach ($cnt as $i => $v) if ($v === 1 && $isPrime[$i]) $ans++;
echo $ans;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}

function isPrimeArr($max)
{
    global $cnt;
    $arr = array_fill(0, $max + 1, true);
    foreach ($cnt as $i => $v) {
        if (!$arr[$i]) continue;
        for ($j = 2 * $i; $j <= $max; $j += $i) $arr[$j] = false;
    }
    return $arr;
}


Measured memory_bytes: 69408
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
//#include<map>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;
typedef unsigned long long ull;
typedef long long ll;

const int MAX_N = 9;
const int MAX_M = 36;

int N,M;
int match[MAX_N+1][MAX_N+1];  //-1...lose , 1...win
int res;
P xy;

void solve(int [][MAX_N+1]);
void printmap();
bool check(int [][MAX_N+1],int);

int main() {

  while(cin>>N && N) {
    memset(match,0,sizeof(match));
    cin>>M;
    R(i,0,M) { cin>>xy.first>>xy.second; match[xy.first][xy.second] = 1; match[xy.second][xy.first] = -1; }
    bool flag;
    int sum;
    R(i,1,N+1) {
      if(!check(match,i)) { cout<<"0"<<endl; goto exit; }
    }
    res = 0;
    solve(match);
    cout<<res<<endl;
    exit: ;
  }
  return 0;
}

void solve(int map[][MAX_N+1]) {
  //printmap();

  R(i,1,N+1) {
    R(j,i+1,N+1) {
      if(map[i][j]==0) {
        int tmp[MAX_N+1][MAX_N+1];
        memset(tmp,0,sizeof(tmp));
        R(i,0,N+1) R(j,0,N+1) tmp[i][j] = map[i][j];
        tmp[i][j] = 1; tmp[j][i] = -1;  //勝利パターン
        if(check(tmp,i) && check(tmp,j)) solve(tmp);
        tmp[i][j] = -1; tmp[j][i] = 1;  //負けパターン
        if(check(tmp,i) && check(tmp,j))  solve(tmp);
        return ;
      }
    }
  }
  res++;
  return ;
}

bool check(int map[][MAX_N+1],int i) {
  int sum = 0;
  int zero = 0;
  R(j,1,N+1) {
    sum+=map[i][j];
    if(i!=j && map[i][j]==0) zero++;
  }
  if(abs(sum)-zero>0) return false;
  return true;
}

void printmap() {
  R(i,0,N+1) {
    cout<<setw(2)<<match[i][0];
    R(j,1,N+1) cout<<" , "<<setw(2)<<match[i][j];
    cout<<endl;
  }
  cout<<endl;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll n, x, y;
    cin >> n >> x >> y;
    x--, y--;

    ll ans[n+1] = {};
    rep(i, n)rep(j, n){
        if(j <= i)continue;

        //そのままの距離かスキップした距離の最短
        ll dist = min(j-i, abs(x-i)+1+abs(y-j));
        
        ans[dist]++;
    }

    rep(i, n-1)cout << ans[i+1] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] h = new int[N];
        for(int i=0; i<N; i++) {
            h[i] = sc.nextInt();
        }

        int[] dp = new int[N];
        int x = 1;
        dp[x] = dp[x-1] + Math.abs(h[x] - h[x-1]);

        for(x=2; x<N; x++){
            dp[x] = Math.min(dp[x-1] + Math.abs(h[x] - h[x-1]), dp[x-2] + Math.abs(h[x] - h[x-2]));
        }

        System.out.println(dp[N-1]);
    }
}


Measured memory_bytes: 51004
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

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

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = 5010;

int N;
struct Cushion {
    LL H, P;
};

Cushion cush[MAXN];
LL din[MAXN];
const LL INF = 1e18;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    cin >> N;
    for (int i = 0; i < N; i++) cin >> cush[i].H >> cush[i].P;
    sort(cush, cush+N, [&](Cushion A, Cushion B) { return A.H + A.P < B.H + B.P; });
    // for (int i = 0; i < N; i++) cout << cush[i].H << " " << cush[i].P << "\n";
    for (int i = 0; i <= N; i++) din[i] = INF;
    din[0] = 0;
    din[1] = cush[0].P;
    for (int i = 1; i < N; i++) {
        for (int j = i+1; j > 0; j--) {
            if (cush[i].H >= din[j-1]) din[j] = min(din[j], din[j-1] + cush[i].P);
        }
    }
    for (int j = N; j >= 0; j--) {
        if (din[j] != INF) {
            cout << j << "\n";
            return 0;
        }
    }
}



Measured memory_bytes: 384
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]
    t = lines[1]

    return (s, t)


def solve(s, t):
    
    result = 0
    for c, d in zip(s, t):    
        if c != d:
            result += 1
                
    return result    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 68356
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		vector<int> a;
		REP(i, n) {
			int tmp;
			cin >> tmp;
			a.push_back(tmp);
		}
		sort(a.begin(), a.end());
		int ans = 10000000;
		for (int q = 1; q < a.size(); ++q) {
			ans = min(ans, a[q] - a[q - 1]);
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3152
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

struct point{double x,y;};

void koch(int n,point a, point b){
    if(n==0)return;
    
    point s,t,u;
    double th=M_PI*60.0/180.0;
    
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}

int main(){
    point a,b;
    int n;
    
    scanf("%d",&n);
    
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    
    return 0;
    
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  int res;

  res = max(A+B, A-B);
  res = max(res, A*B);

  cout << res << endl;
}


Measured memory_bytes: 256
<?php
$gcds = array();
$lcms = array();

function gcd($a, $b) {
	if($a > $b) {
		list($a, $b) = array($b, $a);
	}

	$gcd_a = $a;
	$gcd_b = $b;

	while (($surplus = $gcd_a % $gcd_b) !== 0) {
		$gcd_a = $gcd_b;
		$gcd_b = $surplus;
	}
	
	return $gcd_b;
}

function lcm($a, $b) {
	return $a * $b / gcd($a, $b);
}

while (($stdin = trim(fgets(STDIN))) !== '') {

	$input = explode(' ', $stdin);

	$a = intval($input[0]);
	$b = intval($input[1]);

	$answers[] = gcd($a, $b).' '.lcm($a, $b)."\n";
}

foreach ($answers as $ans) {
	echo $ans;
}

Measured memory_bytes: 6652
N = int(input().strip())
xyh = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    xyh.append((xi, yi, hi))

xyh.sort(key = lambda t: t[2], reverse = True)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                Hi = xyh[i][2] + abs(xyh[i][0]-Cx) + abs(xyh[i][1]-Cy)
                if H == -1:
                    H = Hi

                if xyh[i][2] == 0:
                    if H > Hi:
                        break
                elif H != Hi:
                    break

                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

Measured memory_bytes: 3064
/*input
RDULULDURURLRDULRLR
*/
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <iterator>
#include <limits>
#include <deque>
#include <algorithm>
#include <cmath>
#include <list>
#include <map>
#include <climits>
#define ff first
#define ss second
#define MAX 10005
#define endl "\n"
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#define trace1(x)							cerr << #x << ": " << x << endl;
#define trace2(x, y)						cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)						cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) 			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

signed main(){
 	ios_base::sync_with_stdio(false);	
 	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	for(int i=0;i<len(s);++i){
		if((i+1)&1){
			if(s[i]=='L'){
				cout<<"No\n";
				return 0;
			}
		}
		else{
			if(s[i]=='R'){
				cout<<"No\n";
				return 0;
			}
		}
	}
	cout<<"Yes";
 	return 0;
}

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

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

  int A[N];
  int amin=N+1, amin_i;
  REP(i, N) {
    cin >> A[i];
    if(A[i] < amin){
      amin = A[i];
      amin_i = i;
    }
  }

  int ans;
  if(amin_i == 0 || amin_i == N-1){
    ans = (N-1)/(K-1);
    if((N-1)%(K-1) != 0) ++ans;
  }

  else if((N-amin_i)%(K-1) == 0){
    ans = (N-amin_i)/(K-1) + (amin_i-1)/(K-1);
    if((amin_i-1)%(K-1) != 0)
    ++ans;
  }

  else if( (amin_i-1)%(K-1) == 0){
    ans = (N-amin_i)/(K-1) + (amin_i-1)/(K-1);
    if((N-amin_i)%(K-1) != 0)
    ++ans;
  }

  else {
    ans = (N-1)/(K-1);
    if((N-1)%(K-1) != 0) ++ans;
  }

  cout << ans << '\n';



  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

#define NMAX 100000
#define QMAX 50000

int BinarySearch (int *, int, int);

int main (void)
{
  int i,n,q,result,count=0,arrayS[NMAX],arrayT[QMAX];

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

  for (i = 0 ; i < q ; i++){
    result = BinarySearch(arrayS,arrayT[i],n);
    if (result != -1)
      count++;
  }
  printf ("%d\n",count);
  return 0;
}

int BinarySearch (int *S, int key, int n)
{
  int left,right,mid;

  left = 0;
  right = n;

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

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

int main(){
  vector<int> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < 3; i++) {
    if (i != 2) {
      cout << a.at(i) << ' ';
    } else {
      cout << a.at(i) << endl;
    }
  }
}


Measured memory_bytes: 3112