akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
string solveMeFirst(int a, int b){
    if(a !=2 && b !=2){
        return "Yes";
    }
    return  "No";
}

int main(){
    int a;
    int b;
    cin >> a  >> b;
    string c = solveMeFirst(a,b);
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#define MOD1 1000000007

inline void inp( long long int  &n ){n=0;int ch=getchar();int sign=1;while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}while( ch >= '0' && ch <= '9' )n = (n<<3)+(n<<1) + ch-'0', ch=getchar();n=n*sign;}
#define pi acos(-1)
#define pii pair<int,int>
#define vii vector<pii>
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define ll  long long int
#define LL long long int
#define loop2(i,n) for(ll i=1;i<=n;i++)
#define MIN(a,b) (a) < (b) ? (a) : (b)
#define MAX(a,b) (a) > (b) ? (a) : (b)
#define ABS(a) (a) > 0 ? (a) : -(a)
#define rep1(i,a,n) for(i=a;i<(n);i++)
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl
#define EPS 1e-9
#define ld long double
using namespace std;
//JAI SHREE KRISHNA
// Find the holy grail in an  adventure frought with danger
// The bigger the occasion, the better the response.
// Never giving in, fighting to the end
// Look at  the limits
// Check if it is binary search
// Code till the end of contest

int main(){
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    string s;
    cin>>s;
    vector<ll>ans;
    loop(i, s.size())
    {
        if(s[i]=='0')
        {
            ans.pb(0);
        }
        else if (s[i]=='1')
        {
            ans.pb(1);
        }
        else{
            if(ans.size()>0){
                ans.pop_back();
            }
        }
    }
    
    loop(i, ans.size())
    {
        cout<<ans[i];
    }
    
    return 0;
}

Measured memory_bytes: 256
/**
*  author: rits1272
*  created: Aug 22, 2020
**/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n";

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    int sum = 0;
    for(char c: s){
	sum += c - '0';
    }
    if(sum%9 == 0)
	cout << "Yes\n";
    else
	cout << "No\n";
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n, x, y;
    cin >> n >> x >> y;
    vector<vector<int>> grid(n + 1);
    for(int i=1;i<n;i++) {
        grid[i].push_back(i + 1);
        grid[i+1].push_back(i);
    }
    grid[x].push_back(y); grid[y].push_back(x);
    int res[2001];
    int dist[2001];
    bool vis[2001];
    memset(res, 0, sizeof(res));
    for(int i=1;i<=n;i++) {
        memset(dist, 200000, sizeof(dist));
        memset(vis, false, sizeof(vis));
        queue<int> q;
        dist[i] = 0;
        vis[i] = true;
        q.push(i);
        while(!q.empty()) {
            int f = q.front();
            q.pop();
            for(int next : grid[f]) {
                if(!vis[next]) {
                    vis[next] = true;
                    q.push(next);
                    dist[next] = min(dist[next], dist[f] + 1);
                    res[dist[next]]++;
                }
            }
        }
    }
    for(int i=1;i<=n-1;i++) {
        cout << res[i] / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
vector<lli> one, two;
int main(){
   ios;
  // setin("input.in");
   lli n, t;
   cin >> n >> t;
   lli ans = 0;
   lli mx = -1;
   for(int i=0;i<n;i++){
        lli x, y;
        cin >> x >> y;
        mx = max(x, mx);
        one.push_back(x);
        two.push_back(y);
   }
   sort(two.begin(), two.end());
   reverse(two.begin(), two.end());
   //cout << mx << endl;
   lli i = 0;
   lli tot = 0;
   //cout << two[i] << endl;
   while(two[i] > mx && i < n){
        ans++;
        tot+=two[i];
        if(tot >= t){
            break;
        }
        i++;
   }
   //cout << ans << endl;
   if(tot < t){
    lli rem = t-tot;
    ans+=(rem/mx+(bool)(rem%mx>0));
   }
   //while(tot < t){
   //     ans++;
   //     tot+=mx;
   //}
   cout << ans;
}


Measured memory_bytes: 2036
'use strict';

let input = require('fs').readFileSync('/dev/stdin', 'utf8');
input = input.trim().split(' ');

const stack = [];

for (let i = 0; i < input.length; ++i) {
  const v = input[i];
  switch (v) {
    case '+':
      stack.push(stack.pop() + stack.pop());
      break;
    case '-':
      stack.push(-stack.pop() + stack.pop());
      break;
    case '*':
      stack.push(stack.pop() * stack.pop());
      break;
    default:
      stack.push(Number(v));
      break;
  }
}

console.log(stack[0]);



Measured memory_bytes: 15376
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct SegmentTree {
  using T = lint;
  static T op(const T& x, const T& y) { return min(x, y); }
  static constexpr T e() { return numeric_limits<T>::max(); }

  const int n;
  V<T> t;
  SegmentTree(int n) : n(n), t(2 * n, e()) {}
  T& operator[](int i) { return t[i + n]; }
  void build() { for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]); }
  T acc(int l, int r) const {
    T resl = e(), resr = e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = op(resl, t[l++]);
      if (r & 1) resr = op(t[--r], resr);
    }
    return op(resl, resr);
  }
  void set(int i, const T& x) {
    t[i += n] = x;
    while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  lint E, T; cin >> E >> T;
  V<lint> x(n); for (auto&& e : x) cin >> e;
  x.push_back(E);
  V<lint> dp(n + 1, 9e18);
  SegmentTree st0(n + 1), st1(n + 1);
  dp[n] = 0;
  for (int i = n; i >= 0; --i) {
    if (i < n) {
      int k = lower_bound(begin(x), end(x), x[i] + (T + 1) / 2) - begin(x) + 1;
      k = min(k, n + 1);
      dp[i] = min(dp[i], T - x[i] + st0.acc(i + 1, k));
      dp[i] = min(dp[i], -3 * x[i] + st1.acc(k, n + 1));
    }
    st0.set(i, x[i] + dp[i]);
    if (i) st1.set(i, 2 * x[i - 1] + x[i] + dp[i]);
  }
  cout << x[0] + dp[0] << '\n';
}

Measured memory_bytes: 4976
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<n; i++)
template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int N;
double dp[303][303][303];

double func(int i, int j, int k){
    if(dp[i][j][k] != -1) return dp[i][j][k];
    int m = N - (i + j + k);
    double a = 0, b = 0, c = 0;
    if(i > 0) a = func(i-1, j, k) * i/N;
    if(j > 0) b = func(i+1, j-1, k) * j/N;
    if(k > 0) c = func(i, j+1, k-1) * k/N;
    dp[i][j][k] = (1 + a + b + c) / (1.0 - 1.0 * m/N);
    return dp[i][j][k];
}

int main(){
    cin >> N;
    int b[3] = {0};
    REP(i, N){
        int a;
        cin >> a;
        b[--a]++;
    }
    REP(i, N+1) REP(j, N+1) REP(k, N+1)
        dp[i][j][k] = -1;
    dp[0][0][0] = 0;

    cout << fixed << setprecision(32) << func(b[0], b[1], b[2]) << endl;
    return 0;
}

Measured memory_bytes: 217344
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<ll, ll>
#define mp make_pair
#define pb push_back
#define vi vector<ll>
#define pd pair<double, double>
#define vp vector<pi>
#define f(i, n) for(int i = 0; i < n; i++)
#define fo(i, a, n) for(int i = a; i < n; i++)
#define mod (1000*1000*1000+7)
#define sz(x) int((x).size())
#define all(x) x.begin(),x.end()
#define DBG(v) cerr << #v << " = " << (v) << endl;
ll INF = (1ll<<61);

using namespace std;

int main(int argc, char* argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n; cin >> n;
    string s[2]; cin >> s[0] >> s[1];
    string t;
    f(i, 2*n){
      t.pb(s[i%2][i/2]);
    }cout << t << endl;
    return 0;
}


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

struct Pair{
	int vote=0;
	char name;
};

bool cmp(Pair p1, Pair p2){
	return p1.vote>p2.vote;
}

int main (){
    int n;
	while(cin>>n && n){
		bool isTIE=true;
		vector<Pair> v(26);
		vector<char> c(n);
		for(int i=0;i<26;i++)v[i].name='A'+i;
		for(int i=0;i<n;i++)cin>>c[i];
		for(int i=0;i<n;i++){
			v[c[i]-'A'].vote++;
			vector<Pair> temp_v=v;
			sort(temp_v.begin(),temp_v.end(),cmp);
			if(temp_v[0].vote-temp_v[1].vote>n-i-1){
				cout<<temp_v[0].name<<" "<<i+1<<endl;
				isTIE=false;
				break;
			}
		}

			//for(auto x:v)cout<<x.vote<<endl;
		if(isTIE)cout<<"TIE"<<endl;
	}
}



Measured memory_bytes: 3096
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  int N, i, j, k;
  int ctr = 0;
  cin >> N;

  int *h = new int[N];
  
  for(i=0;i<N;i++){
    cin >> h[i];
  }
  sort(h, h+N);
  
  for(i=0;i<N-2;i++){
    for(j=i+1;j<N-1;j++){
      for(k=j+1;k<N;k++){
	if(h[k]<h[j]+h[i]){
	  ctr++;
	}else{
	  break;
	}
      }
    }
  }

  cout << ctr; 
  return 0;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
#define testP	 cout << "------------------ test ------------------" << endl;	// 動作確認テスト
#define testX(x) cout << "testout : " << x << endl;	// テストアウト
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// ------------------ ベクター表示 ------------------ //
void printVec(vector<int>& vec) {
	cout << "";
	for (auto it = vec.begin(); it != vec.end(); it++) cout << *it << " ";
	cout << endl;
}

// ------------------ ベクター合計 ------------------ //
int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

int main(void) {

	ll cnt[100010] = { 0 };
	ll sum = 0;

	ll N;
	cin >> N;
	for (ll i = 0; i < N; i++) {
		int a;
		cin >> a;
		sum += a;
		cnt[a]++;
	}

	ll Q;
	cin >> Q;

	for (ll i = 0; i < Q; i++) {
		int b, c;
		cin >> b >> c;
		if (cnt[b] != 0) {
			sum += (c - b) * cnt[b];
			cnt[c] += cnt[b];
			cnt[b] = 0;
		}
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 4364
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    readln();
    auto a = aryread();
    a.reduce!((x, y) => gcd(x, y)).writeln();
}


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

int main(void){
    ll N;
    cin >> N;
    ll sum{0};
    ll m{N-1};
    ll i{1};
    for(ll i{1}; i*i<N; ++i){
        if(N%i==0){
            if(i-1>0 and N/(i-1)==N%(i-1))
                sum += i-1;
            if(N/i-1 > 0 and N/(N/i-1)==N%(N/i-1))
                sum += N/i-1;
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<bitset>
#include<utility>

typedef long long ll;
#define INF 1000000000
#define MOD 1000000007

using namespace std;

ll dp[100][2];

int main() {
	vector<int> a(6);
	int count[4] = {0,0,0,0};
	for (int i = 0; i < 6; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 6; i++) {
	    if (a[i] == 1)
			count[0]++;
	    if (a[i] == 2)
			count[1]++;
	    if (a[i] == 3)
			count[2]++;
	    if (a[i] == 4)
			count[3]++;
	}

	if (count[0] < 3 && count[1] < 3 && count[2] < 3 && count[3] < 3) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
N, A, B = list(map(int, input().split()))

diff = B - A

if diff % 2 == 0:
    ans = diff // 2
else:
    # d1 = A - 1
    # ans1 = d1 + (diff - 1) / 2 + 1

    # d2 = N - B
    # ans2 = d2 + (diff - 1) / 2 + 1

    ans = min(A-1, N-B) + 1 + (B - A - 1) // 2

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
  int n, sum=0, max=0;
  
  scanf("%d", &n);
  
  int i1,l[n];
  
  for(i1=0;i1<n;i1++){
    scanf("%d", &l[i1]);
    sum+=l[i1];
    if(l[i1]>max) max=l[i1];
  }
  
  if(max<sum-max) printf("Yes");
  else printf("No");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int ans,a[107],n,x;
int main(){
	cin>>n>>x;for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++){
		if(x>=a[i]){
			x-=a[i];ans++;
		}
	}
	if(x==a[n])ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)
#define size size()

int main(){
    int n,k;
    cin >> n >> k;
    vi x(n);
    rp(i,n){
        cin >> x[i];
    }
    int ans=0;
    rp(i,n){
        ans += ( x[i] > k-x[i] ? 2*(k-x[i]) : 2*x[i] );
    }
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
N = int(input())
evidencies = {}
for i in range(N):
    A = int(input())
    evidence = []
    for j in range(A):
        x, y = map(int, input().split(" "))
        evidence.append((x - 1, y))
    evidencies[i] = evidence

#  B r u t e   F o r c e   S e a r c h
ans = 0
for S in range((1 << N)):
    is_conflict = False
    bitcount = 0
    for i in range(N):
        if ((S >> i) & 1) == 1:
            # i is honest
            bitcount += 1
            for ev in evidencies[i]:
                # ev[0] is ev[1]?
                is_conflict |= ((S >> ev[0]) & 1) ^ ev[1]
    if not is_conflict:
        ans = max(bitcount, ans)

print(ans)


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

#define ll long long
#define sc(n) int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define pi acos(-1)
#define flag bool fl=true;
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0);

int main()
{

       string s;
       cin>>s;

     for(int i=0 ;i<s.size();++i){
        if(s[i]=='?')s[i]='D';
     }
     cout<<s<<endl;
}




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


void solve(long long A, long long B){
  if (A >= 13) {
    cout << B << endl;
  } else if (13 > A &&  A >= 6) {
    cout <<( B / 2) << endl;
  } else {
    cout << 0 << endl;
  }
}

// Generated by 1.1.4 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 A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
<?php

while (($line = trim(fgets(STDIN))) !== '0 0') {
    sscanf($line, '%d %d', $n, $m);
    $arr = array_fill(0, $n, 1);
    $cnt = 0;
    $i = $n - 1;
    while ($cnt < $n - 1) {
        for ($j = 0; $j < $m;) {
            $i = $i + 1 === $n ? 0 : $i + 1;
            if ($arr[$i]) {
                $j++;
            }
        }
        $arr[$i] = 0;
        $cnt++;
    }
    echo array_search(1, $arr) + 1, PHP_EOL;
}

Measured memory_bytes: 6824
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 250010
using namespace std;
struct bb{int x, id;}b[510];
int n, x, a[N], sum[510], now, now1;
inline bool cmp(bb a, bb b){return a.x<b.x;}
int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++){scanf("%d", &x); b[i].x=x; b[i].id=i;}
	sort(b+1, b+1+n, cmp);
	memset(a, 0, sizeof(a)); memset(sum, 0, sizeof(sum));
	for(int i=1; i<=n; i++){a[b[i].x]=b[i].id; sum[b[i].id]++;}
	now=1; if(b[1].id==1)now++;
	now1=1;
	for(int i=1; i<=n*n; i++){
		if(a[i]){if(sum[a[i]]!=a[i]){printf("No"); return 0;} continue;}
		if(now<=n){
			a[i]=b[now].id; sum[b[now].id]++;
			while(now<=n&&sum[b[now].id]==b[now].id)now++;
		}else{
			while(sum[b[now1].id]==n)now1++;
			a[i]=b[now1].id; sum[b[now1].id]++;
		}
	}
	printf("Yes\n");
	for(int i=1; i<=n*n-1; i++)printf("%d ", a[i]); printf("%d", a[n*n]);
	return 0;
}

Measured memory_bytes: 2048
a=int(input())
b=list(map(int,input().split()))
t=0
for i in range(a):
	x=b[i]
	if x % 2 ==0 and x % 3 != 0 and x % 5 != 0:
		t=t+1
if t>0:
	print('DENIED')
else:
	print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int n;
    cin>>n;
    n=n%1000;
    if(n!=0)n=1000-n;
    cout<<n<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
 //解説AC
  int main(){
        lint n,k;
        cin>>n>>k;
         COMinit();
         lint ans=0;
         repp(i,1,k+1){
             if(i>n)break;
             lint sum;
             sum=COM(n,i)*COM(n-1,i);
            sum%=MOD;
            ans+=sum;
            ans%=MOD;
         }
         cout<<ans+1;
  }
  
     


Measured memory_bytes: 23680
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        int ab = a + b;
        int ac = a + c;
        int bc = b + c;

        int result = ab;

        if (ac <= result && ac <= bc) {
            result = ac;
        } else if (bc <= result && bc <= ac) {
            result = bc;
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int t,n,s,f,a;
	for(;;){
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		a=0;
		rep(i,n){
			scanf("%d%d",&s,&f);
			a=a-s+f;
		}
		if(a>=t)puts("OK");
		else printf("%d\n",t-a);
	}
	return 0;
}

Measured memory_bytes: 1196
x0,y0,x1,y1 = map(int, input().split( ))
p0 = [x0,y0]
p1= [x1,y1]
v1 =[p1[0]-p0[0],p1[1]-p0[1]]
q = int(input())
def cross(a,b):
    crs = a[0]*b[1] - a[1]*b[0]
    return crs
def dot(a,b):
    dt = a[0]*b[0] + a[1]*b[1]
    return dt
eps = 0.000001
for i in range(q):
    p2 = list(map(int, input().split( )))
    v2=[p2[0]-p0[0],p2[1]-p0[1]]
    if cross(v1,v2) >eps:
        print("COUNTER_CLOCKWISE")
    elif cross(v1,v2) <-eps:
        print("CLOCKWISE")
    elif dot(v1,v2)<-eps:
        print("ONLINE_BACK")
    elif v1[0]**2+v1[1]**2 < v2[0]**2+v2[1]**2:#abs(v1[0])<abs(v2[0]):はx成分0でおかしい
        print("ONLINE_FRONT")
    else:#p1=p2はこっち
        print("ON_SEGMENT")


Measured memory_bytes: 5632
import numpy as np
inp_n = int(input())

inp = input()
nums = [int(inp.split()[i]) for i in range(inp_n)]

ans = 0
for j in range(len(nums)):
  j += 1
  diff = np.abs(sum(nums[:j]) - sum(nums[j:]))
  if j == 1:
    ans = diff
  else:
    ans = min(ans, diff)
  
print(ans)

Measured memory_bytes: 20780
#include <bits/stdc++.h>
#define MOD 998244353

struct BIT {
	std::vector<int> data;
	int n;
	BIT(int n) {
		this->n = n;
		data.resize(n + 1);
	}
	void add(int i, int val) {
		for (i++; i <= n; i += i & -i) data[i] += val;
	}
	int sum(int i) {
		int res = 0;
		for (; i; i -= i & -i) res += data[i];
		return res;
	}
};

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct Point {
	int x;
	int y;
	int id;
	int y_comped;
};

int main() {
	int n = ri();
	Point a[n];
	for (int i = 0; i < n; i++) a[i].x = ri(), a[i].y = ri(), a[i].id = i;
	
	int b2[n + 3];
	b2[0] = 1;
	for (int i = 1; i <= n + 2; i++) {
		b2[i] = b2[i - 1] + b2[i - 1];
		if (b2[i] >= MOD) b2[i] -= MOD;
	}
	
	std::sort(a, a + n, [](const Point &a, const Point &b) { return a.y < b.y; });
	int cnt = 0;
	for (auto &i : a) i.y_comped = cnt++;
	std::sort(a, a + n, [](const Point &a, const Point &b) { return a.x < b.x; });
	
	BIT tree(cnt);
	uint64_t res = 0;
	for (int i = 0; i < n; i++) {
		int v = tree.sum(a[i].y_comped);
		res += b2[v];
		res += b2[i - v];
		res += b2[a[i].y_comped - v];
		res += b2[n - a[i].y_comped - 1 - i + v];
		
		tree.add(a[i].y_comped, 1);
	}
	res += (uint64_t) (b2[n] - 1) * n;
	res -= b2[n + 2] - 4;
	std::cout << res % MOD << std::endl;
	
	return 0;
}


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

using namespace std;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int A,B,C,D,E,F;
cin>>A>>B>>C>>D>>E>>F;
vector<int> x;
vector<int> y;
for(int i=0;i<F;i++){
for(int j=0;j<F;j++){
    int tmp_x=100*A*i+100*B*j;
    int tmp_y=C*i+D*j;
    if(tmp_x<=F){
        x.push_back(tmp_x);
    }
    if(tmp_y<=F){
        y.push_back(tmp_y);
    }
}
}

std::sort(x.begin(), x.end());
x.erase(std::unique(x.begin(), x.end()), x.end());
std::sort(y.begin(), y.end());
y.erase(std::unique(y.begin(), y.end()), y.end());

int max_j=-1;
int max_i=-1;
float max_val=-1;
for(int i=0;i<x.size();i++){
for(int j=0;j<y.size();j++){
    int limit=(x[i]/100)*E;
    if(y[j]<=limit){
        float tmp_w=x[i]+y[j];
        float concentration=100*(y[j]/tmp_w);
        if(tmp_w<=F&&max_val<concentration){
            max_val=concentration;
            max_i=i;
            max_j=j;
        }
    }
}
}

cout<<x[max_i]+y[max_j]<<" "<<y[max_j]<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

//On or Off
public class Main{

	int h, w, M;
	int[][] cost, on, off, nh, nw, v, dp;
	char[][] map;
	int[][] move = {{-1,0},{0,1},{1,0},{0,-1}};
	boolean[][] u;
	
	boolean dfs(int i, int j, int ti, int tj){
		if(i==ti&&j==tj)return true;
		u[i][j] = true;
		for(int k=0;k<4;k++){
			int ni = i+move[k][0], nj = j+move[k][1];
			if(0<=ni&&ni<h&&0<=nj&&nj<w&&!u[ni][nj]&&map[ni][nj]=='.'){
				if(dfs(ni, nj, ti, tj)){
					nh[i][j] = ni; nw[i][j] = nj; return true;
				}
			}
		}
		nh[i][j] = nw[i][j] = -1;
		return false;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt(); w = sc.nextInt(); M = sc.nextInt();
		cost = new int[h][w];
		on = new int[h][w]; off = new int[h][w];
		nh = new int[h][w]; nw = new int[h][w];
		map = new char[h][w];
		for(int i=0;i<h;i++)map[i]=sc.next().toCharArray();
		v = new int[h][w];
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)v[i][j] = -1;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)cost[i][j]=sc.nextInt();
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)on[i][j]=sc.nextInt();
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)off[i][j]=sc.nextInt();
		int t = 0, pi = sc.nextInt(), pj = sc.nextInt();
		dp = new int[h][w];
		v[pi][pj] = 0;
		dp[pi][pj] = on[pi][pj];
		while(--M!=0){
			int ti = sc.nextInt(), tj = sc.nextInt();
			u = new boolean[h][w];
			dfs(pi, pj, ti, tj);
			for(;pi!=ti||pj!=tj;){
				int ni = nh[pi][pj], nj = nw[pi][pj];
				t++;
				if(v[ni][nj]==-1)dp[ni][nj] = on[ni][nj];
				else dp[ni][nj] = Math.min(dp[ni][nj]+off[ni][nj]+on[ni][nj], dp[ni][nj]+(t-v[ni][nj])*cost[ni][nj]);
				v[ni][nj] = t;
				pi = ni; pj = nj;
			}
		}
		int res = 0;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(v[i][j]!=-1)res+=dp[i][j]+off[i][j];
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  string s;
  int k;
  cin >> s >> k;
  bool b = k < s.size();
  int base = 0;
  for (int i = 0; i < k && i < s.size(); i++) {
    if (s[i] != '1') {
      b = false;
      base = i;
      break;
    }
  }
  if (b) {
    cout << '1' << endl;
  } else {
    cout << s[base] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;


int main() {

  string buf;


  while(cin >> buf) {

    for(int i=0;i<buf.size();i++) {

      if(buf[i]=='A') buf[i]='X';

      else if(buf[i]=='B') buf[i]='Y';

      else if(buf[i]=='C') buf[i]='Z';

      else buf[i]-=3;

    }

    cout << buf << endl;

  }

  return 0;

}

Measured memory_bytes: 0
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

ll n,m;
vector<ll> a;
ll count1[200002];

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a,a+n);
  Comb comb;
  ll under = 0;
  ll upper = 0;
  for(int i=0;i<n;i++){
    if(n-i-1 < k-1) continue;
    under += comb.calc(n-i-1,k-1)*a[i];
    under %= MOD;
  }
  for(int i=0;i<n;i++){
    if(i < k-1) continue;
    upper += comb.calc(i,k-1)*a[i];
    upper %= MOD;
  }
  ll ans = upper - under;
  ans %= MOD;
  ans += 2*MOD;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using p=pair<int,int>;
typedef long long ll;

int main() {
  int x;
  cin >> x;
  if(x==1){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }
  
  
  return 0;

}

Measured memory_bytes: 3588
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> H >> W;
	K = H;
	if (K >= N) {
		cout << 1 << endl;
		return 0;
	}
	if (W >= H) {
		cout << "-1\n";
		return 0;
	}
	cout << ((N - H) / (H - W) + !!((N - H) % (H - W))) * 2 + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
S,T=[q=0,0].map{[q,*gets.chars.map{|c|q-=~c.count(?A)}]};gets;$<.map{|l|a,b,c,d=l.split.map &:to_i;puts (S[b]-S[a-1]-T[d]+T[c-1])%3<1?:YES: :NO}

Measured memory_bytes: 22860
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int i, number_n, count = 0;
    Scanner sc = new Scanner(System.in);
    number_n = Integer.parseInt(sc.next());
    int[] number_array = new int[number_n];
    for(i = 0; i < number_n; i++) number_array[i] = Integer.parseInt(sc.next());
    for(i = 0; i < number_n - 2; i++) {
      if((number_array[i] < number_array[i+1] && number_array[i+1] < number_array[i+2]) || (number_array[i] > number_array[i+1] && number_array[i+1] > number_array[i+2])) {
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define PPC(x) __builtin_popcountll((x))
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
using namespace std;

const int maxN = 200042, mod = 1000000007;

inline void add_mod(long long& a, long long b)	{   a = (a + b) % mod;  }
inline void mult_mod(long long& a, long long b)	{   a = a * b % mod;    }

long long fact[maxN], tcaf[maxN], potos[maxN], B[maxN], W[maxN];

long long qpow(long long a, long long b)
{
    long long res = 1;
    for (; b!=0; b>>=1)
    {
        if (b & 1)  mult_mod(res, a);
        mult_mod(a, a);
    }
    return res;
}

long long cf(int n, int k)
{
	bool static initd = false;
	if (!initd)
	{
		fact[0] = 1;
		FOR(i, 1, maxN)
			fact[i] = fact[i - 1] * i % mod;
		tcaf[maxN - 1] = qpow(fact[maxN - 1], mod - 2);
		for (int i=maxN-1; i>0; i--)
			tcaf[i - 1] = tcaf[i] * i % mod;
		initd = true;
	}
	if (k < 0 or k > n)
		return 0;
	long long res = fact[n];
	mult_mod(res, tcaf[k]);
	mult_mod(res, tcaf[n-k]);
	return res;
}

int main()
{
	cf(1, 1);
	potos[0] = 1;
	long long os = (mod+1) / 2;
	FOR(i, 1, maxN)
		potos[i] = potos[i - 1] * os % mod;
		
	int b, w;
	scanf ("%d%d", &b, &w);
	int n = b + w;
	
	FOR(i, b, n+1)
	{
		B[i] = cf(i-1, b-1);
		mult_mod(B[i], potos[i]);
		add_mod(B[i], B[i - 1]);
	}

	FOR(i, w, n+1)
	{
		W[i] = cf(i-1, w-1);
		mult_mod(W[i], potos[i]);
		add_mod(W[i], W[i - 1]);
	}
	
	FOR(i, 0, n)
	{
		long long res = (B[i] + W[i] + mod-1) % mod;
		mult_mod(res, mod-1);
		mult_mod(res, os);
		add_mod(res, W[i]);
		printf("%lld\n", res);
	}
	return 0;
}




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

int main(){
  int N, x;
  int sum = 0;
  cin >> N;
  x = N;
  
  
  for(int i = 0; i >= 0 ; i++){
    sum += x%10;
    x = (x - x%10)/10;
    if(x == 0){
      break;
    }
  }
  if(N%sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define INF 1LL<<60

int used[100010];


long long calc(int N,vector<pair<int,int>> &v,int skip1 = -1,int skip2 = -1){
    for(int i=1;i<=N;i++) used[i] = false;
    long long total = 0;
    int pos = 0,neg = 0;
    for(int i=0,j=0;j<N;i++,j++){
        if(i == skip1 || i == skip2){
            j -= 1;
            continue;
        }
        total += v[i].first;
        if(v[i].second > 0){
            pos += 1;
            used[v[i].second] = true;
        }else{
            neg += 1;
            used[-v[i].second] = true;
        }
    }
    bool allUsed = true;
    for(int i=1;i<=N;i++) allUsed &= used[i];
    if(allUsed == false || pos == N || neg == N) return total;
    else return INF;
}
int main(){
    int N;cin>>N;
    vector<pair<int,int>> v(2*N);
    for(int i=0;i<N;i++){
        cin>>v[2*i].first>>v[2*i+1].first;
        v[2*i].second = i+1;
        v[2*i+1].second = -(i+1);
    }
    sort(v.begin(),v.end());
    long long ans = calc(N,v);
    ans = min(ans,calc(N,v,N-1));
    ans = min(ans,calc(N,v,N-2));
    ans = min(ans,calc(N,v,N-1,N));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {                 
    
  private static long dfs(String input,long sum,int index){
     if(index >= input.length()){
         return sum;
     }
     
     long total = 0;
     
     for(int i = index + 1;i <= input.length();i++){
         total += dfs(input,sum + Long.parseLong(input.substring(index,i)),i);    
     }   
     
     return total;     
  }  
        
  public static void main(String[] args) {   
      Scanner sc = new Scanner(System.in);                                                                                                         
      String input = sc.next();      
      System.out.println(dfs(input,0,0));             
  }         
  
}

Measured memory_bytes: 23636
N = int(input())
happy = []
result = [[0 for i in range(3)] for j in range(N)]

for i in range(N):
    t = list( map( int, input().split() ) )
    happy.append(t)

for i in range(3):
    result[0][i] = happy[0][i] 

for i in range(1,N):
    for j in range(3):
        result[i][j] = max( [ result[i-1][k] + happy[i][j] for k in range(3) if k != j ] )

print( max( result[N-1] ) )

Measured memory_bytes: 51916
def main():
    s = input()
    mi = min(s.count(c) for c in '01')
    ans = mi * 2
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

#include <algorithm>
#include <array>
#include <chrono>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

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

  vector<ll> A(N);

  FOR(i, 0, N) { cin >> A[i]; }

  ll result = 1;
  N -= K;
  K--;
  result += (N + K - 1) / K;

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
from copy import deepcopy
N, A = map(int, input().split())
x = list(map(int, input().split()))
dp = [[0] * (A*N+1) for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    _x = x[i]
    dpc = deepcopy(dp)
    for j in range(i+1):
        for a in range(A*N+1):
            if a >= _x:
                dp[j+1][a] += dpc[j][a-_x]
ans = 0
for i in range(1, N+1):
    ans += dp[i][i*A]
print(ans)


Measured memory_bytes: 113628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N, H, W;
    cin >> N >> H >> W;
    vector<pair<int,int> > p(N);
    rep(i, N) cin >> p[i].first >> p[i].second;
    int ans=0;
    rep(i,N) if(p[i].first >= H && p[i].second >= W) ans++;
    cout << ans << endl;
    return 0;
}

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

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

typedef long long ll;
using namespace std;

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

  int N;
  int P[20];

  cin >> N;
  REP(i, N) { cin >> P[i]; }

  int ans = 0;

  REP(i, N - 2) {
    if ((P[i] < P[i + 1] && P[i + 1] < P[i + 2]) ||
        (P[i] > P[i + 1] && P[i + 1] > P[i + 2])) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 896
k = int(input())
has = [False] * k
ans = 1
num = 7 % k

while num != 0 and not has[num]:
    has[num] = True
    num = (num * 10 + 7) % k
    ans += 1
    
if num == 0:
    print(ans)
else:
    print(-1)
    


Measured memory_bytes: 71104
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


int main() {
	string s1, s2, s3;
	cin >> s1;
	cin >> s2;
	cin >> s3;

	cout << s1[0] << s2[1] << s3[2] << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = list(map(int,input().split()))
h = [None for _ in range(N)]
MIN = float('inf')
for i in range(N):
  h[i] = int(input())
H = sorted(h)
for i in range(N-(K-1)):
  if MIN >= H[i+(K-1)] - H[i]:
    MIN = H[i+(K-1)] - H[i]
print(MIN)

Measured memory_bytes: 8268
#include <iostream>
using namespace std;
int main(){
    int n;
    while(cin>>n){
        if(n==0)return 0;
        
    int a[n];
    int b[n];
    
    int ansa=0,ansb=0;
    
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]>b[i]){ansa+=a[i];ansa+=b[i];}
        else if(a[i]<b[i]){ansb+=a[i];ansb+=b[i];}
        else{ansa+=a[i];ansb+=b[i];}
        
    }
        cout<<ansa<<" "<<ansb<<endl;
        
    }
}

Measured memory_bytes: 3112
#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;
  cin >>a >>b;
  if(a<=b) cout << a << endl;
  else cout << a-1 << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author JustLive
 */
 
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int mod = 1000000007;
const int inf = 1000000000;
const ll infll = (ll)inf * (ll)inf;
 
class TaskC {
public:
    void solve(istream& in, ostream& out) {
        int n, y;
        in >> n >> y;
        y /= 1000;
        for (int c = 0; c <= n; c++) {
            int b = 10 * n - y - 9 * c;
            if (b % 5 == 0 and b >= 0) {
                b /= 5;
                int a = n - c - b;
                if (a >= 0 and 10 * a + 5 * b + c == y) {
                    cout << a << " " << b << " " << c;
                    return;
                }
            }
        }
        out << "-1 -1 -1";
    }
};
 
 
int main() {
    TaskC solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    //vector<int>v(n);
    int a;
    map<int,int>mp;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        mp[a]++;
    }
  int  ans=0;
    for(auto u: mp)
    {
        if(u.second>=u.first)
        {
            ans+=(u.second-u.first);
        }
        else ans+=u.second;
    }
    return cout<<ans<<endl,0;
}


Measured memory_bytes: 8008
//approach 3--optimised approach
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int32_t main(){
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int dp[n+1][k+1];
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    // //there is always a way to distribute 0 chocolates to i children
    for(int i=1;i<=n;i++){
        dp[i][0]=1;
    }
    for(int i=1;i<=n;i++){
        for(int x=1;x<=k;x++){
            
            if(x-a[i]-1>=0){
                //recurrence is given below but we can access dp[i-1][x-a[i]-1] only if x-a[i]-1>=0
                dp[i][x]=(dp[i][x-1]+dp[i-1][x]-dp[i-1][x-a[i]-1]+mod)%mod;
                
            }
            else{
                dp[i][x]=(dp[i][x-1]+dp[i-1][x])%mod;
            }
        }
    }    
    cout<<dp[n][k]<<endl;
    return 0;
}

Measured memory_bytes: 79104
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string

	fmt.Scan(&S)

	firstS := S[0:2]
	secondS := S[2:4]

	first, _ := strconv.Atoi(firstS)
	second, _ := strconv.Atoi(secondS)

	var judge Judge

	if first >= 1 && first <= 12 {
		judge.MMYY = true
	} else {
		judge.MMYY = false
	}

	if second >= 1 && second <= 12 {
		judge.YYMM = true
	} else {
		judge.YYMM = false
	}

	if judge.YYMM && judge.MMYY {
		fmt.Println("AMBIGUOUS")
	} else if judge.YYMM {
		fmt.Println("YYMM")
	} else if judge.MMYY {
		fmt.Println("MMYY")
	} else {
		fmt.Println("NA")
	}
}

type Judge struct {
	YYMM bool
	MMYY bool
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
const int N=2000*20;

bool dp[N+5]={};

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

    dp[0] = true;
    REP(i,n){
        int a;
        cin>>a;
        FORR(j,a,N){
            dp[j] |= dp[j-a];
        }
    }
    
    // REP(i,100){
    //     DEBUG2(i, dp[i]);
    // }

    int m;
    cin>>m;
    REP(i,m) {
        int q;
        cin>>q;
        if(dp[q]) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int k = 38, n = k * (k - 1) + 1;
  cout << n << ' ' << k << '\n';
  for (int i = 1; i <= k; ++i) {
    cout << i << " \n"[i == k];
  }
  for (int i = 0; i < k - 1; ++i) {
    cout << 1;
    for (int j = 0; j < k - 1; ++j) {
      cout << ' ' << k + 1 + i * (k - 1) + j;
    }
    cout << '\n';
  }
  for (int s = 2; s <= k; ++s) {
    VV<> a(k - 1, V<>(k - 1));
    int t = k + 1;
    for (int j = 0; j < k - 1; ++j) for (int i = 0; i < k - 1; ++i) {
      a[((s - 2) * j + i) % (k - 1)][j] = t++;
    }
    for (int i = 0; i < k - 1; ++i) {
      cout << s;
      for (int j = 0; j < k - 1; ++j) {
        cout << ' ' << a[i][j];
      }
      cout << '\n';
    }
  }
}

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

int a[100010],b[100010],c[100010],dp[100010][3];

int main()
{
    int n; cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(int i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
                dp[i][j]=a[i]+max(dp[i-1][1],dp[i-1][2]);
            else if(j==1)
                dp[i][j]=b[i]+max(dp[i-1][0],dp[i-1][2]);
            else
                dp[i][j]=c[i]+max(dp[i-1][0],dp[i-1][1]);
        }
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist

#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    string inp; cin >> inp;
    ll cnt =0 ; 
    rep(i, inp.size()){
        if(inp[i] == 'x') cnt ++;
    }
    if(cnt < 8 ) cout << "YES" << endl;
    else cout << "NO" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    h, A = map(int, input().split())
    atk = list(map(int, input().split()))
    atk.sort(reverse=True)
    for i in atk:
        h -= i
        if h <=0:
            print("Yes")
            exit()
    if h<=0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13964