akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

static const int N = 55;

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

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

    int w, h;
    string s[N];
    cin >> h >> w;

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

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
                continue;
            int count = 0;
            for (int k = 0; k < 8; k++)
            {
                if (i + dy[k] < 0 || i + dy[k] > h - 1)
                    continue;
                if (j + dx[k] < 0 || j + dx[k] > w - 1)
                    continue;
                if (s[i + dy[k]][j + dx[k]] == '#')
                    ++count;
            }
            s[i][j] = char('0' + count);
        }
    }

    for (int i = 0; i < h; i++)
    {
        cout << s[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from functools import reduce
N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))


def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def lcm(a, b):
    if b > a:
        b, a = a, b
    return a * b // gcd(a, b)


x = reduce(lcm, T)
print(x)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll findGCD(ll arr[], ll n) 
{ 
    ll result = arr[0]; 
    for (ll i = 1; i < n; i++)
        result = gcd(arr[i], result); 
  
    return result; 
} 
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   	ll n; cin>>n;ll a[n];ll ans=0;
  f(i,0,n) cin>>a[i];
  f(i,0,n-1)
  {
  f(j,i+1,n)
  {ans+=a[i]*a[j];}
  }
  cout<<ans;
}


Measured memory_bytes: 768
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define pb push_back
using namespace std;
const int P=139;
const int mod=998244353;
const int maxn=1e7+5;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int minn=0xc0c0c0c0;
ll k,m,n,x,ans,f[maxn],pre[maxn];
int main()
{
    scanf("%lld%lld%lld",&n,&x,&m);
    for(int i=0;i<m;i++)
    	f[i]=-1;
    int a=0;
    ans=0;
    while(n--)
    {
    	f[x]=a++;
    	pre[x]=ans;
    	ans+=x;
    	x=x*x%m;
    	if(f[x]>=0)
    	{
    		int b=a-f[x];
    		ans+=(ans-pre[x])*(n/b);
    		n%=b;
		}
	}
	printf("%lld\n",ans);
    return 0;
}

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

const int MAX = 5100000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	int x,y;
	cin >> x >> y;
	
	
	int b = (2*x-y)/3;
	int a = (2*y-x)/3;
	
	//cout << a <<" " << b << endl;
	if(2*a+b == y && a+2*b== x && (x+y)%3==0){
		COMinit();
		//cout << " ^^" <<endl;
		cout << COM(a+b,a) << endl;;
	}else{
		cout << 0 <<endl;
	}
	
	
	return 0;
	
}

Measured memory_bytes: 119808
#include <iostream>
using namespace std;
int main(){
    int grid[4][4] = {0};
    int num[2][4] = {0};
    int count = 0;
    //グリッドの数字入力
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> grid[i][j];
        }
    }

    /* num[0][i] + x +num[1][j] -x =a(i,j) とする
     * num[0][0] = 0となるxを設定
     * grid[0][0] = num[1][0]
     * grid[1][0] = num[1][1]
     * grid[2][0] = num[1][2]
     * num[0][1] = num[1][0] - grid[0][1]
     * num[0][2] = num[1][0] - grid[0][2]
     */

    num[0][0] = 0;
    num[1][0] = grid[0][0];
    num[1][1] = grid[1][0];
    num[1][2] = grid[2][0];
    num[0][1] = grid[0][1] - num[1][0];
    num[0][2] = grid[0][2] - num[1][0];

    for (int k = 0; k <3 ; ++k) {
        for (int i = 0; i < 3; ++i) {
            if(grid[k][i] == num[0][i] + num[1][k]){
                count++;
            }
        }
    }


    if(count == 9){
        cout << "Yes";
    } else{
        cout << "No";
    }
    return 0;
}

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

int main() {
int h,w,d,q;
long long x[100000];
vector<pair<int,int>> p(100001);
cin>>h>>w>>d;
for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
        int a;
        cin>>a;
        p[a].first=i;
        p[a].second=j;
    }
}

for(int i=1;i<=d;i++){
    x[i]=0;
    for(int j=i+d;j<=h*w;j+=d){
        x[j]=x[j-d]+abs(p[j].first-p[j-d].first)+abs(p[j].second-p[j-d].second);
    }
}
/*
for(int i=1;i<=h*w;i++){
    cout<<i<<":"<<x[i]<<endl;
}
*/
cin>>q;
for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<x[r]-x[l]<<endl;
}

	return 0;
}

Measured memory_bytes: 2560
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>


using namespace std;

int main(void) {
    int A,B;
    cin>>A>>B;
    for(int i=0;i<1300;i++){
        if(floor(i*0.08)==A&&floor(i*0.10)==B){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
    return 0;
}


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



int main(){
    int n;
    cin>>n;
    ll m;
    cin>>m;
    ll a[100005];
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]%=m;
    }
    
    
    map<ll,ll> mod;
    ll sum[100005]={0};
    
    for(int i=0;i<n;i++){
        sum[i+1]=a[i]+sum[i];
        sum[i+1]%=m;
        
    }
    for(int i=0;i<=n;i++){
        mod[sum[i]]++;
    }
    ll ans=0;
    for(auto i : mod){
        ans += (i.second*(i.second - 1)) / 2;
    }
    
    cout<<ans<<endl;
    return 0;
}



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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  string s, t; cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <utility>
#include <fstream>
#include <bitset>
#include <unordered_map>
#include <set>
using namespace std;
 
#define ll long long
#define ldb long double
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	ldb total = 0;
	
	vector<int> a(n);
	
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		total += a[i]; 
	}
	
	total /= (4 * m);
	
	int cnt = 0;
	
	for(int i = 0; i < n; i++)
	{
		if(a[i] >= total)
		{
			cnt++;
		}
	}
	
	if(cnt >= m)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 256
import sys
A="abcdefghijklmnopqrstuvwxyza"
def rot(s):
    x=""
    for c in s:
        if c in A: x+=A[A.index(c)+1]
        else: x+=c
    return x
  
for s in sys.stdin.readlines():
    while not("the" in s or "that" in s or "this" in s):
        s=rot(s)
    print s[:-1]

Measured memory_bytes: 4208
line = input()
a, b = [int(n) for n in line.split()]

if a>=b:
    c = a/2
    d = 16-a
    if c>d or a>8:
        print(":(")
    else:
        print("Yay!")
else:
    c = b/2
    d = 16 -b
    if c>d or b>8:
        print(":(")

    else:
        print("Yay!")



Measured memory_bytes: 2940
import math
def main():
	Q = int(input())
	ans = [0]*Q
	for i in range(Q):
		A, B = sorted(map(int, input().split()))
		if A == B or A+1 == B:
			ans[i] = 2*A-2
			continue

		C = int(math.sqrt(A*B))
		if C*C == A*B:
			C -= 1
		if C*(C+1) >= A*B:
			ans[i] = 2*C-2
		else:
			ans[i] = 2*C-1

	for a in ans:
		print(a)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
// Problem : D - Leaping Tak
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=998244353;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }


signed main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0); 

   int n,k;
   cin>>n>>k;
   vector<array<int,2>> v;
   for (int i=0;i<k;++i){
   		int x,y;
   		cin>>x>>y;
   		y+=1;
   		v.push_back({x,y});
   }
	vector<int> dp(n+1,0);
   dp[0]=1;
   dp[1]=-1;
   for (int i=0;i<n;++i){
   		if (i>0)
   			dp[i]=(dp[i]+dp[i-1])%mod;
   		for (int j=0;j<v.size();++j){
   				int l,r;
   				l=v[j][0];
   				r=v[j][1];
   				if (i+l<n && i+l>=0) 
   					dp[i+l]=(dp[i+l]+dp[i])%mod;
   				if (i+r<n && i+r>=0) 
   					dp[i+r]=(dp[i+r]-dp[i]+mod)%mod;
   		}
   }
   cout<<dp[n-1];
   	return 0;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=1000000;
const ll inf=1e9;
const ll mod=998244353;


ll a[MX], b[MX];

int main()
{

    FasterIO;


    int n;

    cin>>n;

    for(int i=1; i<=n; i++) cin>>a[i]>>b[i];

    ll sm=0;

    for(int i=n; i>=1; i--)
    {
        ll x=a[i], y=b[i];
        ll rem=(x+sm)%y;
        if(rem) sm+=(y-rem);
    }

    cout<<sm<<endl;

    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3+10;
char a[maxn],b[maxn];
int dp[maxn][maxn];

int main() {
	scanf("%s",a+1);
	scanf("%s",b+1);
	int lena = strlen(a+1);
	int lenb = strlen(b+1);
	
	for(int i = lena;i >= 1;i--) {
		for(int j = lenb;j >= 1;j--) {
			if(a[i] == b[j]) 
				dp[i][j] = dp[i+1][j+1] +1;
			else 
				dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
		}
	}
	
	int l = 1,r = 1;
	while(l <= lena && r <= lenb) {
		if(a[l] == b[r]) {
			cout<<a[l];
			l++;
			r++;
		}
		else if(dp[l][r] == dp[l+1][r]) l++;
		else r++;
	}
	return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
#define re          return
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define hell2        1000000009
#define endl        '\n'
#define rep(i,a,b)  for (__typeof(b) i=(a)-((a)>(b));i!=(b)-((a)>(b));i+=1-2*((a)>(b)))
#define PI            3.141592653589793l
#define sz(x)       (int)x.size()
#define fill(c,val) memset(c,val,sizeof(c))
#define LB lower_bound
#define UB upper_bound
using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 123;
const ll infl = (ll)1e18 + 123;
const ll INF=(1LL<<60)-1;
//v.resize(distance(v.begin(),unique(v.begin(),v.end())));
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){ 
		  int n; cin>>n;
		  int dp[100005];
		    rep(i,0,100005) dp[i]=inf;
		    dp[0]=0;
		  for(int i=1;i<=n;i++){
		  	   dp[i]=1+dp[i-1];
		  	   for(int j=6;j<=i;j*=6)
		  	     dp[i]=min(dp[i],dp[i-j]+1);
		  	   for(int j=9;j<=i;j*=9)
		  	     dp[i]=min(dp[i],dp[i-j]+1);  
		  }
		  cout<<dp[n];
	    cout<<endl;
    }
    return 0;
}

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

int main() {

	string s; cin >> s;	
	string a = "dream";
	string b = "dreamer";
	string c = "erase";
	string d = "eraser";
	reverse(s.begin(), s.end());
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	reverse(d.begin(), d.end());
	int na = a.size(); // 5
	int nb = b.size(); // 7
	int nc = na;       // 5
	int nd = d.size(); // 6
	string tmp_s = s;
	bool can = true;
	while (na <= tmp_s.size()) {		
		if (nb <= tmp_s.size()) {
			if (tmp_s.substr(0, na) == a || tmp_s.substr(0, nc) == c) {
				tmp_s = tmp_s.substr(na);
			}
			else if (tmp_s.substr(0, nb) == b) {
				tmp_s = tmp_s.substr(nb);
			}
			else if (tmp_s.substr(0, nd) == d) {
				tmp_s = tmp_s.substr(nd);
			}
			else {
				can = false;
				break;
			}
		}
		else if (tmp_s.size() == nd) {
			if (!(tmp_s == d)) {
				can = false;
				break;
			}
			else break;
		}
		else if (tmp_s.size() == na) {
			if (!(tmp_s == a || tmp_s == c)) {
				can = false;
				break;
			}
			else break;
		}
		else {
			can = false;
			break;
		}
	}
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>                        
#define pb push_back                            
#define mp make_pair                            
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)((x).size())
#define endl "\n"
#define jonathan ios_base::sync_with_stdio(0)
#define livingston cin.tie(0)
using namespace std;                            
                                                
void yes() {cout << "YES" << endl;}                                               
void no() {cout << "NO" << endl;}                                                        
                                                
int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};         
int dy[] = {0, 1, 0, -1, -1, 1, -1, 1}; 
 
const int INF = 1e9 + 9;
const long long LINF = 8e18 + 8;
const double EPS = 1e-9;
const long long MOD = 998244353;

void solve() {
    int n, m, k; cin >> n >> m >> k;
    long long dp[n + 1], new_dp[n + 1], window[n + 1], a[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        dp[i] = a[i];
    }
    for (int j = 2; j <= k; j++) {
        deque<int> q;
        for (int i = 1; i <= m; i++) {
            while (!q.empty() and dp[i] >= dp[q.back()]) {
                q.pop_back();
            }
            q.push_back(i);
        }
        for (int i = m + 1; i <= n; i++) {
            window[i - m] = dp[q.front()];
            while (!q.empty() and q.front() <= i - m) {
                q.pop_front();
            }
            while (!q.empty() and dp[i] >= dp[q.back()]) {
                q.pop_back();
            }
            q.push_back(i);
        }
        window[n + 1 - m] = dp[q.front()];
        for (int i = 2; i <= n; i++) dp[i] = max(dp[i - 1], dp[i]);
        for (int i = 1; i <= n; i++) new_dp[i] = -LINF;
        for (int i = j; i <= n; i++) {
            new_dp[i] = 1ll * j * a[i];
            if (i - m < 1) new_dp[i] += dp[i - 1];
            else new_dp[i] += window[i - m];
        }
        for (int i = 1; i <= n; i++) dp[i] = new_dp[i];
    }
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        res = max(res, dp[i]);
    }
    cout << res << endl;
}
 
int main() {
    jonathan; 
    livingston;
    solve();
    return 0;
}

Measured memory_bytes: 6792
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    _ = ii()
    L = lmi()
    print('APPROVED') if all(map(lambda x: x%2==1 or x%6==0 or x%10==0, L)) else print('DENIED')

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++){
		cin >> x[i];
		y[i] = x[i];
	}
	sort(x.begin(), x.end());
	int midsmall = x[n/2-1];
	int midlarge = x[n/2];

	for (int i = 0; i < n; i++){
		if (y[i] <= midsmall){
			cout << midlarge << endl;
		}else{
			cout << midsmall << endl;
		}
	}
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  sort(a.rbegin(), a.rend());
  if (n == 2) {
    cout << a[0] << endl;
    return 0;
  }
  queue<int> q;
  q.push(a[0]);
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    ans += q.front();
    q.pop();
    q.push(a[i]);
    q.push(a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4840
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#なお、任意の整数 M に対して M の −2 進数表現が一意に定まることが証明できます。
#2桁ごとに見るとよかった（もう実験したよ）
def resolve():
    A=list(pin())
    ans=0
    for i in range(10**6):
        #print(A)
        B=[0]*3
        for a in range(3):
            if A[a]%2!=0:print(ans);return
        B[0]=(A[1]+A[2])//2
        B[1]=(A[0]+A[2])//2
        B[2]=(A[0]+A[1])//2
        A=B[:]
        ans+=1
    print(-1)
    
                
    
#%%submit!
resolve()

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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define range(v) v.begin(),v.end()
#define int long long
#define pb push_back
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


int solve() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &i : a) cin >> i;
	sort(range(a));
	int ans = 0, i = 0;
	while (k--) ans += a[i++];
	return ans;
}

int32_t main() {
	fast
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 3660
let a = [1;3;5;7;8;10;12];;
let b = [4;6;9;11];;
let c = [2];;

let (x, y) = Scanf.scanf "%d %d" (fun x y -> (x, y));;
let ans =
  if List.mem x a && List.mem y a then
    "Yes"
  else if List.mem x b && List.mem y b then
    "Yes"
  else if List.mem x c && List.mem y c then
    "Yes"
  else
    "No";;
let () = print_endline ans;;


Measured memory_bytes: 384
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int cnt[4];

int main() {
    char t[8];
    int x;
    while (scanf("%d,%s", &x, t) != EOF) {
        if (t[1] == 'B') cnt[2]++;
        else if (t[0] == 'A') cnt[0]++;
        else if (t[0] == 'B') cnt[1]++;
        else if (t[0] == 'O') cnt[3]++;
    }
    rep (i, 4) printf("%d\n", cnt[i]);
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793)
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

const int limit = 100010;
struct edge { int to; ll cost; };
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d) {
	depth[v] = d;
	/*for (vector<edge>::iterator itr = tree[v].begin(); itr != tree[v].end(); ++itr) {
		edge e = *itr;
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}*/
	for (int i = 0; i < tree[v].size(); ++i) {
		edge e = tree[v][i];
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}

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

	for (int i = 0; i < n - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		tree[a].push_back({ b,c });
		tree[b].push_back({ a,c });
	}

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		cout << depth[x] + depth[y] << endl;
	}
}

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

Measured memory_bytes: 15872
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << (a<b?a:b)+(c<d?c:d) << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))

B = set(a) #ユニークな要素のリスト
d = Counter(a)

num = len(B) - k #消すべき要素の種類

c = d.most_common()
ans = 0
for i in range(1, num+1):
  ans += c[-i][1]
print(ans)

Measured memory_bytes: 50484
import java.util.*;
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int[] dpA = new int[N+1];
        int[] dpB = new int[N+1];
        int[] dpC = new int[N+1];
        for (int i = 1; i <= N; i++) {
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	int c = sc.nextInt();
        	
        	dpA[i] = a + Math.max(dpB[i-1], dpC[i-1]);
        	dpB[i] = b + Math.max(dpA[i-1], dpC[i-1]);
        	dpC[i] = c + Math.max(dpA[i-1], dpB[i-1]);
        }
        
        System.out.println(Math.max(dpA[N], Math.max(dpB[N], dpC[N])));
    }
}



Measured memory_bytes: 94756
# coding: utf-8

def main():
    x, k, d = map(int, input().split())
    x  = abs(x)
    tmp = min(x // d, k)
    x = x - (d * tmp)
    k = k - tmp
    if k % 2 == 0:
        print(x)
    else:
        print(abs(x - d))

main()


Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
using Int = int64_t;
using Float = double;

int main() {
  Int K;
  cin >> K;
  if (K <= 9) {
    cout << K << endl;
    return 0;
  }
  auto v = vector<Int>(K+1);
  for(auto i=1; i<=9; i++) {
    v[i] = i;
  }
  
  int p = 1;
  int k = 10;
  while(true) {
    int p1 = v[p] % 10;
    Int p10 = v[p] * 10;
    for(int off=max(p1-1, 0); off <= min(p1+1, 9); ++off) {
      v[k++] = p10 + off;
      if (k > K) {
        cout << v[K] << endl;
        return 0;
      }
    }
    p += 1;
  }
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
t = []
d = False
k = 0
for i in range(1,n):
  if a[i-1] == a[i]:
    if d:
      t[k].append(a[i])
    else:
      t.append([a[i-1], a[i]])
      d = True
  elif d:
    d = False
    k += 1
c = 0
for j in t:
  c += len(j)//2
print(c)

Measured memory_bytes: 3064
import sys

def solve():
    n = int(sys.stdin.readline())
    ans = 0

    for i in range(n):
        num = int(sys.stdin.readline())

        ans += is_prime(num)

    print(ans)

def is_prime(n):
    if n < 2 or (n > 2 and n & 1 == 0):
        return False

    for p in range(3, n + 1, 2):
        if p*p > n:
            break
        if n % p == 0:
            return False

    return True

if __name__ == '__main__':
    solve()

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

vector<vector<int> > dataset;
vector<int> temp;

int main() {
	int data[3] = {0, 0, 0};
	int i, j, flag;
	int sum_exam_points;
	i = 0;
	j = 0;
	flag = 0;

	while(1) {
		cin >> data[0] >> data[1] >> data[2];
		if(data[0] == -1 && data[1] == -1 && data[2] == -1)
			break;
		for(i = 0; i < 3; i++)
			temp.push_back(data[i]);
		dataset.push_back(temp);
		temp.clear();
	}

	for(i = 0; i < dataset.size(); i++) {
		sum_exam_points = dataset[i][0] + dataset[i][1];
		if(sum_exam_points >= 80) flag = 1;
		if(sum_exam_points >= 65 && sum_exam_points < 80) flag = 2;
		if(sum_exam_points >= 50 && sum_exam_points < 65) flag = 3;
		if(sum_exam_points >= 30 && sum_exam_points < 50) flag = 4;
		if(sum_exam_points < 30) flag = 0;
		if(dataset[i][0] == -1 || dataset[i][1] == -1) flag = 0;

		switch(flag) {
			case 0:
				cout << "F" << endl;
				break;
			case 1:
				cout << "A" << endl;
				break;
			case 2:
				cout << "B" << endl;
				break;
			case 3:
				cout << "C" << endl;
				break;
			case 4:
				if(dataset[i][2] >= 50) {
					cout << "C" << endl;
					break;
				} else {
					cout << "D" << endl;
					break;
				}
		}
	}
}

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

int main() {
    string S;
    cin >> S;
    ll mod = 2019;
    int K = S.size();
    vector<ll> pow10(K+1, 1);
    for (int i = 1; i <= K; i++) pow10[i] = pow10[i-1] * 10 % mod;
    map<ll, ll> mp;
    ll ans = 0;
    ll now = 0;
    mp[0] = 1;
    for (int i = K-1; i >= 0; i--) {
        now = (now + (ll)(S[i]-'0') * pow10[K-1-i]) % mod;
        ans += mp[now];
        mp[now]++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5244
#include <iostream>

int main()
{
    std::ios_base::sync_with_stdio(false);
    int N, S = 0, n;
    std::cin >> N;
    n = N;
    while (n > 0) {
        S += n % 10;
        n /= 10;
    }
    std::cout << (N % S == 0 ? "Yes" : "No") << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + (c ^ 48), c = getchar();
	return f * x;
}

int n, m, k;

int main()
{
	//File("");
	n = gi(), m = gi(), k = gi();
	int mm = max(n, m);
	if (k % mm == 0) cout << k / mm << endl;
	else cout << k / mm + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int h, w, n; cin >> h >> w >> n;
    int mx = max(h,w);
    cout << (n+mx-1)/mx << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(10);
    double T, X;
    cin >> T >> X;
    cout << (T / X) << endl;
    return 0;
}

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

int count_keta(int n, int count){
    if(n<10){
        return count + 1;
    }
    else{
        return count_keta(n / 10, count + 1);
    }
}
int main()
{
    int N;
    cin >> N;

    int count = 0;
    for (int n = 1; n <= N; n++)
    {
        if(count_keta(n, 0)%2 != 0){
            count += 1;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import math
a,b=map(int,input().split())

def factorization(n):
    arr=[]
    tmp=n
    for i in range(2,int(n**0.5)+1):
        while tmp%i==0:
            tmp//=i
            arr.append(i)
    if tmp!=1:
        arr.append(tmp)
    if arr==[]:
        arr.append(n)
    return list(set(arr))

ans=len(factorization(math.gcd(a,b)))
print(ans+1 if math.gcd(a,b)!=1 else 1)

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

using namespace std;

const long long int MOD = 1000000007;

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


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


	cin >> N;
	M = N;
	while (M) {
		K += M % 10;
		M /= 10;
	}
	if (N%K) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}
	return 0;
}

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

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

	ll A, B, C;
	cin >> A >> B >> C;
	
	C = min(C, A + B + 1);

	cout << B + C << endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<Integer>();
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            list.add(Integer.parseInt(scanner.next()));
        }
        Collections.sort(list);
        Collections.reverse(list);
        for (int i = 0; i < 3; i++) {
            System.out.println(list.get(i));
        }
    }
}

Measured memory_bytes: 17280
#include<stdio.h>
int main(void){
	char s[10000];
	int n,i;
	scanf("%d%s",&n,s);
	for(i=0;s[i]!='\0';i++){
		printf("%c",s[i]+n<='Z'?s[i]+n:s[i]-'Z'+'A'+n-1);
	}
	return 0;
}


Measured memory_bytes: 1672
S, T = input(), input()
l1, l2 = [i for i in S], [i for i in T]
l1.sort()
l2.sort(reverse=True)
S1, T1 = "", ""
for i in range(len(l1)):
  S1 = S1[:] + l1[i]
for i in range(len(l2)):
  T1 = T1[:] + l2[i]
if S1 < T1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    while(true) {
        string s;
        cin>>s;
        if(cin.eof()) break;
        int joi=0,ioi=0;
        REP(i,s.size()-2) {
            string sub=s.substr(i,3);
            if(sub=="JOI") joi++;
            if(sub=="IOI") ioi++;
        }
        cout<<joi<<endl;
        cout<<ioi<<endl;
    }
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){
	cin.sync_with_stdio(0);
	cout << fixed << setprecision(8);
	// cin.tie(0);

	ll n;
	double as = 0.0;

	cin >> n;

	FOR(i,0,n) {
		ll a;
		cin >> a;
		as += 1.0/a;
	}

	cout << 1.0/as << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int gint(){
	char c; int f=1;
	while(c=getchar(),c<48||c>57)
		if(c=='-')f=-1;
	int x=0;
	for(;c>47&&c<58;c=getchar()){
		x=x*10+c-48;
	}
	return x*f;
}

#define max_N 200005
#define mod 1000000007

int n,a[max_N],s,pre,nex;

bool vis[max_N];

int inv[max_N],f[max_N],invf[max_N];

inline int C(int n,int m){
	if(n<m)return 0;
	return 1ll*f[n]*invf[m]%mod*invf[n-m]%mod;
}

int main(){
	n=gint();
	for(int i=1;i<=n+1;++i)a[i]=gint();
	for(int i=1;i<=n+1;++i){
		if(vis[a[i]])s=a[i];
		vis[a[i]]=1;
	}
	for(int i=1;i<=n+1&&a[i]!=s;++i)++pre;
	for(int i=n+1;i&&a[i]!=s;--i)++nex;
	f[0]=invf[0]=1;
	inv[1]=f[1]=invf[1]=1;
	for(int i=2;i<=nex+pre||i<=n+1;++i){
		inv[i]=mod-1ll*(mod/i)*inv[mod%i]%mod;
		f[i]=1ll*f[i-1]*i%mod;
		invf[i]=1ll*invf[i-1]*inv[i]%mod;
	}
	for(int i=1;i<=n+1;++i){
		int ans=(C(n+1,i)-C(pre+nex,i-1)+mod)%mod;
		printf("%d\n",ans);
	}
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    if (M1 != M2)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long x;
	int i;
	long long num;
	scanf("%lld",&x);
	num=100;
	for(i=1;i<3770;i++)
	{
		num*=1.01;
		if(num>=x)
		{
			printf("%d\n",i);
			break;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 1732
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// chrono::steady_clock sc;
 //  	auto start = sc.now();
 //  	ifstream cin;
 //  	cin.open("INPUT.txt");

	int H,W;
	cin>>H>>W;
	int ans=H*W;
	int h,w;
	cin>>h>>w;
	ans=ans-h*W;
	ans=ans-w*(H-h);
	cout<<ans<<endl;
	
	// cin.close();
	// auto end = sc.now();
 //   	auto time_span = static_cast<chrono::duration<double>>(end - start);
 //   	cout<<"Operation took: "<<time_span.count()<<" seconds";

	return 0;
}

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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007

int main()
{
	FASTIO;
	ll a,x;
	ld b;
	cin>>a>>b;
	x=a*b;
	cout<<x;


}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

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

  int change = 0;
  for (int i=1; i<n; ++i) if (s[i] == 'E') ++change;

  int ans = change;
  for (int i=1; i<n; ++i) {
    if (s[i-1] == 'W') ++change;
    if (s[i] == 'E') --change;
    ans = min(ans, change);
  }

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


Measured memory_bytes: 900
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		if ((i+1) % 2 == 1 && a % 2 == 1)
			++ans;
	}
	cout << ans << endl;
}



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

int n,m;
long long ans,dp[3010][3010][2];
const long long mod=1e9+7;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	dp[0][i][0]=1;
	dp[0][0][1]=1;
	for(int i=1;i<=m;++i)
	{
		for(int j=0;j<=n;++j)
		{
			if(j>=1)
			{
				dp[i][j-1][1]=(dp[i][j-1][1]+dp[i-1][j][1])%mod;
				dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][1])%mod;
			}
			if(j>=2)
			{
				dp[i][j-1][0]=(dp[i][j-1][0]+dp[i-1][j][0])%mod;
				dp[i][j][0]=(dp[i][j][0]+dp[i-1][j][0])%mod;
			}
			if(j==1)
			{
				dp[i][j-1][1]=(dp[i][j-1][1]+dp[i-1][j][0])%mod;
				dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][0])%mod;
			}
			if(j<n)
			{
				dp[i][j+1][0]=(dp[i][j+1][0]+dp[i-1][j][0])%mod;
				dp[i][j+1][1]=(dp[i][j+1][1]+dp[i-1][j][1])%mod;
				dp[i][j][0]=(dp[i][j][0]+dp[i-1][j][0])%mod;
				dp[i][j][1]=(dp[i][j][1]+dp[i-1][j][1])%mod;
			}
		}
	}
	for(int i=0;i<=n;++i)
	ans=(ans+dp[m][i][1])%mod;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  ll x;
  cin>>x;
  vector<ll> d(1001);
  rep(i,1001){
    d[i]=1;
    rep(j,5){
      d[i]*=i;
    }
  //  cout<<d[i]<<endl;
  }
  ll A,B;
  rep(i,1001)rep(j,1001){
    ll a1,b1;

    a1=d[i];
    b1=d[j];
  //  cout<<a1<<' '<<b1<<endl;
    if (a1-b1==x){
      A=i;
      B=j;
      cout<<A<<' '<<B;
      return 0;
    }
    if (a1+b1==x){
      A=i;
      B=-j;
      cout<<A<<' '<<B;
      return 0;
    }

  }

}


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

template <class T = long long>
struct BIT_Range_Add_Point_Get {
	// 区間更新・点取得
	//階差数列のBITを作って端から足す方針 vec[i] = data[i-1]-data[i-2];
	vector<T> vec;
	int n;
	BIT_Range_Add_Point_Get(int sz) : vec(sz + 1, 0), n(sz) {}
	//元の値に足す 更新は不可
	void add(int lef, int rig, T val, int index = 0) {
		if(!index) {
			lef++;
			rig++;
		}
		for(int x = lef; x <= n; x += x & -x) vec[x] += val;
		for(int x = rig; x <= n; x += x & -x) vec[x] -= val;
	}
	//端からの合計値 = 値計算
	T get(int a, int index = 0) {
		a += 1 - index;
		T ret = 0;
		for(int x = a; x > 0; x -= x & -x) ret += vec[x];
		return ret;
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	BIT_Range_Add_Point_Get<int> b(n);
	for(int i = 0; i < q; i++) {
		int com;
		cin >> com;
		if(com) {
			int idx;
			cin >> idx;
			cout << b.get(idx - 1) << endl;
		} else {
			int s, t, x;
			cin >> s >> t >> x;
			b.add(s - 1, t, x);
		}
	}
}



Measured memory_bytes: 3144
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let [n,x] = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  li <- BS.getLine
  let xs = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n x xs
  print ans

compute :: Int -> Int -> [Int] -> Int
compute n x xs = w
  where
    xs1 = sort (x:xs)
    w = foldl1' gcd $ zipWith subtract xs1 (tail xs1)


Measured memory_bytes: 21144