akhauriyash/Code-Regression huggingface dataset:
# 02

a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

tapple = (a1,a2,a3,b1,b2,b3)
city_list = list(tapple)

city_num = []
isYes = True

for index in range(4):
    num = index+1
    city_num.append(city_list.count(num))
    if city_list.count(num) >= 3:
        isYes = False
if isYes:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s.find("AC")<s.size()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


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

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(1e6+2);

    int d = 1;
    for (int j = 0; j < n; j++) {
        int a;
        cin >> a;
        if (j == 0) {
            d = a;
        }
        d = __gcd(a, d);
        
        for (int i = 2; i * i <= a; i++) {
            if (a % i == 0) {
                v[i]++;
            }
            while (a % i == 0) {
                a /= i;
            }
        }
        if (a > 1) {
            v[a]++;
        }
    }
    
    sort(all(v));

    if (v.back() <= 1) {
        cout << "pairwise coprime";
    }
    else if (d == 1) {
        cout << "setwise coprime";
    }
    else {
        cout << "not coprime";
    }
    
    return 0;
} 


Measured memory_bytes: 7144
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define DBG(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll p = 1e9+7;
const ll INF = 1LL << 60;

double dp[3333][3333];

int main(){
  int n;
  cin>>n;
  double ps[3333];
  for(int i=0;i<n;i++){
    cin>>ps[i];
  }
  dp[0][0]=1.0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
	 dp[i+1][j+1]+=dp[i][j]*ps[i];
	 dp[i+1][j]+=dp[i][j]*(1.0-ps[i]);
    }
  }
  double ans=0;
  for(int i=n/2+1;i<=n;i++)ans+=dp[n][i];
  printf("%.10lf\n",ans);
  return 0;
}


Measured memory_bytes: 80128
/**
 * author: Behradm
 * Created: 2020.08.22 16:29:33
 * In The Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int sum = 0;
  for (int i = 0; i < (int) s.size(); i++) {
    sum = (sum % 9) + ((int) (s[i] - '0')) % 9;
    sum %= 9;
  }

  cout << (sum % 9 == 0 ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3748
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    m1,d1 = mi()
    m2,d2 = mi()

    if m1 == m2:
        print(0)
    else:
        print(1)
    


        


main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pip(k,l,n) for(int k =(int)l;k<=(int)n;k++)
int main() {
  int I,J;
  string A[I] ={};
  cin >> I >> J;
  int i,j,k,l;
  int cous;
  
  // ここにプログラムを追加
  rep(i,I){
    cin >> A[i];
    rep(j,J){
      if(A[i][j] == '.') A[i][j] = '0';
    }
  }
  
  rep(i,I){
    rep(j,J){
      if(A[i][j] == '#') continue;
      cous = 0;
        pip(k,-1,1){
          if((i+k < 0) || (i+k >= I)) continue;
          pip(l,-1,1){
            if((j+l < 0) || (j+l >= J)) continue;
            if(A[i+k][j+l] == '#') cous++;
          }
        }
      A[i][j] = '0'+(char)(cous);
    }
  }
  
  rep(i,I) cout << A[i] << endl;
}


Measured memory_bytes: 49408
import sys


class Cupgame:
    def __init__(self, ballin):
        self.ballin = ballin

    def swap(self, x, y):
        if x == self.ballin:
            self.ballin = y
        elif y == self.ballin:
            self.ballin = x
        else:
            pass


cupgame = Cupgame('A')

for line in sys.stdin:
    x, y = tuple(line.rstrip('\n').split(','))
    cupgame.swap(x, y)
print cupgame.ballin

Measured memory_bytes: 4224
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
    long long minu(long long a, long long b){
        return mod(mod(a)-mod(b));
    }
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    vector<int>dirX={-1,0,1};
    vector<int>dirY={-1,0,1};
 
 
    ll dp[2005];
    ll ok(int s){
        // cout<<"in "<<s<<"\n";
        if(s==0)
            return 1LL;
        else if(s==1 || s==2)
            return 0LL;
        else if(s>=3 && s<=5)
            return 1LL;
        else if(dp[s]!=-1)
            return dp[s];
        else{
            ll total=0;
            for(int i=3;i<=s;i++){
                if(s-i>=0)
                    total=add(total,ok(s-i));
            }
            return dp[s]=total;
        }
    }
    void solve(){
        int s;
        cin>>s;
        memset(dp,-1,sizeof(dp));
        dp[0]=1;
        cout<<ok(s);
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
        //    cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits.h>
#include <cmath>
#include <map>
using namespace std;
using P=pair<int,int>;
using PP=pair<P,P>;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<vector<int>> b(20,vector<int>(2,n));
    for(int i=n;i>=0;i--){
        for(int j=0;j<20;j++){
            if((1<<j)&a[i]){
                b[j].push_back(i);
            }
        }
    }
    ll ret=0;
    for(int i=0;i<n;i++){
        int mn=n;
        for(int j=0;j<20;j++){
            mn=min(mn,b[j][b[j].size()-2]);
            if(b[j][b[j].size()-1]==i)b[j].pop_back();
        }
        ret+=mn-i;
    }
    cout<<ret<<endl;
}

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

int main(){
  int a, b;
  string op;
  cin >> a >> op >> b;
  while(op != "?"){
    if(op == "+"){
      cout << a + b << endl;
    }
    if(op == "-"){
      cout << a - b << endl;
    }
    if(op == "*"){
      cout << a * b << endl;
    }
    if(op == "/"){
      cout << a / b << endl;
    }
    cin >> a >> op >> b;
  }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
#define pb push_back
#define SZ(x) ((int)x.size())
#define fi first
#define se second
#define mp make_pair
typedef long long LL;
const int N=19;
int n; LL val[N];
map<int,LL> a[N][N][2000];
LL solve(int x,int y,int sx,int sy){
	if(x==y||x+1==y)return 0;
	LL&res=a[x][y][sx][sy];
	if(res)return res-1;
	LL ans=1e18;
	ref(z,x+1,y-1){
		ans=min(ans,solve(x,z,sx,sx+sy)+solve(z,y,sx+sy,sy)+val[z]*(sx+sy));
	}
	res=ans+1;
	return ans;
}
int main(){
	cin>>n;
	ref(i,1,n)cin>>val[i];
	cout<<solve(1,n,1,1)+val[1]+val[n]<<endl;
}

Measured memory_bytes: 50432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const long long mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    int sum = 0;
    rep(i, n)
    {
        cin >> s[i];
        sum += s[i];
    }
    sort(s.begin(), s.end());
    int i = 0;
    if (sum % 10 != 0)
    {
        cout << sum << endl;
    }
    else
    {
        rep(i, n)
        {
            if (s[i] % 10 != 0)
            {
                cout << sum - s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N,Y;
    cin >> N >> Y;
    
    rep(i,N+1)rep(j,N+1){
        if(i+j>N) break;
        int k1000 = Y-(10000*i+5000*j);
        if(k1000%1000 != 0) continue;
        int k = k1000/1000;
        if(i+j+k == N){
            printf("%d %d %d\n",i,j,k);
            return 0;
        }
    }
    printf("-1 -1 -1\n");
}

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

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

  ll N, K;
  cin >> N >> K;
  vector<ll> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  ll ans = 0;

  sort(H.begin(), H.end(), greater<ll>());
  for (int i = K; i < N; i++) {
    ans += H[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <queue>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 100000
using namespace std;

class edge{
  public:
    int u, v, w;
    edge(){}
    edge(int u, int v, int w):
      u(u), v(v), w(w){}
};

vector< edge > graph[MAX_N];

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

  int k;
  cin >> k;

  for(int v = 0; v < k; v++){
    graph[v].push_back(edge(v, (v + 1) % k, 1));
    graph[v].push_back(edge(v, (10 * v) % k, 0));
  }

  int dist[k];
  fill(dist, dist + k, INF);
  priority_queue< pair< int, int > > pq;
  pq.push(pair< int, int >(0, 1));
  dist[1] = 0;
  while(not pq.empty()){
    pair< int, int > p = pq.top();  pq.pop();
    int u = p.second, d = -p.first;
    if(d > dist[u]) continue;
    for(edge e: graph[u]){
      if(d + e.w < dist[e.v]){
        dist[e.v] = d + e.w;
        pq.push(pair< int, int >(-(d + e.w), e.v));
      }
    }
  }

  cout << (dist[0] + 1) << endl;

  return 0;
}

Measured memory_bytes: 6780
calc :: Int -> String -> Int -> Int
calc a op b = case op of
  "+" -> a + b
  "-" -> a - b
  "*" -> a * b
  "/" -> a `div` b

main = do
  [sa, op, sb] <- fmap words getLine
  if op == "?" then
    return ()
  else do
    let [a, b] = map read [sa, sb] :: [Int]
    print $ calc a op b
    main

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n;
int dfs(i64 a){
	if(a > n) return 0;
	int cnt = 0;
	cnt += dfs(a*10+3);
	cnt += dfs(a*10+5);
	cnt += dfs(a*10+7);
	bool b[3] = {0};
	for(int i = 1; i < a; i*=10){
		if(a/i%10 == 3) b[0] = 1;
		if(a/i%10 == 5) b[1] = 1;
		if(a/i%10 == 7) b[2] = 1;
	}
	if(b[0]&&b[1]&&b[2]) cnt++;
	return cnt;
}
void solve(){
	cin >> n;
	
	cout << dfs(0) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL X,X0;
	cin>>X;
	X0=X;
	LL num500=0;
	if (X>=500){
		num500=X/500;
		X=X%500;
	}
	LL num5=0;
	if (X>=5){
		num5=X/5;
		X=X%5;
	}

	LL X1=num500*1000+num5*5;
	X=X0;
	num5=0;
	if (X>5){
		num5+=X/5;
		X=X%5;
	}
	cout<<max(X1,5*num5)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define k 10001
signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int> A(n),B(n);
  for(int i=0;i<n;i++) cin>>A[i];
  int C[k];
  for(int i=0;i<k;i++) C[i]=0;
  for(int j=0;j<n;j++) C[A[j]]++;
  for(int i=1;i<k;i++) C[i]=C[i]+C[i-1];
  for(int j=n-1;j>=0;j--){
    B[C[A[j]]-1]=A[j];
    C[A[j]]--;
  }
  for(int i=0;i<n;i++) cout<<B[i]<<" \n"[i==n-1];
  return 0;
}

Measured memory_bytes: 34136
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
int a[100][100],l[51],r[51],cnt,n;
bool visit[51];
void solve(int x){
  rep(k,n){
    if(a[k][x]==1&&visit[k]==false){
      visit[k]=true;
      int next=k;
      solve(next);
      }
    }
  }
int main(){
  int m;
  cin>>n>>m;
  rep(i,n)rep(j,n)a[i][j]=0;
  rep(i,m){
    cin>>l[i]>>r[i];
    a[l[i]-1][r[i]-1]=1;
    a[r[i]-1][l[i]-1]=1;
    }
  int ans=m;
  rep(i,m){
    rep(j,n) visit[j]=false;
    visit[0]=true;
    a[l[i]-1][r[i]-1]--;
    a[r[i]-1][l[i]-1]--;
    solve(0);
    bool ok=true;
    rep(i,n)ok=ok&visit[i];
    if(ok)ans--;
    a[l[i]-1][r[i]-1]++;
    a[r[i]-1][l[i]-1]++;
    }
  cout<<ans<<endl;
  return 0;
  }


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

using namespace std;


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

  int happiness[N][3];
  int maxH[N][3];
  int taken[3] = {false,false,false};
  long mh = 0;
  for(int i=0;i<N;i++){
    int h1,h2,h3;
    cin>>h1>>h2>>h3;
    happiness[i][0] = h1;
    happiness[i][1] = h2;
    happiness[i][2] = h3;
    maxH[i][0] = 0;
    maxH[i][1] = 0;
    maxH[i][2] = 0;
  }
  maxH[0][0] = happiness[0][0];
  maxH[0][1] = happiness[0][1];
  maxH[0][2] = happiness[0][2];

  for(int i=1;i<N;i++){
    maxH[i][0] = max(maxH[i-1][1],maxH[i-1][2]) + happiness[i][0];
    maxH[i][1] = max(maxH[i-1][0],maxH[i-1][2]) + happiness[i][1];
    maxH[i][2] = max(maxH[i-1][0],maxH[i-1][1]) + happiness[i][2];
  }
  cout<<max(maxH[N-1][0],max(maxH[N-1][1],maxH[N-1][2]));
  return 0;
}


Measured memory_bytes: 5864
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define np(str) next_permutation(str.begin(),str.end())
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define PI 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll mod = 1e9 + 7 ;
ll INF = 1e12;

ll n, m;

int main() {
	// your code goes here
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];
	ll grt = a[0];
	ll sum = 0;
	rep(i, n) {
		sum += max(0LL, grt - a[i]);
		grt = max(grt, a[i]);
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647

//問題として、n=1を代入してしまった時のみmapに1がはいる。
map<ll, ll> insu;
void bunkai(ll n)
{
    ll a = 2; //割る数
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            insu[a] += 1;
            n /= a;
        }
        else
        {
            a++;
        }
    }
    // 最後に残った n は素因数
    insu[n] += 1;
}
int main()
{
    ll n;
    cin >> n;
    if (n == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        bunkai(n);
        ll j = 0;
        map<ll, ll> stock;
        //vector<ll> stock;
        ll count = 0;
        for (auto x : insu)
        {
            count = max(x.second, count);
            stock[x.second] += 1; //そのペアが何個あるのかを入れている。
        }
        vector<ll> data;
        ll p = 0;
        for (int i = 0; i < 200000; i++)
        {
            p += i + 1;
            data.push_back(p);
            if (p >= count)
            {
                break;
            }
        } //1,3,6,10,15,21,とかの値が出てくるようにしておく
        ll ans = 0;
        for (int x : data)
        {
            //cout << x << endl;
        }
        //cout << count << endl;
        for (auto x : stock)
        {
            //cout << x.first << " " << x.second << endl;
            ll o = upper_bound(data.begin(), data.end(), x.first) - data.begin();
            //これ以下の最大のindex+1
            // upper_bound:探したい値より大きい値が現れる最小のindexをイテレータで返す
            ans += o * x.second;
        }
        cout << ans << endl;
        //まだ1の時試してないで
    }
}

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

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

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int MOD = (int)1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}

const int N = 2010;
int dp1[N][N];
int C[N][N];
int sumC[N][N];

void solve() {
	
	for (int i = 0; i < N; i++)
		C[i][0] = C[i][i] = 1;
	for (int i = 1; i < N; i++)
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j], C[i - 1][j - 1]);
	for (int i = 0; i < N; i++) {
		sumC[i][0] = 0;
		for (int j = 0; j < N - 1; j++)
			sumC[i][j + 1] = add(sumC[i][j], C[i][j]);
	}

	for (int x = 0; x < N; x++)
		dp1[x][0] = 1;
	for (int y = 1; y < N; y++) {
		dp1[0][y] = 1;
		for (int x = 1; x < N; x++)
			dp1[x][y] = add(dp1[x - 1][y], sumC[y - 1][x + 1]);
	}

}

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

	solve();

	int X, y;
	scanf("%d%d", &X, &y);

	int ans = 0;
	for (int x = 0; x <= X; x++) {
		for (int z = 0; z <= x; z++) {
			ans = add(ans, mult(C[y - 1][x - z], dp1[z][x - z]));
		}
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 47616
#include<iostream>
#include<string>
#include<algorithm>
#include<iterator>

int main(){
	std::string str;

	std::cin >> str;

	std::reverse_copy(str.begin(), str.end(),
		std::ostream_iterator<char>(std::cout,""));
  	std::cout << std::endl;
  	return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, P;
  cin >> N >> P;
  vector<ll> dp(2, 0);
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    vector<ll> ndp = dp;
    for (int j = 0; j < 2; j++) {
      ndp[(j + A) % 2] += dp[j];
    }
    dp = ndp;
  }
  cout << dp[P] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string O, E;
    cin >> O >> E;
    int N = E.size();
    REP(i, N) {
        cout << O[i] << E[i];
    }
    if (N != O.size()) {
        cout << O[N];
    }
    cout << endl;
    return 0;
}


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

int main()
{
    int n;
    scanf("%d", &n);
    int t = 0, x = 0, y = 0;
    bool check = true;
    for (int i = 0, tt, xx, yy; i < n; ++ i) {
        scanf("%d%d%d", &tt, &xx, &yy);
        int d = std::abs(x - xx) + std::abs(y - yy);
        check &= tt - t >= d && (tt - t - d) % 2 == 0;
        t = tt, x = xx, y = yy;
    }
    puts(check ? "Yes" : "No");
}

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

using namespace std;
const int maxn = 1e5 + 7;

int A[maxn];

int main(){
    memset(A, 0, sizeof(A));
    int n, tot = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> A[i];
        tot += abs(A[i] - A[i-1]);
    }
    tot += abs(-A[n]);
    for(int i = 1; i <= n; i++) {
        cout << (tot + abs(A[i+1] - A[i-1]) - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i])) << endl;
    }
    return 0;

}


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

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    //freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	
	int N;
	int ans=0;
	cin >> N;
	
	for(int i=1; i<=N; i++)
		for(int j=1; j<=N; j++){
			if(i*j>=N)
				break;
			ans++;
		}
		
    cout << ans;
	
	return 0;
}

Measured memory_bytes: 3684
n = str(input())

if(n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9"):
    print("hon")

elif(n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8"):
    print("pon")

else:
    print("bon")

Measured memory_bytes: 61704
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

bool cmp(pair<int, int> lhs, pair<int, int> rhs)
{
    return lhs.first > rhs.first;
}

signed main()
{
    int n, m;
    vector<int> a;
    vector<pair<int, int> > cb;

    cin >> n >> m;

    a.resize(n);
    cb.resize(m);

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

    for(int i = 0; i < m; ++i)
    {
        int b, c;
        cin >> b >> c;
        cb[i] = make_pair(c, b);
    }

    sort(a.begin(), a.end());
    sort(cb.begin(), cb.end(), cmp);

    /*
    for(int i = 0; i < n; ++i)
    {
        cout << a[i] << " ";
    }
    cout << endl;

    for(int i = 0; i < m; ++i)
    {
        cout << cb[i].first << " ";
    }
    cout << endl;

    cout << "fuck" << endl;
    */
    int cb_idx = 0;
    for(int i = 0; i < n; ++i)
    {
        if(cb[cb_idx].first > a[i])
        {
            //cout << cb[cb_idx].first << " " << a[i] << endl;
            a[i] = cb[cb_idx].first;
            --cb[cb_idx].second;
            if(cb[cb_idx].second == 0)
            {
                ++cb_idx;
            }
        }

        if(cb_idx == m)
        {
            break;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        ans += a[i];
    }

    cout << ans << endl;

    /*
    int base = 0;
    for(int i = 0; i < m; ++i)
    {
        int b = cb[i].second;
        int c = cb[i].first;

        vector<int>::iterator range_begin = a.begin() + base;
        vector<int>::iterator range_end;

        if(base + b > a.size())
        {
            range_end = a.end();
        }
        else
        {
            range_end = a.begin() + base + b;
        }

        int bound = lower_bound(range_begin, range_end, b) - a.begin();

        if(bound == a.end())
        {
            // 全て書き換えられる
        }
    }
    */

    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main(void){
	int n;
	string text,key;

	cin >> n;
	getline(cin, text);
	map <string, char> S;

	for (int i=0; i<n; i++){
		getline(cin, text);
		switch (text[0]){
		case 'i':
			S[text.substr(7)] = 1;
			break;
		case 'f':
			if (S.find(text.substr(5)) == S.end()) cout << "no" <<endl;
			else cout << "yes" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 31348
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 200010
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")

vi tree[range];

ll counter[range];

void DFS(int node, int par, int curr){
	counter[node] += curr;
	for(int v:tree[node]){
		if(par == v)continue;
		DFS(v,node,counter[node]);
	}
}
int main(){

//    freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
	int n,q;cin>>n>>q;
	forn(i,n-1){
		int a,b;cin>>a>>b;
		tree[a].pb(b);
		tree[b].pb(a);
	}

	forn(i,q){
		int p,x;cin>>p>>x;
		counter[p] += x;
	}

	DFS(1,0,0);

	forn1(i,n)cout<<counter[i]<<" ";
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


Measured memory_bytes: 23296
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    string S;
    cin >> S;
    if (S.size() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) + "..." << endl;
    }
}


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

s=[int(input()) for _ in range(a)]
t=[int(input()) for _ in range(b)]
x=[int(input()) for _ in range(q)]

s.sort()
t.sort()

import bisect
#a=[0,2,3,4,67,8]
#a.sort()
for item in x:
    ss=bisect.bisect_left(s, item)
    tmp=[]
    if ss>0:
        tmp.append(s[ss-1])
    if ss<len(s):
        tmp.append(s[ss])
    tmp2=[]
    tt=bisect.bisect_left(t, item)
    if tt>0:
        tmp2.append(t[tt-1])
    if tt<len(t):
        tmp2.append(t[tt])
    #print(item,tmp2,tmp)
    result=10**18
    for item2 in tmp:
        for item3 in tmp2:
            #print(item,item2,item3)
            result=min(result,abs(item-item3)+abs(item3-item2),abs(item-item2)+abs(item3-item2))
    print(result)





Measured memory_bytes: 87256
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, C;
  rd(n, C);
  struct T {
    int s, t, c;
  }

  T[] seqs;
  foreach (_; 0 .. n) {
    int s, t, c;
    rd(s, t, c);
    seqs ~= T(s, t, c);
  }
  sort!"a.s<b.s"(seqs);
  struct U {
    int end, c;
  }

  U[] data;
  foreach (seq; seqs) {
    bool found = false;
    foreach (i; 0 .. data.length) {
      if (data[i].end < seq.s) {
        data[i] = U(seq.t, seq.c);
        found = true;
        break;
      } else if (data[i].c == seq.c && data[i].end <= seq.s) {
        data[i] = U(seq.t, seq.c);
        found = true;
        break;
      }
    }
    if (!found) {
      data ~= U(seq.t, seq.c);
    }
  }
  writeln(data.length);

}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int n,k;
	string s;
	cin >> n >> k;
	cin >> s;
	if(s[k - 1] == 'A'){
		s[k - 1] = 'a';
	}
	else if(s[k - 1] == 'B'){
		s[k - 1] = 'b';
	}
	else s[k - 1] = 'c';
	cout << s << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3540
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)[0..n]
n.times do |i|
  v = a[i]
  j = i-1
  while j >= 0 && a[j] > v
    a[j+1] = a[j]
    j-=1
  end
  a[j+1] = v
  puts a.join(' ')
end

Measured memory_bytes: 8900
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element



signed main()
{
	int S;
	cin >> S;
	int a = S / 100;
	int b = S % 100;
	
	bool is_yymm = (0 <= a && a <= 99 && 1 <= b && b <= 12);;
	bool is_mmyy = (1 <= a && a <= 12 && 0 <= b && b <= 99);
	
	if (is_yymm && is_mmyy)
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if (is_yymm)
	{
		cout << "YYMM" << endl;
	}
	else if (is_mmyy)
	{
		cout << "MMYY" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
}



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

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

    vector<vector<int>> rec(9, vector<int>(9, 0));

    rep(i, N) {
        string i_str = to_string(i + 1);
        int first = i_str[0] - '0';
        int last = i_str[i_str.size() - 1] - '0';

        if (first != 0 && last != 0) {
            rec[first - 1][last - 1]++;
        }
    }

    long long int result = 0;

    rep(i, 9) {
        rep(j, 9) {
            result += rec[i][j] * rec[j][i];
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 9e18
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}
string YN(bool y) { return (y ? "YES" : "NO"); }
string yn(bool y) { return (y ? "Yes" : "No"); }
string ON(bool y) { return (y ? "OK" : "NG"); }

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;

int dir4[4][2] = { {0,-1},{-1,0},{1,0},{0,1} };
int dir8[8][2] = { {-1,-1},{0,-1},{1,-1},{-1,0},{1,0},{-1,1},{0,1},{1,1} };

//=======ここまでテンプレート===============================================


int main(void) {
	int N;
	cin >> N;
	vi a(N), b(N), c(N);
	rep(i, N) {
		cin >> a[i];
		a[i] *= -1;
	}
	rep(i, N) {
		cin >> b[i];
		b[i] *= -1;
	}
	rep(i, N) {
		cin >> c[i];
		c[i] *= -1;
	}

	sort(all(a));
	sort(all(b));
	sort(all(c));

	vll cum(N + 1, 0), numb(N, 0);

	rep(i, N) {
		numb[i] = lower_bound(all(c), b[i]) - c.begin();
	}
	repr(i, 1, N + 1) {
		cum[i] = cum[i - 1] + numb[i - 1];
	}

	//rep(i, N)cout << numb[i] << " "; cout << endl;
	//rep(i, N + 1)cout << cum[i] << " "; cout << endl;

	ll ans = 0;

	rep(i, N) {
		int idx = lower_bound(all(b), a[i]) - b.begin();
		ans += cum[idx];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2944
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int input(int *a, int *b, int *c);  //入力関数
int swap (int *a, int *b);          //入れ替え
int count(int a, int b, int c,int *d);  //計算用
int main (void)
{
	int a, b, c, d = 0;
	input(&a, &b, &c);
	swap(&a, &b);
	count(a, b, c, &d);
	printf("%d\n", d); 
	return 0;
}
int input(int *a, int *b, int *c)
{
	scanf("%d%d%d", a, b, c);
	return 0;
}
int swap(int *a, int *b)
{
	int iTemp = 0;

	if (*a > *b)
	{
		iTemp = *a;
		*a = *b;
		*b = iTemp;
	}
	return 0;
}
int count(int a, int b, int c,int *d)
{
	int iDifere;

	for (iDifere = a; iDifere <= b; iDifere++)
	{
		if (0 == c % iDifere)
		{
			(*d)++;
		}
	}
	return 0;
}



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

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int sum = y + 2 * z;
  int ans = 1;
  while(true) {
    sum += y + z;
    if (sum > x) break;
    else ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[600000], vs[600000], dp[4000][4000], fs[500][500];
map<int,int>mp;

int main()
{
    IO;
    ll j=0, n, m, k, m1, m2, a1=0, a2=0, l  = 1, t=3, mn, cnt=0, mx=0, h=0, mod=1e8+7, i; int tc=0;
    //cin>>t;
    //while(t--){
        for(i=1; i<=5; i++){
            cin>>a[i];
            if(a[i]==0) j=i;
        }
        cout<<j<<endl;

    //}
    return 0;
}



Measured memory_bytes: 3652
#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 h,w;
    cin>>h>>w;
    map<char,int>mp;
    vector<int>cnt(10010,0);
    rep(i,h){
        string s; cin>>s;
        rep(j,w){
            mp[s[j]]++;
        }
    }
    for(auto&p:mp){
        cnt[p.second]++;
    }
    int g1=0,g2,g3;
    if(h%2==1&&w%2==1)g1=1,g2=h/2+w/2;
    else if(h%2==0&&w%2==1)g2=h/2;
    else if(h%2==1&&w%2==0)g2=w/2;
    else g2=0;
    g3=(h/2)*(w/2);
    while(g1!=0){
        bool ok=false;
        for(int i=1; i<=10000; ++i){
            if(i%4==1||i%4==3){
                if(cnt[i]>0){
                    cnt[i]--,cnt[i-1]++;
                    ok=true;
                    g1--;
                }
            }
        }
        if(!ok){cout<<"No"<<endl; return 0;}
    }
    while(g3!=0){
        bool ok=false;
        for(int i=4; i<=10000; ++i){
            if(i%2==0){
                if(cnt[i]>0){
                    cnt[i]--,cnt[i-4]++;
                    ok=true;
                    g3--;
                }
            }
        }
        if(!ok){cout<<"No"<<endl; return 0;}
    }
    while(g2!=0){
        bool ok=false;
        for(int i=1; i<=10000; ++i){
            if(i%2==0){
                if(cnt[i]>0){
                    cnt[i]--,cnt[i-2]++;
                    ok=true;
                    g2--;
                }
            }
        }
        if(!ok){cout<<"No"<<endl; return 0;}
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main(){
  int a,b,c;
  int x,y;
  int sum1,sum2,sum3;
  int answer;
  cin >> a >> b >> c >> x >> y;
  int min,max,min_pizza,max_pizza;
  
  if(x < y){
    min = x;
    min_pizza = a;
    max = y;
    max_pizza = b;
  }else{
    min = y;
    min_pizza = b;
    max = x;
    max_pizza = a;
  }
  
  sum1 = a*x+b*y;
  sum2 = c*2*max;
  sum3 = c*2*min+(max-min)*max_pizza;
  
  if(sum1 > sum2){
    answer = sum2;
  }else{
    answer = sum1;
  }
  
  if(answer > sum3){
    answer = sum3;
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

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

	for (auto i = N; i <= 999; ++i)
	{
		if ((i / 100 == (i % 100) / 10) && (i / 100 == (i % 10)))
		{
			cout << i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
    
using namespace std;
    
string str[2];
int s, n, t, m, lt, rt, t_w, t_t;
double p;
    
int conv(string s){
  string data[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};  
  for(int i=0;i<7;i++) if(s == data[i]) return i;
  return -1;
}

inline    
int calc(int s_w, int s_t){
  int cnt = 0;
  for(int k=0;k<m;k++){
    int f_w = s_w;
    int f_t = s_t + s;
    if(f_t >= 24 * 60){
      f_t -= 24 * 60;
      f_w = (f_w + 1) % 7;
    }
    bool f = false;
    if(t_w == -1 || (t_w == s_w && t_w == f_w)){
      if(t_t == 0 && 0 <= s_t && s_t < 24 * 60 && 0 <= f_t && f_t < 24 * 60) f = true;
      if(t_t == 1 && 6 * 60 <= s_t && s_t < 18 * 60 && 6 * 60 <= f_t && f_t < 18 * 60) f = true;
      if(t_t == 2 && (18 * 60 <= s_t && s_t < 24 * 60 || 0 <= s_t && s_t < 6 * 60)
         && (18 * 60 <= f_t && f_t < 24 * 60 || 0 <= f_t && f_t < 6 * 60)) f = true;
    }
    if(f) cnt++;
    s_t += t;
    if(s_t >= 24 * 60){
      s_t -= 24 * 60;
      s_w = (s_w + 1) % 7;
    }
  }
  return cnt;
}
    
main(){
  while(cin >> s >> n >> t >> str[0] >> str[1] >> p >> m && (s|n|t|m) && str[0] != "None" && str[1] != "None"){
    t_w = conv(str[0]);
    if(str[1] == "All") t_t = 0;
    if(str[1] == "Day") t_t = 1;
    if(str[1] == "Night") t_t = 2;
    int ans = 0;
    for(int i=0;i<7;i++) for(int j=0;j<24*60;j++) ans = max(ans, calc(i, j));
    printf("%.10f\n", 1.0 - pow(1.0 - 1.0 / p, n * ans));
  }
}

Measured memory_bytes: 1296
//Problem Y

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define endl "\n"
 
int main ()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #define int ll
  
  int n, k;
  cin >> n >> k;
  vector <int> numbers(n);
  for(auto& i:numbers) cin >> i;
  sort(numbers.begin(), numbers.end());
	int ans =0;
	for (int i=0; i<min(n, k); i++){
		ans += numbers[i];
	}

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


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; } 
template<class T> void chmax(T &t, T f) { if (t < f) t = f; } 

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;
LL a[100010];
char op[100010];
LL dp[100010][3];

void init() {
}

void input() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		if (i < n-1) cin >> op[i+1];
	}
}

void solve() {
	REP(i, 100010) REP(j, 3) dp[i][j] = -1e15;
	dp[0][0] = a[0];
	FOR(i, 1, n){
		if(op[i] == '+'){
			dp[i][0] = max(
				dp[i-1][0]+a[i], 
				dp[i-1][1]+a[i]);
			dp[i][1] = dp[i-1][1]-a[i];
			dp[i][2] = dp[i-1][2]+a[i];
		}
		else{
			dp[i][1] = dp[i-1][0]-a[i];
			dp[i][2] = max({
				dp[i-1][1]+a[i], 
				dp[i-1][2]+a[i]
				});
		}
	}
	cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
}

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








Measured memory_bytes: 3456
from math import sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort()
    return divisors


if __name__ == "__main__":
    n = int(input())

    div = Calc_Divisors(n)

    ans = len(str(n))
    for d in div:
        tmp = max([len(str(d)), len(str(n//d))])
        if tmp < ans:
            ans = tmp

    print(ans)


Measured memory_bytes: 3064
N,C,K = map(int,input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
t_0 = T[0]
ans = 0
c = C
for t in T:
    if c == 0 or t - t_0 > K:
        ans += 1
        t_0 = t
        c = C - 1
    else:
        c -= 1
if c != C:
    ans += 1
print(ans)  

Measured memory_bytes: 7488
using System;
using System.Linq;
 
   class Program
    {
        static void Main()
        {
            var args = Console.ReadLine().Split().ToList().ConvertAll(x=>long.Parse(x));
            var a = args[0];
            var b = args[1];
            var c = args[2];
            var d = args[3];
            var ans = (long)0;
            ans = a * c;
            if (a * d > ans) ans = a * d;
            if (b * c > ans) ans = b * c;
            if (b * d > ans) ans = b * d;
            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 28304
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder output = new StringBuilder();
        int i = 1;
        while(true){
            int x = Integer.parseInt(br.readLine());
            if(x == 0){
                break;
            }
            output.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(x)).append("\n");
      }
      System.out.print(output);
    }
}

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

int main(){
    int  n,m;
    cin >> n >> m;
    int s = 0 ,ps = 0;
    map<int,int> mp;
    for(int i=0;i<m;i++){
        int t;
        string st;
        cin >>t;
        cin >> st;
        if (mp[t] == -1){
            continue;
        } 
        else if (mp[t]){
            if (st == "AC") {
                s+= mp[t];
                mp[t] = -1;
                ps += 1;
            }
            else mp[t] ++;
        }
        else{
            if (st == "AC"){
                mp[t] = -1;
                ps += 1;
            }
            else mp[t] = 1;
                
        }
    }
    cout << ps << " " << s << endl;

}


Measured memory_bytes: 4992
//
// Created by sark2 on 22-10-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define PB push_back
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define CASES int t;cin>>t;while(t--)
#define MP make_pair

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

ll mod = 1e9 + 7;

int main() {
    IOS
    int n,k;
    cin>>n>>k;
    int c = 0;
    int h;
    for(int i = 1; i <= n; i++) {
        cin >> h;
        if (h >= k) c++;
    }

    cout<<c;



}


Measured memory_bytes: 256