akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long int lli;
bool comp(const vector<pair<lli, lli> > &a, const vector<pair<lli, lli> > &b){
    return a.size() < b.size();
}

int main(){
    int n;
    lli a,b;
    cin >> n >> a >> b;
    vector<vector<pair<lli, lli> > > wv(5);
    for(int i=0; i<n; i++){
        lli t,x,y;
        cin >> t >> x >> y;
        t--;
        wv[t].push_back(make_pair(x, y));
    }
    sort(wv.begin(), wv.end(), comp);
    for(int i=0; i<5; i++){
        wv[i].push_back(make_pair(0, 0));
    }

    vector<pair<lli, lli> > en1, en2;
    for(int i=0; i<(int)wv[0].size(); i++){
        for(int j=0; j<(int)wv[1].size(); j++){
            for(int k=0; k<(int)wv[2].size(); k++){
                lli w = wv[0][i].first +wv[1][j].first +wv[2][k].first;
                lli v = wv[0][i].second +wv[1][j].second +wv[2][k].second;
                en1.push_back(make_pair(w, v));
            }
        }
    }
    for(int i=0; i<(int)wv[3].size(); i++){
        for(int j=0; j<(int)wv[4].size(); j++){
            lli w = wv[3][i].first +wv[4][j].first;
            lli v = wv[3][i].second +wv[4][j].second;
            en2.push_back(make_pair(w, v));
        }
    }
    sort(en1.begin(), en1.end());
    sort(en2.begin(), en2.end());

    bool yes = false;
    multiset<lli> validrange;
    int end = en2.size()-1;
    int begin = end; //逆半開
    for(int i=0; i<(int)en1.size(); i++){
        while(begin >= 0 && en2[begin].first +en1[i].first >= a){
            validrange.insert(en2[begin].second);
            begin--;
        }
        while(end > begin && en2[end].first +en1[i].first > b){
            validrange.erase(validrange.find(en2[end].second));
            end--;
        }
        auto itr = validrange.lower_bound(a -en1[i].second);
        if(itr != validrange.end() && *itr +en1[i].second <= b){
            yes = true;
            break;
        }
    }

    if(yes){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 19480
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
/**
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B&lang=ja
 * 
 * How many ways?
 * 
 * 1 から n までの数の中から、重複無しで３つの数を選びそれらの合計が x となる組み合わせの数を求めるプログラムを作成して下さい。
**/
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    while(true){
        int n = 0, x = 0, ans = 0;
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        for1(i, n-2){
            fore(j, i+1, n-1){
                int diff = x - i - j;
                if(diff >= j + 1 && diff <= n){
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


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


int main()
{	
	int a, b, c, d;

	cin >> a >> b >> c;

	if (a>=b)
	{
		d = a;
		a = b;
		b = d;

	}
	
	if (c<=a)
	{
		cout << c << " "  << a << " " << b << endl;
		return 0;
	}

	if (b <= c)
	{
		cout << a << " " << b << " " << c << endl;
		return 0;
	}
	
	if (a <= c && c <= b)
	{
		cout << a << " " << c  << " " << b << endl;
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 1164
x=int(input())
import math
y=0
if x==2:
  y=2
else:
  while y==0:
    if x % 2 ==0:
      x+=1
      continue
    else:
      c=0
      for i in range(3,int(math.sqrt(x))):
        if x % i == 0:
          c+=1
      if c ==0:
        y=x
        break
      else:
        x+=1
print(y)
        

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

int main(){
    char ku[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    char c;
    cin>>c;
    for(int i=0;i<26;i++){
        if(ku[i]==c){
            cout<<ku[i+1];
            break;
        }
    }

    
    
}




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

int main(){
    ll n,a[200005],count[200005],ans=1;
    rep(i,200005){
        count[i]=0;
    }
    cin>>n;
    rep(i,n){
        cin>>a[i];
        count[a[i]]++;
    }
    rep(i,200005){
        ans+=count[i]*(count[i]-1)/2;
    }
    rep(i,n){
        cout<<ans-count[a[i]]<<endl;
    }
}

Measured memory_bytes: 6628
input_first = input().split()
N = int(input_first[0])
L = int(input_first[1])
list_input = []

for i in range(N):
    list_input.append(input())

sorted_list_input = sorted(list_input)
#print(list_input)
#print(sorted(list_input))
for j in range(N):
    print(sorted_list_input[j], end="")
print("")

Measured memory_bytes: 3060
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int u[SIZE];
PII AA[SIZE];
int main(){
    int N,K;
    R(N,K);
    REP(i,N)R(AA[i].S,AA[i].F);
    sort(AA,AA+N,greater<PII>());
    int cnt=0;
    LL v=0;
    REP(i,K){
        u[AA[i].S]++;
        if(u[AA[i].S]==1)cnt++;
        v+=AA[i].F;
    }
    int it=K-1;
    LL an=v+(LL)cnt*cnt;
    REPP(i,K,N){
        if(!u[AA[i].S]){
            while(it>=0&&u[AA[it].S]==1)it--;
            if(it<0)break;
            u[AA[it].S]--;
            v-=AA[it].F;
            it--;
            u[AA[i].S]++;
            v+=AA[i].F;
            cnt++;
            an=max(an,v+cnt*(LL)cnt);
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin>>n;
	bool a[26],b[26];
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<n;i++){
		for(int i=0;i<26;i++){
			a[i]=0,b[i]=0;
		}
		for(int j=0;j<i;j++){
			a[(int)s[j]-'a']++;
		}
		for(int j=i;j<n;j++){
			b[(int)s[j]-'a']++;
		}
		int sum=0;
		for(int i=0;i<26;i++){
			if(a[i]&b[i]){
				sum++;
			}
		}
		ans=max(ans,sum);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct Operation {
  int y, x, ny, nx;
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int h,w;
  cin >> h >> w;
  vector<vector<int> > a(h, vector<int>(w));
  rep(i,h) rep(j,w) {
    cin >> a[i][j];
  }
  vector<Operation> ans;
  rep(y,h) rep(x,w) {
    if (a[y][x] % 2 == 1) {
      if (x < w-1) { //右に渡す
        a[y][x+1]++;
        a[y][x]--;
        Operation op;
        op.x = x; op.y = y; op.nx = x+1; op.ny = y;
        ans.emplace_back(op);
      }
      else if (y < h-1) { //下に渡す
        a[y+1][x]++;
        a[y][x]--;
        Operation op;
        op.x = x; op.y = y; op.nx = x; op.ny = y+1;
        ans.emplace_back(op);
      }
    }
  }
  cout << ans.size() << endl;
  for (auto op : ans) {
    cout << op.y+1 << " " << op.x+1 << " " << op.ny+1 << " " << op.nx+1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 5236
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	auto tmp = n;
	int s = 0;
	while (tmp > 0) {
		s += tmp % 10;
		tmp /= 10;
	}

	cout << (n % s == 0 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main() {
    int a, b, c;
    int cnt = 0, i;
    
    scanf("%d%d%d", &a, &b, &c);
    for(i = a; i <= b; i++) {
        if(c%i == 0) cnt++;
    }
    printf("%d\n", cnt);
    
    return 0;
}


Measured memory_bytes: 2104
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
void f(int a[],int c,int m,int n){
  int i;
  if(n==0){
    for(i=0;i<c-1;i++)
      cout<<a[i]<<" ";
    cout<<a[i]<<endl;
    return;
  }
  for(i=m;i>0;i--){
    if(i<=n){
      a[c]=i;
      f(a,c+1,i,n-i);
    }
  }
  return;
}
int main(){
  int a[30],n;
  while(cin>>n&&n)
    f(a,0,n,n);
  return 0;
}

Measured memory_bytes: 872
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
int a[200001];
int b[200001];

int main() { // 34        
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	vector<int> v;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = n; i >= 1; i--) {
		int sum = 0;
		for (int j = 2; j*i <= n; j++) {
			if (b[j * i])sum += 1;
		}
		if ((sum % 2) != a[i]) {
			b[i] = 1;
			v.push_back(i);
		}
	}

	cout << v.size() << '\n';
	for (int i = 0; i < v.size(); i++) {
		cout << v[i] << ' ';
	}cout << '\n';

}

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

int main () {
  int a,b,c;
  cin >> a >> b >> c;
  
  if(a==b && a ==c){
    cout<<1<<endl;
  }else if(a!=b && a!=c && b!=c){
    cout<<3<<endl;
  }else {
    cout<<2<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

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

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

int n;
int arr[3005];
int dp[3005][3005];

int solve(int l, int r) {

	if (r - l <= 1) {
		return max(arr[l], arr[r]);
	}

	if (dp[l][r] != -1)	return dp[l][r];

	int ans;

	ans = max((arr[l] + min(solve(l + 2, r), solve(l + 1, r - 1))), (arr[r] + min(solve(l + 1, r - 1), solve(l, r - 2))));
	dp[l][r] = ans;
	return ans;
}

int32_t main() {

	fastIO();
	fo(i, 0, 3001, 1) {
		fo(j, 0, 3001, 1)
		dp[i][j] = -1;
	}
	cin >> n;
	arrIn(arr, n);
	int sum = 0;
	fo(i, 0, n, 1)	sum += arr[i];
	// cout << solve(0, n - 1) << endl;
	cout << 2 * solve(0, n - 1) - sum;

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N, X, Y, Z;

// x の n 乗 を m で余りをとったもの
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while ( n > 0) {
        if (n & 1) { res = res * x % mod; } // 最下位ビットが立っているときに x^(2^i) を掛ける
        x = x * x % mod;                    // x を順次 2 乗していく
        n >>= 1;
    }
    return res;
}

// ビットパターンから XYZ が作れるなら true
bool Check(int pat) {
    if( (((pat >> (X - 1)) & 1 ) == 1) &&
        (((pat >> (X + Y - 1)) & 1 ) == 1) &&
        (((pat >> (X + Y + Z - 1)) & 1 ) == 1) ) {
        return true;
    }
    return false;
}

void DispBit(int pat) {
    for(int i = 15; i >= 0; --i) {
        if( ((pat >> i) & 1) == 1) {
            printf("1");
        } else {
            printf("0");
        }
    }
    printf("\n");
}

// 今 i まで見ていて、これ以前に出てくる数字のパターンが pat だった場合
// の XYZ が現れない回数
ll dfs(ll i, int pat) {
    if(i >= N) { return 1; }

    //DBG("i: %lld pat: ", i);
    //DispBit(pat);

    ll ret = 0;
    pat <<= 1;
    pat |= 1;
    REP(j, 10) {
        if(!Check(pat)) {
            ret += dfs(i+1, pat);
            ret %= MOD;
        }
        pat <<= 1;
    }
    return ret;
}

ll dp[50][140000];

int main()
{
    cin >> N >> X >> Y >> Z;

    ll base = mod_pow(10, N, MOD);
    //ll ans = (base - dfs(0, 0) + MOD) % MOD;

    ZERO(dp);
    for(int i = N; i >= 0; --i) {
        for(int j = 0; j <= (1 << 17); ++j) {
            if(i == N) { dp[i][j] = 1; }
            else {
                ll ret = 0;
                int pat = j;
                pat <<= 1;
                pat |= 1;
                pat &= 0x1FFFF;
                REP(k, 10) {
                    if(!Check(pat)) {
                        ret += dp[i+1][pat];
                        ret %= MOD;
                    }
                    pat <<= 1;
                    pat &= 0x1FFFF;
                }
                dp[i][j] = ret;
            }
        }
    }
    ll ans = (base - dp[0][0] + MOD) % MOD;

    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;
const int Ns = 105;

int dp[N];
int vis[Ns];
int n, k;
int a[Ns];

void clearvis(){
    for(int i=0;i<Ns;i++){
        vis[i]=0;
    }
}

int findlow(){
    for(int i=0;i<Ns;i++){
        if(!vis[i]) return i;
    }
}

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

    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    dp[0] = 0;
    for(int i=1;i<=k;i++){
        clearvis();
        for(int j=0;j<n;j++){
            int u = i-a[j];
            if(u<0) continue;
            vis[dp[u]] = 1;
        }
        dp[i] = findlow();
    }

    if(dp[k]){
        cout << "First\n";
    }else{
        cout << "Second\n";
    }

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

ll MOD = 1000000007;




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

	for (int i = 0; i < S.length(); ++i)
	{
		if (i % 2)
		{
			if(S[i]=='L'|| S[i] == 'D' || S[i] == 'U')
			{

			}
			else
			{
				cout << "No" << endl;
				return 0;
			}
		}
		else
		{
			if (S[i] == 'R' || S[i] == 'D' || S[i] == 'U')
			{

			}
			else
			{
				cout << "No" << endl;
				return 0;
			}
		}

	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 1e18;
    for(int bit = 0; bit < 1 << n; bit++) {
        if(__builtin_popcount(bit) < k) continue;
        ll now = 0;
        int mx = 0;
        for(int i = 0; i < n; i++) {
            if(1 & bit >> i) {
                if(mx >= a[i]) {
                    now += mx + 1 - a[i];
                    mx = mx + 1;
                }else{
                    chmax(mx, a[i]);
                }
            }else {
                chmax(mx, a[i]);
            }
        }
        chmin(ans, now);
    }
    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 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)

using ll = long long;
using ld = long double;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    ll res = 0;
    map<ll, ll> mp;
    FOR (i, 1, n + 1) {
        ll a;
        cin >> a;
        res += mp[i - a];
        mp[i + a]++;        
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 26244
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  ll sum1[N],sum2[N];
  sum1[0] = a[0];
  sum2[0] = a[0];
  for(int i=1;i<N;i++){
    sum1[i] = sum1[i-1] + a[i];
    sum2[i] = sum2[i-1] + a[i];
  }

  /*for(int i=0;i<N;i++) cout << sum1[i] << " ";
  cout << endl;*/

  //+-+-+-...
  ll ans1 = 0LL;
  ll ope = 0LL;
  for(int i=0;i<N;i++){
    sum1[i] += ope;
    if(i%2==0 && sum1[i]<=0){
      ope += 1 - sum1[i];
      ans1 += 1 - sum1[i];
    }
    else if(i%2==1 && sum1[i]>=0){
      ope += -1 - sum1[i];
      ans1 += sum1[i] + 1;
    }
  }

  //-+-+-+...
  ll ans2 = 0LL;
  ope = 0;
  for(int i=0;i<N;i++){
    sum2[i] += ope;
    if(i%2==1 && sum2[i]<=0){
      ope += 1 - sum2[i];
      ans2 += 1 - sum2[i];
    }
    else if(i%2==0 && sum2[i]>=0){
      ope += -1 - sum2[i];
      ans2 += sum2[i] + 1;
    }
  }

  /*for(int i=0;i<N;i++) cout << sum1[i] << " ";
  cout << endl;
  for(int i=0;i<N;i++) cout << sum2[i] << " ";
  cout << endl;

  cout << ans1 << ans2 << endl;*/
  cout << min(ans1, ans2) << endl;
  return 0;
}


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

using namespace std;

void fill(char b, char c, int n){
  for(int i=0; i<100; i++) cout << b;
  cout << endl;
  for(int j=0;j<49;j++){
    for(int i=0;i<100;i++){
      if(n>0 && j%2==1 && i%2 == 0){
        n--;
        cout << c;
      } else cout << b;
    }
    cout << endl;
  }
}

int main(void){
  int A, B;
  cin >> A >> B;
  cout << 100 << " " << 100 << endl;
  fill('#', '.', A-1);
  fill('.', '#', B-1);
  return 0;
}


Measured memory_bytes: 256
fn c_id() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let tmp: Vec<usize> = input.trim_right()
        .split_whitespace()
        .map(|s| s.parse::<usize>().unwrap())
        .collect();
    let n = tmp[0];
    let m = tmp[1];

    let mut pref = Vec::new();
    let mut city = Vec::new();
    let mut list : Vec<Vec<usize>> = vec![Vec::new(); n + 1]; 

    for i in 0..m {
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        let tmp: Vec<usize> = input.trim_right()
            .split_whitespace()
            .map(|s| s.parse::<usize>().unwrap())
            .collect();

        pref.push(tmp[0]);
        city.push(tmp[1]);
        list[tmp[0]].push(tmp[1]);
    }

    for arr in &mut list {
        arr.sort();
    }

    for (p, c) in pref.iter().zip(city.iter()) {
        let index = list[*p].binary_search(c).expect("not found");
        println!("{0: >06}{1: >06}", p, index + 1);
    }
}

fn main() {
    c_id();
}

Measured memory_bytes: 15868
//0066

#include<stdio.h>
int main(void)
{
	const int N = 9;
	char str[N+1];
	while(scanf("%s", str) == 1)
	{
		const char ca[] = "ox";
		char findC = 'd';
		for(int i = 0; i <= 1; i++)
		{
			const char c = ca[i];
			if(
				(c == str[0] && c == str[1] && c == str[2]) ||
				(c == str[3] && c == str[4] && c == str[5]) ||
				(c == str[6] && c == str[7] && c == str[8]) ||
				(c == str[0] && c == str[3] && c == str[6]) ||
				(c == str[1] && c == str[4] && c == str[7]) ||
				(c == str[2] && c == str[5] && c == str[8]) ||
				(c == str[0] && c == str[4] && c == str[8]) ||
				(c == str[2] && c == str[4] && c == str[6]) )
			{
				findC = c;
				break;
			}
		}
		putchar(findC);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 0
while True:
	n, x = map(int, input().split())
	if n == 0 and x == 0:
		break
	ans = 0
	for i in range(1, n + 1):
		for j in range(1, i):
			for k in range(1, j):
				if i + j + k == x:
					ans += 1
	print(ans)


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<unsigned, unsigned>> balls(N);
    for(auto& i : balls)cin >> i.first >> i.second;
    map<unsigned long, unsigned long> mp;
    unsigned long mx{0};
    for(const auto& i : balls)for(const auto& j : balls)if(i.first != j.first || i.second != j.second)mx = max(mx, ++mp[(static_cast<unsigned long>(i.first - j.first) << 30) + (i.second - j.second)]);
    cout << N - mx << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T1, class T2, class T3> void sortA_L(int N, T1 a[], T2 b[], T3 c[], void *mem = wmem){
  int i;
  pair<T1, pair<T2, T3> > *arr=(pair<T1, pair<T2, T3> > *) mem;
  for(i=0;i<N;i++){
    arr[i].first = a[i];
    arr[i].second.first = b[i];
    arr[i].second.second = c[i];
  }
  sort(arr, arr+N);
  for(i=0;i<N;i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second.first;
    c[i] = arr[i].second.second;
  }
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
char memarr[96000000];
int N;
int Q;
int S[200000];
int T[200000];
int X[200000];
int D[200000];
int res[200000];
int pl[600000];
int tp[600000];
int ev[600000];
int sz;
int main(){
  int i, k;
  set<int> s;
  wmem = memarr;
  rd(N);
  rd(Q);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(S[Lj4PdHRW]);
      rd(T[Lj4PdHRW]);
      rd(X[Lj4PdHRW]);
    }
  }
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<Q;KL2GvlyY++){
      rd(D[KL2GvlyY]);
    }
  }
  sz = 0;
  for(i=0;i<N;i++){
    pl[sz] = X[i]-T[i];
    tp[sz] = -1;
    ev[sz] = i;
    sz++;
    pl[sz] = X[i]-S[i];
    tp[sz] = -2;
    ev[sz] = i;
    sz++;
  }
  for(i=0;i<Q;i++){
    pl[sz] = -D[i];
    tp[sz] = -3;
    ev[sz] = i;
    sz++;
  }
  sortA_L(sz, pl, tp, ev);
  for(k=0;k<sz;k++){
    if(tp[k]==-1){
      s.insert(X[ev[k]]);
    }
    if(tp[k]==-2){
      s.erase(X[ev[k]]);
    }
    if(tp[k]==-3){
      if(s.size()==0){
        res[ev[k]] = -1;
      }
      else{
        res[ev[k]] = *(s.begin());
      }
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS=0;Q5VJL1cS<Q;Q5VJL1cS++){
      wt_L(res[Q5VJL1cS]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190526-1

// --- original code ---
// int N, Q;
// int S[2d5], T[2d5], X[2d5];
// int D[2d5];
// 
// int res[2d5];
// int pl[6d5], tp[6d5], ev[6d5], sz;
// 
// {
//   int i, k;
//   set<int> s;
// 
//   rd(N,Q,(S,T,X)(N),D(Q));
// 
//   sz = 0;
//   rep(i,N){
//     pl[sz] = X[i]-T[i];
//     tp[sz] = -1;
//     ev[sz] = i;
//     sz++;
// 
//     pl[sz] = X[i]-S[i];
//     tp[sz] = -2;
//     ev[sz] = i;
//     sz++;
//   }
//   rep(i,Q){
//     pl[sz] = -D[i];
//     tp[sz] = -3;
//     ev[sz] = i;
//     sz++;
//   }
// 
//   sortA(sz, pl, tp, ev);
// 
//   rep(k,sz){
//     if(tp[k]==-1) s.insert(X[ev[k]]);
//     if(tp[k]==-2) s.erase(X[ev[k]]);
//     if(tp[k]==-3){
//       if(s.size()==0)  res[ev[k]] = -1;
//       else             res[ev[k]] = *(s.begin());
//     }
//   }
// 
//   wtLn(res(Q));
// }


Measured memory_bytes: 29056
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int D, G;
int A[10], C[10];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> D >> G;
  rep(i, D) cin >> A[i] >> C[i];
  int m = INF;
  rep(S, 1<<D) {
    int s = 0, g = 0;
    rep(i, D) if ((S>>i)&1) s += A[i], g += A[i]*(100*(i+1)) + C[i];
    for (int i=D-1; i>=0; i--) if (((S>>i)&1) == 0) {
      rep(_, A[i]) if (g < G) g += (i+1)*100, s++;
    }
    if (g >= G) m = min(m, s);
  }
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a;
  cin >>a;
  int b = a%10;
  if(b == 3){ cout << "bon" << endl;}
  else if((b==0) || (b==1) || (b==6) || (b==8)){ cout << "pon" << endl;}
  else {cout << "hon" << endl;}
}

Measured memory_bytes: 3560
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
all=sum(B)-sum(A)
for a,b in zip(A,B):
   if a>b:count -=a-b
   elif b>a:count +=(b-a)//2

print("Yes" if count>=0 else "No")

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

using namespace std;
 
int main(void){
  int H,W;
  cin >> H >> W;
  
  vector<string> vec(H);
  
  for(int i = 0;i < H;i++){
    cin >> vec.at(i);
  }
  
  for(int i = 1;i <= H + 2;i++){
    if(i == 1 || i == H + 2){
      for(int j = 1;j <= W + 2;j++) cout << "#";
      cout << endl;
    }else{
      cout << "#" << vec.at(i-2) << "#" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	bool turn = true;//trueのとき高橋君
	while (1) {
		if (turn) {
			//高橋
			C = C - B;
		}
		else {
			//青木
			A = A - D;
		}

		if (A <= 0) {
			cout << "No" << endl;
			break;
		}else if(C <= 0) {
			cout << "Yes" << endl;
			break;
		}

		turn = !turn;
	}
}


Measured memory_bytes: 3556
#include <stdio.h>

int main(void){
  int numberlist[31], vertical, horizon, swap1, swap2, i, tmp;

  scanf("%d", &vertical);
  for(i = 0; i <= vertical; ++i){
    numberlist[i] = i;
  }
  scanf("%d", &horizon);
  for(i = 0; i < horizon; ++i){
    scanf("%d%*c%d", &swap1, &swap2);
    tmp = numberlist[swap1];
    numberlist[swap1] = numberlist[swap2];
    numberlist[swap2] = tmp;
  }
  for(i = 1; i <= vertical; ++i){
    printf("%d\n", numberlist[i]);
  }
  return 0;
}

Measured memory_bytes: 0
#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)

using ll = long long;
using ld = long double;

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

int n, a, b, c;
vector<int> l;

int dfs(int cur = 0, int x = 0, int y = 0, int z = 0) {
    if (cur == n) {
        if (!x || !y || !z) return Inf;
        return abs(x - a) + abs(y - b) + abs(z - c);
    }
    int res = Inf;
    res = min(res, dfs(cur + 1, x + l[cur], y, z) + 10);
    res = min(res, dfs(cur + 1, x, y + l[cur], z) + 10);
    res = min(res, dfs(cur + 1, x, y, z + l[cur]) + 10);
    res = min(res, dfs(cur + 1, x, y, z));

    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> n >> a >> b >> c;
    l.resize(n);
    rep (i, n) cin >> l[i];
    cout << dfs() - 30 << endl;

    return 0;
}



Measured memory_bytes: 256
// ~K Perm Counting
// * frank_c1
// * 2017 / 10 / 01

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

const int maxn = 2005;
const int mo = 924844033;
int f[maxn][maxn][3], g[maxn], h[maxn], fac[maxn];

inline int M(int x) {
	if (x >= mo) x -= mo; return x;
}

inline void add(int& x, int v) {
	x += v; if (x >= mo) x -= mo;
}

int main() {
	int n, K;
	scanf("%d%d", &n, &K);
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i - 1] * i % mo;
	int mx = n / K + 1;
	f[0][0][0] = 1;
	for (int i = 0; i < mx; ++i) for (int j = 0; j <= i; ++j) {
		int all = M(f[i][j][0] + f[i][j][2]);
		add(f[i + 1][j][0], all);
		add(f[i + 2][j + 2][0], all);
		add(f[i + 1][j][1], M(all << 1));
		add(f[i + 1][j + 1][2], f[i][j][1]);
		add(f[i + 1][j + 1][2], f[i][j][2]);
	}
	g[0] = 1;
	for (int i = 1; i <= K; ++i) {
		int w = (n - i) / K + 1; 
		memcpy(h, g, sizeof(g)); memset(g, 0, sizeof(g));
		for (int j = 0; j <= w; ++j) {
			for (int k = n; k >= j; --k) add(g[k], 1LL * h[k - j] * (f[w][j][0] + f[w][j][2]) % mo);
		}
	}
	LL ret = 0; int sgn = 1;
	for (int i = 0; i <= n; ++i) (ret += 1LL * sgn * fac[n - i] * g[i]) %= mo, sgn = -sgn;
	return printf("%lld\n", (ret % mo + mo) % mo), 0;
}

Measured memory_bytes: 45696
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll>a(x+1),b(y+1),c(z+1);
  rep(i,x)cin>>a[i];
  rep(i,y)cin>>b[i];
  rep(i,z)cin>>c[i];
  a[x]=(-(ll)1e17);
  b[y]=(-(ll)1e17);
  c[z]=(-(ll)1e17);
  sort(all(a),greater<ll>());
  sort(all(b),greater<ll>());
  sort(all(c),greater<ll>());
  priority_queue<pair<ll,int>>q;
  unordered_set<int> ma;
  q.push({a[0]+b[0]+c[0],0});
  rep(i,k)
  {
    auto tq=q.top();q.pop();
    int x[3]={tq.second&1023,tq.second>>10&1023,tq.second>>20&1023};
    int ts;
    rep(j,3)
    {
      x[j]++;
      if(!ma.count(ts=tq.second+(1<<(10*j)))){ma.insert(ts);q.push({a[x[2]]+b[x[1]]+c[x[0]],ts});};
      x[j]--;
    }
    cout<<tq.first<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 768
# @uthor : Kaleab Asfaw
from sys import stdin, stdout
# Fast IO
# from math import gcd

def input():
	a = stdin.readline()
	if a[-1] == "\n": a = a[:-1]
	return a
def print(*argv, end="\n", sep=" "):
	n = len(argv)
	for i in range(n):
		if i == n-1: stdout.write(str(argv[i]))
		else: stdout.write(str(argv[i]) + sep)
	stdout.write(end)
# Others
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
	ans = 1
	for i in range(1, x+1): ans = (ans * i) % mod
	return ans
def arr2D(n, m, default=0):
	lst = []
	for i in range(n): temp = [default] * m; lst.append(temp)
	return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n, lst):
	if sum(lst) > n: return -1
	return n - sum(lst)

n, a = list(map(int, input().split()))
lst = list(map(int, input().split()))
print(solve(n, lst))

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


void solve(long long H, long long W, std::vector<std::string> S){
    long long ans[H][W] = {};
    for(long long h = 0; h < H; ++h){
        for(long long w = 0; w < W; ++w){
            if(S[h][w] == '#'){
                if(w-1 >= 0 && ans[h][w-1] != '#') ans[h][w-1] ++;
                if(h-1 >= 0 && ans[h-1][w] != '#') ans[h-1][w] ++;
                if(w-1 >= 0 && h-1 >= 0 && ans[h-1][w-1] != '#') ans[h-1][w-1] ++;
                if(h+1 <= H-1 && ans[h+1][w] != '#') ans[h+1][w] ++;
                if(w+1 <= W-1 && ans[h][w+1] != '#') ans[h][w+1] ++;
                if(h+1 <= H-1 && w+1 <= W-1 && ans[h+1][w+1] != '#') ans[h+1][w+1] ++;
                if(h-1 >= 0 && w+1 <= W-1 && ans[h-1][w+1] != '#') ans[h-1][w+1] ++;
                if(w-1 >= 0 && h+1 <= H-1 && ans[h+1][w-1] != '#') ans[h+1][w-1] ++;
            }
        }
    }
    for(long long h = 0; h < H; ++h){
        for(long long w = 0; w < W; ++w){
            if(S[h][w] == '#') cout << '#';
            else cout << ans[h][w];
        }
        cout << endl;
    }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<std::string> S(H);
    for(int i = 0 ; i < H ; i++){
        std::cin >> S[i];
    }
    solve(H, W, std::move(S));
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.append(0)
B=[0]
tmp=0
x=0
for a in A:
    tmp+=abs(x-a)
    x=a
    B.append(tmp)
A.insert(0,0)
for i in range(N):
    print(B[i]+(B[N+1]-B[i+2])+abs(A[i+2]-A[i]))


Measured memory_bytes: 57580
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

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

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int a,b,c;cin>>a>>b>>c;
  if((b-c)*(c-a)>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



signed main() {

	int a;
	cin >> a;
	string s;
	cin >> s;

	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
	

	return 0;
}


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

int N;
int A[210];         // 最大 200 個なので余裕を持って 210 に

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

    int res = 0;

    // 操作が行える限り操作を繰り返す
    while (true) {
        bool exist_odd = false;
        for (int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;
        }

        if (exist_odd) break;  // 奇数があったら break

        // 操作を行えるなら操作を実際に行う
        for (int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;  // 操作回数をインクリメント
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

#define int ll
void solve()
{
	ll n;
	cin>>n;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	int ans=1000;
	int cul=0;
	rep(i,n-1){
		int pos=i;
		if(a[i]<a[i+1]){
			while(pos<n-1&&a[pos]<=a[pos+1]){
				++pos;
			}
			int x=ans/a[i];
			ans-=x*a[i];
			ans+=a[pos]*(x+cul);
			cul=0;
			i=pos-1;
		}
		else{
			while(pos<n-1&&a[pos]>=a[pos+1]){
				++pos;
			}
			if(pos==n-1){
				i=pos-1;
				break;
			}
			int x=ans/a[pos];
			ans-=x*a[pos];
			//ans+=b[i]*x;
			cul=x;
			i=pos-1;
		}
		//cout<<ans<<endl;
	}
	cout<<max(1000ll,ans);
}
#undef int
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 110;

int a, b, k;

int main()
{
    cin >> a >> b >> k;

    for(int i = a; i >= 1; i--)
    {
        if(a % i == 0 && b % i == 0) k--;
        if(!k)
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

case class Input(xs: List[Int], as: List[Int]) {
  def solved: Output = {
    val xary: Array[Int] = xs.toArray
    val n = xs.length
    for (a <- as) {
      if (!(xary(a-1) == 2019) && (a == n || !(xary(a-1)+1 == xary(a))))
        xary(a-1) += 1
    }
    Output(xary.toList)
  }
}

object Input {
  def fromStdin(): Input = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val xs = List.fill(n)(sc.nextInt)
    val m = sc.nextInt()
    val as = List.fill(m)(sc.nextInt)
    Input(xs, as)
  }
}

case class Output(ys: List[Int]) {
  override def toString(): String = {
    ys.foldLeft("")(_ + _.toString() + "\n")
  }
  def print() = printf(this.toString())
}

object Main extends App {
  Input.fromStdin().solved.print()
}



Measured memory_bytes: 45644
N= int(input())
S = [input() for _ in range(N)]

IB= [0] * (N)
LA = [0] * (N)
flag = True
Eflag = False
cntb= 0
cnta = 0
ans = 0
for i in range(N):
    if S[i][0] == 'B':
        IB[i] = 1
        cntb += 1
    if S[i][len(S[i])-1] == 'A' :
        LA[i] = 1
        cnta += 1
    if (IB[i] == 1 and LA[i] == 0) or (IB[i]==0 and LA[i] == 1):
        flag = False
    elif (IB[i] == 1 and LA[i] == 1):
        Eflag = True
    for j in range(len(S[i])-1):
        if S[i][j] == 'A' and S[i][j+1]=='B' : ans += 1
        
        
ans += min(cntb,cnta)
if Eflag and flag:    
    ans -= 1



print(ans)
    


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;


int main() {


    int N;
    cin >> N;

    int p;
    cin >> p;
    int m = p;
    int cnt = 1;

    for (int i = 0; i < N - 1; ++i) {
        cin >> p;
        if (m >= p) {
            cnt += 1;
            m = p;
        }
    }

    cout << cnt << "\n";

    return 0;
}


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

string a, b, u;
int n, m;

int main() {
	cin >> a >> b;
	cin >> n >> m;
	cin >> u;

	if(u == a)
		n--;

	if(u == b)
		m--;

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

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

using namespace std;


/* //vector
int main()
{
	int N, ans = 0, check = 0;
	char c;
	string S;

	cin >> N;
	cin >> S;

	int mark = 0;
	for (int j = 1; j < N; j++) {
		if (S[j] == 'E') mark++;
	}
	ans = mark;
	check = mark;
	for(int i = 1; i < N; i++){
		if (S[i - 1] == 'W') check++;
		if (S[i] == 'E') check--;
		ans = min(ans, check);
	}
	


	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}
*/


int main()
{
	int N, ans = 0, check = 0;
	char c;
	char S[300005];

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}

	int mark = 0;
	for (int j = 1; j < N; j++) {
		if (S[j] == 'E') mark++;
	}
	ans = mark;
	check = mark;
	for (int i = 1; i < N; i++) {
		if (S[i - 1] == 'W') check++;
		if (S[i] == 'E') check--;
		ans = min(ans, check);
	}



	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}

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

int main() {
  string ans = "No";
  vector<vector<int>> data(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int l = 0; l < 3; l++) {
      cin >> data.at(i).at(l);
    }
  }
  int n;
  cin >> n;
  vector<int> num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  for (int i = 0; i < 3; i++) {
    for (int l = 0; l < 3; l++) {
      for (int x : num) {
        if (x == data.at(i).at(l)) {
          data.at(i).at(l) = -1;
        }
      }
    }
  }
  vector<int> sum_V(3), sum_H(3), sum_D(2);
  for (int i = 0; i < 3; i++) {
    for (int l = 0; l < 3; l++) {
      if (data.at(i).at(l) == -1) sum_V.at(l) += 1;
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int l = 0; l < 3; l++) {
      if (data.at(i).at(l) == -1) sum_H.at(i) += 1;
    }
  }
  for (int i = 0; i < 3; i++) {
    if (data.at(i).at(i) == -1) sum_D.at(0) += 1;
    if (data.at(i).at(2 - i) == -1) sum_D.at(1) += 1;
  }
  for (int i = 0; i < 3; i++) {
    if (sum_V.at(i) == 3 || sum_H.at(i) == 3) {
      ans = "Yes";
    }
  }
  if (sum_D.at(0) == 3 || sum_D.at(1) == 3) ans = "Yes";

  cout << ans << endl;
}

Measured memory_bytes: 256
n, m, l = map(int, input().split())

A=[list(map(int, input().split())) for a in range(n)]
b=[list(map(int, input().split())) for B in range(m)]

x = [[sum([j*k for j,k in zip(h,i)]) for i in zip(*b)] for h in A]

for ans in x:
    print(*ans)



Measured memory_bytes: 6996
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  ll a;
  double b;
  cin >> a >> b;
  double b2=b*100+0.5;
  ll ans=a*(int)b2;
  ans/=10ll;
  ans/=10ll;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3728
n,w = map(int,input().split())

lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key = lambda x:x[1])

dp = {0:0}

for weight ,value in lis:
    gone = dp.copy()
    for key in dp:
        gone[key+value] = min(dp[key] + weight, dp.get(key+value, float("inf")))
    dp = gone
for key in sorted(dp.keys(), reverse = True):
    if dp[key] <= w:
        print(key)
        exit()

Measured memory_bytes: 119768
#include <iostream>

int main() {
  unsigned int N;
  std::cin >> N;

  unsigned int max;
  unsigned int min;

  for (size_t i=0; i<N; i++) {
    unsigned int a;
    std::cin >> a;

    if (i==0) {
      max = a;
      min = a;
    }

    if (max < a) max = a;
    if (min > a) min = a;
  }

  std::cout << (max - min) << std::endl;

  return 0;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    ll x;
    cin >> x;
    vector<ll> dp(x+1,INF);
    dp[0] = 0;
    for(i=0;i<=5;i++){
        for(j=0;j<=x;j++){
            if(100+i+j<=x)dp[100+i+j] = min(dp[j]+1,dp[100+i+j]);
        }
    }
    if(dp[x]!=INF)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1024