akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace _0370
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            DateTime a = new DateTime(x[0],x[1],x[2]);
            int[] y = Console.ReadLine().Split().Select(int.Parse).ToArray();
            DateTime b = new DateTime(y[0],y[1],y[2]);
            int yearsspan = (int)(Math.Abs((a - b).Days) / 365.2425);
            Console.WriteLine(x[1] == y[1] && x[2] == y[2] ? yearsspan : yearsspan + 1);
        }
    }
}


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

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i  = 0; i < n; i++) cin >> v.at(i);
    
    vector<int> c(n);
    for(int i  = 0; i < n; i++) cin >> c.at(i);
    
    int ans = 0;
    for(int i  = 0; i < n; i++) {
        if (v.at(i) >= c.at(i)) ans +=  v.at(i) - c.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>

using namespace std;

typedef long long ll;

int gcd(int a, int b) {
  return (b == 0 ? a : gcd(b, a % b));
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int x;
  cin >> x;
  cout << 360 / gcd(360, x) << '\n';
}



Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define INF 1e7
int main(void){
    int n;
    string s;
    cin >> n;
    string ret;
    map<char, int> buf;
    for(char c='a'; c<='z'; c++){
        buf[c] = INF;
    }
    for(int i=0; i<n; i++){
        cin >> s;
        for(char c='a'; c<='z'; c++){
            buf[c] = min(buf[c], int(count(s.begin(), s.end(), c)));
        }
    }
    for(char c='a'; c<='z'; c++){
        for(int i=0; i<buf[c]; i++){
            ret += c;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000;
ll max(ll x,ll y){
    if(x < y)return y;
    else x;
}
int main(){
    int n;
    cin >> n;
    int f[n][10];
    ll p[n][11];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 10;j++){
            cin >> f[i][j];
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 11;j++){
            cin >> p[i][j];
        }
    }
    ll m = -1*INF;
    for(int bit = 1;bit <(1<<10);bit++){
        ll b = 0;
        for(int i = 0;i < n;i++){//shop
            int count = 0;
            for(int j = 0;j < 10;j++)if((bit & (1<<j)) && f[i][j] == 1)count++;
            b += p[i][count];
        }
        m = max(m,b);
    }
    cout << m << endl;
    //cin >> n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll D,N;
  cin>>D>>N;
  ll ans=1;
  for(ll i=0;i<D;i++) {
ans*=100;
  }
  if(N==100) {
ans*=101;
  }
  else {

  ans*=N;
  }
  cout<<ans<<endl;
}
  
  
  


Measured memory_bytes: 3640
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N;

int cnt = 0;
string ask(int n){
    cnt++;
    cout << "?";
    rep(i, N) cout << " " << (n+i)%(2*N) +1;
    cout << endl;
    string ret;
    cin >> ret;
    return ret;
}

string ask2(int l, int n){
    cnt++;
    cout << "?";
    rep(i, N-1) cout << " " << (l+i)%(2*N) +1;
    cout << " " << n%(2*N) +1;
    cout << endl;
    string ret;
    cin >> ret;
    return ret;
}

signed main(){
    cin >> N;

    string SL, SR;
    SL = ask(0);
    if(SL == "Red") SR = "Blue";
    else SR = "Red";

    int l = 0;
    int r = N;
    while(r-l > 1){
        int m = (l+r) / 2;
        string ret = ask(m);
        if(ret == SL) l = m;
        else r = m;
    }

    string ans(2*N, '?');
    ans[l] = SL[0];
    ans[l+N] = SR[0];
    rep(i, N-1){
        int n = (l+N+1+i) % (2*N);
        string ret = ask2(r, n);
        ans[n] = ret[0];
    }
    rep(i, N-1){
        int n = (l+1+i) % (2*N);
        string ret = ask2(r+N, n);
        ans[n] = ret[0];
    }
    cout << "! " << ans << endl;

    while(cnt > 210){

    }
}

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

int main()
{
  int n;
  cin >> n;
  int h[n];
  int dp[n];

  for (auto i = 0; i < n; i++) {
    cin >> h[i];
    dp[i] = numeric_limits<int>::max();
  }
  dp[0] = 0;
  for (auto i = 0; i < n; i++) {
    if (i + 1 < n) dp[i + 1] = min(dp[i + 1], dp[i] + (h[i] < h[i + 1] ? h[i + 1] - h[i] : h[i] - h[i + 1]));
    if (i + 2 < n) dp[i + 2] = min(dp[i + 2], dp[i] + (h[i] < h[i + 2] ? h[i + 2] - h[i] : h[i] - h[i + 2]));
  }
  cout << dp[n - 1] << endl;
}


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

int main()
{
   char b;
   cin>>b;

    if(b=='A')
    {
        cout<<"T";
    }
    else if(b=='T')
    {
        cout<<"A";
    }
    else if(b=='C')
    {
        cout<<"G";
    }
    else
    {
        cout<<"C";
    }
}

Measured memory_bytes: 256
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]
ans=0
for i in range(2**h):
  sr=set([])
  for hi in range(h):
    if (i>>hi)&1:
      sr.add(hi)
  for j in range(2**w):
    sc=set([])
    for wi in range(w):
      if (j>>wi)&1:
        sc.add(wi)
    cnt=0
    for hi in range(h):
      for wi in range(w):
        if hi not in sr and wi not in sc and c[hi][wi]=='#':
          cnt+=1
    if cnt==k:
      ans+=1
      #print(sc,sr)
print(ans)


Measured memory_bytes: 9208
//113 B - Palace 2018/11/04
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n , t , a;
    cin >> n >> t >> a;
    vector<int> h(n);
    rep(i , n) cin >> h[i];
    double min=20000000.0;int place;
    rep(i ,n){
        if(min>abs(a-(t-h[i]*0.006))) { min = abs(a-(t-h[i]*0.006)); place=i; }
    }
    cout << place+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int Max = 1000000;
bool P[Max];

void eratos()
{
	for( int i = 0;i < Max;i++ ) P[i] = true;
	P[0] = P[1] = false;
	for( int i = 2;i * i < Max;i++ ) if( P[i] ) for( int j = 2;i * j < Max;j++) P[i * j] = false;
}
int main(int argc, char const* argv[])
{
	int n;
	eratos();

	while( cin >> n && n != 0 ){
		int answer = 0;

		for( int i = 2;i <= n/2;i++ ){
			if( P[i] == true && P[n - i] == true ){ answer++;}
		}

		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
string a,b;
long long n,ans,k;
long long ds(int u)
{
    int now=0;
    for(int s=u;s<n;s++)
    {
        if(a[s]!=b[now])break;
        now++;
    }
    return now;
}
int main()
{
    cin>>n>>a>>b;
    ans=n*2;
    for(int s=0;s<n;s++)
    {
        k=ds(s);
        ans=min(ans,n*2-k);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
int a,b,c,d;
  cin >> a >> b >>c >>d;
  int ma = a *b;
  ma = max (ma,c*d);
  cout << ma << endl;
}

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

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

    ll ans=1;
    int k=0;
    int t=0;
    string s3,s4;


    s3=s1[0];
    s4=s2[0];
    if(s3==s4){
        ++k;
        ans*=3;
        t=0;
    }
    else{
        k+=2;
        t=1;
        ans*=6;
    }
    
    while(k<n){
        s3=s1[k];
        s4=s2[k];
        if(s3==s4){
            ++k;
            if(t==0){
                ans*=2;
            }
            else{
                t=0;
            }
        }
        else{
            k+=2;
            if(t==0){
                ans*=2;
                t=1;
            }
            else{
                ans*=3;
            }
        }



        ans=ans%1000000007;
    }

    cout << ans << endl;
    
    

    return 0;
}

Measured memory_bytes: 3528
/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cout << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

struct edge {
  int to, cost;
  edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<edge> > Graph;
Graph G(2001);

void add_edge(int from, int to, int cost) {
  G[from].push_back(edge(to, cost));
}

edge visit(int p, int v, Graph &g) {
  edge r(v, 0);
  for (edge e : g[v]) {
    if (e.to != p) {
      edge t = visit(v, e.to, g);
      t.cost += 1;
      if (r.cost < t.cost) {
        r = t;
      }
    }
  }
  return r;
}

// (r.to, t.to) is farthest pair
int diameter(vector<vector<edge> > &g) {
  edge r = visit(-1, 0, g);
  edge t = visit(-1, r.to, g);
  return t.cost;
}


int N, K;


int countV(int p, int v, int depth) {
  int c = 1;
  if (depth) {
    for (edge e : G[v]) {
      if (e.to != p) {
        c += countV(v, e.to, depth - 1);
      }
    }
  }
  return c;
}

void solve() {
  int ans = 0;
  if (K % 2 == 0) {
    // 直径が偶数→すべての頂点に関して, 距離K/2以上の頂点を数え,それの最小値が答え
    REP(i, N) {
      ans = max(ans, countV(-1, i, K/2));
    }
  } else {
    // 直径が奇数→すべての辺に関して, 距離(K - 1)/2 以上となる頂点を数え, それの最小値が答え
    REP(i, N) {
      for (edge e : G[i]) {
        int l = countV(e.to, i, K/2);
        int r = countV(i, e.to, K/2);
        ans = max(ans, l + r);
      }
    }
  }
  cout << N - ans << endl;
}

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

  cin >> N >> K;
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    add_edge(a - 1, b - 1, 1);
    add_edge(b - 1, a - 1, 1);
  }
  solve();
  return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

typedef long long ll;
/*
constexpr ll MOD=1000000007ll;

constexpr int MAX=510000;

ll fact[MAX],fact_inv[MAX];

ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1)res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

ll comb(ll n,ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
*/

ll comb(int n,int r){
    
    ll num=1;
    for(int i=1;i<=r;i++){
        num=num*(n-i+1)/i;
    }
    

    return num;
    
}




int main() {
    
    /*
    int n=100000;
    fact[0]=1;
    for(int i=0;i<n;++i){
        fact[i+1]=fact[i]*(i+1)%MOD;
    }
    fact_inv[n]=power(fact[n],MOD-2);
    for(int i=n-1;i>=0;--i){fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
    
    */
    
    int N,P;
    cin>>N>>P;
    //int A[N];
    
    int count=0;
    
    for(int i=0;i<N;++i){
        int tmp;
        cin>>tmp;
        if(tmp%2==1)++count;
    
    }
    
    //cout<<"N: "<<N<<"count: "<<count<<endl;
    
    ll cb1=0;
    
    for(int i=0;i<=count;++i){
        if(i%2==P){
            cb1+=comb(count,i);
        }
    }
  //  cout<<cb1<<endl;
    ll cb2=0;
    for(int i=0;i<=N-count;++i){
        //cout<<"N: "<<N<<" i: "<<i<<"comb: "<<comb(N-count,i)<<endl;
        cb2+=comb(N-count,i);
       
    }
   // cout<<cb2<<endl;
        
    cout<<cb1*cb2<<endl;
 
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main() {
    int n = 0;
    int m = 0;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int buff = 0;
        cin >> buff;
        n = n-buff;
    }
    if(n < 0){
        cout << -1;
    } else{
        cout << n;
    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N;
    cin >> N;
    for (int i=0; i<100; i++){
        for (int j=0; j<100; j++){
            if (4*i + 7*j == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#define INF 1000000005

using namespace std;


int n, m;//n vertices m edges

vector<int> tab[1000000];
int wynik[1000000];
int x, y;
int score = 0;

int check(int vertex){
    
    if(wynik[vertex] != 0){
        return wynik[vertex];
    }
    //cout << vertex << "\n";
    
    int score = 1;
    for(int i = 0; i < tab[vertex].size(); i++){
        if(wynik[vertex] != 0){
            score = max(score, wynik[vertex]);
        }
        else{
            score = max(score, check(tab[vertex][i]) + 1);
        }
    }
    wynik[vertex] = score;
    return score;
}


int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        cin >> x >> y;
        tab[x].push_back(y);
    }
    
    
    for(int i = 1; i <= n; i++){
        score = max(score, check(i));
    }
    /*cout<<"\n\n";
    for(int i = 1; i <= n; i++)
        cout << wynik[i] << " ";
    cout << "\n\n";
     */
    cout << score - 1;
}
//1.3


Measured memory_bytes: 31104
x,k,d=map(int,input().split())


if d>=abs(x):
    if k%2==0:
        p=abs(x)
    else:
        if x>=0:
            p=abs(x-d)
        else:
            p=abs(x+d)
    print(p)
    exit(0)
else:
    cnt=abs(x)//d

    if cnt>=k:
        cnt=k

    if x>=0:
        p=x-d*cnt
    else:
        p=x+d*cnt

    k-=cnt

    if k==0:
        print(abs(p))
        exit(0)

    if k%2==0:
        print(abs(p))
    else:
        if p>=0:
            p=abs(p-d)
        else:
            p=abs(p+d)

        print(p)

Measured memory_bytes: 9196
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

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

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

int n;
string s;

bool palim(int l, int r){
	l--;
	for(int i=0; i<(r-l); i++)
		if(s[l+i] != s[r-1-i]) return false;
	return true;
}

int main(){
	cin >> s;
	n = s.length();
	bool good = palim(1, n);
	good = good && palim(1, (n-1)/2);
	good = good && palim((n+3)/2, n);
	printf(good ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
deque < char > que;
int main()
{
    string s;
    cin>>s;
    int u=s.size();
    for(int i=0;i<u;i++)
		que.push_back(s[i]);
    int rev=0;
    int q;
    cin>>q;
    while(q--)
	{
        int t;
        cin>>t;
        if(t==1)
		{
            rev=1-rev;
        }
		else
		{
            int f;
            char c;
            cin>>f>>c;
            f--;
            if(rev!=f)
			{				
                que.push_back(c);
            }
			else
			{
                que.push_front(c);
            }
        }
    }
    if(rev!=0) 
		reverse(que.begin(), que.end());
	int p=que.size();
    for(int i=0;i<p;i++)
		cout<<que[i];
    return 0;
}

Measured memory_bytes: 896
// nlather (Nishant Raj Lather)
// Chrollo_Lucifer

/* ------------------------------ TEMPLATE BEGIN ------------------------------ */

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

/* ----------------- ORDERED SET (POLICY BASED DS) ----------------- */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree
    <T, null_type, less<T>, rb_tree_tag, 
    tree_order_statistics_node_update>;

/* -------------- BETTER RANDOM (RAND() IS DANGEROUS) -------------- */
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

/* ----------------- CUSTOM HASH FUNCTION FOR UMAP ----------------- */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = 
            chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

/* ----------------------- DEBUGGING UTILITY ----------------------- */
#define cerr cout
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {
    cerr << t; if(sizeof...(v)) cerr << ", "; _print(v...);
}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define rep(i, x, n) for (ll i = (ll)(x); i < (ll)(n); i++)
#define rrep(i, x, n) for (ll i = (ll)(x); i >= (ll)(n); i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define bs binary_search
#define minSelf(a, b) a = min(a, b)
#define maxSelf(a, b) a = max(a, b)
#define mem(arr, x) memset(arr, x, sizeof(arr))
using ll = long long int;
using ld = long double;
template <typename T, typename V> using P = pair<T, V>;
template <typename T> using V = vector<T>;
 ll MOD = 998244353LL;
const ll INF = 0x3f3f3f3f; // ~1e9 (1061109567)
const ld PI = 3.1415926535897932384626;
const ld EPS = 1e-9;
#define endl '\n' // REMOVE FOR INTERACTIVE TASKS
const ll MAX = 1e7+5;

/* ------------------------------- TEMPLATE END ------------------------------- */

int main() {
    boost
    ll k, a, b;
    cin >> k >> a >> b;
    rep(i, a, b+1) {
        if(i%k == 0) return cout << "OK\n", 0;
    }
    cout << "NG\n";
}


Measured memory_bytes: 3640
import sys
from bisect import bisect_left

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    a = [2 * i + 1 for i in range(m) if p[i]]
    a[0] = 2
    return a


def main():
    X = int(readline())

    P = prime_numbers(10 ** 6)
    ans = P[bisect_left(P, X)]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 80472
import sys

def main():
    S = input()
    S_list = [S[i] for i in range(0, 4)]

    S_set = set(S_list)
    if len(S_set) != 2:
        print('No')
        return
    
    for i_set in S_set:
        num = 0
        for i_list in S_list:
            if i_set == i_list:
                num += 1
        
        if num != 2:
            print('No')
            break
    
    else:
        print('Yes')
        
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 38384
#include<stdio.h>

int main()
{
    int n, n_min, n_max, max, index, data, tmp;

    while(1){
        scanf("%d %d %d", &n, &n_min, &n_max);

        if ( n == 0 && n_max == 0 && n_min == 0 ) break;

        for(int i = data = tmp = 0, max = -1; i < n; i++){
            tmp = data;
            scanf("%d", &data);
            if( n_min <= i && i <= n_max ){
                if( max <= tmp - data ){
                    index = i;
                    max = tmp - data;
                }
            }
        }
        printf("%d\n", index);
    }
    return 0;
}

Measured memory_bytes: 1828
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void solve() {
		String str = s.next();
		if(str.equals("SUN")) {
			out.println(7);
		}else if(str.equals("MON")) {
			out.println(6);
		}else if(str.equals("TUE")) {
			out.println(5);
		}else if(str.equals("WED")) {
			out.println(4);
		}else if(str.equals("THU")){
			out.println(3);
		}else if(str.equals("FRI")) {
			out.println(2);
		}else {
			out.println(1);
		}
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	
}


Measured memory_bytes: 21332
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
acsum = [0]

for i in range(n):
    acsum.append(acsum[i] + a[i])

if acsum[-1] < x:
    print(n - 1)
else:
    for i in range(n + 1):
        if acsum[i] == x:
            print(i)
            break
        if acsum[i] > x:
            print(i - 1)
            break

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;


class UnionFind{
private:
    vec<int> p,s;
    int cnt;
public:
    UnionFind(){}
    UnionFind(int N):cnt(N),s(N,1),p(N){
        iota(p.begin(),p.end(),0);
    }
    int find(int x){
        if(p[x]==x) return x;
        else return p[x] = find(p[x]);
    }
    void unite(int x,int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(s[x]>s[y]) swap(x,y);
        p[x] = y;
        s[y] += s[x];
        cnt--;
    }
    bool is_same_set(int x,int y) {return find(x)==find(y);}
    int size(int x) {return s[find(x)];}
    int compnents_number(){return cnt;}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    UnionFind uf(N);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    cout << uf.compnents_number()-1 << "\n";
}

Measured memory_bytes: 3992
#include <stdio.h>
#define N 100000

int main(void){
    int n;
    int a[N+1];
    int b[N];
    int i;
    unsigned long long int count = 0;
    scanf("%d", &n);
    for(i = 0; i <= n; i++){
        scanf("%d", &a[i]);
    }
    for(i = 0; i < n; i++){
        scanf("%d", &b[i]);
    }
    
    for(i = 0; i < n; i++){
        if(a[i] >= b[i]){
            count += b[i];
            b[i] = 0;
        }else{
            count += a[i];
            b[i] -= a[i];
        }
        
        if(b[i] > 0){
            if(a[i+1] >= b[i]){
                count += b[i];
                a[i+1] -= b[i];
            }else{
                count += a[i+1];
                a[i+1] = 0;
            }
        }
        
    }
    
    printf("%llu\n", count);
    return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = scan.nextInt();
            y[i] = scan.nextInt();
        }
        double sum = 0;
        for (int i = 0; i < N; i++) {
            HashSet<Integer> set = new HashSet<>();
            set.add(i);
            sum += dfs(0, x, y, N, 1, i, set);
            set.remove(i);
        }
        double ans = sum / (double) total(N);
        System.out.printf("%.9f\n", ans);
    }
    private long total(int N) {
        long total = 1;
        while (0 < N) {
            total *= N;
            N -= 1;
        }
        return total;
    }
    private double dfs(double sum, int[] x, int[] y, int N, int done, int prev, HashSet<Integer> set) {
        if (N <= done) {
            return sum;
        }
        double result = 0;
        for (int i = 0; i < N; i++) {
            if (set.contains(i)) {
                continue;
            }
            set.add(i);
            double tx = Math.abs(x[prev]-x[i])*Math.abs(x[prev]-x[i]);
            double ty = Math.abs(y[prev]-y[i])*Math.abs(y[prev]-y[i]);
            result += dfs(sum+Math.sqrt(tx+ty), x, y, N, done+1, i, set);
            set.remove(i);
        }
        return result;
    }
}


Measured memory_bytes: 31036
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    for(int i = 0; i < s.size()-1; i++) {
        if (s[i] == 'A' && s[i+1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
#define watch(x) cout << (#x)<<" = "<<x<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
#define x first
#define y second
#define r 0
#define l 1
#define u 2
#define d 3
const int N = 2e5 + 9;
vi dia[N + N + 9][2][4];
vi arr[N][4];
int gt(char ch) {
	if (ch == 'R') return r;
	if (ch == 'L') return l;
	if (ch == 'U') return u;
	if (ch == 'D') return d;
}
int main() {
	file();
	fast();
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		char ch; int xx, yy;
		cin >> xx >> yy >> ch;
		int g = gt(ch);
		dia[yy - xx + N][l][g].push_back(yy);
		dia[yy + xx][r][g].push_back(yy);
		if (g == l || g == r) arr[yy][g].push_back(xx);
		else arr[xx][g].push_back(yy);
	}
	
	for (int i = 0; i < N + N; i++)
		for (int j = 0; j < 4; j++)
			sort(all(dia[i][l][j])), sort(all(dia[i][r][j]));
	for (int i = 0; i < N; i++)
		for (int j = 0; j < 4; j++)
			sort(all(arr[i][j]));
	
	int ans = INT_MAX;
	// on the same horizonatl
	for (int i = 0; i < N; i++) {
		for (auto& it : arr[i][r]) {
			auto bs = lower_bound(all(arr[i][l]), it);
			if (bs != arr[i][l].end())
				ans = min(ans, (*bs - it) * 5);
		}
	}
	// on the same vertically
	for (int i = 0; i < N; i++) {
		for (auto& it : arr[i][u]) {
			auto bs = lower_bound(all(arr[i][d]), it);
			if (bs != arr[i][d].end())
				ans = min(ans, (*bs - it) * 5);
		}
	}

	// from r or l to d
	for (int i = 0; i < N + N; i++) {
		for (auto& it : dia[i][l][r]) {
			auto bs = lower_bound(all(dia[i][l][d]), it);
			if (bs != dia[i][l][d].end())
				ans = min(ans, (*bs - it) * 10);
		}
		for (auto& it : dia[i][r][l]) {
			auto bs = lower_bound(all(dia[i][r][d]), it);
			if (bs != dia[i][r][d].end())
				ans = min(ans, (*bs - it) * 10);
		}
	}
	// from u to r or l
	for (int i = 0; i < N + N; i++) {
		for (auto& it : dia[i][l][u]) {
			auto bs = lower_bound(all(dia[i][l][l]), it);
			if (bs != dia[i][l][l].end())
				ans = min(ans, (*bs - it) * 10);
		}
		for (auto& it : dia[i][r][u]) {
			auto bs = lower_bound(all(dia[i][r][r]), it);
			if (bs != dia[i][r][r].end())
				ans = min(ans, (*bs - it) * 10);
		}
	}
	if (ans == INT_MAX)
		RT("SAFE\n");
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 116120
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var H = long.Parse(Console.ReadLine());
            Console.WriteLine(solver(H));
        }
        static long solver(long h)
        {
            if (h == 1) return 1;
            else return solver(h / 2) * 2 + 1;
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
double abs_double(double x){
    if(x<0)return -1*x;
    return x;
}
int main(){
    double n,a[200],sum=0;
    scanf("%lf",&n);
    for(int i=0;i<n;i++){
        scanf("%lf",&a[i]);
        sum+=a[i];
    }
    double ave=sum/n,min=9999.0;
    //printf("ave:%lf\n",ave);
    int ans=0;
    for(int i=0;i<n;i++){
        if(abs_double(a[i]-ave)<min){
            min=abs_double(a[i]-ave);
            //printf("min:%lf\n",min);
            ans=i;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// stack
int top, S[100000];
void push(int x) {
  S[++top] = x;
}
int pop() {
  top--;
  return S[top+1];
}

int main() {
  int a, b;
  top = 0;
  char s[100];

  while (scanf("%s", s) != EOF) {
    if (s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if (s[0] == '-') {
      b = pop();
      a = pop();
      int tmp = a - b;
      push(a - b);
    } else if (s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }

  printf("%d\n", pop());
  return 0;
}

Measured memory_bytes: 548
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	if (n % 1000 == 0) {//1000の倍数のとき
		cout << 0 << endl;
	}
	else { //1000の倍数じゃないとき
		cout << 1000 - (n % 1000) << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m,i,ans=0;
cin>>n>>m;
ll a[n+2]={0},x,y;
for(i=0;i<m;i++)
{
	cin>>x>>y;
	a[x]++;
	a[y+1]--;
}
for(i=1;i<=n;i++)
{
	a[i]+=a[i-1];
//	cout<<a[i]<<el;
	if(a[i]>=m)
	ans++;
}
cout<<ans;
}


Measured memory_bytes: 1024
//  RAKSHIT KADAM
//ALWAYS USE &IT FOR ITERATING USING AUTO ...
//USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN THE RESPECTIVE DATA STRUCTURE
//NOTE THAT MEMSET CANNOT ASSIGN A VALUE OF 10^18 IT WILL ASSIGN A LOWER VALUE THAN THAT!!!
//NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
//ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
    #define INF 2000000000000000005
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long

 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>

 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;                                                  return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){int g = gcd(a, m); { return power(a, m-2, m);}}
const int maxn= 500004;
ll bad;
void solve()
{
    ll n;cin>>n;
    ll ans=1;
    ll c=1;
    for(ll j=1;j<=18;j++)c*=10;ll x;
    
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        if(ans!=0)
        if(c/ans<x)
        {
            bad=1;
        }
        if(ans!=0)
        if(c/ans>=x)
        {
            ans*=x;
        }
        if(x==0)bad=0,ans=0;
        
    }
    if(bad)cout<<"-1"<<endl;
    else cout<<ans<<endl;
        
}
signed main()
{
   Need_for_speed(activated);
    
//satisfy
//    {
//   solve();
//   }

    solve();
    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
const int N=200;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
char a[N],b[N];

int main()
{
	int n=read();
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) cin>>b[i];
	for (int i=1;i<=n;i++)
	{
		putchar(a[i]);
		putchar(b[i]);
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n, A[50];

int solve (int i, int m) {
	int res;
	if(m == 0) return 1;
	if(i >= n) return 0;
	res = solve(i + 1, m) || solve(i + 1, m- A[i]);
	return res;
}

int main() {
	int q, M, i;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &A[i]);
	scanf("%d", &q);
	for(i = 0; i < q; i++) {
		scanf("%d", &M);
		if(solve(0, M)) printf("yes\n");
		else printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 1812
n=int(input())
l = list(map(int,input().split()))
total = sum(l)
sumtillindex = [0 for i in range(n)]
summ = 0
for k in range(n):
	summ+=l[k]
	sumtillindex[k] = summ
ans = 0
print(min([abs(s-(total-s)) for s in sumtillindex]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    string t;
    cin >> t;
    int n = t.length();
    
    rep(i, n) {
        if (t[i] == '?') t[i] = 'D';
        cout << t[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod=1000000007 ;

void solve(){
	
	int n,x,t ;
	cin>>n>>x>>t ;

	int time=0 ;
	int total=0 ;
	while(total<n){
		total+=x ;
		time+=t ;
	}	

	cout<<time ;

}


int main(){


	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
using ll=long long;
int main()
{
    ll n,m,ac=0,wa=0;
    cin>>n>>m;
    vector<ll> a(n+1),w(n+1);
    rep(i,m)
    {
        ll x;
        string s;
        cin>>x>>s;
        if(s=="AC")
        {
            if(a[x]==0)
            {
                ac++;
                a[x]++;
            }
        }
        else if(s=="WA")
        {
            if(a[x]==0)
            {
                w[x]++;
                wa++;
            }
        }
    }
    rep(i,n) if(a[i]==0) wa-=w[i];
    cout<<ac<<" "<<wa;
}

Measured memory_bytes: 4776
/*** keep hungry and calm CoolGuang!***/
#include <bits/stdc++.h>
#define debug(x) cout<<#x<<" :"<<x<<" "<<endl;
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const ll INF=1000000000000007;
const ll maxn=1e6+5;
const int mod=1e9+7;
ll n,m;
ll num[maxn];
int main()
{
    scanf("%lld%lld%lld",&num[1],&num[2],&num[3]);
    sort(num+1,num+1+3);
    if(num[1]==num[2]||num[2]==num[3]){
        if(num[1]==num[2]&&num[1]==num[3])
            printf("No\n");
        else printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X;cin>>A>>B>>C>>X;
  int cou=0;
  for(int a=0;a<=A;a++){
    for(int b=0;b<=B;b++){
      for(int c=0;c<=C;c++){
        int total=a*500+b*100+c*50;
        if(total==X)++cou;
      }
    }
  }
  cout<<cou<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if((a[0]==a[1]&&a[1]!=a[2])||(a[1]==a[2]&&a[0]!=a[1]))
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 100 + 5;

char s[N];
int n,k;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>k>>s+1;
	int n=strlen(s+1);
	if(n<=k){
		for(int i=1;i<=n;i++){
			cout<<s[i];
		}
	}else{
		for(int i=1;i<=k;i++){
			cout<<s[i];
		}
		cout<<"...";
	}
	return 0;
}

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

struct UnionFind {
    vector<int> par; 
    UnionFind(int N) : par(N){for(int i = 0; i < N; i++) par[i] = i;}
    int root(int x) {if(par[x] == x)return x;return par[x]=root(par[x]);}
    void unite(int x, int y) 
    {
        int rx = root(x);int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) 
    {
        int rx = root(x);int ry = root(y);
        return rx == ry;
    }
};

int main()
{
  int N;scanf("%d",&N);
  vector<pair<int,int>> x,y;
  for(int X,Y,i=0;i<N;i++)
  {
    scanf("%d %d",&X,&Y);
    x.push_back(make_pair(X,i));
    y.push_back(make_pair(Y,i));
  }
  sort(x.begin(),x.end());sort(y.begin(),y.end());
  vector<tuple<int,int,int>> G;
  for(int i=1;i<N;i++)
  {
    G.push_back(make_tuple(x[i].first-x[i-1].first,x[i].second,x[i-1].second));
    G.push_back(make_tuple(y[i].first-y[i-1].first,y[i].second,y[i-1].second));
  }
  sort(G.begin(),G.end());long long ans=0;
  UnionFind tree(N);
  for(int dist,a,b,i=0;i<2*N-2;i++)
  {
    dist=get<0>(G[i]);a=get<1>(G[i]);b=get<2>(G[i]);
    if(tree.same(a,b))continue;
    ans+=dist;
    tree.unite(a,b);
  }
  printf("%lld",ans);
}

Measured memory_bytes: 8616
def SelectionSort(A):
    n = 0
    for i in range(len(A)):
        mini = i
        for j in range(i, len(A)):
            if A[j]<A[mini]:
                mini=j
        if i!=mini:
            A[i], A[mini] = A[mini], A[i]
            n += 1
    print(' '.join(map(str, A)), n, sep='\n')

input()
SelectionSort(list(map(int, input().split())))


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

using namespace std;

int main(int argc, const char *argv[]) {
  char x, y;
  cin >> x >> y;
  if (x == y) {
    cout << '=' << '\n';
  } else if (x < y) {
    cout << '<' << '\n';
  } else {
    cout << '>' << '\n';
  }

  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	priority_queue<int>q;    //优先队列自动从大到小排序
	int m,n,t;
	cin >>n>>m;
	for(int i=0;i<n;i++){
		cin>>t;
		q.push(t);    //每输入一个数都入队
	}
	long long sum=0;
	while(m)
	{
		t=q.top()/2;
		q.pop();
		q.push(t);
		m--;
	}
	while(!q.empty())
	{
		sum+=q.top();
		q.pop();
	}
	cout<<sum;    //输出都处理完的总和
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <queue>
using namespace std;
int main()
{
    long long n,i,sum,ans;
    while(~scanf("%lld",&n))
    {
        for(i=1; i<=n; i++)
        {
            sum=i*i;
            if(sum==n)
            {
                ans=i;
                break;
            }
            if(sum>n)
            {
                ans=i-1;
                break;
            }
        }
        ans=ans*ans;
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const ll oo = 1e18;
const int MOD = 1000000007;
const int BASE = 26;

#define pb push_back
#define mp make_pair
#define x first
#define y second

int n , m , b[5010][210], sp[5010][210][13], lg2[5010];
ll a[5010];

int mx(int ticket , int l , int r){
	int len = lg2[r-l+1];
	return max(sp[l][ticket][len],sp[r-(1<<(len))+1][ticket][len]);
}

ll compute(int l , int r){
	ll ans = 0;
	for(int i = 1; i <= m ; ++i){
		ans += 1ll*mx(i,l,r);
	}
	return ans - (a[r]-a[l]);
}

ll res = 0;
void calc(int l , int r , int x , int y) {
	if (l > r)return;
	int md = (l + r) / 2;
	ll ans = -oo;
	int optIdx = -1;
	for (int i = max(md, x); i <= y ; ++i) {
		ll res = compute(md,i);
		if(res>ans){
			ans = res;
			optIdx = i;
		}
	}
	res = max(res,ans);
	calc(l, md - 1, x, optIdx);
	calc(md + 1, r, optIdx, y);
}
int main() {
	scanf("%d%d", &n, &m);
	lg2[1] = 0;
	for (int i = 2; i <= n ; ++i) {
		lg2[i] = lg2[i >> 1] + 1;
	}
	for (int i = 2; i <= n; ++i) {
		scanf("%lld", &a[i]);
		a[i] += a[i-1];
	}
	for (int i = 1 ; i <= n; ++i) {
		for (int j = 1 ; j <= m ; ++j) {
			scanf("%d", &b[i][j]);
			sp[i][j][0] = b[i][j];
		}
	}
	for (int ti = 1 ; ti <= m ; ++ti) {
		for (int j = 1; (1 << j) <= n ; ++j) {
			for (int i = 1; i + (1<<j) - 1 <= n ; ++i) {
				sp[i][ti][j] = max(sp[i][ti][j-1],sp[i+(1<<(j-1))][ti][j-1]);
			}
		}
	}	
	calc(1,n,1,n);
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 57856
N = int(input())
A = [int(input()) for i in range(N)]
max_A = max(A)
B = set(A)
if len(B) == 1 or A.count(max_A) >= 2:
    for i in range(N):
        print(max_A)
else:
    C = list(A)
    for i in range(N):
        if A[i] == max_A:
            C.remove(max_A)
            print(max(C))
        else:
            print(max_A)

Measured memory_bytes: 18176
from collections import Counter
import sys
MOD = 998244353
n, m = map(int, input().split())
d = Counter()
ans = 1
d_num = 0
def k(a, n):
	x = 1
	while n > 0:
		if n&1 == 1:
			x = (x*a) % MOD
		a = (a**2) % MOD
		n >>= 1
	return x
for _ in range(m):
	a, b, c = map(int, input().split())
	d[(a-1)*n+b-1] = c
	if abs(a-b) >= 3:
		if (b-1)*n+a-1 not in d:
			d_num += 1
			d[(b-1)*n+a-1] = c
		elif d[(b-1)*n+a-1] != d[(a-1)*n+b-1]:
			print(0)
			sys.exit()
ans = (ans*k(2, ((n-2)*(n-3)//2)-d_num))%MOD
e = 0
if 0 not in d:
	e+=1
if 1 not in d:
	e+=1
if n not in d:
	e+=1
if n+1 not in d:
	e+=1
if e == 0 and n*0+0 in d:
	if (d[n*0+0]+d[n+1])%2!=(d[1]+d[n]) % 2:
		ans *= 0
if e == 1 and n+1 not in d and n*0+0 in d:
	d[n+1] = (d[1]+d[n])%2-d[n*0+0]
ans = (ans*(2**max(0, e-1))) % MOD
for i in range(n-2):
	e = 0
	if n*i+i+2 not in d:
		e += 1
	if n*i+i+2*n not in d:
		e += 1
	if e == 0 and n*i+i+n+1 in d:
		if (d[n*i+i+2] + d[n*i+i+n+1] + d[n*i+i+2*n]) % 2 != 0:
			ans *= 0
	if e == 0 and n*i+i+n+1 not in d:
		d[n*i+i+n+1] = (d[n*i+i+2] + d[n*i+i+n*2]) % 2
		ans = (ans*499122177) % MOD
	ans = (ans*(2 ** max(0, e-1))) % MOD
	e=0
	if n*(i+1)+i+2 not in d:
		e += 1
	if n*(i+1)+i+1+n not in d:
		e += 1
	if n*(i+1)+i+n+2 not in d:
		e += 1
	if e == 0 and n*(i+1)+i+1 in d:
		if (d[n*(i+1)+i+1]+d[n*(i+1)+i+n+2]) % 2 != (d[n*(i+1)+i+2]+d[n*(i+1)+i+1+n])%2:
			ans *= 0
	if e == 0 and n*(i+1)+i+1 not in d:
		ans = (ans*499122177) % MOD
	if e == 1 and n*(i+1)+i+2+n not in d and n*(i+1)+i+1 in d:
		d[n*(i+1)+i+2+n]=(d[n*(i+1)+i+2]+d[n*(i+1)+i+1+n])%2-d[n*(i+1)+i+1]
	ans = (ans*(2**max(0, e-1))) % MOD
print(ans)

Measured memory_bytes: 15416