akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#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 << '\n'; }
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 << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n , m , k ;
    cin >> n >> m >> k ; 
    vector<int> A(n + 1) , B(m + 1) ; 
    for(int i = 0; i < n; i++){
        int x ;
        cin >> x ;
        A[i + 1] = A[i] + x ;
    }
    for(int i = 0; i < m; i++){
        int x ;
        cin >> x ;
        B[i + 1] = B[i] + x ;
    }
    int answer = 0 ;
    for(int i = 0; i < n + 1; i++){
        if ( A[i] <= k ){
            int target = k - A[i] ;
            int L = 0, R = m ;
            int ans = -1 ;
            while(L <= R){
                int mid = L + (R - L) / 2 ;
                if ( B[mid] <= target ){
                    ans = mid ;
                    L = mid + 1;
                }
                else R = mid - 1;
            }
            assert(ans != -1) ;
            answer = max(answer, i + ans) ;
        }
    }
    cout << answer << endl;
    return 0; 
}

Measured memory_bytes: 6332
import math
X = int(input())

total = 100
year = 0

while total < X:
  """
  if total < 1000:
    for i in range(1,100):
      num = 0
      if 100%i == 0:
        num = int(100/i)
      else:
        num = int(round(100/i+0.5,1))
      for j in range(num):
        total += i
        year += 1
        if total >= X:  break
      if total >= X:  break
  else:
    total += int(total*0.01)
    year += 1
    if total >= X:  break
  """
  total += int(total*0.01)
  year += 1
  if total >= X:  break
print(year)

Measured memory_bytes: 9176
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class FManySlimes {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int n;
        cin >> n;
        vector<int> s(1 << n);
        REP(i, 1 << n) cin >> s[i];
        sort(s.begin(), s.end());

        multiset<int> ms;
        REP(i, (1 << n) - 1) ms.insert(s[i]);

        vector<int> cur;
        cur.push_back(s.back());
        REP(i, n) {
            vector<int> next = cur;
            for (int t: cur) {
                auto itr = ms.lower_bound(t);
                if (itr == ms.begin()) {
                    cout << "No" << endl;
                    return;
                }
                itr--;
                next.push_back(*itr);
                ms.erase(itr);
            }

            sort(next.begin(), next.end());
            reverse(next.begin(), next.end());
            swap(cur, next);
        }
        cout << "Yes" << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    FManySlimes solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 17780
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    a = list(map(int,input().split()))
    ttl = 0
    for k in range(m):
        ttl += b[k]*a[k]
    if ttl +c >0:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <unordered_map>
#include <array>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#include <numeric>

#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

int a, b, c, d, e, f;

int main() {
  cin >> a >> b >> c >> d >> e >> f;

  int water = 100*a, sugar = 0;
  for (int i = 0; i*100*a <= f; ++i) {
    for (int j = 0; j*100*b+i*100*a <= f; ++j) {
      if (i == 0 && j == 0) continue;
      int ub = min(f-100*(i*a+j*b), (i*a+j*b)*e);
      int tw = 100*(i*a+j*b), ts = 0;
      for (int k = 0; c*k <= ub; ++k) {
        for (int l = 0; c*k+d*l <= ub; ++l) {
          ts = max(ts, c*k+d*l);
        }
      }
      if ((tw+ts)*sugar < (water+sugar)*ts) {
        water = tw; sugar = ts;
      }
    }
  }

  printf("%d %d\n", water+sugar, sugar);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define m 1000000007
using namespace std;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	ll ans=INT_MAX;
	for(int i=0;i<s1.size()-s2.size()+1;i++){
		ll local=0;
		for(int j=0;j<s2.size();j++){
			if(s1[i+j]!=s2[j])local++;
		}
		ans=min(local,ans);
	}
	cout<<ans;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;


int main() {
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	for (int i = 0; i < n; i++) {
		string a = "", b = "";
		for (int j = 0; j <= i; j++) {
			a += s[j];
		}
		for (int j = i + 1; j < n; j++) {
			b += s[j];
		}
		if (a == b) {
			cout << "Yes" << endl;
			return 0;

		}
	}
	cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
#include <queue>
#include <cstring>
using namespace std;
typedef long long int ll;
int n;
vector<string> ans;

void make(string t,int cnt,int last){
	if(cnt==n){
		ans.push_back(t);
		return;
	}
	for(int i=0;i<=last+1;i++){
		make(t+(char)('a'+i),cnt+1,max(last,i));
	}
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
    cin >> n;
	vector<string> s;
	make("a",1,0);
	sort(ans.begin(),ans.end());
	for(string p:ans){
		cout << p << endl;
	}
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    string s,t;
    cin >> s >> t;
    // まずsortで辞書順最小のs',t'を作ります
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    // 'tをreverseして可能な辞書順最大の文字列にします
    reverse(t.begin(), t.end());
    
    if ( s < t )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s;cin>>s;
  char v[]={'a','i','u','e','o'};
  bool f=0;
  for(int i=0;i<(int)s.size();i++)
    for(int j=0;j<5;j++) f|=s[i]==v[j];
  cout << (f?"vowel":"consonant")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string s;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> s;
}

int solve(){
    int n=s.length();
    int cntp = n/2;
    int ans=0;
    vector<char> str(n,'-');
    for (int i = 0; i < n; i++)
    {
        if(s[i]=='g' && cntp) {
            str[i]='p';
            cntp--;
            ans++;
            }
    }

    for (int i = 0; i < n; i++)
    {
        if(str[i]=='-'){
            if(s[i]=='p'){
                if(cntp){
                    str[i]='p';
                    cntp--;
                }
                else
                {
                    str[i]='g';
                    ans--;
                }
                
            }
            else{
                str[i]='g';
            }
        }
    }
    cout << ans << endl;
    return 0;
}   

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


Measured memory_bytes: 512
N,M = map(int,input().split())

LIST=[[0,0] for i in range(M)]
for i in range(M):
    LIST[i][0],LIST[i][1] = map(int,input().split())
m=1000
for i in range(999,-1,-1):
    NUM=str(i)
    if len(NUM)!=N:
        continue
    f=0
    for k in range(M):
        if int(NUM[LIST[k][0]-1])!=LIST[k][1]:
            f=1
    if f == 0:
        m=i
if m==1000:
    print(-1)
else:
    print(m)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;

int M,N;
int count;
char flag;
char ss[105][105];
void dsf(int x,int y)
{
	
	ss[x][y]='.';
	if(x>0&&ss[x-1][y]==flag) dsf(x-1,y);
	if(x<N-1&&ss[x+1][y]==flag) dsf(x+1,y);
	if(y>0&&ss[x][y-1]==flag) dsf(x,y-1);
	if(y<M-1&&ss[x][y+1]==flag) dsf(x,y+1);
}
int main() 
{
	while(~scanf("%d%d",&N,&M))
	{
		if(M==0&&N==0) break;
		memset(ss,'\0',sizeof(ss));
		getchar();
		int m,n;
		count=0;
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<M;j++)
			{
				scanf("%c",&ss[i][j]);
			}
			getchar();
		}
		for(int i=0;i<N;i++)
		{
			for(int j=0;j<M;j++)
			{
				if(ss[i][j]!='.')
				{flag=ss[i][j];
					dsf(i,j);
					count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}


Measured memory_bytes: 3896
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;

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


int main(void) {
	ll t, n;
	ll a[100001];
	ll mini, maxi;
	ll count = 0;

	cin >> n >> t;
	FOR(i, 1, n) {
		cin >> a[i];
	}
	mini = a[1];
	maxi = 0;

	FOR(i, 2, n) {
		maxi = max(maxi, a[i] - mini);
		mini = min(mini, a[i]);
	}

	mini = a[1];
	FOR(i, 2, n) {
		mini = min(mini, a[i]);
		if (maxi == a[i] - mini) {
			count++;
			if (i != n) {
				mini = a[i + 1];
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin>>N>>K;
  vector<unsigned long> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  
  unsigned long long ans=0;
  sort(H.begin(),H.end());
  for(int i=0; i<N-K; i++){
    ans+=H.at(i);
  }
  cout<<ans<<endl;
}

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

class AIDU0012
    {
        public static void Main(){
            const ushort lim= 100;
            string s;
            string[] ss;
            int i,j=0;
            double[] Point=new double[8], R=new double[3];
            bool[] surrounds=new bool[lim];
            bool b;
            while(true) {
                s=Console.ReadLine();
                if(string.IsNullOrEmpty(s))break;
                ss=s.Split();
                for(i=0;i<8;i++) {
                    Point[i]=double.Parse(ss[i]);
                }
                b=true;
                for(i=0;i<6;i+=2) {
                    R[i/2]=Cross(Point[(i+2)%6]-Point[i],Point[(i+3)%6]-Point[i+1],
                        Point[6]-Point[i],Point[7]-Point[i+1]);
                    if(R[i/2]*R[0]<=0)b=false;
                }
                surrounds[j]=b;
                j++;
            }
            for(i=0;i<j;i++) {
                Console.WriteLine(surrounds[i]?"YES":"NO");
            }
            Console.ReadLine();
        }
        public static double Cross(double a, double b, double c, double d) {
            return a*d-b*c;
        }
    }

Measured memory_bytes: 9092
# ref. https://atcoder.jp/contests/abc124/submissions/4963013
N, K = map(int, input().split())
S = map(int, list(input()))

num_list = []
now = 1
count = 0

for char in S:
    if char == (0 + now):
        count += 1
    else:
        num_list.append(count)
        now = 1 - now
        count = 1
if count > 0:
    num_list.append(count)
# 1-0-1-0になっていたら、最後に1つ0を足す
if len(num_list) % 2 == 0:
    num_list.append(0)

#累積和を作る
cumulative = [0] * (len(num_list) + 1)
for i in range(len(num_list)):
    cumulative[i + 1] = cumulative[i] + num_list[i]

ans = 0
add = 2 * K + 1

for i in range(len(cumulative)):
    if i % 2 == 0:
        add_i = min(i + add, len(cumulative) - 1)
        ans = max(ans, cumulative[add_i] - cumulative[i])
print(ans)


Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
signed main(){
	ll k,a,b; cin>>k>>a>>b;
	if(k<=a || b-a<=1){
		cout<<k+1<<endl;
		return 0;
	}
	ll ans=1;
	ans+=a-1;
	k-=a-1;
	ans+=(k/2)*(b-a);
	ans+=k%2;
	cout<<ans<<endl;
	


	
	return 0;
}

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

#define mod 1000003 // 素数

// F_mod 上でのべき乗, 蟻本p115
ll modPow(ll x, ll n) {
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

// Fermat の小定理を用いた F_mod 上での逆元計算x^(mod-2)
ll Inverse(ll x){
    return modPow(x, mod - 2);
}

// iの階乗 = fact[i]
ll fact[mod];

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

    // 階乗計算
    fact[0]=1;
    for(int i = 1; i < mod; ++i) {
        fact[i] = fact[i-1] * i % mod;
    }

    vector<int>ans(Q);
    for (int i = 0; i < Q; ++i) {
        ll x, d, n;
        cin >> x >> d >> n;
        if(d == 0){
            ans[i] = modPow(x, n);
            continue;
        }
        if(d > 1){
            x = x * Inverse(d) % mod;
        }
        if(x < mod && (x + n - 1) >= mod){
            ans[i] = 0;
            continue;
        }
        ans[i] = fact[x+n-1];
        if(x > 1) ans[i] = ans[i] * Inverse(fact[x-1]) % mod;
        ans[i] = ans[i] * modPow(d, n) % mod;
    }

    for (int i = 0; i < Q; ++i) {
        cout << ans[i] << "\n";
    }
    return 0;
}

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

#define ll long long
#define ar array

int n, k, c[2000001][26], m, cnt[2000001];
int ans;

void dfs(int u=0, int d=0) {
	for(int v=0; v<26; ++v)
		if(c[u][v])
			dfs(c[u][v], d+1), cnt[u]+=cnt[c[u][v]];
	ans += (cnt[u] / k ) * d;
	cnt[u] %= k;
}

void solve() {
	int n, m ;cin >> n >> m;
	cout << n * (n-1) / 2 + (m-1) * m / 2 << "\n";
}

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

	int t= 1, i=1;
	// cin >> t;
	while(t--) {
		// cout << "Case #" << i << ": ";
		solve();
		++i;
	}
}

Measured memory_bytes: 256
import math
x = 0
n = int(input())
for i in range(n):
    for j in range(n):
        t = math.gcd(i+1,j+1)
        if t == 1:
            x += n
            continue
        for k in range(n):
            x += math.gcd(t, k+1)
print(x)

Measured memory_bytes: 67896
#include <stdio.h>
#define bit(n,m)((n>>m)&1)
#define min(p,q)((p)<(q)?(p):(q))
#define MOD 1000000007

#define add(x)(x=(x+t)%MOD)
long dp[70][3];
//n桁目まで見て猶予がi
int main(){
	long N;
	scanf("%ld",&N);
	dp[63][0]=1;
	for(int n=63;n>=1;n--)for(int i=0;i<3;i++){
		int t=dp[n][i];
		int x=i*2+bit(N,n-1);
		//x0 y0
		add(dp[n-1][min(2,x)]);
		//x0 y1
		if(x>=1)add(dp[n-1][min(2,x-1)]);
		//x1 y1
		if(x>=2)add(dp[n-1][min(2,x-2)]);
	}
	printf("%lld",(dp[0][0]+dp[0][1]+dp[0][2])%MOD);
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
count = 0
for i in range(N):
  if A[i] % 2 == 0:
    if A[i] %3 ==0 or A[i] %5 ==0:
      count +=1
    else:
      count -=10000
      break
if count >=0:
  print("APPROVED")
else:
  print("DENIED")


Measured memory_bytes: 2940
N, K = map(int, input().split())
xys = [tuple(map(int, input().split())) for _ in range(N)]

# H - x - i
# W - y - j

xs_decode = sorted(map(lambda t: t[0], xys))
ys_decode = sorted(map(lambda t: t[1], xys))
xs_encode = {e:i for i, e in enumerate(xs_decode)}
ys_encode = {e:i for i, e in enumerate(ys_decode)}

H = len(xs_encode)
W = len(ys_encode)

field_csum = [[0] * (W+1) for _ in range(H+1)]
for x, y in xys:
    i = xs_encode[x]
    j = ys_encode[y]
    field_csum[i+1][j+1] += 1
for i in range(H+1):
    for j in range(W):
        field_csum[i][j+1] += field_csum[i][j]
for i in range(H):
    for j in range(W+1):
        field_csum[i+1][j] += field_csum[i][j]


ans = 1 << 63 # INF
# bi < i <= ei and bj < j <= ej
for bi in range(H):
    for ei in range(bi + 1, H + 1):
        for bj in range(W):
            for ej in range(bj + 1, W + 1):
                if field_csum[ei][ej] - field_csum[bi][ej] - field_csum[ei][bj] + field_csum[bi][bj] >= K:
                    area = (xs_decode[ei-1] - xs_decode[bi]) * (ys_decode[ej-1] - ys_decode[bj])
                    ans = min(ans, area)
                    break # don't have to check larger ej 

print(ans)

Measured memory_bytes: 74448
#include <iostream>
using namespace std;
typedef long long ll;

ll N,inf = 1e9+7;
ll fact[1000010] = {0};
ll inv[1000010] = {0};

ll mult(ll n, ll m){
	if(m==1) return n%inf;
	else if(m%2==0){
		ll t = mult(n,m/2);
		return (t*t)%inf;
	}else{
		ll t = mult(n,m-1);
		return (t*n)%inf;
	}
}

void factorial(ll N){
	for(ll i=0;i<=N;i++){
		if(i==0){
			fact[i] = 1;
			inv[i] = 1;
		}
		else{
			fact[i] = (i*fact[i-1])%inf;
			inv[i] = mult(fact[i],inf-2);
		}
	}
}

ll comb(ll n,ll k){
	if(k==0 || n==k) return 1;
	else return (((fact[n]*inv[k])%inf)*inv[n-k])%inf;
}

ll hcomb(ll n,ll k){
	if(n==0 && k==0) return 1;
	return comb(n+k-1,k);
}

ll A[1000010] = {0};

int main(){
	cin >> N;
	factorial(N);
	if(N==2) cout << 1 << endl;
	else if(N==3) cout << 4 << endl;
	else{
		ll ans = 0;
		for(ll i=1;i<=N-1;i++){
			ll s = comb(i-1,N-1-i), t = (fact[i]*fact[N-1-i])%inf;
			A[i] = (s*t)%inf;
			ll a = A[i]-A[i-1];
			a = (a+inf)%inf;
			ans += i*a;
			ans %= inf;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 23680
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
    int n;
    int tmp;
    int nmax=0;
    scanf("%d", &n);
    int a[100000] = {0};
    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &tmp);
        a[tmp] += 1;
        if ( tmp > nmax ) {
            nmax = tmp;
        }
    }
    int max = 0;
    for ( int i = 0; i <= nmax ; i++ ) {
        int temp;
        if ( i == 0 ) {
            temp = a[i] + a[i+1];
        } else if ( i == nmax ) {
            temp = a[i-1] + a[i];
        } else {
            temp = a[i-1] + a[i] + a[i+1];
        }
        if ( temp > max ) {
            max = temp;
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int n;
int a, b;
int s[100005];

int main(void)
{
	cin >> n;
	cin >> a >> b;
	for(int i = 1; i <= n; i++) cin >> s[i];
	
	int g = 0;
	for(int i = 1; i <= n; i++) g ^= s[i] % (min(a, b)+1);
	
	if(a == b){
		if(g) cout << "Hanako" << endl;
		else cout << "Jiro" << endl;
		return 0;
	}
	
	int cnt = 0, idx;
	for(int i = 1; i <= n; i++){
		if(s[i] > min(a, b)) cnt++, idx = i;
	}
	if(a > b){
		if(cnt) cout << "Hanako" << endl;
		else{
			if(g) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
	}
	else{
		if(cnt >= 2) cout << "Jiro" << endl;
		if(cnt == 0){
			if(g) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
		if(cnt == 1){
			if(g == 0 || s[idx] > 2*a) cout << "Jiro" << endl;
			else{
				int tg = g ^ (s[idx] % (a+1));
				if(tg > a) cout << "Jiro" << endl;
				else if(tg > s[idx]%(a+1)) cout << "Hanako" << endl;
				else cout << "Jiro" << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 2e6+5;
const dd eps = 1e-8;
const ll mod = 1e9+7;

ll dp[305][305],n,k,a[305],ans=LLONG_MAX;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>k;
  for(int i = 0;i <= n+1;i++){
    for(int j = 0;j <= k;j++) dp[i][j] = 1e12;
  }
  for(int i = 1;i <= n;i++) cin>>a[i];
  a[++n] = 0;
  dp[0][0] = 0ll;
  for(int i = 1;i <= n;i++){
    for(int j = 0;j <= min(k,(ll)i);j++){
      for(int p = 0;p <= j;p++){
	int pos = i-p-1;
	if(pos < 0) break;
	dp[i][j] = min(dp[i][j],dp[pos][j-p] + max(0ll,a[i]-a[pos]));
      }
    }
  }
  for(int i = 0;i <= k;i++) ans = min(ans,dp[n][i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
use Math::BigInt;
my $input = <STDIN>;
chomp $input;
my ($N, $X) = split / /, $input;
my $input = <STDIN>;
chomp $input;
my @x = split / /, $input;
for ($i=0; $i<$N; $i++) {
  $x[$i] -= $X;
}
my $gcd = Math::BigInt::bgcd(@x);
print $gcd;


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

int main() {
  int N;
  cin>>N;
  vector<string> s(N);
  int g=0;
  int ans=0;
  string tans;
  for(int i=0;i<N;i++){
    cin>>s.at(i);
  }
  int M;
  cin>>M;
  vector<string> t(M);
  for(int i=0;i<M;i++){
    cin>>t.at(i);
  }
  for(int i=0;i<N;i++){
    tans=s.at(i);
    g=0;
    for(int j=0;j<N;j++){
      if(tans==s.at(j)){
        g++;
      }
    }
    for(int j=0;j<M;j++){
      if(tans==t.at(j)){
        g--;
      }
    }
    if(i==0){
      ans=g;
    }
    if(i!=0){
      if(ans<g){
        ans=g;
      }
    }
  }
  if(ans<=0){
    ans=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3588
s = input()
q = int(input())
a = []
b = []
c = 0
for i in range(q):
    init = list(input().split())
    if init[0] == '1':
        a, b = b, a
        c += 1
    else:
        if init[1] == '1':
            a.append(init[2])
        else:
            b.append(init[2])
if c % 2 == 1:
    s = s[::-1]
print(''.join(a[::-1]) + s + ''.join(b))


Measured memory_bytes: 6268
#include <stdio.h>

#define INF 1000000000

#define min(x, y) ((x) < (y) ? (x) : (y))

int adj[100][100];

int main(void) {
	int i, j, k;
	int n;

	scanf("%d", &n);

	for (i = 0; i < n; i++)
		for (j = 0; j < n; j++)
			adj[i][j] = INF;
	for (i = 0; i < n; i++)
		adj[i][i] = 0;

	for (i = 0; i < n; i++) {
		int u, k;
		scanf("%d %d", &u, &k);
		for (j = 0; j < k; j++) {
			int v, c;
			scanf("%d %d", &v, &c);
			adj[u][v] = c;
		}
	}

	for (k = 0; k < n; k++)
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);

	for (i = 0; i < n; i++)
		printf("%d %d\n", i, adj[0][i]);

	return 0;
}

Measured memory_bytes: 636
def isPrime(x):
    if x == 2:
        return True
    elif x<2 or x%2 == 0:
        return False
    else:
        i=3
        while i<=x**0.5:
            if x%i == 0:
                return False
            i += 2
        else:
            return True

n = int(input())
cnt = 0
for _ in range(n):
    if isPrime(int(input())):
        cnt+= 1
        
print(cnt)


Measured memory_bytes: 5672
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  a=[1,400,800,1200,1600,2000,2400,2800,3200]
  b=[0]*9
  c=0
  for x in l:
    for i in range(len(a)-1):
      if a[i]<=x and x<a[i+1]:
        b[i]+=1

    if 3200<=x:
      c+=1

  d=0
  for x in b:
    if x>0:
      d+=1

  if d==0:
    print(1,c)
  else:
    print(d,d+c)

main()


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

int arr[205], stitle[205];

int main(){
    int maks = 0;
    string S;
    cin >> S;
    for(int i=0; i<S.length(); i++){
        arr[S[i] - 96]++;
        if (arr[S[i] - 96] > maks){
            maks = arr[S[i] - 96];
        }
        stitle[i] = S[i] - 96;
    }
    if(maks == 1){
        cout << S.length()/2 << endl;
    } else{
        int min = 201;
        for(int i=1; i<=26; i++){
            int jumlah = arr[i], cnt = 0;
            if(arr[i] != 0){
                int cstitle[205];
                for(int j=0; j<S.length(); j++){
                    cstitle[j] = stitle[j];
                }
                while(true){
                    bool hehe = true;
                    for(int j=0; j<S.length(); j++){
                        if(cstitle[j] != i && j <= S.length() - cnt - 1) hehe = false;
                        if(cstitle[j+1] == i && cstitle[j] != i){
                            jumlah++;
                            cstitle[j] = i;
                        }
                    }
                    if(hehe) break;
                    cnt++;
                }
                if (cnt < min){
                    min = cnt;
                }
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 3564
package main

import (
	"fmt"
)

type node struct {
	parent, left, right int
}

var tree []node

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func setHeight(height []int, u int) int {
	// あるノードuから葉までの経路の長さの最大値を「ノードuの高さと呼ぶ」
	var h1, h2 int
	if tree[u].right != -1 { // 右の子供がいる
		h1 = setHeight(height, tree[u].right) + 1
	}
	if tree[u].left != -1 { // 左の子供がいる
		h2 = setHeight(height, tree[u].left) + 1
	}
	height[u] = max(h1, h2)
	return height[u]
}
func setDepth(depth []int, u, d int) {
	// 根からノードuまでの経路の長さを「ノードuの深さと呼ぶ」
	if u == -1 {
		return
	}
	depth[u] = d
	setDepth(depth, tree[u].left, d+1)
	setDepth(depth, tree[u].right, d+1)
}

func main() {
	var n, root int
	fmt.Scan(&n)
	tree = make([]node, n)
	for i := 0; i < n; i++ {
		tree[i].parent = -1
	}
	depth := make([]int, n)
	height := make([]int, n)
	for i := 0; i < n; i++ {
		var id, left, right int
		fmt.Scan(&id, &left, &right)
		tree[id].left = left
		tree[id].right = right
		if left != -1 {
			tree[left].parent = id
		}
		if right != -1 {
			tree[right].parent = id
		}
	}
	for i := range tree {
		if tree[i].parent == -1 {
			root = i
		}
	}
	setDepth(depth, root, 0) // 各ノードの深さを計算する
	setHeight(height, root)  // 各ノードの高さを計算する
	for me := range tree {
		fmt.Printf("node %d: parent = %d, ", me, tree[me].parent)
		parent := tree[me].parent
		sibling := -1
		if parent != -1 { //ルートではない
			left := tree[parent].left
			right := tree[parent].right
			if left != me && left != -1 {
				sibling = left
			} else if right != me && right != -1 {
				sibling = right
			}
		}
		fmt.Printf("sibling = %d, ", sibling)
		degree := 0
		if tree[me].left != -1 && tree[me].right != -1 {
			degree = 2
		} else if tree[me].left == -1 && tree[me].right == -1 {
			degree = 0
		} else {
			degree = 1
		}
		fmt.Printf("degree = %d, depth = %d, height = %d, ", degree, depth[me], height[me])
		if parent == -1 {
			fmt.Printf("root")
		} else if degree == 0 {
			fmt.Printf("leaf")
		} else {
			fmt.Printf("internal node")
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1180
/*
  Author - KISHAN TIWARI
  Dream bigger. Do bigger.
  Wake up with determination. Go to bed with satisfaction.
*/
//Sometimes later becomes never. Do it now.
#include<bits/stdc++.h>
using namespace std;
#define ll           long long
#define f(i,a,b)     for(ll i=a;i<b;i++)
#define mod          1000000007
#define fi           first
#define se           second
#define pa           pair <ll,ll>
#define mp           make_pair
#define pb           push_back
#define ve           vector<ll>
#define vep          vector< pa >
#define all(a)       a.begin(), a.end()
#define sz(x)        (ll)x.size()
#define c(t)         cout<<t<<"\n"
using namespace std;
void solve()
{  ll n;
cin>>n;
c(pow(n,3));
}
int main()
{
    ios::sync_with_stdio(true);
   //freopen ("input.txt","r",stdin);
   //freopen ("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    //cin>>t;
    while(t--)
    {

        solve();
    }
return 0;
}


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

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

    int h[n];
    rep(i, n)
        cin >> h[i];

    int max = 0;
    rep(i, n){
        if(h[i] > max){
            max = h[i];
            for(int j = i; j < n; j++){
                if(h[j] > max)
                    max = h[j];
                if(max - 1 > h[j]){
                    puts("No");
                    return 0;
                }
            }
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

  if(x < 4){
    std::cout << 1 << '\n';
    return 0;
  }

  int num = 2;
  int ans = 0;
  while(num*num < x) {
    int pq = 1;
    while(pq <= x) {
      pq *= num;
    }
    pq/=num;
    if(ans < pq)
      ans = pq;
    ++num;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long i,l,r,mid,min1,y;
char s[15];
void query(long long x){
	printf("? %lld\n",x);
	fflush(stdout);
	scanf("%s",s);
}
int main(){
	//freopen("camp.in","r",stdin);
	//freopen("camp.out","w",stdout);
	y=1000000000;
	query(y);
	if(s[0]=='Y'){
		i=9;
        while(i){
            query(y-1);
            if(s[0]!='Y')
            	break;
            y/=10;
            i--;
        }
        cout<<"! "<<y<<endl;
        return 0;
    }
	for(i=1;;i=i*10){
		query(i);
		if(s[0]=='N'){
			i/=10;
			l=i;
			r=i*10-1;
			mid=(l+r)/2;
			break;
		}
	}
	min1=r+1;
	while(l<=r){
		query(mid*10);
		if(s[0]=='Y'){
			min1=min(min1,mid);
			r=mid-1;
		}
		else
			l=mid+1;
		mid=(l+r)/2;
	}
	cout<<"! "<<min1<<endl;
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  int h = 0;
  for(int i = 0;i<a;i++){
    int t;
    cin >> t;
    if(t!=i+1)h++;}
  if(h>2)cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 256
/*
 * Matheus Oliveira
 * 16/06/2018
 * a.cpp
*/
 
#include <bits/stdc++.h>
using namespace std;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);

	if(a > 8 or b > 8) printf(":(\n");
	else printf("Yay!\n");
	return 0;
}

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

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var h = long.Parse(inputs[0]);
            var w = long.Parse(inputs[1]);
            var matrix = new char[h, w];
            var count = new int[h, w];

            for (var i = 0; i < h; i++)
            {
                var list = Console.ReadLine().ToCharArray();
                for (var j = 0; j < w; j++)
                {
                    matrix[i, j] = list[j];
                }
            }

            for (var i = 0; i < h; i++)
            {
                for (var j = 0; j < w; j++)
                {
                    if (matrix[i, j] != '#') continue;

                    if (i - 1 >= 0 && j - 1 >= 0) count[i - 1, j - 1]++;
                    if (i - 1 >= 0) count[i - 1, j]++;
                    if (i - 1 >= 0 && j + 1 < w) count[i - 1, j + 1]++;

                    if (j - 1 >= 0) count[i, j - 1]++;
                    if (j + 1 < w) count[i, j + 1]++;

                    if (i + 1 < h && j - 1 >= 0) count[i + 1, j - 1]++;
                    if (i + 1 < h) count[i + 1, j]++;
                    if (i + 1 < h && j + 1 < w) count[i + 1, j + 1]++;
                }
            }

            for (var i = 0; i < h; i++)
            {
                var t = "";
                for (var j = 0; j < w; j++)
                {
                    t += matrix[i, j] == '#' ? "#" : count[i, j].ToString();
                }
                Console.WriteLine(t);
            }
        }
    }
}


Measured memory_bytes: 27544
#include <stdio.h>

int main(void){
  int A, B;
  
  scanf("%d %d", &A, &B);
  
  if(A > 12){
    printf("%d",B);
   }
  else if(A > 5 && A < 13){
    printf("%d", B/2);
   }
  else{
    printf("0");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
int a[5];
int main()
{
	scanf("%d%d%d%d",&a[1],&a[2],&a[3],&a[4]);
	sort(a+1,a+5);
	if(a[1]==1&&a[2]==4&&a[3]==7&&a[4]==9)printf("YES\n");
	else printf("NO\n");
	return 0;
}

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

int main(){
    int r,D,x;
    cin >> r >> D >> x;
    for(int i = 0;i < 10;i ++){
        x = r*x - D;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# include <stdio.h>

int main(){
    int x, a, b;
    int da = 0, db = 0;
    scanf("%d %d %d", &x, &a, &b);
    
    da = a - x;
    db = b - x;
    if (da < 0)
        da *= -1;
    if (db < 0)
        db *= -1;
    
    if (da > db)
        printf("B\n");
    else
        printf("A\n");
    
    return 0;
}


Measured memory_bytes: 128
n,k = map(int, input().split())
xs = []
ys = []
ps = []
for i in range(n):
    x,y = map(int, input().split())
    xs.append(x)
    ys.append(y)
    ps.append((x,y))
# 座圧
xs = sorted(list(set(xs)))
ys = sorted(list(set(ys)))
xdic = {x:i for i, x in enumerate(xs)}
ydic = {y:i for i, y in enumerate(ys)}
xrdic = {i:x for i, x in enumerate(xs)}
yrdic = {i:y for i, y in enumerate(ys)}
nx = len(xs)
ny = len(ys)


fs = [[0] * (1+ny) for i in range(nx+1)]
for x,y in ps:
    ix = xdic[x]
    iy = ydic[y]
    fs[ix][iy] += 1

acc = [[0] * (1+ny) for i in range(nx+1)]
for i in range(nx):
    for j in range(ny):
        acc[i+1][j+1] = acc[i+1][j] + acc[i][j+1] - acc[i][j] + fs[i][j]

def calc(sx,sy,tx,ty):
    ix1 = xrdic[sx]
    ix2 = xrdic[tx]
    iy1 = yrdic[sy]
    iy2 = yrdic[ty]
    return (ix2-ix1) * (iy2-iy1)

# print(xs,xdic,".",ys,ydic)
ans = 10**20
for sx in range(nx+1):
    for sy in range(ny+1):
        for tx in range(sx+1, nx+1):
            for ty in range(sy+1, ny+1):
                cnt = acc[tx][ty] - acc[sx][ty] - acc[tx][sy] + acc[sx][sy]
                if cnt >= k:
                    S = calc(sx,sy,tx-1,ty-1)
                    ans = min(ans, S)
print(ans)

Measured memory_bytes: 74520
from collections import Counter

N = int(input())
A = Counter(list(map(int, input().split()))).most_common()
ans = 0
for a in A:
    if a[0] < a[1]:
        ans += a[1] - a[0]
    elif a[0] > a[1]:
        ans += a[1]
print(ans)


Measured memory_bytes: 21232
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  string a, b;
  cin >> a >> b;
  int ab = stoi(a+b);
  int square = sqrt(ab);
  if (square * square == ab) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.math;
import std.range;

void main()
{
    auto x4 = readln.chomp.split.map!(to!real).array;
    writefln("%.6f", ((x4[0] - x4[2])^^2 + (x4[1] - x4[3])^^2)^^0.5);
}

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

int main() {
    string s;
    while (cin >> s, s != "#") {
        int y, m, d; cin >> y >> m >> d;

        if (y > 31 || (y == 31 && m > 4)) {
            cout << "? " << y-30;
        } else {
            cout << s << " " << y;
        }
        cout << " " << m << " " << d << endl;
    }
}



Measured memory_bytes: 3124
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;



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

    vector<vector<int>> edges(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> min(n, INF);
    min[0] = 0;

    queue<pair<int,int>> q;
    q.push(make_pair(0, 0));
    int now = 0;
    while (q.size()) {
        auto qf = q.front();
        q.pop();
        int next = qf.first;
        int cost = qf.second;
        min[next] = cost;
        now++;
        if (next == n - 1)
            break;

        for (auto t : edges[next]) {
            if (min[t] == INF)
                q.push(make_pair(t, cost+1));
        }
    }

    cout << (min[n - 1] == 2 ? "POSSIBLE" : "IMPOSSIBLE") << endl;


    return 0;
}

Measured memory_bytes: 13552
#include<iostream>

using namespace std;

bool solve(int n){
	int sum = 0;
	int temp = n;
	int digit;
	while(n>0){
		digit = n%10;
		sum += digit;
		n = n/10;
	}
	return (temp%sum==0);
}

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

	int n;
	cin >> n;
	if(solve(n)) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 3604
<?php
  $a = fgets(STDIN);
  $b = fgets(STDIN);
  $c = fgets(STDIN);
  $x = fgets(STDIN);
  $result = 0;
  for($i = 0; $i <= $a; $i++){
    for($j = 0; $j <= $b; $j++){
      for($k = 0; $k <= $c; $k++){
        if(500 * $i + 100 * $j + 50 * $k == $x){
          $result++;
        }
      }
    }
  }
  echo $result;
?>

Measured memory_bytes: 3700
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = new string[n];
        for (int i = 0; i < n; i++)
        {
            s[i] = Console.ReadLine();
        }
        var ansArray = s.Distinct();
        int ans = 0;
        foreach (var i in ansArray)
        {
            ans++;
        }
        Console.WriteLine(ans);
    }
}

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

int n, k, r, len;
set <int> s;

int main() {
	ios::sync_with_stdio(0);
	n = 7;
	cin >> k;
	r = n % k;
	len = 1;
	while(r != 0) {
		if(s.find(r) != s.end()) {
			cout << -1 << endl;
			return 0;
		}
		s.insert(r);
		n = r * 10 + 7;
		r = n % k;
		len++;
	}
	cout << len << endl;
	return 0;
}

Measured memory_bytes: 50404
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}
ll lcm(ll p,ll q){return p/gcd(p,q)*q;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
// qsort(array, length, sizeof(int), asc);

int main(void) {
    int a, b;
    scanf("%d %d", &a, &b);
    if(a>b){
        int tmp = a;
        a = b;
        b = tmp;
    }
    int i;
    int j = 0;
    for( i=a; i<=b; i++){
        if(abs(a-i) == abs(b-i)){
            printf("%d\n", i);
            j++;
            break;
        }
    }
    
    
    
    if(j == 0){
        printf("IMPOSSIBLE\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  string s;
  cin >> n >> s;

  vector<char> alpha;
  for (char ch = 'A'; ch <= 'Z'; ch++) {
    alpha.push_back(ch);
  }

  for (int i = 0; i < s.size(); i++) {
    int index = s[i] - 'A';
    index += n;
    index %= 26;
    s[i] = alpha.at(index);
  }

  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

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

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

    if (s == "abc") {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}



int main(){
    ll n; cin >> n;
    string ans = "";
    while(n > 0){
        n--;
        ans += 'a'+n%26;
        n /= 26;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()

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

using namespace std;
typedef long long ll;
const int INF = 10000000;

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; ++i) {
            if(i % k == 0) {
                cout << "OK" << endl;
                return 0;
            }
    }

    cout << "NG" << endl;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  int counter = 0;
  
  for (int i = 0; i < S.size(); i++){
    if (S.at(i) != T.at(i)){
      counter++;
    }
  }
  
  cout << counter << endl;
}

Measured memory_bytes: 3888