akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

int main() {
    ll N, K; cin >> N >> K;
    ll ans = 0;
    for (ll i = K; i <= N+1; i++) {
        ans += i * (N - i + 1 + N) / 2 - i * (i-1) / 2 + 1;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
    int c = getchar();
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        puts("vowel");
    } else {
        puts("consonant");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
using namespace std;
static const int MAX_N=100000;
static const int MAX_h=100000000000;
int main(void){
    int n,k;
    int H[MAX_N];
    cin >> n;
    cin >> k;
    for(int i=0; i<n; i++){
        cin >> H[i];
    }

    //dp[i][j]は足場i-jから足場iに移る場合のiまでの最小コスト
    int dp[n][k];
    for(int i=0; i<n; i++){
        for(int j=0; j<k; j++){
            dp[i][j]=MAX_h;
        }
    }
    dp[0][0] = 0;

    for(int i=0; i<n; i++){
        for(int j=0; j<k; j++){
            for(int bfj=0; bfj<k; bfj++){
                //0スタートなのに1スタートで考えてたi-jをi-j-1に変換し忘れていた
                if((dp[i][j] > dp[i-j-1][bfj]+abs(H[i-j-1]-H[i])) && i-j>0){
                    dp[i][j] = dp[i-j-1][bfj] + abs(H[i-j-1]-H[i]);
                }
            }
        }
    }
    //cout << dp[0][0] << "\n";


    //ansを探す
    int ans = MAX_h;
    for(int j=0; j<k; j++){
        if(ans>dp[n-1][j]) ans = dp[n-1][j];
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 39680
n = int(input())
a = list(map(int, input().rstrip().split(" ")))

t = list(0 for i in range(n+1))
for i in range(1, n+1):
    t[i] = t[i-1] + a[i-1]

def sum_a(i, j):
    return t[j]-t[i]

min_dif = sum_a(0, n)

i = 0
k = 2
for j in range(2, n-1):
    u = sum_a(0, j) // 2
    while sum_a(0, i) < u:
        i = i + 1
    if abs(sum_a(0, i-1)-sum_a(i-1, j)) < abs(sum_a(0, i) - sum_a(i, j)): 
        i = i - 1
    p = sum_a(0, i)
    q = sum_a(i, j)

    u = sum_a(j, n) // 2
    while sum_a(j, k) < u:
        k = k + 1
    if abs(sum_a(j, k-1)-sum_a(k-1, n)) < abs(sum_a(j, k) - sum_a(k, n)): 
        k = k - 1
    r = sum_a(j, k)
    s = sum_a(k, n)

    min_dif = min(min_dif, max(p, q, r, s)-min(p, q, r, s))

print(min_dif)


Measured memory_bytes: 25676
import Control.Monad

main = do
  str <- getLine
  let [n, k] = map read (words str) ::[Int]
  as <- forM [1..k] $ \i -> do
    str <- getLine
    let d = read str ::Int
    str <- getLine
    let a = take d $ map read (words str) ::[Int]
    return a
  print $ length $ filter (\x -> not (x `elem` (concat as))) [1..n]
  

Measured memory_bytes: 5240
N = int(input())
name = [input() for i in range(N)]
dic = {"M":0,"A":0,"R":0,"C":0,"H":0}
for i in name :
    if i[0] in dic.keys():
        dic[i[0]] += 1
    else : pass
ans = 0

head_name = ["M","A","R","C","H"]
for i in head_name:
    for j in head_name:
        for k in head_name:
            if i != j and j!= k and i != k :
                ans += dic[i]*dic[j]*dic[k]

print("{}".format(ans//(3*2*1)))

Measured memory_bytes: 9752
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    int p;
    vector<pair<string, int> > v;
    for(int i=0;i<n;i++) {
        cin >> s >>p;
        v.push_back(make_pair(s+ string(100-p,'a'), i+1));
    }

    sort(v.begin(), v.end());
    for(int i=0;i<n;i++) cout << v[i].second<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <cstdlib>
typedef long long int lld;
lld mgcd(lld x, lld y)
{
    while(y)
    {
        lld t = x % y;
        x = y;
        y = t;
    }
    return x+y;
}
lld x[100002];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0;i<=n;i++)
        scanf("%lld", &x[i]);
    std::sort(x,x+1+n);
    lld g = x[1]-x[0];
    for(int i=1;i<n;i++)
        g = mgcd(g, x[i+1]-x[i]);
    printf("%lld\n", g);
}

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

int main(){
string a;cin>>a;
int b=0,c=a.length()-1;
for(;b<a.length();b++){
if(a[b]=='A')break;
}
for(;c>=0;c--){
if(a[c]=='Z')break;
}
cout<<c-b+1<<endl;
}

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

int main()
{
	const int seg[] = {0x3f, 0x6, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27, 0x7f, 0x6f};
	int n;
	
	while (cin >> n, n != -1){
		int res = 0;
		int num;
		for (int i = 0; i < n; i++){
			cin >> num;
			cout << bitset<7>(res^seg[num]) << endl;
			res = seg[num];
		}
	}
	return (0);
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=0;
    string pre="";
    string cur="";
    for(int i=0;i<s.size();i++)
    {
        cur=cur+s[i];
        if(cur!=pre)
        {
            pre=cur;
            cur="";
            c++;
        }
    }
    cout<<c;
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e3 + 10;
const int M = (int) 1e4 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int h, n;
int a[N];
int b[N];
int f[N][M];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    cin >> h >> n;
    FOR(i, 1, n) cin >> a[i] >> b[i];
    FOR(i, 1, h)
        f[0][i] = INF;
    FOR(i, 1, n)
    {
        FOR(j, 1, h)
        {
            f[i][j] = min(f[i - 1][j], f[i][max(0, j - a[i])] + b[i]);
        }
    }
    cout << f[n][h];
    return 0;
}


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

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

	int r = n % 10;
	std::string s = "";

	if(r == 3){
		s = "bon";
	}
	else if(r == 0 || r == 1 || r == 6 || r == 8){
		s = "pon";
	}
	else{
		s = "hon";
	}

	std::cout << s << std::endl;

	return 0;
}
	


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

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define FF(i,x,n,y) for(int i=x;i>=n;i-=y)
#define fa(x,y) for(auto x:y)

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int a,b;
    cin>>a>>b;
    if((a+b)&1){
        cout<<"IMPOSSIBLE";
        return 0;
    }
    cout<<(a+b)/2;
    return 0;
}


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

using namespace std;
#define ll long long int
#define vi vector<int>
#define pi pair<int,int>
#define ff first
#define ss second
#define vll vector<long long int>
#define si set<int>
#define loop(i,k,n) for(int i=k;i<n;i++)
#define MOD 1000000007
#define r0 return 0
/*
//gcd in O(log(an n n nnnnn n n
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
*/
/*
int gcd, x, y;

void extendedEuclid (int a, int b)
{
    if (b==0)
    {
        x=1;
        y=0;
        gcd=a;
        return;
    }
    extendedEuclid(b, a%b);
    int x1=y;
    int y1=x-(a/b)*y;
    x=x1;
    y=y1;
}

int nCr (int n, int r)
{
    int p=1, k=1, modInv;
    if (n-r<r)
        r=n-r;
    if (r!=0)
    {
        while (r)
        {
            p=(p*n)%MOD;
            k*=r;
            n--;
            r--;
        }
        extendedEuclid(k, MOD);
        modInv=(x+MOD)%MOD;
        p=(p*modInv)%MOD;
    }
    else
        p=1;
    return p;
}

*/
// A modular inverse based solution to

int main(void)
{

  
    int t=1;
    //cin>>t;
    while(t--)
    {
       int n,k;
       cin>>n>>k;
       vi a(n);
       for(int i=0;i<n;i++)
       {
        cin>>a[i];
       }
       bool dp[k+1];
       for(int i=0;i<=k;i++)
        dp[i]=false;
      dp[0]=false;
      //dp[i] can a player win when he starts with i stones
      for(int stones=1;stones<=k;stones++)
      {
        for(int i=0;i<n;i++)
        {
          if(stones-a[i]>=0&&dp[stones-a[i]]==false)
          {
            dp[stones]=true;
          }

        }
      }

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

}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int h, w, m;
  cin >> h >> w >> m;
  vector<pair<int, int>> r(h), c(w);
  rep(i,h){
    r[i] = make_pair(0, i);
  }
  rep(i,w){
    c[i] = make_pair(0, i);
  }
  map<pair<int, int>, int> mp;
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    r[a].first++;
    c[b].first++;
    mp[make_pair(a,b)]++;
  }

  sortall(r);
  sortall(c);
/*
  prt("=>r");
  rep(i,h){
    prt2(r[i].first, r[i].second);
  }
  prt("=>c");
  rep(i,h){
    prt2(c[i].first, c[i].second);
  }
*/
  int x=r[h-1].first;
  int y=c[w-1].first;
  //prt3("===>", x, y);
  int mx=x+y;
  bool aru=true;
  rep(i,h){
    rep(j,w){
      int nowx=h-1-i, nowy=w-1-j;
      if(r[nowx].first!=x || c[nowy].first!=y) break;
      pair<int, int> p = make_pair(r[nowx].second, c[nowy].second);
      if(mp.find(p)==mp.end()){
        aru=false;
        break;
      }
    }
  }
  if(aru) mx--;
  prt(mx);
}


Measured memory_bytes: 26724
K=int(input())
L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(L[K-1])


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

ll solve(ll a, ll b, ll c, ll k) {
  
  if(k <= a)
    return k;
  ll kk = k-a;
  ll points = a;
  if(kk<=b)
    return points;
  kk -= b;
  return points - kk;
}

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  cout << solve(a, b, c, k);
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define HASH 18014398241046527
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
template <typename T>
ll SIZEOF(T a){return (ll)a.size();}
ll xlcm(ll a, ll b){return (a/__gcd(a, b))*b;}

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


const int N = 100005;


void SOLVE(){
    string s;
    cin >> s;
    ll x = 0;
    for(auto i:s){
        x += (i-'0');
    }
    if(x%9){
        cout << "No" << '\n';
    }
    else{
        cout << "Yes" << '\n';
    }
}

int main() {
	fastIO();
	// #ifndef ONLINE_JUDGE
    //     freopen("i.txt", "r", stdin);
    //     freopen("o.txt", "w", stdout);
	// #endif

    ll TC = 1;
    // cin >> TC;
    for(ll tc1=1; tc1<=TC; tc1++){
        // cout << "Case #" << tc1 << ": ";
        SOLVE();
    }
    printclock;
}

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

int P[10010]; // 0 から 10000 までの頂点を取り扱い可能
void init(int N) { // 初期化 はじめは全ての頂点はバラバラ
  for (int i=0; i<N; i++) P[i] = i;
}
int root (int a) { //aの大表現を求める
  if (P[a] == a) return a;
  return (P[a] = root(P[a]));
}
bool is_same_set (int a, int b){
  return root(a) == root(b);
}
void unite(int a, int b){
  P[root(a)] = root(b);
}

int main(){
  int n;
  int q;
  cin >> n >> q;
  int com;
  int x;
  int y;
  init(n + 10);
  int i = 0;
  while  (i < q){
    cin >> com >> x >> y;
    if (com == 0){
      unite (x, y);
    }
    if (com == 1){
      cout << is_same_set(x,y) << endl;
    }
    i++;
  }
  return 0;
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a,a + n);
    vector<long long int> v;
    for(int i = n - 2;i >= 0;i--)
    {
        if(a[i] == a[i + 1])
        {
            v.push_back(a[i]);
            i--;
        }
    }
    if(v.size() < 2)
    {
        cout << "0";
    }
    else
    {
        cout << v.at(0) * v.at(1);
    }
    
    return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
double dp[301][301][301];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    int a[N];
    rep(i,0,N){
        cin>>a[i];
    }
    dp[0][0][0]=0;
    rep(i,0,N+1){
        rep(j,0,N+1-i){
            rep(k,0,N+1-i-j){
                if(!(i==0&&j==0&&k==0)){
                    dp[i][j][k]=N*1.0/(i+j+k)*((k>=1?1.0*k/N*(dp[i][j][k-1]+1):0)+(j>=1?1.0*j/N*(dp[i][j-1][k+1]+1):0)+(i>=1?1.0*i/N*(dp[i-1][j+1][k]+1):0)+1.0*(N-i-j-k)/N);
                }
            }
        }
    }
    int s=0,t=0,u=0;
    rep(i,0,N){
        if(a[i]==3){
            s++;
        }
        if(a[i]==2){
            t++;
        }
        if(a[i]==1){
            u++;
        }
    }
    cout <<setprecision(15)<<dp[s][t][u]<<"\n";
}

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

int main()
{
	int h, n;
	cin >> h >> n;
	int a =0;
	int x;
	for(int i=0; i< n; ++i)
	{
		cin >> x;
		a+=x;
	}
	if(a >= h)
	{
		cout << "Yes";
	}else {cout << "No";}
	

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[] a = new int[26];
    for(int i = 0; i<H; i++) {
      String s = sc.next();
      for(int j = 0; j < W; j++) {
        char c = s.charAt(j);
        a[c - 'a']++;
      }
    }

    int num = (H / 2) * (W / 2);
    int num2 = H * W - (num * 4);

    for(int i =0; i<26; i++){
      if(num == 0) break;
      while(a[i] >= 4) {
        a[i] = a[i] - 4;
        num--;
        if(num == 0) break;
      }
    }
    if(num != 0){
      System.out.println("No");
      return;
    }

    for(int i =0; i<26; i++){
      if(num2 < 2) break;
      while(a[i] >= 2) {
        a[i] = a[i] - 2;
        num2 = num2 - 2;
        if(num2 < 2) break;
      }
    }

    if(num2 >= 2) System.out.println("No");
    else System.out.println("Yes");
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	int t;
	ll n=0, x, a, b;
	cin >> t >> x;
	while(t--) {
		cin >> a >> b;
		if(a*a + b*b <= x*x) n++;
	}
	cout << n << '\n';
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  max_heap<int> pq;

  rep(i,n){
    int a;
    cin >> a;
    pq.emplace(a);
  }

  rep(i,m){
    int v = pq.top();
    pq.pop();
    v /= 2;
    pq.emplace(v);
  }

  int res = 0;
  while(!pq.empty()){
    res += pq.top();
    pq.pop();
  }

  cout << res << '\n';  

  return 0;
}

Measured memory_bytes: 1400
day = input()

if day == 'MON':
  print(6)
elif day == 'TUE':
  print(5)
elif day == 'WED':
  print(4)
elif day == 'THU':
  print(3)
elif day == 'FRI':
  print(2)
elif day == 'SAT':
  print(1)
elif day == 'SUN':
  print(7)

Measured memory_bytes: 2940
import heapq
import math

NN = 2020202
MOD = 10**9+7
INF = float("inf")

x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

que = [(-(A[0]+B[0]+C[0]), 0, 0, 0)]
seen = set([(0, 0, 0)])

for i in range(k):
    v, ai, bi, ci = heapq.heappop(que)
    print(-v)
    if ai < len(A)-1 and (ai+1, bi, ci) not in seen:
        seen.add((ai+1, bi, ci))
        heapq.heappush(que, (-(A[ai+1]+B[bi]+C[ci]), ai+1, bi, ci))
    if bi < len(B)-1 and (ai, bi+1, ci) not in seen:
        seen.add((ai, bi+1, ci))
        heapq.heappush(que, (-(A[ai]+B[bi+1]+C[ci]), ai, bi+1, ci))
    if ci < len(C)-1 and (ai, bi, ci+1) not in seen:
        seen.add((ai, bi, ci+1))
        heapq.heappush(que, (-(A[ai]+B[bi]+C[ci+1]), ai, bi, ci+1))



Measured memory_bytes: 57048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BOneClue solver = new BOneClue();
        solver.solve(1, in, out);
        out.close();
    }

    static class BOneClue {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            int k = s.nextInt(), x = s.nextInt();
            for (int i = x - k + 1; i <= x + k - 1; i++)
                w.print(i + " ");
            w.println();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22612
#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(V) (V).begin(), (V).end()
using namespace std;
typedef long long ll;
ll getf(ll a, ll b) {
	ll ans1 = a - 1;
	ll a1 = 1, b1 = b - ans1 - 1;
	ans1++;
	return ans1 + (b1 - a1) / 2;
}
int main() {fio;
	ll n, a, b;
	cin >> n >> a >> b;
	if(a > b) swap(a, b);
	if((a % 2) == (b % 2)) {
		cout << (b - a) / 2 << endl;
	} else {
		cout << min(getf(a, b), getf(n + 1 - b, n + 1 - a)) << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl;


//UnionFind群
class UnionFind {
protected:
    vector<int> par;
    vector<int> data;
    int cnt;
public:
    UnionFind() : par(1), data(1), cnt(1) {};

    UnionFind(int N);

    int root(int x);

    int marge(int x, int y);

    bool same(int x, int y);

    int add();

    int add(int x);

    inline int getSize(int x) { return data.at(root(x)); };

    int allroot();

    inline bool isroot(int x) { return (par.at(x) == -1); };
};

UnionFind::UnionFind(int N) : par(N), data(N), cnt(N) {
    for (int i = 0; i < N; i++) {
        par.at(i) = -1;
        data.at(i) = 1;
    }
}


int UnionFind::root(int x) {
    if (par.at(x) == -1) return x;
    return par.at(x) = root(par.at(x)); // 経路圧縮
}

int UnionFind::marge(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return rx;
    else { // ノード数の少ない方に接続
        if (data.at(rx) < data.at(ry)) swap(rx, ry);
        par.at(ry) = rx;
        data.at(rx) += data.at(ry);
        return rx;
    }
}

bool UnionFind::same(int x, int y) {
    return root(x) == root(y);
}

int UnionFind::add() {
    par.push_back(cnt);
    cnt++;
    return cnt - 1;
}

int UnionFind::add(int x) {
    par.push_back(cnt);
    cnt++;
    return marge(x, cnt);
}

int UnionFind::allroot() {
    int cnt = 0;
    for (const auto it : par) {
        if (it == -1) cnt++;
    }
    return cnt;
}

struct UF {
    vector<int> par;

    UF(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        else {
            return par[x] = root(par[x]);
        }
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        else {
            par[rx] = ry;
            return;
        }
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int ansYes(bool y) {
    if (y) cout << "Yes" << endl; else cout << "No" << endl;
}

//約数の数を数える
int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


int main() {
    int d , n;
    cin >> d  >> n;
    int s = pow (100,d);
    if (n <= 99) cout << n * s << endl;
    else  cout << 101 * s << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[101][256][256];

const int MAX = 200000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    int n, K;
    cin >> n >> K;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 255; j++)
        {
            for (int k = 0; k <= 255; k++)
            {
                if (k < 255)
                {
                    (dp[i + 1][j ^ a[i]][k + 1] += dp[i][j][k]) %= MOD;
                }
                (dp[i + 1][j][k] += dp[i][j][k]) %= MOD;
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i <= 255; i++)
    {
        (ans += (dp[n][K][i] * fac[i] % MOD)) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 56704
#include <stdio.h>
#include <stdlib.h>

#define N 45

int fibonach(int);

int fib[N];

int main(){
  int n, i;

  scanf("%d", &n);

  for(i = 0; i < N; i++)
    fib[i] = -1;
  
  printf("%d\n", fibonach(n));

  return 0;
}

int fibonach(int n){
  if(n == 0 || n == 1)
    return fib[n] = 1;

  if(fib[n] != -1)
    return fib[n];

  return fib[n] = fibonach(n - 1) + fibonach(n - 2);
}



Measured memory_bytes: 2128
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	int N,K;
	ios::sync_with_stdio(false);
	cin>>N>>K;
	int t=1;
	int ans=1;
	for(int i=0;i<N;i++)
	{
		if(K>t)
		{ 
			ans+=t;
			t=t*2;
		}
		else 
		{
			ans+=K;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		char[] a = in.next().toCharArray();
		char[] b = in.next().toCharArray();
		char[] c = in.next().toCharArray();
		
		if (a[a.length - 1] == b[0] && b[b.length - 1] == c[0]) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 20948
str = gets.chomp
q = gets.chomp.to_i
q.times do
  cmd, a, b, p = gets.chomp.split
  a = a.to_i
  b = b.to_i
  case cmd
  when "print"
    puts str[a..b]
  when "reverse"
    str[a..b] = str[a..b].reverse
  when "replace"
    str[a..b] = p
  end
end

Measured memory_bytes: 8732
#include <iostream>
using namespace std;
int main() {
    int a[5] = {0};
    int k = 0;
    int min = 999;
    int max = 0;
    for (int i = 0; i < 5; ++i) {
        cin >> a[i];
        if(a[i] < min) min = a[i];
        if(a[i] > max) max = a[i];
    }
    cin >> k;
    if(k >= max - min){
        cout << "Yay!";
    } else{
        cout << ":(";
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");

		int N = Integer.parseInt(tokens[0]);
		long Z = Long.parseLong(tokens[1]);
		long W = Long.parseLong(tokens[2]);
		long[] a = new long[N];
		tokens = in.readLine().split(" ");
		for (int i = 0; i < N; ++i) {
			a[i] = Long.parseLong(tokens[i]);
		}
		long score = Math.abs(a[N - 1] - W);
		if (N >= 2) {
			score = Math.max(score, Math.abs(a[N - 2] - a[N - 1]));
		}
		System.out.println(score);
	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
using namespace std;
typedef long long ll;

ll a[100005]={0};
bool cmp(ll c, ll b)
{
	return c > b;
}
int main()
{
	std::ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 0; i < n;i++)
	{
		cin >> a[i];
	}
	
	sort(a, a+n, cmp);

	while(n != 1)
	{
		int tmp = n;
		ll min = a[n-1];
		for(int i = 0; i < n - 1; i++)
		{
			a[i] = a[i] % min;
			if(a[i] == 0) tmp--;
		}
		sort(a, a+n, cmp);
		n = tmp;
	}
	cout << a[0];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int X=0,Y=0;
  for(int i=0; i<N-1; i++){
    if(vec[i] == vec[i+1]){
      if(X>0){
        Y = vec[i];
        break;
      }
      else{
        X = vec[i];
      }
      i++;
    }
  }
  cout << X*Y << endl;
}


Measured memory_bytes: 3952
use std::error::Error;
use std::io;

pub fn main() {
    if let Err(_e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<dyn Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    let n: i32 = input.trim().parse()?;
    input.clear();
    io::stdin().read_line(&mut input)?;
    let numbers: Vec<i64> = input
        .trim()
        .split_whitespace()
        .map(|s| s.parse::<i64>().unwrap())
        .collect();
    if numbers.contains(&0) {
        println!("0");
        return Ok(());
    }
    let mut result: i64 = 1;
    for i in numbers {
        if let Some(num) = result.checked_mul(i) {
            if num > 1_000_000_000_000_000_000i64 {
                println!("-1");
                return Ok(());
            }
            result = num;
        } else {
            println!("-1");
            return Ok(());
        }
    }

    println!("{}", result);
    Ok(())
}


Measured memory_bytes: 4884
<?php
list($H, $N) = array_map("intval", explode(" ", trim(fgets(STDIN))));
$dp = array_fill(0, $H + 1, 10**18);
$dp[0] = 0;
for($i = 1; $i <= $N; $i++){
  list($a, $b) = array_map("intval", explode(" ", trim(fgets(STDIN))));
  for($j = 1; $j <= $H; $j++){
    if($j - $a >= 0){
      if($dp[$j]>$dp[$j-$a]+$b)$dp[$j] = $dp[$j-$a]+$b;
    }else{
      if($dp[$j]>$b)$dp[$j] = $b;
    }
  }
}
echo $dp[$H];


Measured memory_bytes: 4604
N, M = map(int, input().split())
H = list(map(int, input().split()))

f = [1]*N
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    if H[A] <= H[B]:
        f[A] = 0
    if H[B] <= H[A]:
        f[B] = 0

print(sum(f))

Measured memory_bytes: 20112
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = input()
	q = int(input())
	ff = []
	bb = []
	frip = False
	for _ in range(q):
		ss = input()
		if ss[0] == '1':
			frip = not frip
		else:
			_a, f, c = ss.split()
			is_ff = ((1 if frip else 0) + (1 if f == '1' else 0 )) % 2 == 1
			if is_ff:
				ff.append(c)
			else:
				bb.append(c)
	
	ret = ''.join(ff[::-1]) + s + ''.join(bb)
	if frip:
		ret = ret[::-1]
	print(ret)
			
	
	
	
#+++++
isTest=False

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

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

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int a,b,h; scanf("%d%d%d",&a,&b,&h);
	printf("%d\n",(a+b)*h/2);
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import sys

def check(n, N):
	sum = n
	while n > 0 and sum < N:
		n -= 1
		sum += n
	if sum == N:
		return True
	else:
		return False

def compute(N):
	count = 0
	half = int(float(N) / 2 + 0.5)
	for i in range(half, 1, -1):
		if check(i, N):
			count += 1
	return count

if __name__ == '__main__':
	for N in sys.stdin:
		if int(N) > 0:
			print compute(int(N))
		

Measured memory_bytes: 4252
N, M = map(int, input().split())
x = [1] + [0] * N
broken = [False] * (N+1)
mod = 10**9 + 7

for i in range(M):
  a = int(input())
  broken[a] = True

if not broken[1]:
  x[1] = 1

for i in range(2, N+1):
  if broken[i]:
    continue
  
  x[i] = (x[i-1] + x[i-2]) % mod

print(x[N])

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

int main()
{
	scanf("%d",&n);
	int sum=0,mx=0;
	for (int i=1;i<=n;i++) {
		int x; scanf("%d",&x);
		sum+=x;
		mx=max(mx,x);
	}
	if (sum>mx*2) puts("Yes"); else puts("No");
	return 0;
}

Measured memory_bytes: 384
S = str(input())
s = []
for i in range(len(S)):
    s.append(int(S[i]))

x = 753
l = len(s)
ans = 100000
for i in range(l-2):
    n = s[i] * 100 + s[i+1] * 10 + s[i+2]
    ans = min(abs(n-x),ans)
print(ans)

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


signed main() {
    //my-code
    int n; cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << endl;

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<math.h>

using namespace std;



int main(void){
	int N;
	long a[10010] = {0};
	long count = 0;
	cin >> N;

	for(int i=0; i < N; i++){
		scanf("%d", &a[i]);
 	}

 	for(int i=0; i< N; i++){
		while(a[i] % 2 == 0 && a[i] != 0){
			a[i] = a[i] / 2;
			count++;
		}
 	}
 	cout << count << endl;

	
	return 0;
}

Measured memory_bytes: 384
r, g, b, n = list(map(int, input().split()))

import math

counter = 0
for x in range(math.ceil(n / r) + 1):
    left = n - x * r

    for y in range(math.ceil(left / g) + 1):
        left2 = left - y * g

        if left2 >= 0 and left2 % b == 0:
            counter += 1
        # print(x, y, left2 / b)
print(counter)


Measured memory_bytes: 3060
use std::cmp::Ordering::*;
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let mut a: u32 = 0;
    let mut b: u32 = 0;

    let n: u32 = sc.next();
    for _ in 0..n {
        let s: String = sc.next();
        let t: String = sc.next();

        match s.cmp(&t) {
            Greater => {
                a += 3;
            }
            Equal => {
                a += 1;
                b += 1;
            }
            Less => {
                b += 3;
            }
        }
    }
    println!("{} {}", a, b);
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn char(&mut self) -> char {
        self.next::<String>().chars().next().unwrap()
    }
}



Measured memory_bytes: 5036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PGC
{
	class Program
	{
		static void Main(string[] args)
		{
			var header = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var N = header[0];
			var K = header[1];
			var W = new List<int>();
			for (int i = 0; i < N; i++)
			{
				W.Add(int.Parse(Console.ReadLine()));
			}
			var min = W.Max();
			var max = W.Sum();
			var mid = 0;
			var minP = int.MaxValue;
			while (min <= max)
			{
				mid = (max + min) / 2;

				var weight = 0;
				var track = 1;
				for (int i = 0; i < N; i++)
				{
					var tmpWeight = weight + W[i];
					if (tmpWeight <= mid)
					{
						weight = tmpWeight;
					}
					else
					{
						track++;
						weight = W[i];
					}
				}

				if (track <= K)
				{
					minP = Math.Min(minP, mid);
					max = mid - 1;
				}
				else
				{
					min = mid + 1;
				}
			}

			System.Console.WriteLine(minP);
		}
	}
}



Measured memory_bytes: 21052
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	long long n;
	cin >> n;
	long long ans = n * (n-1) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int a;

main(){
	cin>>a;
	dump(3*a*a);
}

Measured memory_bytes: 256