akhauriyash/Code-Regression huggingface dataset:
// ※※※ 解答不能 ※※※
// 正解者のソースを学習する(一部改変).
// tourist氏
// https://atcoder.jp/contests/agc035/submissions/6377064
#include <bits/stdc++.h>
using namespace std;

int main(){

    int N;
    scanf("%d", &N);
    vector<int> a(N);
    map<int, int> cnt;
    for(int i = 0; i < N; i++){
        scanf("%d", &a[i]);
        ++cnt[a[i]];
    }
    
    if(cnt[0] == N){
        printf("%s\n", "Yes");
        return 0;
    }
    
    if(N % 3 != 0){
        printf("%s\n", "No");
        return 0;
    }
    
    vector<int> all;
    for(auto& p : cnt){
        for(int i = 0; i < p.second / (N / 3); i++){
            all.push_back(p.first);
        }
    }
    
    if(all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) printf("%s\n", "Yes");
    else                                                   printf("%s\n", "No");
    
    return 0;
}

Measured memory_bytes: 4224
/*
	Created on 29-09-20 13:11

	@author: roastedcoder
*/

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const int MAX = 1e6 + 5;
const int N = 1e5 + 5;
//const int MAXX = 1e14;

//#define ll long long
#define int long long
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pb push_back
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
//__________________________________________________________________


int32_t main() {
	roastedcoder
	int k; cin>>k;
	while(k--) cout<<"ACL";
}

//__________________________________________________________________
/*
Sample Input:


Sample Output:


*/
/*
MY NOTES:
  int for long long
  Don't make Segment Tree and Fenwick Tree 0-based you FOOL.
  Always try to exhaust the time being provided and PACE yourself.
*/

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputArray = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = inputArray[0] - 1;
            int K = inputArray[1];
            List<long> L = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToList();
            L.Sort();
            for(int i = N;i > N - K && i >= 0; i--)
            {
                L.RemoveAt(i);
            }
            Console.WriteLine(L.Sum());
        }
    }
}

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

const int MAX=1e7+10;

int n,ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n,n){
        vector<int> a(n);
        for (int i=0;i<n;++i) cin >> a[i];
        ans=MAX;
        for (int i=0;i<n;++i)
            for (int j=i+1;j<n;++j)
                ans=min(ans,abs(a[i]-a[j]));
        cout << ans << endl;
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using lb=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   int n;cin>>n;
           bool ans=false;
           int sz=0;
           rep(i,0,11000){
             if(i*(i+1)/2==n){
               ans=true;
               sz=i;
             }
           }
           if(ans){
             vvin ans(sz+1,vin(sz,-1));
             int h=1;
             cout<<"Yes"<<endl;
             cout<<sz+1<<endl;
             rep(i,0,sz+1){
               cout<<sz<<" ";
               rep(j,0,sz){
                 if(i>j)ans[i][j]=ans[j][i-1]; 
                 else{
                   ans[i][j]=h;
                   h++;
                 }
                 cout<<ans[i][j]<<" ";
               }
               cout<<endl;
             }
             
           }
           else{
            cout<<"No"<<endl; 
           }
}

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

using namespace std;

int main(){
  long long input_data;
  long long ans=0;
  long long current=1;
  long long tmp;
  int i;

  cin >> input_data;

  for(i=0; i<input_data; ++i){
    cin >> tmp;
    if(tmp==current){
      current++;
    }else{
      ans++;
    }
  }
  if(current==1){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
int a,b,c,n,r;int main(){while(std::cin>>a>>b>>c,a|b|c){a*=a;b*=b;c*=c;std::cin>>n;while(n--)std::cin>>r,r*=4*r,puts(a+b<r|b+c<r|c+a<r?"OK":"NA");}}

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

#define ll long long

ll arr[10004];

ll max(ll a, ll b) {
    return a > b ? a : b;
}

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << c <<  " " << a  << " " << b << "\n";
}


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

#define int ll
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = 998244353;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int DIS[N];
vector<pii> G[N];

int32_t main() {
 
	sync;
	
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) G[i].push_back(make_pair(i - 1, 0));
	while (m--) {
		int l, r, c; cin >> l >> r >> c;
		G[l].push_back(make_pair(r, c));
	}
	int src = 1;
    for(int i = 0; i < N; i++) DIS[i] = INF * INF;
    DIS[src] = 0;
    priority_queue< pii > q; q.push(make_pair(0, src));
    while(!q.empty()) {
        int v = q.top().second; q.pop();
        for(pii u : G[v]) {
            if (DIS[v] + u.second < DIS[u.first]) {
                DIS[u.first] = DIS[v] + u.second;
                q.push(make_pair(- DIS[u.first], u.first));
            }
        }
    }
	cout << (DIS[n] == INF * INF ? -1 : DIS[n]) << endl;

	return 0;
}


Measured memory_bytes: 10232
#include <bits/stdc++.h>
using namespace std;
 
#define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i)
 
#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl
 
#define LOWBIT(x) ((x)&(-x))
 
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
 
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
 
template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
    in >> p.first >> p.second;
    return in;
}
 
template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
    for (auto &x: v)
        in >> x;
    return in;
}
 
template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]" << "\n";
    return out;
}

inline int gc(){
	static const int BUF = 1e7;
	static char buf[BUF], *bg = buf + BUF, *ed = bg;
	
	if(bg == ed) fread(bg = buf, 1, BUF, stdin);
	return *bg++;
} 

inline int ri(){
	int x = 0, f = 1, c = gc();
	for(; c<48||c>57; f = c=='-'?-1:f, c=gc());
	for(; c>47&&c<58; x = x*10 + c - 48, c=gc());
	return x*f;
}
 
typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< string, int > PSI;
typedef set< int > SI;
typedef vector< int > VI;
typedef map< int, int > MII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
const double EPS = 1e-10;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + 7;
const int maxN = 1e5 + 7;
const LL ONE = 1;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555;

LL pow2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072};

int N, K;
double ans;

int main(){
	//INIT(); 
	cin >> N >> K;
	
	For(i, 1, N) {
		//prln(i);
		//prln((int)log2((K - 1) / i));
		if(i < K) {
			int tmp = lower_bound(pow2, pow2 + 18, 1.0 * K / i) - pow2;
			//prln(tmp);
			ans += 1.0 / pow2[tmp];
		}
		else {
			ans += N - i + 1;
			break;
		}
		
	}
	ans /= N;
	
	printf("%.12f", ans);
	
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    long long m1,m2,n1,n2,i,j,a,n,M,l;

    scanf("%lld%lld%lld",&n,&M,&l);

    m1=n;
    n1=M;
    m2=M;
    n2=l;
    long long A[m1][n1],B[m2][n2],m[m1][n2];
    for(i=0; i<m1; i++)
        for(j=0; j<n2; j++)
            m[i][j]=0;
    for(i=0; i<m1; i++)
        for(j=0; j<n1; j++)
        {
            //printf("Enter %d,%d element of 1st matrix :",i+1,j+1);
            scanf("%lld",&A[i][j]);
        }
    //printf("\n");
    for(i=0; i<m2; i++)
        for(j=0; j<n2; j++)
        {
            //printf("Enter %d,%d element of 2nd matrix :",i+1,j+1);
            scanf("%lld",&B[i][j]);
        }
    for(a=0; a<m1; a++)
        for(i=0; i<n2; i++)
            for(j=0; j<n1; j++)
                m[a][i]+=A[a][j]*B[j][i];

    for(i=0; i<m1; i++)
    {
        for(j=0; j<n2; j++)
        {
            printf("%lld",m[i][j]);
            if(j!=n2-1)
                printf(" ");
        }

        printf("\n");
    }


}



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

int main() {

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  while(b > 0) {
    c -= b;
    if(c <= 0) {
      cout << "Yes" << endl;
      break;
    }
    
    a -= d;
    if(a <= 0) {
      cout << "No" << endl;
      break;
    }
  }

}


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

int n;
int times[16][17];
int dp[1 << 16];

void bfs(int cnt){
  if(cnt == 0) return;
  REP(i, 1 << n){
    bitset<16> flag(i);
    if(flag.count() != cnt) continue;
    bitset<16> orgn = flag;
    REP(k, n){
      if(flag[k]) continue;
      int tmp = times[k][0];
      REP(j, n) if(flag[j]) tmp = min(tmp, times[k][j+1]);
      flag.set(k);
      dp[flag.to_ulong()] = min(dp[flag.to_ulong()], dp[orgn.to_ulong()] + tmp);
      flag.reset(k);
    }
  }
  return;
}

int main(){
  while(cin >> n and n){
    memset(dp, 0, sizeof(dp));
    memset(times, 0, sizeof(times));
    REP(i, n) REP(j, n+1) cin >> times[i][j];
    REP(i, 1 << n) dp[i] = INF;
    bitset<16> tmp(0);
    REP(i, n){
      tmp.set(i); dp[tmp.to_ulong()] = times[i][0];
      tmp.reset(i);
    }
    REP(i, n) bfs(i);
    cout << dp[(1<<n) - 1] << endl;
  }
  return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n;cin>>n;
  vector<ll> L(n);
  for(ll i=0;i<n;i++)cin>>L[i];
  sort(L.begin(), L.end());
  ll ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      for(ll k=j+1;k<n;k++){
        if(L[i]==L[j]||L[j]==L[k])continue;
        if(L[i]+L[j]>L[k])ans++;
      }
    }
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 3656
def gattai(ar,i):
    sm = sum(ar[:i+1])
    idx = i
    while True:
        if idx == len(ar)-1:
            return len(ar)
        elif ar[idx+1] <= sm*2:
            sm += ar[idx+1]
            idx += 1
            continue
        else: return i-idx-1

n = int(input())
ar = list(map(int, input().split()))
ar.sort()

ans = 0
idx = 0
while ans <= 0:
    hoge = gattai(ar, idx)
    ans += hoge
    idx = abs(ans)

print(ans)

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

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(3 * n);
    REP(i, 3 * n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    for(ll i = 0; i < n; ++i){
        ans += a.at(3 * n - 2 * i - 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

i64 solve() {
  i64 N;
  cin >> N;
  vector<tuple<i64, i64, i64, i64>> lefters;
  vector<tuple<i64, i64, i64, i64>> righters;
  vector<tuple<i64, i64, i64>> samers;
  REP(i, N) {
    i64 k, l, r;
    cin >> k >> l >> r;
    if (l > r) {
      lefters.emplace_back(l - r, k, l, r);
    } else if (r > l) {
      righters.emplace_back(r - l, k, l, r);
    } else {
      samers.emplace_back(k, l, r);
    }
  }
  sort(lefters.rbegin(), lefters.rend());
  sort(righters.rbegin(), righters.rend());

  set<int> available;
  REP(i, N) available.insert(i);
  available.insert(-1);  // sentinel
  available.insert(N);   // sentinel

  vector<i64> delight(N, -1);
  vector<i64> rest;
  for (auto [gain, k, l, r] : lefters) {
    i64 j = min<i64>(k - 1, lefters.size() - 1);
    auto it = available.lower_bound(j);
    assert(it != available.end());
    if (*it > j) {
      --it;
      if (*it == -1) {
        DEBUG(k, l, r);
        rest.push_back(r);
        continue;
      }
    }
    delight[*it] = l;
    available.erase(it);
  }
  for (auto [gain, k, l, r] : righters) {
    i64 j = max<i64>(k, lefters.size());
    auto it = available.lower_bound(j);
    assert(it != available.end());
    if (*it == N) {
      DEBUG(k, l, r);
      rest.push_back(l);
      continue;
    }
    delight[*it] = r;
    available.erase(it);
  }
  /*
  REP(i, lefters.size()) {
    auto x = delight[i];
    if (x < 0)
      cerr << " _";
    else
      cerr << " " << x;
  }
  cerr << " |";
  for (int i = lefters.size(); i < N; ++i) {
    auto x = delight[i];
    if (x < 0)
      cerr << " _";
    else
      cerr << " " << x;
  }
  cerr << endl;
*/
  i64 ans = 0;
  int vacant = 0;
  for (auto x : delight) {
    if (x >= 0)
      ans += x;
    else
      vacant++;
  }
  DEBUG(vacant, rest.size(), samers.size());
  for (auto x : rest) {
    ans += x;
    --vacant;
  }
  for (auto [gain, l, r] : samers) {
    ans += l;
    --vacant;
  }
  DEBUG(vacant);
  assert(vacant == 0);
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  while (T--) {
    cout << solve() << '\n';
  }
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++)cin >> h[i];
    int mi = 1000000000;
    sort(h,h+n);
    int ans;
    for(int i=0;i<n-k+1;i++){
        ans=h[i+k-1]-h[i];
        mi=min(ans,mi);
    }
    cout << mi << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int N, T;
	cin >> N >> T;

	int c[100], t;

	rep(i, N) {
		cin >> c[i] >> t;
		if (t > T) c[i] = 100000;
	}
	int saishou = *min_element(c, c + N);

	if (saishou == 100000) co("TLE");
	else co(saishou);


	Would you please return 0;
}

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

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


    string a,b,c; cin >> a >> b >> c;
    stack<char> S[3];

    for(int i=0;i<a.size();i++){
        S[0].push(a[a.size()-1-i]);
    }
    for(int i=0;i<b.size();i++){
        S[1].push(b[b.size()-1-i]);
    }
    for(int i=0;i<c.size();i++){
        S[2].push(c[c.size()-1-i]);
    }

    int turn = 0;
    string winner = "";
    while(true){
        if(S[turn].empty()){
            winner += 'A'+turn;
            cout << winner;
            break;
        }
        int prev = turn;
        turn = S[turn].top()-'a';
        S[prev].pop();
    }


    return 0;
}


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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  if(N == 0) {
    cout << "0" << endl;
    return 0;
  }
  string ans;
  while(N != 0) {
    if(N & 1) {
      ans = "1" + ans;
      N--;
    } else {
      ans = "0" + ans;
    }
    N /= -2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2000)
input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(float, input().split())
LIN=lambda : list(IN())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = IN()
	#s = input()
	al = LIN()
	#p[i][j]は、i番目までにj枚が表になっている確率をあらわす。
	p = [[0]*(n+1) for _ in range(n+1)]
	p[0][0]=1
	for i in range(1, n+1):
		for j in range(n+1):
			omote = al[i-1]
			ura = 1 - omote
			p[i][j] += p[i-1][j]*ura
			if j > 0:
				p[i][j] += p[i-1][j-1]*omote
	k = p[-1][(n+1)//2:]
	#pa(k)
	r = sum(k)
	print(r)


memo_s=[]
al=[1,1]
n=1
def cc(state, maisuu):
	nokori = n-state
	if maisuu==0:
		return 1
	if nokori < maisuu:
		return 0
	global memo_s
	k = memo_s[state][maisuu]
	if k >= 0:
		return k
	
	omote = al[state]
	ura = 1-omote
	r = cc(state+1, maisuu-1)*omote
	r += cc(state+1, maisuu)*ura
	
	memo_s[state][maisuu]=r
	return r
	
def main2():
	global n
	n = int(input())
	global memo_s
	memo_s = [[-1]*(n+1) for _ in range(n+1)]
	
	v = LIN()
	global al
	al=v[:]
	
	r = cc(0, (n+1)//2)
	print(r)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 259336
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).ok();
    return word.trim().to_string();
}

fn main() {
    let n:usize = get_input().parse().unwrap();

    let mut p:Vec<u32> = Vec::with_capacity(n);

    for i in get_input().split_whitespace() {
        p.push(i.parse().unwrap());
    }

    let mut ans = 0;
    for i in 1..p.len()-1 {
        let mut a = [p[i-1], p[i], p[i+1]];
        a.sort();
        if a[1] == p[i] {
            ans += 1;
        }
    }
    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int M[101][101];
int main(){
  int n,u,k,v;
  cin>>n;
  for(int i=0;i< n;i++){
    cin>>u>>k;
    u--;//
    for(int j=0;j< k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j) cout<<" ";//
      cout<<M[i][j];
    }
    cout<<endl;
  }
  return(0);
}



Measured memory_bytes: 3116
n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
i = 0
ans = 0
while i <= n-1:
    m = a[i]
    c = 0
    while i <= n-1 and a[i] == m:
        c += 1
        i += 1
    if c < m:
        ans += c
    elif c > m:
        ans += c - m
print(ans)

Measured memory_bytes: 14268
#include <stdio.h>
#include <string.h>
#define MAX 101
#define PEOPLE 3
int main(void) {
	char card[PEOPLE][MAX], player;
	int ai, bi = 0, ci = 0, alen, blen, clen, i;
	for (i = 0; i < PEOPLE; i++) {
		if (scanf("%s", card[i]) < 1) {
			return 1;
		}
	}
	alen = strlen(card[0]);
	blen = strlen(card[1]);
	clen = strlen(card[2]);
	player = card[0][0];
	ai = 1;
	while (1) {
		switch (player) {
			case 'a':
				player = card[0][ai];
				ai++;
				if (player == '\0') {
					printf("A\n");
				}
				break;
			case 'b':
				player = card[1][bi];
				bi++;
				if (player == '\0') {
					printf("B\n");
				}
				break;
			case 'c':
				player = card[2][ci];
				ci++;
				if (player == '\0') {
					printf("C\n");
				}
				break;
			default:
				goto end;
		}
	}
end:
	fflush(stdout);
	return 0;
}

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

int main() {

    int N;
    cin >> N;

    N %= 1000;

    if (N == 0) cout << 0 << endl;
    else cout << 1000 - N << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){

    int n;
    cin>>n;
    long a[n],b[n],suma=0,sumb=0;
    vector<pair<long, pair<long, long> > >inp;
    for(int i=0;i<n;i++){
        cin>>a[i];
        suma+=a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        sumb+=b[i];
    }

    if(suma<sumb){
        cout<<"-1\n";
        return 0;
    }

    long ans=0,neg=0;
    for(int i=0;i<n;i++){
        inp.push_back(make_pair(a[i] - b[i], make_pair(a[i], b[i])));

        if(a[i] - b[i] < 0){
            ans++;
            neg += b[i]-a[i];
        }
    }

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


    for(int i=n-1;i>=0;i--){
        if(neg<=0){
            break;
        }
        else{
            neg-=inp[i].first;
            ans++;
        }
    }

    cout<<ans<<endl;
    return 0;


}


Measured memory_bytes: 6388
#include<stdio.h>

int gcd(int,int);

int main(){

  int x,y,key;

  scanf("%d %d",&x,&y);

  if(x<y){
    key=x;
    x=y;
    y=key;
  }
  printf("%d\n",gcd(x,y));

  return 0;
}

int gcd(int x,int y){

  int r;
  
  while(y>0){
    r = x % y;
    x = y;
    y = r;
  }

  return x;
}

Measured memory_bytes: 592
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a,b;
    cin >> a >> b;
    if (a%3==0||b%3==0|| (a+b)%3==0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    //cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))

a_max=max(a)

if a.count(a_max)>=2:
    for i in range(n):
        print(a_max)
else:
    max_ind=a.index(a_max)
    a.remove(a_max)
    a_2nd=max(a)
    for _ in range(1,max_ind+1):
        print(a_max)
    print(a_2nd)
    for _ in range(max_ind+1,n):
        print(a_max)

Measured memory_bytes: 12520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((int)(x).size())

using namespace std;
typedef long long ll;


void solve(long long N, long long D, std::vector<std::vector<long long> > X){
  int count = 0;
  REP(i, N) {
    for (int j = i + 1; j < N; j++) {
      float dist = 0;
      for (int k = 0; k < D; k++) {
        dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      dist = sqrt(dist);
      if (floor(dist) == dist) count++;
    }
  }

  printf("%d\n", count);
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long D;
  scanf("%lld",&D);
  std::vector<std::vector<long long> > X(N, std::vector<long long>(D));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < D ; j++){
      scanf("%lld",&X[i][j]);
    }
  }
  solve(N, D, std::move(X));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}

#define MOD 1000000007
typedef long long ll;

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int v=0,maxi=-100;
  
  FOR(i,n){
    if(s[i]=='('){
      v--;
    }else{
      v++;
    }
    chmax(maxi,v);
  }
  int cnt1=maxi;
  v=0;
  maxi=-100;
  FOR(i,n){
    if(s[n-1-i]=='('){
      v++;
    }else{
      v--;
    }
    chmax(maxi,v);
    
  }
  int cnt2=maxi;

    FOR(i,cnt1){
      cout << '(';
    }
    cout << s;
    FOR(i,cnt2){
      cout << ')';
    }
    cout << endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace ABC099C
{
    public class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var N = ss.Next(int.Parse);
            sw.WriteLine(Dfs(N, 0));
            //---------------------------------
        }

        readonly int[] six = {6, 36, 216, 1296, 7776, 46656};
        readonly int[] nine = {9, 81, 729, 6561, 59049};

        int Dfs(int n, int c)
        {
            if (n < 6) return n + c;

            var ret = int.MaxValue;

            if (n >= 6)
            {
                var yen = six.Where(x => x <= n).Max();
                ret = Math.Min(ret, Dfs(n - yen, c + 1));
            }

            if (n >= 9)
            {
                var yen = nine.Where(x => x <= n).Max();
                ret = Math.Min(ret, Dfs(n - yen, c + 1));
            }

            return ret;
        }

        static void Main()
        {
            var ss = new StreamScanner(new StreamReader(Console.OpenStandardInput()));
            var sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            new Program().Solve(ss, sw);
            sw.Flush();
        }

        static readonly Func<string, string> String = s => s;
    }

    public class StreamScanner
    {
        static readonly char[] Sep = {' '};
        readonly Queue<string> buffer = new Queue<string>();
        readonly TextReader textReader;

        public StreamScanner(TextReader textReader)
        {
            this.textReader = textReader;
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (buffer.Count != 0) return parser(buffer.Dequeue());
            var nextStrings = textReader.ReadLine().Split(Sep, StringSplitOptions.RemoveEmptyEntries);
            foreach (var nextString in nextStrings) buffer.Enqueue(nextString);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }
}

Measured memory_bytes: 15524
# include <cstdio>
# include <iostream>
# include <vector>
# include <map>
# include <set> 
# include <algorithm> 
# include <string>
# include <cstring>
# include <queue> 
# include <stack> 
# include <cstdlib> 

using namespace std ; 

int main()
{
	string s ; 
	cin >> s; 
	int len = s.length(); 
	for(int i = 0 ; i < len; )
	{
		if(s[i]=='P' || s[i]=='D'){ 
			++i;
			continue ; 
		}
		if(i > 0)
		{
			if(s[i-1]=='P'){
				s[i] = 'D' ; 
				++i;
				continue;
			}
		}
		if(i<len-1)
		{
			if(s[i+1]=='D'){
				s[i] = 'P' ; 
				++i ; 
				continue ; 
			}
			else if(s[i+1]=='?')
			{
				s[i]='P';
				s[i+1]='D'; 
				i+=2 ; 
				continue; 
			}
		}
		s[i] = 'D' ; 
	}
	cout << s << "\n" ; 
	return 0 ; 
}

Measured memory_bytes: 3388
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

int abs(int x){
    return x >= 0 ? x : -x;
}


int main(){
    
    int n,W; cin >> n >> W;
    ll v[n+10];
    int w[W+10];

    rep1(i,n){
        cin >> w[i] >> v[i];
    }

    ll d[n+10][W+10];
    rep(i,W+10){
        d[0][i] = 0;
    }

    rep1(i,n){
        for(int j = 0 ; j <= W ; j++){
            if(j >= w[i]){
                d[i][j] = max(d[i-1][j - w[i]] + v[i] , d[i-1][j]);
            }else{
                d[i][j] = d[i-1][j];
            }
        }
        
    }

    cout << d[n][W] << endl;
    

}


Measured memory_bytes: 80000
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<P> a(n);
    rep(i, n)cin >> a[i].second >> a[i].first;
    sort(all(a));
    ll now = 0;
    rep(i, n){
        now += a[i].second;
        if(now > a[i].first){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}       


Measured memory_bytes: 1792
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int k;
  cin >> k;

  for(int i = 0; i < n; i++){
    if(s[i] != s[k - 1]) s[i] = '*';
  }

  cout << s << endl;

  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> d(N);

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

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

  int ans = 1;
  for (int i = 0; i < N - 1; i++) {
    if (d[i] < d[i + 1]) {
      ans++;
    }
  }

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


Measured memory_bytes: 256
s=input()
a='dream'
b='dreamer'
c='erase'
d='eraser'
i=0

while(True):
	if i==len(s):
		print("YES")
		exit()
	if s[-7-i:len(s)-i]==b:
		i+=7
	elif s[-5-i:len(s)-i]==a:
		i+=5
	elif s[-6-i:len(s)-i]==d:
		i+=6
	elif s[-5-i:len(s)-i]==c:
		i+=5
	else :
		print("NO")
		exit()

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

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

    bool flg = true;

    for(int i=0; i<S.size(); ++i){
        if(S.at(i) != T.at(i)) flg = false;
    }

    if(flg == true && T.size() == S.size() + 1){
        cout << "Yes" << endl;
    } else cout << "No" << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int c[N-1], s[N-1], f[N-1];
  for(int i=0; i<N-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  for(int i=0; i<N; i++){
    int t=0;
    for(int j=i; j<N-1; j++){
      if(t<=s[j]){
        t=s[j];
      }else{
        if(t%f[j] == 0){
        }else{
          t=t+f[j]-(t%f[j]);
        }
      }
      t+=c[j];
    }
    cout << t << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int A,B;
  cin>>A>>B;

  for(int i=1;i<=100010;i++){
    double a=i*0.08;
    double b=i*0.10;
    a=floor(a);
    b=floor(b);

    if((int)a==A&&(int)b==B){
      cout<<i<<endl;
      return 0;
    }
  }

  cout<<-1<<endl;

  return 0;
}


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

int n, q, r;
char b[1005][1005];
string p4[4] = {"aacd", "bbcd", "cdaa", "cdbb"};
string p5[5] = {"aabba", "bcc.a", "b..cb", "a..cb", "abbaa"};
string p6[6] = {"aacd..", "bbcd..", "..aacd", "..bbcd", "cd..aa", "cd..bb"};
string p7[7] = {"aabbcc.", "dd.dd.a", "..d..da", "..d..db", "dd.dd.b", "..d..dc", "..d..dc"};

void f(int p) {
	int i, j;
	for(i=0; i<4; i++) for(j=0; j<4; j++) {
		b[4*p+i][4*p+j] = p4[i][j];
	}
}

int main() {
	int i, j;
	cin>> n;
	if(n==2) {puts("-1"); return 0;}
	if(n==3) {puts("aa.\n..a\n..a"); return 0;}
	q = n/4;
	q--;
	r = n - 4*q;
	memset(b, '.', sizeof(b));
	for(i=0; i<q; i++) f(i);
	for(i=0; i<r; i++) for(j=0; j<r; j++) {
		if(r==4) b[4*q+i][4*q+j] = p4[i][j];
		else if(r==5) b[4*q+i][4*q+j] = p5[i][j];
		else if(r==6) b[4*q+i][4*q+j] = p6[i][j];
		else if(r==7) b[4*q+i][4*q+j] = p7[i][j];
	}
	for(i=0; i<n; i++) {
		for(j=0; j<n; j++) putchar(b[i][j]);
		puts("");
	}
	return 0;
}

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

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

  int ans;

  for (int i = 0; i <= 10; i++) {
    if (i * 1000 < n && n <= (i + 1) * 1000) {
      ans = (i + 1) * 1000 - n;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long N, long long D){
  cout << roundup(N,((D*2)+1)) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long D;
    scanf("%lld",&D);
    solve(N, D);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,k,x,y;
    int sum = 0;

    scanf("%d", &n);
    scanf("%d", &k);
    scanf("%d", &x);
    scanf("%d", &y);

    for(int i = 1; i <= n; i++){
        if(i <= k){
            sum += x;
        }
        else {
            sum += y;
        }
    }

    printf("%d", sum);

    return 0;


}

Measured memory_bytes: 1732
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;
ll dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
ll dy[9] = {-1,  0,  1,-1, 0, 1,-1, 0, 1};

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

    int A, B, C;
    cin >> A >> B >> C;
    for(int i = 0; i < 10000; i++){
        if(i*A % B == C){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#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, q;
	ll sum = 0;
	cin >> n;
	map<ll, int> mp;
	rep (i, n) {
	  ll a;
	  cin >> a;
	  mp[a]++;
	  sum += a;
	}
	cin >> q;
	rep (i, q) {
	  ll b, c;
	  cin >> b >> c;
	  sum += (c - b) * mp[b];
	  mp[c] += mp[b];
	  mp[b] = 0;
	  cout << sum << endl;
	}
    
    return 0;
}


Measured memory_bytes: 9400
#include "bits/stdc++.h"
using namespace std;
int main(){
  int a[4],c[4]={0,0,0,0},ans=0;
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  for(int i=0;i<4;i++){
    if(a[i] == 1 && c[0] != 1){
      c[0] = 1;
      ans++;
    }else if(a[i] == 9 && c[1] != 1){
      c[1] = 1;
      ans++;
    }else if(a[i] == 7 && c[2] != 1){
      c[2] = 1;
      ans++;
    }else if(a[i] == 4 && c[3] != 1){
      c[3] = 1;
      ans++;
    }
  }
  if(ans == 4){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  string s;
  ll k;
  cin >> s >> k;
  char c;
  rep(i,s.size()) {
    if (i == k-1 || s[i] != '1') {
      c = s[i];
      break;
    }
  }
  cout << c << endl;

}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = 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 fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

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

    int r = 0;
    for (char c : s) r += (c == 'R');

    int x = 0;
    rep(i, r) x += (s[i] == 'W');
    cout << x << "\n";
    return 0;
}


Measured memory_bytes: 3756
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    if(n % 10 == 9 || n / 10 == 9)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[105],b[105];

int main()
{
	boost
	ll n,i,sum=0;
	cin>>n;
	b[0]=INT_MAX;
	for(i=1;i<n;i++)
	{
		cin>>arr[i];
		b[i]=INT_MAX;
	}
	for(i=1;i<n;i++)
	{
		b[i-1]=min(arr[i],b[i-1]);
		b[i]=arr[i];
	}
	for(i=0;i<n;i++)
		sum+=b[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
A = [int(input()) for _ in range(5)]
cmin = 10**4
for x in permutations(range(5),5):
    cnt = A[x[0]]
    if cnt%10>0:
        cnt = (cnt//10)*10+10
    for i in range(1,4):
        cnt += A[x[i]]
        if cnt%10>0:
            cnt = (cnt//10)*10+10
    cnt += A[x[4]]
    cmin = min(cmin,cnt)
print(cmin)


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, start, end) for (int i = (start); i <= (end); ++i)
#define all(n) begin(n), end(n)

#define DEBUG

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

	int ans = 0;
	if (a < b)
	{
		rep(i, b)
		{
			ans += a * pow(10, i);
		}
		cout << ans << endl;
	}
	else
	{
		rep(i, a)
		{
			ans += b * pow(10, i);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)
int main()
{
  int N;
  int data[205][3];
  int cnt[3][101] = {0};
  cin >> N;
  Rep(i,N)Rep(j,3) {
    cin >> data[i][j];
    cnt[j][data[i][j]]++;
  }
  Rep(i,N) {
    int sum = 0;
    Rep(j,3) {
      if(cnt[j][data[i][j]] == 1) {
	sum += data[i][j];
      }
    }
    cout << sum << endl;
  }
  return 0;
}
    

Measured memory_bytes: 3060
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e6 + 2;
//
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) ;
//        y = y >> 1;
//        x = (x * x) ;
//    }
//    return res  ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }
//
//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}

void solve()
{
    ll n , W;
    cin >> n >> W;
    vector<pii> w(n);
    for(ll i = 0 ;i < n ;i ++)
        cin >> w[i].ff >> w[i].ss;
    ll ans[W + 1];
    mem(ans , 0);
    sort(all(w) , [&](pii a , pii b){return a.ss < b.ss;});
    reverse(all(w));
    for(ll i = 0 ; i < n ; i ++){
    for(ll j = 0 ; j <= W ; j ++){
        if(j - w[i].ff >= 0)
            ans[j - w[i].ff] = max(ans[j - w[i].ff] , ans[j] + w[i].ss);
    }}
    ll fi = 0;
    for(ll i = 0 ; i <= W ; i ++)
        fi = max(fi , ans[i]);
    print(fi);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 1024
# Your code here!
n=gets.to_i
a=gets.split(" ").map(&:to_i)

s=a.inject(:+)

sl=0
sr=0
sa=s

(0..n-1).each do |n|
    sl=sl+a[n].to_i
    sr=s-sl

    if sl==sr
        break;
    end
    if sa>(sl-sr).abs
        sa=(sl-sr).abs
    end
end

p sl==sr ? 0 : sa

Measured memory_bytes: 16132