akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> a(m);
    int ans = 0;
    rep(i,m){
        cin >> a[i].first >> a[i].second;
    }
    sort(ALL(a),greater<>());
    int x = 1e9+7; // x:= x番目とx-1番目の間の端を切った
    rep(i,m){
        if(x > a[i].second){
            ans++;
            x = a[i].first+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

    int div = 1e9 + 7;

    map<int, int> A;
    if (N % 2 == 0) {
        for (int i = 0; i < N; i++) {
            int tmp;
            cin >> tmp;
            tmp = (tmp - 1) / 2;
            A[tmp]++;
        }
    } else {
        for (int i = 0; i < N; i++) {
            int tmp;
            cin >> tmp;
            tmp = tmp / 2;
            A[tmp]++;
        }
    }
    if (N % 2 == 1 && A[0] != 1) {
        cout << 0 << endl;
        return 0;
    }

    // for (auto a : A) {
    // cout << a.first << " " << a.second << endl;
    // }

    int before = -1;
    int count = 0;
    for (auto a : A) {
        if (N % 2 == 1 && a.first == 0) {
            before = 0;
            continue;
        }
        if (a.second != 2 || a.first != before + 1) {
            cout << 0 << endl;
            return 0;
        }
        count++;
        before = a.first;
    }

    ll output = 1;
    for (int i = 0; i < count; i++) {
        output *= 2;
        output %= div;
    }
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vi A(N),B(M);
  rep(i,0,N) cin>>A[i];
  rep(i,0,M) cin>>B[i];
  int ans=1;
  sort(ALL(A));
  sort(ALL(B));
  rep(i,1,N){
    if(A[i]==A[i-1]){
      cout<<0<<endl;
      return 0;
    }
  }
  rep(i,1,M){
    if(B[i]==B[i-1]){
      cout<<0<<endl;
      return 0;
    }
  }
  REP(i,1,N*M){
    int X=dislow(A,i),Y=dislow(B,i);
    int sum=1;
    if(A[X]!=i) sum*=N-X;
    if(B[Y]!=i) sum*=M-Y;
    if(A[X]!=i&&B[Y]!=i) sum-=N*M-i;
    ans*=sum;
    ans%=MOD;
  }
  cout<<ans<<endl;
  }



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	int N; cin >> N;
	int X = (int)(N / 1.08);
	
	if(((int)X * 1.08) == N) cout << X << endl;
	else if((int)((X+1) * 1.08) == N) cout << X + 1 << endl;
	else cout << ":(" << endl;
	

	return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	string s, t;

	cin>>s>>t;

	vvll hist1(26), hist2(26);

	rep(i, s.size()){
		hist1[t[i]-'a'].push_back(i);
		hist2[s[i]-'a'].push_back(i);
	}

	bool flag=true;

	rep(i, 26){
		if(hist1[i].size()>1){
			rep(j, hist1[i].size()-1){
				if(s[hist1[i][j]]!=s[hist1[i][j+1]]){
					flag=false;
				}

			}
		}
		if(hist2[i].size()>1){
			rep(j, hist2[i].size()-1){
				if(t[hist2[i][j]]!=t[hist2[i][j+1]]){
					flag=false;
				}
			}
		}
	}
	cout<<yn(flag)<<endl;
	
}


Measured memory_bytes: 4616
import bisect
N, M, K = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

Asums = [0] * (N + 1)
for i, a in enumerate(A):
    Asums[i+1] = Asums[i] + a

Bsums = [0] * (M + 1)
for i, b in enumerate(B):
    Bsums[i+1] = Bsums[i] + b

ans = 0
for anum in range(N + 1):
    t = Asums[anum]
    if K < t:
        break
    bnum = bisect.bisect_right(Bsums, K - t) - 1
    ans = max(ans, anum + bnum)
print(ans)

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

int ok=0;

typedef struct{
	int mp[10][10];//現在のマップの状態
	int n;//残り落とせる数
	int x;//
	int y;//見るべき点
	int dr;//落とした回数
	int lst[12][3];//落とした点
	int sum;//濃さ合計
}state;

stack<state>S;

int drpx[13]={0,0,1,0,-1,1,1,-1,-1,0,2,0,-2};
int drpy[13]={0,1,0,-1,0,1,-1,1,-1,2,0,-2,0};

void dfs(state t){
	//cout<<t.x<<" "<<t.y<<" "<<t.n<<" "<<t.sum<<endl;
	if(ok)return;
	if(t.n==0 && t.sum==0){
		for(int i=0;i<t.dr;i++){
			cout<<t.lst[i][0]<<" "<<t.lst[i][1]<<" "<<t.lst[i][2]<<endl;
		}
		ok=1;
		return;
	}
	if(t.n<=0)return;
	if(t.sum<5)return;
	if(t.y>=10)return;
	
	
	if(t.mp[t.x][t.y]==0){
		t.x++;
		if(t.x>=10){
			t.x=0;
			t.y++;
		}
		S.push(t);
		return;
	}
	
	if(t.x<=8&&t.y<=7 && t.x>=1){
		
		int k=1;
		int flg=1;
		
		for(int i=0;i<=k*4;i++){
			t.mp[t.x+drpx[i]][t.y+drpy[i]+1]--;
			if(t.mp[t.x+drpx[i]][t.y+drpy[i]+1]<0)flg=0;
		}
		t.sum-=1+k*4;
		t.n--;
		t.lst[t.dr][0]=t.x;
		t.lst[t.dr][1]=t.y+1;
		t.lst[t.dr][2]=k;
		t.dr++;
		if(flg)S.push(t);
		t.dr--;
		t.n++;
		t.sum+=1+k*4;
		for(int i=0;i<=k*4;i++){
			t.mp[t.x+drpx[i]][t.y+drpy[i]+1]++;
		}
	}
	
	if(t.x<=7&&t.y<=7){
		int k=2;
		int flg=1;
		
		for(int i=0;i<=k*4;i++){
			t.mp[t.x+drpx[i]+1][t.y+drpy[i]+1]--;
			if(t.mp[t.x+drpx[i]+1][t.y+drpy[i]+1]<0)flg=0;
		}
		t.sum-=1+k*4;
		t.n--;
		t.lst[t.dr][0]=t.x+1;
		t.lst[t.dr][1]=t.y+1;
		t.lst[t.dr][2]=k;
		t.dr++;
		if(flg)S.push(t);
		t.dr--;
		t.n++;
		t.sum+=1+k*4;
		for(int i=0;i<=k*4;i++){
			t.mp[t.x+drpx[i]+1][t.y+drpy[i]+1]++;
		}
	}
	if(t.x<=7&&t.y<=5 && t.x>=2){
		int k=3;
		int flg=1;
		
		for(int i=0;i<=k*4;i++){
			t.mp[t.x+drpx[i]][t.y+drpy[i]+2]--;
			if(t.mp[t.x+drpx[i]][t.y+drpy[i]+2]<0)flg=0;
		}
		t.sum-=1+k*4;
		t.n--;
		t.lst[t.dr][0]=t.x;
		t.lst[t.dr][1]=t.y+2;
		t.lst[t.dr][2]=k;
		t.dr++;
		if(flg)S.push(t);
		t.dr--;
		t.n++;
		t.sum+=1+k*4;
		for(int i=0;i<=k*4;i++){
			t.mp[t.x+drpx[i]][t.y+drpy[i]+2]++;
		}
	}
	
	
	return;
}

int main(){
	state fst;
	cin>>fst.n;
	fst.dr=0;
	fst.x=0;
	fst.y=0;
	fst.sum=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin>>fst.mp[j][i];
			fst.sum+=fst.mp[j][i];
		}
	}
	S.push(fst);
	
	while(ok==0){
		state t=S.top();
		S.pop();
		dfs(t);
	}
	
	return 0;
}


Measured memory_bytes: 1224
#include <iostream>
#define ll unsigned long long
using namespace std;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a * (b / gcd(a, b));}
int main() {
	int N; cin>>N;
	ll l, a;
	for (int i = 0; i < N; i++) {
		cin>>a;
		if (i) l = lcm(l, a);
		else l = a;
	}
	cout<<l<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int n;
#define  N (200010)
int a[N], b[N], c[N], d[N];
void print(int c[]){
    for (int i = 1; i <= n; ++i){
        printf("%d%c", c[i], " \n"[i == n]);
    }
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i){
        scanf("%d", a+i);
    }
    for (int i = 1; i <= n; ++i){
        scanf("%d", b+i);
    }
    int ans = 0;
    for (int i = 0, j = 1, T = 1; i <= 28; ++i, j=j*2+1, T<<=1){
        for (int k = 1; k <= n; ++k){
            c[k] = a[k] & j;
            d[k] = b[k] & j;
        }
        sort(c+1,c+n+1);
        sort(d+1,d+n+1);
        // print(c);
        // print(d);
        int cur = 0;
        for (int k = n, l1 = 1, l2 = 1, p1 = 1, p2 = 1; k; --k){
            while (l1 <= n && c[k] + d[l1] < T) ++l1;
            while (l2 <= n && c[k] + d[l2] < 2*T) ++l2;
            while (p1 <= n && c[k] + d[p1] < 3*T) ++p1;
            while (p2 <= n && c[k] + d[p2] < 4*T) ++p2;
            // printf("%d %d %d %d\n", l1,l2,p1,p2);
            cur ^= l2-l1+p2-p1 & 1;
        }
        ans ^= cur<<i;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef long double     ld;
typedef string          str;
#define all(x)			(x).begin(),(x).end()
#define Sort(x)			sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define endl            '\n'
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MAX1 = 2e5+7,
	     MOD = 1e9+7;

ll n, m;
string s, t, ans;

int main(){
	fast_io;
	cin >> n >> m;
	cout << n*m/__gcd(n,m);
    return 0;
}
/*                     now or never                         */


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	std::string S;
	std::cin >> S;
	
	if (S[2] == S[3] & S[4] == S[5])
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


Measured memory_bytes: 256
import Control.Monad

addPoints :: [String] -> [Int] -> [Int]
addPoints [sa, sb] [a, b] | sa > sb = [a + 3, b]
                          | sa < sb = [a, b + 3]
                          | otherwise = [a + 1, b + 1]

main :: IO ()
main = do
  n <- readLn
  inputs <- fmap (map words) $ replicateM n getLine
  putStrLn $ unwords $ map show $ foldr addPoints [0, 0] inputs

Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
int main()
{
    int M,N;
    cin >> N >> M;
    if(M==N)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  sort(A.begin(), A.end(), greater<int>());
  int ans = 0;
  rep(i, N) {
    if (i%2 == 0) {
      ans += A[i];
    }
    else {
      ans -= A[i];
    }
  }
  cout << ans << endl;

}

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

vector<long long int> X;
long long int mini = 2e15;

long long int abs_my(long long a) {
        if(a < 0) return -a;
        return a;
}
int main() {
        int N, K;
        cin >> N >> K;
        for(int i = 0; i < N; i++) {
                long long int tmp;
                cin >> tmp;
                X.push_back(tmp);
        }
        for(int i = 0; i < N ; i++) {
                if(i - (K - 1) >= 0) mini = min(mini, (X[i] - X[(i-K+1)]) + abs_my(X[i]));
                if(i + (K - 1) < N) mini = min(mini, (X[i+K-1] - X[i]) + abs_my(X[i]));
        }
        cout << mini << endl;
        return 0;
} 

Measured memory_bytes: 1400
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
d = sorted(list(map(int, input().split())))

diff = d[n//2:][0] - d[:n//2][-1]
if diff <= 0:
    print(0)
else:
    print(diff)


Measured memory_bytes: 86008
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[110];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<110;i++)c[i]=0;
		for(int i=0;i<a;i++){
			int d;scanf("%d",&d);c[d]++;
		}
		int ret=0;
		for(int i=1;i<=100;i++){
			for(int j=i;j<=100;j++){
				if(i+j<=b)continue;
				if(i==j)ret+=c[i]*(c[i]-1)/2;
				else ret+=c[i]*c[j];
			}
		}
		printf("%d\n",ret);
	}
}

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

int main(){
	string S;
	cin>>S;
	reverse(S.begin(),S.end());
	string a="maerd",b="remaerd",c="esare",d="resare";
	string ans;
	int i=0;
	while(true){
		//cout<<ans<<endl;
		if(ans==S)break;
		if(S.substr(i,5)==a){
			i+=5;
			ans+=a;
			continue;
		}
		else if(S.substr(i,7)==b){
			i+=7;
			ans+=b;
			continue;
		}
		else if(S.substr(i,5)==c){
			i+=5;
			ans+=c;
			continue;
		}
		else if(S.substr(i,6)==d){
			i+=6;
			ans+=d;
			continue;
		}
		break;
	}
	if(ans==S)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}



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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef long long ll;

#define maxn 200000

int a[maxn],b[maxn],c[maxn],d[maxn];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n; cin >> n;
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];

  int ans = 0;

  rep(k,30){ // k bit目
    ll tmp = 0; // k bit目が1の数
    ll t = 1ll << k;
    rep(i,n){
      c[i] = a[i] % (2 * t);
      d[i] = b[i] % (2 * t);
    }
    sort(d, d + n);
    rep(i,n){ // a_i
      tmp += lower_bound(d,d+n,2*t-c[i]) - lower_bound(d,d+n,t-c[i]);
      tmp += lower_bound(d,d+n,4*t-c[i]) - lower_bound(d,d+n,3*t-c[i]);
    }
    if(tmp % 2 == 1) ans += t;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll h, n;
	cin >> h >> n;
	vector<ll> A(n);
	rep(i, n) cin >> A[i];

	ll sum = 0;
	rep(i, n) sum += A[i];

	dunk(sum >= h ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int x,y,a,temp;
	scanf("%d%d",&x,&y);
	
	if(x<y){
		temp=x;
		x=y;
		y=temp;
	}
	
	a=x%y;
	while(a!=0){
		x=y;
		y=a;
		a=x%y;
	}
	
	printf("%d\n",y);
	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int a[100];
int main()
{
    int n,k,i,j,key,sum=0;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(k=1; k<=n; k++)
    {
        if(k>1)
            printf(" ");
        printf("%d",a[k]);
    }
    printf("\n");

    for(j=2; j<=n; j++)
    {
        key=a[j];
        i=j-1;
        while(i>=1&&a[i]>key)
        {
            a[i+1]=a[i];
            i--;
        }
        a[i+1]=key;
        for(k=1; k<=n; k++)
        {
            if(k>1)
                printf(" ");
            printf("%d",a[k]);
        }
        printf("\n");
    }
    return 0;
}


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

using namespace std;

int p[111111], q[30][111111];
int main()
{
	int N, m, n = 0;
	cin >> N >> m;
	for (int i = 0; i < N; i++) {
		int s, t, c;
		scanf("%d%d%d", &s, &t, &c);
		n = max(n, t);
		if (!q[--c][s])
			q[c][s--] = 1;
		if (q[c][t]) t--;
		else q[c][t] = 1;
		while (s < t) p[s++]++;
	}
	m = 0;
	for (int i = 1; i <= n; i++)
		m = max(m, p[i]);
	cout << m << endl;
	return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}
int counterBit(int x){
    if(x==0)return 0;
    return counterBit(x>>1)+(x&1);
}
int main(void)
{
    ll n;
    cin>>n;

    vector<int> res;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(n/i !=i)res.push_back(n/i);
            if(i*i==n)res.push_back(i);
        }
    }

//    rep(i,0,res.size())cout<<res[i]<<endl;
    ll ans=INF;
    for(int i=0;i<res.size()-1;i+=2){
        ll tmp=to_string(res[i]).size();
        ll tmp2=to_string(res[i+1]).size();
        ans=min(ans,max(tmp,tmp2));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  int H, W; cin >> H >> W;
  vector<string> field(H);
  rep(h, H) cin >> field[h];

  rep(h, H) rep(w, W) if(field[h][w] == '.') field[h][w] = '0';
  rep(h, H) rep(w, W) if(field[h][w] == '#'){
    REP(i, -1, 1) REP(j, -1, 1) if(0<=h+i && h+i<H && 0<=w+j && w+j<W){
      if(field[h+i][w+j] == '#') continue;
      field[h+i][w+j]++;
    }
  }

  rep(h, H) cout << field[h] << endl;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
c = list(range(0,int(N/4)+1))
d = list(range(0,int(N/7)+1))
ans = "No"
for i in range(len(c)):
    for j in range(len(d)):
        if N - (4*i + 7*j) == 0:
            ans = "Yes"
            break
print(ans)

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

int n, m;

int main(){
  for(int SET = 1; cin >> n >> m, n || m; SET++){
    int ans = 0;
    int rem[m + 1];
    memset(rem, 0, sizeof(rem));
    rem[0] = n;

    while(rem[m] == 0){
      int nrem[m + 1];
      memset(nrem, 0, sizeof(nrem));

      for(int i = 0; i < m; i++){
        if(rem[i] % 2 == 0){
          nrem[i + 1] += rem[i] / 2;
          nrem[0] += rem[i] / 2;
        }
        else{
          nrem[i + 1] += rem[i] / 2;
          nrem[i] += rem[i] % 2;
          nrem[0] += rem[i] / 2;
        }
      }

      for(int i = 0; i <= m; i++){
        rem[i] = nrem[i];
      }
      ans++;
    }

    cout << "Case " << SET << ": " << ans << endl;
  }
}

Measured memory_bytes: 1164
n, m = map(int, input().split())

MOD = 10 ** 9 + 7

ans = 0
if abs(n-m) <= 1:
    ans = 1
    for i in range(1, min(n,m)+1):
        ans *= i
        ans %= MOD
    if n != m:
        ans = ans * ans * (i + 1)
    else:
        ans = ans * ans * 2
    ans %= MOD

print(ans)


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

long a[100001]={};

int main(){
  int N,M,idx;
  cin >> N >> M;
  for(int i=0; i<M; i++){
    cin >> idx;
    a[idx]=-1;
  }
  a[0]=1;
  if(a[1]!=-1) a[1]=1;
  for(int i=2; i<N+1; i++){
    if(a[i]==-1) continue;
    if(a[i-1]==-1 && a[i-2]==-1) break;
    if(a[i-1]==-1){
      a[i] = a[i-2];
    }else if(a[i-2]==-1){
      a[i] = a[i-1];
    }else{
      a[i] = (a[i-1]+a[i-2])%1000000007;
    }
  }
  cout << a[N] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

ll a[100005] = {},wa[100005] = {},bwa[100005] = {};
    

int main(){
    ll n,k;
    cin >> n >> k;
    
    rep(i,1,n+1){
        cin >> a[i];
        wa[i] = a[i];
        wa[i] += wa[i-1];
        bwa[i] = bwa[i-1];
        if(a[i] > 0)bwa[i] += a[i];
    }

    ll ans = -linf;
    
    rep(i,0,n-k+1){
        ans = max(ans,(bwa[i] - bwa[0]) + (wa[i+k]-wa[i]) + (bwa[n] - bwa[i+k]));
        ans = max(ans,(bwa[i] - bwa[0]) + (bwa[n] - bwa[i+k]));
      
    }

    P(ans);
	
	return  0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>

using namespace std;




void Solution()
{
    int a, b, n;
    
    while(cin>>a>>b>>n)
    {
        int sum = 0;
        
        //algorithm
        for (int i = 0; i < n; i++)
        {
            a %= b;
            a *= 10; // for devided by b
            sum += a / b;  //only get the decimal place
        }
        
        cout<<sum<<endl;
    }
}

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

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,t;
    cin >> s >> t;
    int n= s.size(),ans=1e9;
    for(int i=0;i<n;i++){
        for(int j=0;i+j<=n;j++){
            string k = s.substr(i,j);
            if(k.size()!=t.size()) continue;
            int cnt = 0;
            for(int l=0;l<(int) t.size();l++){
                if(t[l]!=k[l]) cnt++;
            }
            ans = min(ans,cnt);
        }
    }
    cout << ans << endl;
}

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

#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)

#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)

#define getI(a) scanf("%d", &a) //next three are handy ways to get ints, it's also force you to use '&' sign
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)

#define wez(n) int (n); scanf("%d",&(n)) //handy if the input is right after the definition of a variable
#define wez2(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define wez3(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))

#define whileZ int T; getI(T); while(T--)
#define lastEle(vec) vec[vec.size()-1]
#define SZ(x) ((int)((x).size()))

#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) // traverse an STL data structure

#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"

#define PRESENT(c,x) ((c).find(x) != (c).end())

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short

//for map, pair
#define mp make_pair
#define fi first
#define se second

// for debug
#define printA(a,L,R) FE(i,L,R) cout << a[i] << (i==R?'\n':' ')
#define printV(a) printA(a,0,a.size()-1)

//for vectors
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;

int dp[100004][2]; // min removals

int main()
{
    wez(n);
    vector <ii> v;
    F(i,0,n) {
        wez2(x,l);
        v.pb(mp(x+l,x-l));
    } sort(ALL(v));
    int mx = v[0].fi;
    int cnt = 1;
    F(i,1,n) {
        if (v[i].se>=mx) {cnt++;
            mx = v[i].fi;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

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

        String str = scan.nextLine();
        char[] cStr = str.toCharArray();

        String num1 = new StringBuilder().append(String.valueOf(cStr[0])).append(String.valueOf(cStr[1])).toString();
        String num2 = new StringBuilder().append(String.valueOf(cStr[2])).append(String.valueOf(cStr[3])).toString();

        boolean num1MMFlg = false;
        boolean num2MMFlg = false;

        if(1 <= Integer.parseInt(num1) && Integer.parseInt(num1) <= 12){
            num1MMFlg = true;
        }

        if(1 <= Integer.parseInt(num2) && Integer.parseInt(num2) <= 12){
            num2MMFlg = true;
        }

        if(num1MMFlg && num2MMFlg){
            System.out.println("AMBIGUOUS");
            return;
        }

        if(num1MMFlg){
            System.out.println("MMYY");
            return;
        }

        if(num2MMFlg){
            System.out.println("YYMM");
            return;
        }

        System.out.println("NA");
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <vector>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L


const int N = 2e5 + 5;

 
int vis[N];


int32_t  main() {

	IOS;

 
	int a, b, h, m;

	cin >> a >> b >> h >> m;


	long double tmp1 = h * 5.0 + m / 60.0 * 5.0;
	//cout << tmp1 << endl;
	long double diff = abs(tmp1 - m);

	long double degree = diff * 6 ;
	//cout << degree << endl;
	long double rad = (degree * PI) / 180;

	long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *
		b) * cosl(rad);

	cout << fixed << showpoint << setprecision(20) << sqrt(rsq) << endl;

}

Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
   int i,n,even=0,odd=0;
   scanf("%d",&n);
   for(i=1; i<=n; i++){
       if(i%2==0){
           even++;
       }
       else odd++;
   }
   printf("%d",even*odd);

    return 0;
}


Measured memory_bytes: 760
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

MOD = 10 ** 9 + 7


def main(K, N, MOD):
    def fact_table(N, MOD):
        inv = np.empty(N, np.int64)
        inv[0] = 0
        inv[1] = 1
        for n in range(2, N):
            q, r = divmod(MOD, n)
            inv[n] = inv[r] * (-q) % MOD
        fact = np.empty(N, np.int64)
        fact[0] = 1
        for n in range(1, N):
            fact[n] = n * fact[n - 1] % MOD
        fact_inv = np.empty(N, np.int64)
        fact_inv[0] = 1
        for n in range(1, N):
            fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD
        return fact, fact_inv, inv

    fac, finv, _ = fact_table(2_000_010, MOD)
    f = np.zeros(K + 1, np.int64)
    f = fac[N - 1:K + N] * finv[N - 1] % MOD * finv[0:K + 1] % MOD

    x = 1
    for i in range(1, K + 1):
        x = (x * 25) % MOD
        f[i] = f[i] * x % MOD
    for i in range(1, K + 1):
        f[i] += f[i - 1] * 26
        f[i] %= MOD
    return f[-1]


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8)
    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main
K = int(readline())
N = len(read().rstrip())
print(main(K, N, MOD))


Measured memory_bytes: 73852
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a + w >= b && a <= b + w) {
            System.out.println(0);
        } else if (a + w < b) {
            System.out.println(Math.abs(a + w - b));
        } else {
            System.out.println(Math.abs(b + w - a));
        }
    }
}

Measured memory_bytes: 25300
from collections import defaultdict
n = int(input())
s = [input() for i in range(n)]
d = defaultdict(int)
for si in s:
    d[si] += 1
print('AC x {}'.format(d['AC']))
print('WA x {}'.format(d['WA']))
print('TLE x {}'.format(d['TLE']))
print('RE x {}'.format(d['RE']))

Measured memory_bytes: 16632
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <math.h>
#define MOD 1000000007
using namespace std;
#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll num[1000];
int main(){
    ll N;
    ll count = 0;
    cin >> N;
    ll sp = sqrt(N);
    ll a = 1,b = 1;
    for(int i=sp+1;i>1;i--){
        if(N%i==0){
            while(N%i==0){
            N/=i;
            num[count] = i;
            count++;
        }
        }
    }
    
    if(N!=1){
        num[count] = N;
        count++;
    }
    //sort(num,num+count);
    for(ll i=0;i<count;i++){
        if(b>=a)a*=num[i];
        else b*= num[i];
    }
    cout << a+b-2 << endl;;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

signed main(void) {
    int i,j;
    int n;
    cin >> n;
    vi a(n+1,0);
    rep(i,n) cin >> a[i+1];
    rep(i,n) a[i+1] += a[i];
    map<int,int>mp;
    rep(i,n+1)mp[a[i]]++;
    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        int t = itr->second;
        ans += t*(t-1)/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

//s.find_by_order(index);
//s.order_of_key(value);
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){
    string s,t; cin>>s>>t;
    if(t.substr(0,sz(s)) == s) {cout<<"Yes";}
    else cout<<"No";
    return 0;
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}  

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int res =n;
    for(int i=0;i<=n;i++){
        int cc = 0;
        int t = i;
        while(t>0)cc+=t%6,t/=6;
        t=n-i;
        while(t>0)cc+=t%9,t/=9;
        if(res >cc)res=cc;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    l = [2, 3, 4, 5, 6, 7, 8, 9]
    if N == 1:
        print('Yes')
        return
    for i in range(8):
        c = N // l[i]
        r = N % l[i]
        if c > 0 and c < 10 and r == 0:
            print('Yes')
            return
    print('No')
main()

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

//static const ll MOD = 1e+9 + 7;
//static const int MAX = 10001;

int main() {

    int N; cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        B[i] = A[i];
    }

    sort(B.begin(), B.end(), greater<int>());
    if (B[0] == B[1]) {
        for (int i = 0; i < N; i++) {
            cout << B[0] << '\n';
        }
    }
    else {
        for (int i = 0; i < N; i++) {
            if (A[i] != B[0]) {
                cout << B[0] << '\n';
            }
            else {
                cout << B[1] << '\n';
            }
        }
    }
}



Measured memory_bytes: 3200
#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()
const int INF = 1e9;

int N,A,B,C;
vector<int> x;

int calc(int a, int b, int c) {
    return 
        abs(accumulate(x.begin(), x.begin() + a, 0) - A) + (a-1)*10 +
        abs(accumulate(x.begin()+a, x.begin() + b, 0) - B) + (b-a-1)*10 +
        abs(accumulate(x.begin()+b, x.begin() + c, 0) - C) + (c-b-1)*10;
}

int main(void){
    cin >> N >> A >> B >> C;
    x.resize(N);
    rep(i,N) cin >> x[i];
    sort(all(x));
    int res = INF;
    do {
        rep(c,N+1) rep(b,c) rep(a,b){
            if (a == 0) continue;
            res = min(res, calc(a,b,c));
        }
    } while(next_permutation(all(x)));
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n; 
    if (n%1000 == 0) PRINT(0);
    else PRINT(1000-n%1000);
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
int a=0;
string dait;
cin >> dait;

if (dait == "SUN") {
  a = 7;
} else if (dait == "TUE") {
  a = 5;
}else if (dait == "WED") {
  a = 4;
}else if (dait == "THU") {
  a = 3;
}else if (dait == "FRI") {
  a = 2;
}else if (dait == "SAT") {
  a = 1;
}else if (dait == "MON") {
  a = 6;
}
cout << a << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 2e5 + 10;
int a[M], vis[M];
int main(){
    ll ans = 0;
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]), vis[a[i]]++;
    for(int i = 1; i <= n; i++)
        if(vis[i]) ans += 1ll * vis[i] * (vis[i] - 1) / 2;
    for(int i = 1; i <= n; i++) {
        if(vis[a[i]]) ans -= 1ll * vis[a[i]] * (vis[a[i]] - 1) / 2;
        vis[a[i]]--;
        if(vis[a[i]]) ans += 1ll * vis[a[i]] * (vis[a[i]] - 1) / 2;
        printf("%lld\n", ans);
        if(vis[a[i]]) ans -= 1ll * vis[a[i]] * (vis[a[i]] - 1) / 2;
        vis[a[i]]++;
        if(vis[a[i]]) ans += 1ll * vis[a[i]] * (vis[a[i]] - 1) / 2;
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

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



struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r-l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    ll getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        ll vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }

};


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

    vector<P> section(n);
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        section[i] = make_pair(r-l+1, l);
    }

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

    LazySegmentTree seg(vector<ll> (m+1, 0));

    int i = 0;
    for (int d = 1; d <= m; d++) {
        while (section[i].first < d && i < n) {
            seg.add(section[i].second, section[i].second + section[i].first, 1);
            i++;
        }

        int ans = n-i;
        for (int j = 0; j <= m; j += d) {
            ans += seg.getsum(j, j+1);
        }
        cout << ans << endl;
    }
    



    return 0;

}


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

int main(){
	char ss[100000],sst[100000];//üÍpÆroßpÌ¶ñzñ
	int n,i,j,ki,a,b;
	
	
	while(0<=scanf("%d",&n)){
	
		if(n==0)break;
		scanf(" %s ",ss);
		
		while(n>0){
			--n;
			j=0;	//üÍ³ê½¶ñzñÌY
			i=0;	//roßÌ¶ñzñÌY
			
			//±Ìfor¶P[vÅÌ©½ÜèPÂð·é
			for(;;){
				if(ss[j]=='\0')break;
				ki=ss[j];
				b=1;
				
				//A±µÄ¢éð¦éiÂÍbÉüêéj
				for(a=j;;a++){
					if(ss[a]!=ss[a+1])break;
					++b;
				}
				
				//ªå«¢Ì
				if(b>99){
					sst[i]=b/100+'0';
					++i;
				}
				if(b>9){
					sst[i]=(b/10)%10+'0';
					++i;
				}
				
				sst[i]=b%10+'0';
				sst[i+1]=ki;
				i=i+2;
				j=a+1;
				sst[i]='\0';
				
			}
			
			//roßðüÍpzñÉüêÄ[v
//			strcpy(ss,sst);
			for(i=0;;i++){
				ss[i]=sst[i];
				if(sst[i]=='\0')break;
			}
		}
		printf("%s\n",sst);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define mo 1000000007
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 ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long n,m,i,j;
char s[505][505],ans1[505][505],ans2[505][505];
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
   	n=read();m=read();
   	for(i=1;i<=n;i++)
   		scanf("%s",s[i]+1);
   	for(i=1;i<=n;i++)
   		for(j=1;j<=m;j++){
			ans1[i][j]='.';
			ans2[i][j]='.';
		}
   	for(i=1;i<=n;i++)
   		for(j=1;j<=m;j++){
			if(i==1||(j&1)&&i!=n||s[i][j]=='#')
				ans1[i][j]='#';
			if(i==n||(j&1)==0&&i!=1||s[i][j]=='#')
				ans2[i][j]='#';
		}
	for(i=1;i<=n;i++)
		printf("%s\n",ans1[i]+1);
	cout<<endl;
	for(i=1;i<=n;i++)
		printf("%s\n",ans2[i]+1);
    return 0;
}

Measured memory_bytes: 1536
n,m,k = map(int,input().split())
a_list = list(map(int,input().split()))
check = [0]*(n+1)
for i in a_list:
    check[i-1] = 1
left = sum(check[0:k])
right = sum(check[k:n+1])
if left > right:
    print(right)
else:
    print(left)

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

int main() {
    string s;
    cin >> s;
    for (int i=0; i<s.size(); i++) {
        if (i % 2 == 0) {
            cout << s.at(i);
        } else {
            continue;
        }
    }
    return 0;
}


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

import math

X, K, D = map(int, input().split())

X = abs(X)
N = math.ceil(X/D)

if K < N:
    print(X-K*D)
    exit()
if N % 2 == K % 2 :
    print(abs(X-N*D))
else:
    print(abs(X-N*D+D))

Measured memory_bytes: 61940
#include <stdio.h>
#include <math.h>
#include <time.h>

int main(void) {
	char s[6];

	for (int i = 0; i < 6; i++) {
		scanf("%c", &s[i]);
	}
	if (s[2] == s[3] && s[4] == s[5]) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 1660
# coding: utf-8
"""Snuke's Coloring 2 (ABC Edit)

@author: hijiri.n
@modified: 11-19-2016

"""

def data(): return list(map(int, input().split()))


def solve():
    w, h, N = data()
    rect = [0, w, 0, h]

    for i in range(N):
        x, y, a = data()
        if [1, -1][a % 2] * ([x, y][a > 2] - rect[a - 1]) < 0:
            rect[a - 1] = [x, y][a > 2]

        if rect[1] <= rect[0] or rect[3] <= rect[2]:
            return 0
        
    return (rect[1] - rect[0]) * (rect[3] - rect[2])

print(solve())

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static char[] al = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
			't', 'u', 'v', 'w', 'x', 'y', 'z' };

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		Map<Integer, Integer[]> map = new HashMap<Integer, Integer[]>();
		for (int i = 0; i < N; i++) {
			char[] s = in.next().toCharArray();
			Integer[] count = new Integer[26];
			Arrays.fill(count, 0);
			for (int j = 0; j < s.length; j++) {
				count[s[j] - 'a'] += 1;
			}
			map.put(i, count);
		}
		int[] alCount = new int[26];
		for (int i = 0; i < al.length; i++) {
			int min = Integer.MAX_VALUE;
			for (Map.Entry<Integer, Integer[]> entry : map.entrySet()) {
				min = Math.min(min, entry.getValue()[i]);
			}
			alCount[i] = min;
		}
		StringBuilder ans = new StringBuilder();
		for (int i = 0; i < alCount.length; i++) {
			for (int j = 0; j < alCount[i]; j++) {
				ans.append(al[i]);
			}
		}
		System.out.println(ans.toString());
		in.close();
	}
}

Measured memory_bytes: 25300