akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf = 1e18;
ll p = 1e9 + 7;
ll power(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;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i, j, y, x, k, z, w, g, c, key, l, r, n, m, t;
    ll t2, t3, t4, t1;
    string s;
    cin >> n;
    ll arr[n];
    for (i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    ll ans = 0;
    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            if (arr[i] != arr[j])
            {
                ll sum = arr[i] + arr[j];
                for (k = j + 1; k < n; k++)
                {
                    if (arr[k] != arr[j])
                    {
                        if (sum > arr[k])
                            ans++;
                        else
                            break;
                    }
                }
            }
        }
    }
    cout << ans;




    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k,q,i,a;
	cin>>n>>k>>q;
	vector<int>br(n+1,0);
	for(i=0;i<q;i++)
	{
		cin>>a;
		br[a]++;
	}
	for(i=1;i<=n;i++)
	{
		if(k+br[i]-q>0)cout<<"Yes\n";
		else cout<<"No\n";
	}
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n=0,d,x,y,ans=0;
	scanf("%d%lld",&n,&d);
	d*=d;
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&x,&y);
		ans+=(x*x+y*y<=d);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <ctime>

using namespace std;

#define LOCAL 0
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1& arg1){
    cerr << name << ": " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1& arg1, Args&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " /";
    __f(comma + 1, args...);
}

template <class T> bool mini(T& a, T b) { return a > b ? (a = b, 1) : 0; }
template <class T> bool maxi(T& a, T b) { return a < b ? (a = b, 1) : 0; }

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const int INF = 1e9 + 7;

int main() {
#if LOCAL
    freopen("CP.inp", "r", stdin);
//    freopen("CP.out", "w", stdout);
#endif // LOCAL
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    string s; cin >> s;
    s.resize(unique(s.begin(), s.end()) - s.begin());
    cout << (int)s.size() << '\n';
    return 0;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        string answer = s.Substring(0, 4) + " " + s.Substring(4);

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25860
a = []
a = gets.split.map(&:to_i)

if a[0]*a[1]<=0
    puts "Zero"
    exit
end
if a[0]>0
    puts "Positive"
    exit
end
if (a[1]-a[0])%2 == 0
    puts "Negative"
else
    puts "Positive"
end

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

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(200001, 0);
    rep(i, n){
        int x; cin >> x;
        a[x] ++;
    }
    sort(a.begin(), a.end(), greater<int>());
    int rewrite = 0;
    for (int i = k; i < 200001; i++){
        rewrite += a[i];
    }
    cout << rewrite << endl;
}


Measured memory_bytes: 4024
MOD=10**9+7

def isvalid(bit):
    for t in range(W-2):
        if (bit>>t&1) and (bit>>(t+1)&1):
            return False
    return True

H,W,K=map(int,input().split())
dp=[[0]*W for i in range(H+1)]
dp[0][0]=1

for i in range(1,H+1):
    for k in range(W):
        l,c,r=0,0,0
        for bit in range(2**(W-1)):
            if not isvalid(bit):
                continue
            if ((k>0 and not(bit>>(k-1)&1)) or k==0) and ((k<W-1 and not(bit>>k&1))or k==W-1):
                c+=1
            if (k>0) and (bit>>(k-1)&1):
                l+=1
            if (k<W-1) and (bit>>k&1):
                r+=1
        dp[i][k]=(dp[i][k]+dp[i-1][k]*c)%MOD
        if k>0:
            dp[i][k]=(dp[i][k]+dp[i-1][k-1]*l)%MOD
        if k<W-1:
            dp[i][k]=(dp[i][k]+dp[i-1][k+1]*r)%MOD
print(dp[H][K-1])

Measured memory_bytes: 74468
s=input()
if s[0] == s[1] and s[0] != s[2] and s[0] != s[3] and s[2] == s[3]:
  print('Yes')
elif s[0] == s[2] and s[0] != s[1] and s[0] != s[3] and s[1] == s[3]:
  print('Yes')
elif s[0] == s[3] and s[0] != s[2] and s[0] != s[1] and s[2] == s[1]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char s[1000008];
int n,i,j,k,a[1000008];
int main() {
    for(scanf("%d%s",&n,s+1),--n; i++<n;
            i&1?0:a[i]=1+a[i>>1],j|=1==(s[i-1]=abs(s[i]-s[i+1])));
    if(j)
        for(i=n; i--; s[i]&=1);
    for(--n,k=s[i=j=0]; i++<n; (j+=a[n+1-i]-a[i])?0:k^=s[i]);
    printf("%d\n",k),exit(0);
}

Measured memory_bytes: 5120
#include<stdio.h>
int main(void)
{
  int max1=0;
  int max2=0;
  int max3=0;
  int i;
  int high;

  for(i=0;i<10;i++){
    scanf("%d", &high);
    if(high>=max1){
      max3=max2;
      max2=max1;
      max1=high;
    }else if(max1>high && high>=max2){
      max3=max2;
      max2=high;
    }else if(max2>high && high>=max3){
      max3=high;
    }
  }
  printf("%d\n", max1);
  printf("%d\n", max2);
  printf("%d\n", max3);

  return 0;
}

Measured memory_bytes: 600
import java.awt.Point;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			n = scanner.nextInt();
			Integer[][] x = new Integer[2][n];
			Integer[][] y = new Integer[2][n];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < 2; j++) {
					x[j][i] = scanner.nextInt();
					y[j][i] = scanner.nextInt();
				}
			h = slove(y, h);
			w = slove(x, w);
			boolean[][] map = new boolean[h][w];
			for (int i = 0; i < n; i++) {
				for (int j = y[0][i]; j < y[1][i]; j++)
					for (int k = x[0][i]; k < x[1][i]; k++)
						map[j][k] = true;
			}
			int ans = 0;
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					if (map[i][j])
						continue;
					ans++;
					map[i][j] = true;
					Deque<Point> deque = new ArrayDeque<Point>();
					deque.push(new Point(j, i));
					while (!deque.isEmpty()) {
						Point p = deque.poll();
						for (int[] m : move) {
							int ny = p.y + m[0];
							int nx = p.x + m[1];
							if (!isOK(ny, nx))
								continue;
							if (map[ny][nx])
								continue;
							map[ny][nx] = true;
							deque.push(new Point(nx, ny));
						}
					}
				}

			System.out.println(ans);
		}
	}

	private boolean isOK(int y, int x) {
		if (0 <= y && y < h && 0 <= x && x < w)
			return true;
		return false;
	}

	private int slove(Integer[][] xy, int hw) {
		NavigableSet<Integer> set = new TreeSet<Integer>();
		set.add(0);
		set.add(hw);
		set.addAll(Arrays.asList(xy[0]));
		set.addAll(Arrays.asList(xy[1]));
		Integer[] a = set.toArray(new Integer[0]);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 2; j++)
				xy[j][i] = Arrays.binarySearch(a, xy[j][i]);
		return a.length - 1;
	}

	int w, h, n;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
}

Measured memory_bytes: 39200
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 300000

struct Info{
	bool operator<(const struct Info &arg) const{
		return limit > arg.limit;
	}
	ll release,limit;
};

struct Data{
	Data(ll arg_release){
		release = arg_release;
	}
	bool operator<(const struct Data &arg) const{
		return release < arg.release;
	}
	ll release;
};

int N;
Info info[NUM];

bool check(ll num){

	priority_queue<Data> Q;

	ll sum = 0;

	for(int i = 0; i < num-1; i++){
		sum += info[i].release;
		Q.push(info[i].release);
	}

	int index = num-1;

	do{
		if(sum <= num*info[index].limit-info[index].release){
			return true;
		}
		sum += info[index].release;
		Q.push(Data(info[index].release));
		sum -= Q.top().release;
		Q.pop();
		index++;
	}while(index < N);

	return false;
}


int main(){

	scanf("%d",&N);

	for(int i = 0; i < N; i++){
		scanf("%lld %lld",&info[i].release,&info[i].limit);
	}

	sort(info,info+N);

	ll left = 0,right = N,m = (left+right)/2;
	ll ans = 0;

	while(left <= right){
		if(check(m)){
			ans = m;
			left = m+1;
		}else{
			right = m-1;
		}
		m = (left+right)/2;
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 13820
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define n 300000
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
struct edge{
	int to, weight;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
vector<edge> V[n + 50];
int a, b, c, d, e, f;
int arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;

void solve()
{
	cin >> a >> b >> c;
	if(a + b + c >= 22) cout << "bust";
	else			 	cout << "win"; 
}

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

int n, m;
int coins[25];
int dp[50100];
bool vis[50100];

int coinChange( int changeLeft )  {
    if (changeLeft == 0) return 0;
    if (changeLeft < 0) return 999999;

    if ( vis[changeLeft] ) return dp[changeLeft];
    vis[changeLeft] = 1;

    int res = 100000;
    for (int i = 0; i < m; ++i)
        res = min(res, coinChange( changeLeft - coins[i] ) + 1);
    
    return dp[changeLeft] = res;
}

int main() {    
    cin >> n >> m;
    for (int i = 0; i < m; ++i) cin >> coins[i];
    cout << coinChange( n ) << endl;
    return 0;
}




Measured memory_bytes: 5684
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int INF = 100000;
int n, x, y;
vi g[2000];
vec<bool> vis;
vi d;

int main() {
    fastio();

    cin >> n >> x >> y;
    x--, y--;

    forn(i, n - 1) {
        g[i].push_back(i + 1);
        g[i + 1].push_back(i);
    }
    g[x].push_back(y);
    g[y].push_back(x);

    vi ans(n);
    forn(i, n) {
        d = vi(n, INF);
        vis = vec<bool>(n, false);

        d[i] = 0;
        vis[i] = true;
        que<int> q({ i });

        while (!q.empty()) {
            int j = q.front();
            q.pop();

            for (auto p : g[j]) {
                if (vis[p]) continue;
                vis[p] = true;
                d[p] = d[j] + 1;
                q.emplace(p);
            }
        }

        forn(i, n) {
            ans[d[i]]++;
        }
    }

    for (int j = 1; j < n; j++) {
        cout << ans[j] / 2 << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
from collections import deque

def create_lunlun(n):
    q=deque([i for i in range(1,10)])
    count=0
    while count<n:
        count+=1
        a=q.popleft()
        if count==n:
            print(a)
            exit()
        for i in range(-1,2):
            d=a%10+i
            if d<0 or d>9:
                continue
            q.append(a*10+d)
    return q

def main():
    N=int(input())
    print(create_lunlun(N))

main()


Measured memory_bytes: 12396
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MAXN 100000
using namespace std;
typedef long long LL;
struct node
{
	int to;
	node *nxt;
}edges[MAXN*2+5];
node *ncnt,*Adj[MAXN+5];
int N,M,spx,spy;
LL sum[MAXN+5];
LL cirlen,dist[MAXN+5],xs[MAXN+5];
LL stk[MAXN+5],t;
bool vis[MAXN+5];
void Init()
{
	ncnt=&edges[0];
}
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->nxt=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->nxt=Adj[v];
	Adj[v]=q;
}
void DFS(int u,int fa)
{
	vis[u]=true;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==fa)
			continue;
		if(vis[v]==true)
		{
			spx=u,spy=v;
			cirlen=dist[v]-dist[u]+1;
			continue;
		}
		dist[v]=dist[u]+1;
		DFS(v,u);
	}
}
void GetXs(int u,int fa)
{
	vis[u]=true;
	for(node *p=Adj[u];p!=NULL;p=p->nxt)
	{
		int v=p->to;
		if(v==fa||vis[v]==true)//·ÀÖ¹·ÃÎÊspx,spyÄÇÌõ±ß
			continue;
		GetXs(v,u);
		xs[u]+=xs[v];
		sum[u]+=sum[v];
	}
}
int main()
{
//	freopen("print.in","r",stdin);
//	freopen("print.out","w",stdout);
	Init();
	scanf("%d %d",&N,&M);
	int u,v;
	for(int i=1;i<=M;i++)
	{
		scanf("%d %d",&u,&v);
		AddEdge(u,v);
	}
	dist[1]=0;
	DFS(1,-1);//ÇóÉî¶È/»·ÉÏµÄµã
	LL ans=0,tot=0;
	for(int i=1;i<=N;i++)
	{
		if(dist[i]%2==0)
			sum[i]=-1LL;
		else
			sum[i]=1LL;
		tot+=sum[i];
	}
	if(N-1==M)//´¦ÀíÊ÷
	{
		if(tot!=0)
		{
			printf("-1\n");
			return 0;
		}
	}
	else
	{
		if(cirlen%2==1)//´¦ÀíÆæ»·
		{
			if(tot%2!=0)
			{
				printf("-1\n");
				return 0;
			}
			sum[spx]-=tot/2;
			sum[spy]-=tot/2;
			ans+=abs(tot)/2;
		}
		else//´¦ÀíÅ¼»·
		{
			if(tot!=0)
			{
				printf("-1\n");
				return 0;
			}
			xs[spx]=1LL;
			xs[spy]=-1LL;
		}
	}
	memset(vis,0,sizeof(vis));
	GetXs(1,-1);//Èç¹ûÊÇÅ¼»·£¬ÕâÒ»²½²ÅÊÇÓÐÐ§µÄ²Ù×÷
	for(int i=1;i<=N;i++)
	{
		if(xs[i]==0)	ans+=abs(sum[i]);
		else
		{
			if(xs[i]==1)
				sum[i]=-sum[i];//³ËÉÏÏµÊý
			stk[++t]=sum[i];
		}
	}
	stk[++t]=0;
	sort(stk+1,stk+1+t);
	LL k=stk[(t+1)/2];
	for(int i=1;i<=t;i++)
		ans+=1LL*abs(stk[i]-k);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12032
/*ID:PROG:LANG:*/
#include<bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 998244353
#define MAXN 100005
using namespace std;
int n,m,k,ans,a[MAXN],b[MAXN],c[MAXN],u[MAXN],v[MAXN];
int rd(){
	int x=0,tp=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("1.out","w",stdout);
	int mn1=INF,mn2=INF;
	n=rd(),m=rd(),k=rd();
	for(int i=1;i<=n;i++)a[i]=rd(),mn1=min(a[i],mn1);
	for(int i=1;i<=m;i++)b[i]=rd(),mn2=min(b[i],mn2);
	ans=mn1+mn2;
	for(int i=1;i<=k;i++)u[i]=rd(),v[i]=rd(),c[i]=rd(),ans=min(ans,a[u[i]]+b[v[i]]-c[i]);
	printf("%d\n",ans);
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  vector<int> p(N);
  for (int &e : p) {
    cin >> e;
    sum += e;
  }
  
  if (sum % 10 != 0) {
    cout << sum << endl;
    return 0;    
  }
  
  sort(p.begin(), p.end());
  for (int i = 0; i < N; i++) {
    if (p[i] % 10 != 0) {
      cout << sum - p[i] << endl;
      return 0;
    }
  }
  
  cout << 0 << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val (A, B) = readLine()!!.split(" ").map{it.toInt()}
    val P = readLine()!!.split(" ").map{it.toInt()}
    val a = P.count { it <= A }
    val b = P.count { it in (A + 1) .. B }
    val c = N - a - b

    println(Math.min(a, Math.min(b, c)))
}

Measured memory_bytes: 36004
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		int a = sc.nextInt(), b = sc.nextInt();
		int ans[][] = new int[h][w];
		sc.close();
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(i<b) {
					if(j<a)ans[i][j]=1;
				}
				else {
					if(j>=a)ans[i][j]=1;
				}
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				sb.append(ans[i][j]);
			}
			sb.append("\n");
		}
		System.out.println(sb.toString());
	}
}


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

int merge_sort(int S[], int left, int right) {
    int cnt = 0;
    if (left == right) return cnt;
    int mid = (left + right) / 2;
    cnt += merge_sort(S, left   , mid  );
    cnt += merge_sort(S, mid + 1, right);
    queue<int> A;
    queue<int> B;
    for (int i = left; i <= mid; i++) {
        A.push(S[i]);
    }
    for (int i = mid + 1; i <= right; i++) {
        B.push(S[i]);
    }
    int j = left;
    while (!A.empty() && !B.empty()) {
        cnt++;
        if (A.front() <= B.front()) {
            S[j++] = A.front();
            A.pop();
        } else {
            S[j++] = B.front();
            B.pop();
        }
    }
    while (!A.empty()) {
        cnt++;
        S[j++] = A.front();
        A.pop();
    }
    while (!B.empty()) {
        cnt++;
        S[j++] = B.front();
        B.pop();
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; i++) {
        cin >> S[i];
    }
    int cnt = merge_sort(S, 0, n - 1);
    cout << S[0];
    for (int i = 1; i < n; i++) {
        cout << " " << S[i];
    }
    cout << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6856
#include<iostream>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int x,y;
	cin >>x>>y;
	if(y%2){
		cout << "No";
		return 0;
	}
	y=y/2;
	if(x<=y && y<=2*x){
		cout <<"Yes";
		return 0;
	}
	cout << "No";
	return 0;
}


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

int main(){
    int n, j, count,flag,tmp;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    count = 0;
    j = 0;
    flag = 1;
    while (flag==1) {
        flag = 0;
        for (int i=n-1; j < i; i--) {
            if (a[i] < a[i-1]) {
                tmp = a[i];
                a[i] = a[i-1];
                a[i-1] = tmp;
                flag = 1;
                count++;
            } 
        }
        j++;
    }
    for (int i=0; i<n-1; i++) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3112
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)

	switch {
	case n == "A":
		fmt.Println("T")
	case n == "T":
		fmt.Println("A")
	case n == "C":
		fmt.Println("G")
	case n == "G":
		fmt.Println("C")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define inf 1000000007
#define N 1000005
using namespace std;

int n, k, a[N], dp[N];

int f(int x){
	if(dp[x] != -1)
		return dp[x];
	if(x > n)
		return inf;
	if(x == n)
		return 0;
	dp[x] = inf;
	for(int i = 1; i <= k; i++)
		dp[x] = min(dp[x], abs(a[x + i] - a[x]) + f(x + i));
	return dp[x];
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	memset(dp, -1, sizeof dp);
	scanf("%d %d",&n ,&k);
	for(int i = 1; i <= n; i++)
		scanf("%d",a + i);
	printf("%d\n", f(1));
	return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end



int main(){
   int h,w,n; scanf("%d%d%d",&h,&w,&n);
   vector<int> x(n),y(n);
   map<int,vector<int>> mp;
   rep(i,0,n){
      scanf("%d%d",&x[i],&y[i]); x[i]--; y[i]--;
      x[i]-=y[i];
      if(x[i]>=0&&y[i]>=0)mp[y[i]].push_back(x[i]);
   }
   int res=h,lb=0;
   for(auto& p:mp){
      vector<int> v=p.second;
      sort(ALL(v));
      for(int pos:v){
         if(lb<=pos-1)chmin(res,pos+p.first);
         if(lb==pos)lb=pos+1;
      }
   }
   printf("%d\n",res);
   return 0;
}

Measured memory_bytes: 10240
a = []
3.times do
  a << gets.split.map(&:to_i)
end
m = Array.new(2){Array.new(3,0)}
mm = Array.new(2){Array.new(3,0)}
2.times do |i|
  3.times do |j|
    m[i][j] = a[j][i+1] - a[j][i+1]
    mm[i][j] = a[i][j] - a[i+1][j]
  end
end
2.times do |i|
  if (1 < m[i].uniq.size or 1 < mm[i].uniq.size)
    puts "No"
    exit
  end
end
puts "Yes"

Measured memory_bytes: 3836
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 

using namespace std;

int n,x,y;

bool check(int t,int xx,int x,int yy,int y)
{
	int len=abs(xx-x)+abs(yy-y);
	if(len>t)return false;
	
	if((t&1)==(len&1))return true;
	else return false;
}



int main()
{
	 scanf("%d",&n);
	 int t=0,x=0,y=0;
	 for(int i=0;i<n;i++)
	 {
	 	int tt,xx,yy;
	 	scanf("%d%d%d",&tt,&xx,&yy);
	 	if(!check(tt-t,xx,x,yy,y))
	 	{
	 		printf("No\n");
			return 0;	
		}
		else
		{
			t=tt;
			x=xx;
			y=yy;
		}
	 }
	 printf("Yes\n");
	 
	

	return 0;	
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)

const double BTCJPY = 380000.0;
int main() {
  int n;
  cin >> n;
  double sum = 0.0;
  rep(i, n) {
    double x;
    string u;
    cin >> x >> u;
    if(u == "BTC") x *= BTCJPY;
    sum += x;
  }
  printf("%.10f\n", sum);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007

bool vis[200005];
vector<int> vec[2000005], v1;
int child[2000005];
int parent[2000005];
int div1[100005];
int min_indx[900005];
int count1 = 0;
int height = 0;
int max_indx[200005];
void dfs(int node)
{

    vis[node] = 1;
    // cout << node << "\n";
    min_indx[count1] = node;
    max_indx[node] = min(max_indx[node], count1);
    count1++;

    //  count1++;
    child[node] = height++;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            min_indx[count1] = node;
            max_indx[node] = min(max_indx[node], count1);
            count1++;
        }
    }
    height--;
}

int MAXN = 200005;
int LOGMAXN = (int)log2(200005) + 1;
int M[200005][60];
void process2(int A[], int N)
{
    int i, j;

    //initialize M for the intervals with length 1
    for (i = 0; i < N; i++)
        M[i][0] = i;
    //compute values from smaller to bigger intervals
    for (j = 1; 1 << j <= N; j++)
        for (i = 0; i + (1 << j) - 1 < N; i++)
            if (A[M[i][j - 1]] < A[M[i + (1 << (j - 1))][j - 1]])
                M[i][j] = M[i][j - 1];
            else
                M[i][j] = M[i + (1 << (j - 1))][j - 1];
}
//int parent[200005];
vector<int> vec1;
//bool vis[200005];
//int hei[200005];
int lev[200005];
int dis[200005];
bool cmp(pair<int, int> &a,
         pair<int, int> &b)
{
    return a.second < b.second;
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    //  int t;
    int n, m;
    cin >> n;
    int arr[n];
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        if (arr[i] % 2)
            continue;
        else
        {
            int count = 0;
            while (!(arr[i] % 2))
            {
                arr[i] /= 2;
                count++;
            }
            ans += count;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 50524
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	LLONG N, K; cin >> N >> K;
	LLONG cc = N / K;
	LLONG ans = cc * cc * cc;
	if(K % 2 == 0 && N >= K / 2)
	{
		cc = (N - K / 2) / K + 1;
		ans += cc * cc * cc;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
import sys
input = sys.stdin.readline

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
a, b = [0], [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

j = m

for i in range(n+1):
    if a[i] > k:
        break
    while True:
        if a[i] + b[j] <= k:
            break
        j -= 1
    res = max(res, i+j)

print(res)

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

int main() {
    int N, M;
    cin >> N >> M;
    int INF = 10000000;
    vector<vector<int>> edge(N);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge.at(a-1).push_back(b-1);
        edge.at(b-1).push_back(a-1);
    }

    typedef pair<int, int> P;
    vector<int> d(N, INF);
    vector<int> prev(N, -1);
    d[0] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, 0));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) {
            continue;
        }
        for (auto e : edge.at(v)) {
            if (d[e] > d[v] + 1) {
                d[e] = d[v] + 1;
                que.push(P(d[e], e));
                prev.at(e) = v+1;
            }
        }
    }

    if (count(d.begin(), d.end(), INF) == 0) {
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++) {
            cout << prev[i] << endl;
        }
    }else{
        cout << "No" << endl;
    }    
}

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

const int MOD = 1e9 + 7;

void add(int &a, int b) {
    a += b;
    while(a >= MOD)
        a -= MOD;
    while(a < 0)
        a += MOD;
}

void mult(int &a, int b) {
    a = 1LL * a * b % MOD;
};

int len(pair<int, int> a) {
    return a.second - a.first + 1;
}

int isInside(pair<int, int> a, pair<int, int> b) {
    return a.first >= b.first and a.second <= b.second;
}

int two(int n) {
    int ans = 1, temp = 2;
    for(int i = 0; (1 << i) <= n; i += 1) {
        if((1 << i) & n)
            mult(ans, temp);
        mult(temp, temp);
    }
    return ans;
}

int main() {
    int n; cin >> n;
    vector<int> v(n, 0);

    for(int i = 0; i < n; i += 1) {
        cin >> v[i];
    }
    
    auto nxt = [&] (int i) {
        if(i + 1 < n)
            return v[i + 1];
        return 0;
    };

    auto prv = [&] (int i) {
        if(i - 1 >= 0)
            return v[i - 1];
        return 0;
    };

    vector<pair<int, int>> plateaus;
    vector<vector<int>> minim(n, vector<int> (n, numeric_limits<int>::max()));

    for(int i = 0; i < n; i += 1) {
        for(int j = i; j < n; j += 1) {
            minim[i][j] = min(minim[i][j], v[j]);
            if(j - 1 >= i)
                minim[i][j] = min(minim[i][j], minim[i][j - 1]);
            if(prv(i) < minim[i][j] and nxt(j) < minim[i][j]) {
                plateaus.push_back({i, j});
            }
        }
    }

    sort(plateaus.begin(), plateaus.end(), [&] (pair<int, int> a, pair<int, int> b) {
        return len(a) > len(b);
    });

    int p = plateaus.size();
    vector<bool> seen(p, 0);
    vector<int> dp_alt(p, 0), dp_whatever(p, 0);
    
    auto all = [&] (int index) {
        return (dp_whatever[index] + 2LL * dp_alt[index]) % MOD;
    };

    function<void(int, int)> rec = [&] (int index, int ground) {

        seen[index] = 1;
        vector<int> sons;
        int min_h = minim[plateaus[index].first][plateaus[index].second];

        for(int i = 0; i < p; i += 1) {
            if(i != index and isInside(plateaus[i], plateaus[index]) and not seen[i]) {
                rec(i, min_h);
                sons.push_back(i);
            }
        }       

        dp_alt[index] = 1;
        int rem = len(plateaus[index]);

        for(auto son : sons) {
            mult(dp_alt[index], 2 * dp_alt[son] % MOD);
            rem -= len(plateaus[son]);
        }

        dp_whatever[index] = two(rem);
        
        for(auto son : sons) {
            int coef = (4LL * dp_alt[son] + dp_whatever[son]) % MOD;
            mult(dp_whatever[index], coef);
        }

        add(dp_whatever[index], -(2 * dp_alt[index] % MOD));
        mult(dp_alt[index], two(min_h - ground - 1));
    };
    
    rec(0, 0);
    int ans = all(0);
    cout << ans << "\n";
}

Measured memory_bytes: 256
from functools import reduce
N,X=map(int,input().split())
x=list(map(int,input().split()))
L=x+[X]
if N==1:
	print(abs(X-x[0]))
else:
	LL=[abs(L[i+1]-L[i]) for i in range(N)]
	def gcd(a,b):
		while b>0:
			a,b=b,a%b
		return a
	print(reduce(gcd,LL))

Measured memory_bytes: 14744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String input_line = input.readLine();

		String[] coordinate_group = input_line.split(" ");

		double coordinate_x = Double .parseDouble(coordinate_group[0]);

		double coordinate_y = Double .parseDouble(coordinate_group[1]);

		double coordinate_xi = Double .parseDouble(coordinate_group[2]);

		double coordinate_yi = Double .parseDouble(coordinate_group[3]);

		double x_distance = Math.pow(coordinate_x - coordinate_xi, 2);

		double y_distance = Math.pow(coordinate_y - coordinate_yi, 2);

		double distance = Math.sqrt(x_distance + y_distance);

		System.out.println(distance);

	}

}

Measured memory_bytes: 24408
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    int a, b, c;
    cin >> a >> b >> c;

    int ma = max({a, b, c});
    int sum = a + b + c;

    int ans;
    if ((ma * 3 - sum) % 2 == 0)
    {
        ans = (ma * 3 - sum) / 2;
    }
    else
    {
        while (((ma * 3 - sum) % 2))
        {
            ma++;
        }
        ans = (ma * 3 - sum) / 2;
    }
    cout << ans << endl;
    return (0);
}


Measured memory_bytes: 3616
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
S = sys.stdin.readline().rstrip()


def factorial(n):
    ret = 1
    for a in range(2, n + 1):
        ret = ret * a % MOD
    return ret


def solve(S):
    S = np.array(list(S)) == 'B'
    # 右にするか左にするか
    LR = np.zeros_like(S, dtype=str)
    LR[::2][S[::2] == 0] = 'R'
    LR[::2][S[::2] == 1] = 'L'
    LR[1::2][S[1::2] == 0] = 'L'
    LR[1::2][S[1::2] == 1] = 'R'
    if (LR == 'R').sum() != len(LR) // 2:
        return 0
    l_cnt = (LR == 'L').cumsum()
    ans = 1
    r = 0
    for i, lr in enumerate(LR):
        if lr == 'R':
            l = l_cnt[i] - r
            if l <= 0:
                return 0
            ans = ans * l % MOD
            r += 1
    return ans * factorial(len(LR) // 2) % MOD


ans = solve(S)
print(ans)


Measured memory_bytes: 17052
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	int N;
	scanf("%d", &N);
	char*S = new char[N+1];
	scanf("%s", S);
	int res = 1;
	for (int i = 1; i < N; i++) {
		if (S[i] != S[i - 1])res++;
	}
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 384
while True:
    a0, L = map(int, input().split())
    if a0==0 and L==0:
        break

    s = ("{:0" + str(L) + "d}").format(a0)
    hist = [a0]
    for i in range(1, 21):
        # print(hist)
        large = "".join(sorted(s, reverse=True))
        small = "".join(sorted(s))
        # print(large)
        # print(small)
        ai = int(large) - int(small)
        if ai in hist:
            j = hist.index(ai)
            print(j, int(ai), i-j)
            break
        else:
            hist.append(ai)
            s = ("{:0" + str(L) + "d}").format(ai)

    else:
        raise AttributeError



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

int A, B, col[109][109];

int main() {
	cin >> A >> B; swap(A, B);
	for (int i = 50; i < 100; i++) {
		for (int j = 0; j < 100; j++) col[i][j] = 1;
	}
	A--; B--;
	for (int i = 1; i <= 47; i += 2) {
		for (int j = 1; j <= 97; j += 2) {
			if (A > 0) { col[i][j] = 1; A--; }
		}
	}
	for (int i = 51; i <= 97; i += 2) {
		for (int j = 1; j <= 97; j += 2) {
			if (B > 0) { col[i][j] = 0; B--; }
		}
	}
	cout << "100 100" << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			if (col[i][j] == 0) cout << ".";
			else cout << "#";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	double a;
	while(scanf("%lf",&a)){
		if(a<0)return 0;
		int b=a*16;
		if(a*16-(double)b>0.0f||a>=4096){
			printf("NA\n");
		}else{
			for(int i=11;i>=4;i--){
				printf("%d",b%(1<<(i+1))/(1<<(i)));
			}
			printf(".");
			for(int i=3;i>=0;i--){
				printf("%d",b%(1<<(i+1))/(1<<(i)));
			}
			printf("\n");
		}
	}
}

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

int N, A[200005], bit[25];

int main() {

  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, 25) bit[i] = 0;


  long long ans = 0;
  int s, t;
  bool foward = true;
  s = t = 0;
  while (t < N) {

    if (foward) {
      rep(i, 25) {
        if (A[t] & (1<<i)) bit[i]++;
      }
    }

    bool flag = true;
    rep(i, 25) {
      if (bit[i] > 1) {
        flag = false;
        break;
      }
    }

    if (flag) {
      ans += t - s + 1;
      t++;
      foward = true;
    } else {
      rep(i, 25) {
        if (A[s] & (1<<i)) bit[i]--;
      }
     s++;
     foward = false;
    }

  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
using namespace std;

double spase(double a,double b,double c,double d,double e,double f){
	double x,y,z;
	x=sqrt( (a-c)*(a-c)+(b-d)*(b-d) );
	y=sqrt( (c-e)*(c-e)+(d-f)*(d-f) );
	z=sqrt( (e-a)*(e-a)+(f-b)*(f-b) );
	return sqrt((x+y+z)*(y-x+z)*(x-y+z)*(x+y-z));
}

int main(){
	double a,b,c,d,e,f,p,q;
	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f,&p,&q) != EOF ){
	if( (float)spase(a,b,c,d,e,f)==(float)(spase(a,b,c,d,p,q)+spase(a,b,e,f,p,q)+spase(p,q,c,d,e,f)) ){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}
	}
	return 0;
}

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

using namespace std;
using ll = long long;

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

	int res = 0;
	for (int i = 0; i < s.size(); ++i) {
		res += (s[i] == '2' ? 1 : 0);
	}

	cout << res << endl;

	return 0;
}


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

int main()
{
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(a==0) cout<<1<<endl;
	if(b==0) cout<<2<<endl;
	if(c==0) cout<<3<<endl;
	if(d==0) cout<<4<<endl;
	if(e==0) cout<<5<<endl; 
	return 0;
 } 

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


void modcomb(vec &c, ll n, ll k, ll m)
{
    vec inv(k+1, 0);
    inv[1] = 1;
    c[0] = 1; c[1] = n;
    REP(i,2,k+1) {
        inv[i] = m - inv[m%i] * (m / i) % m;
        c[i] = (((c[i-1] * (n - i + 1)) % m) * inv[i]) % m;
    }
}

int main()
{
    ll X, Y;
    cin >> X >> Y;

    ll cnt = 0;
    ll A = 2 * X - Y;
    ll B = 2 * Y - X;
    if(A % 3 == 0 && B % 3 == 0 && A >= 0 && B >= 0) {
        A /= 3; B /= 3;
        ll N = A + B;
        ll M = MIN(A,B);
        vec C(M+1);
        modcomb(C, N, M, MOD);
        cnt = C[M];
    }
    _PR(cnt);


    return 0;
}

/*
 

*/

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
list<ll> a;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        ll temp;
        scanf("%Ld", &temp);
        if (i%2) {
            a.push_back(temp);
        }else{
            a.push_front(temp);
        }
    }
    if (!(n%2)) reverse(a.begin(), a.end());
    for (auto iter = a.begin(); iter != a.end(); iter++) {
        printf("%Ld", *iter);
        if (iter != a.end()) printf(" ");
    }
    cout << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c;
  d = a % b;
  if (d == 0) {
    cout << "NO";
    return 0;
  }
  for (int i = 1; i <= 100; ++i) {
    if (d * i % b == c) {
      cout << "YES";
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int func1(int a, int b, int c) {
	int temp;

	if(a > b) {
		temp = a;
		a = b;
		b = temp;
	}
	if(b > c) {
		temp = b;
		b = c;
		c = temp;
	}

	if(a*a + b*b == c*c) return 1;
	else return 0;
}

int main() {
	int a, b, c;
	int n, i;

	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d %d %d", &a, &b, &c);
		if(func1(a, b, c)) printf("YES\n");
		else printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


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

	int sum = 0;
	for(int i=0;i<s.length();i++) if(s[i]=='2') sum++;
	
	cout << sum << endl;
	

	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(n,c,k) = readLine.split(" ").map{_.toInt}
  val t = (1 to n).map{_ => readInt}.toArray.sorted
  
  var ans = 0
  var i = 0
  var t_temp = t.toList
  
  while (i < n) {
    ans += 1
    val c_th_id = t(Array(n-1,i+c-1).min)
    val num_within_k = (
      t_temp.indexWhere({_ > t(i)+k},0) match {
        case -1 => t_temp.length
        case x => x
      })
    
    if(c <= num_within_k) {
      i += c
      t_temp = t_temp.drop(c)
    } else {
      i += num_within_k
      t_temp = t_temp.drop(num_within_k)
    }
  }
  
  println(ans)
}

Measured memory_bytes: 45140
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
     cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    vector<int> x(m); cinf(m,x);//x0,x1...xm-1
    vector<int> d(m-1);
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    else{
        sort(x.begin(),x.end());
        for(int i=0;i<m-1;i++){
        d[i]=x[i+1]-x[i];
         //d0,...,d[m-2]
        }
        sort(d.begin(),d.end());
        int ans=0;
        for(int i=0;i<m-n;i++){
        ans+=d[i]; 
        }
    cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
int main(void)
{
    int n;
    cin >> n;
    map<int, int> mp;
    int ans = 0;
    REP(i, n)
    {
        int t;
        cin >> t;
        if (mp.count(t) == 1)
        {
            mp.erase(t);
        }
        else
        {
            mp[t]++;
        }
    }
    /*
    for (auto i : mp)
    {
        if (i.second % 2 == 1)
            ans++;
    }
    */
    cout << mp.size() << endl;
}

Measured memory_bytes: 4864
from scipy.sparse import*
(n,m,s,*D),*t=[map(int,t.split())for t in open(0)]
x=51
r=range(0,x**3,x)
for u,v,a,b in t[:m]:
 for i in r:D+=i+a*x+u,i+v,b,i+a*x+v,i+u,b
i=0
for c,d in t[m:]:
 i+=1
 for j in r:D+=j+i,j+c*x+i,d
d=csgraph.dijkstra(csr_matrix((D[2::3],(D[::3],D[1::3])),[8**6]*2),1,min(x*x,s)*x+1)
for i in range(2,n+1):print(int(min(d[i::x])))

Measured memory_bytes: 127196
def main():
  import sys
  input = sys.stdin.readline
  n=input()
  a=tuple(map(int,input().split()))
  cnt=[0]*(pow(10,5)+2)
  for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
  print(max(set(cnt)))   
if __name__=='__main__':
  main()

Measured memory_bytes: 14004
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <fstream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i,j,tt=1;
    //cin>>tt;
    while(tt--)
    {
        lli l,r,d,ans=0;
        cin>>l>>r>>d;
        for(i=l;i<=r;i++)
        {
            if(i%d==0)
                ans++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
  int i;
  int th, h, ten, one; 
  scanf("%d", &i);

  th=i/1000;
  h=i%1000/100;
  ten = i%100/10;
  one = i%10;
  
  if((th == h && h == ten) || (h == ten && ten == one))
    printf("Yes");
  else
    printf("No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N;
    cin >> N;

    string A, B, C;
    cin >> A >> B >> C;

    ll ans  = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == B[i] && B[i] == C[i]) {
            continue;
        } else if (A[i] != B[i] && B[i] != C[i] && A[i] != C[i]) {
            ans += 2;
        } else {
            ans++;
        }
    }


    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 384
//22
#include<iostream>
#include<algorithm>

using namespace std;

int a[30];

void spl(int n,int m,int x){
  for(int i=min(n,m);i;i--){
    a[x]=i;
    if(i==n){
      for(int i=0;i<=x;i++){
	cout<<a[i]<<((i==x)?'\n':' ');
      }
    }else{
      spl(n-i,min(m,i),x+1);
    }
  }
}

int main(){
  for(int n;cin>>n,n;){
    spl(n,n,0);
  }
  return 0;
}

Measured memory_bytes: 0