akhauriyash/Code-Regression huggingface dataset:
from fractions import gcd

A, B, C, D = map(int, input().split())
l = C * D // gcd(C, D)
x = (A - 1) - (A - 1) // C - (A - 1) // D + (A - 1) // l
y = B - B // C - B // D + B // l
print(y - x)

Measured memory_bytes: 5344
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, t;
    scanf("%d%d",&n,&t);
    int a[n];
    int m;
    int maxdif = 0;
    int c1 = 0;
    int ans = 0;
    scanf("%d",&a[0]);
    m = a[0];
    for (int i = 1; i < n; i++) {
        scanf("%d",&a[i]);
        int dif = a[i]-m;
        if (dif > maxdif){
            maxdif = dif;
            c1 = 0;
        }
        if (dif == maxdif) c1++;
        m = min(m,a[i]);
    }
    printf("%d",c1);

}


Measured memory_bytes: 640
import java.io.*; 
class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int i=0;
int x;
while((x=Integer.parseInt(br.readLine())) != 0){
i++;
System.out.println("Case " +i+ ": " + x);
}
br.close();
}
}

Measured memory_bytes: 32336
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

    if(s[0] == s[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
k = [0]*2
for i in range(9):
    name,a,b = input().split()
    k[0] = int(a)+int(b)
    k[1] = int(a)*200+int(b)*300
    print(name,k[0],k[1])
    k[0] = 0
    k[1] = 1


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

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

	char pre[3] = {};
	char post[3] = {};
	pre[0] = str[0];
	pre[1] = str[1];
	post[0] = str[2];
	post[1] = str[3];

	int preValue = atoi(pre);
	int postValue = atoi(post);

	bool isYYMM = false;
	bool isMMYY = false;

	if (preValue >= 1 && preValue <= 12) {
		isMMYY = true;
	}
	if (postValue >= 1 && postValue <= 12) {
		isYYMM = true;
	}

	if (isYYMM) {
		if (isMMYY) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "YYMM" << endl;
		}
	}
	else {
		if (isMMYY) {
			cout << "MMYY" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
import fractions

def lcm(x,y):
    return x*y // fractions.gcd(x,y)


a,b,c,d = map(int,input().split(' '))
not_a_1 =0
not_b = 0
not_b =  b-(b//c)-(b//d)+(b//lcm(c,d))
not_a_1 = a-1-((a-1)//c)-((a-1)//d)+((a-1)//lcm(c,d))

print(not_b-not_a_1)

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
ll rec(ll x) {
  if(x == 1) return 1;
  return 2 * rec(x / 2) + 1;
}

int main() {
  ll h;
  cin >> h;
  cout << rec(h) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=100005;

namespace DSU
{
	long long fa[MAXN];
	void Clear()
	{memset(fa,-1,sizeof fa);}
	long long Root(long long x)
	{return fa[x]==-1?x:(fa[x]=Root(fa[x]));}
	void Union(long long x,long long y)
	{
		long long r1=Root(x),r2=Root(y);
		if(r1!=r2)
			fa[r1]=r2;
	}
}

struct Vertice
{
	long long val,id;
	Vertice(){val=0x3F3F3F3F3F3F3F3FLL;}
	Vertice(long long v,long long i){val=v;id=i;}
	bool operator < (const Vertice &t)const
	{return val<t.val;}
};

Vertice V[MAXN],tr[MAXN];
bool used[MAXN];
bool mk[MAXN];

int main()
{
	long long n,m;
	scanf("%lld%lld",&n,&m);
	for(long long i=0,a;i<n;i++)
	{
		scanf("%lld",&a);
		V[i]=Vertice(a,i);
	}
	DSU::Clear();
	for(long long i=0,u,v;i<m;i++)
	{
		scanf("%lld%lld",&u,&v);
		DSU::Union(u,v);
	}
	int cc=0;
	for(int i=0;i<n;i++)
		if(!mk[DSU::Root(i)])
		{
			mk[DSU::Root(i)]=true;
			cc++;
		}
	if(cc==1)
	{
		puts("0");
		return 0;
	}
	if(2*cc-2>n)
	{
		puts("Impossible");
		return 0;
	}
	for(long long i=0;i<n;i++)
	{
		int r=DSU::Root(i);
		tr[r]=min(tr[r],V[i]);
	}
	long long ans=0,cnt=2*cc-2;
	for(long long i=0;i<n&&cnt;i++)
	{
		int r=DSU::Root(i);
		if(!used[tr[r].id])
		{
			ans+=tr[r].val;
			used[tr[r].id]=true;
			cnt--;
		}
	}
	sort(V,V+n);
	for(long long i=0;i<n&&cnt;i++)
		if(!used[V[i].id])
		{
			ans+=V[i].val;
			cnt--;
		}
	
	printf("%lld\n",ans);
	return 0;
}


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

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

    int count, t, ans = n;
    
    for(int i=0; i<=n; i++){
        count = 0;
        t = i;
        while(t>0){
            count += t%6;
            t /= 6;
        }
        t = n-i;
        while(t>0){
            count += t%9;
            t /= 9;
        }
        if(ans > count){
            ans = count;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef unsigned long long ll;
const char sp = ' ';

ll gcd(ll a, ll b){
    if(a%b==0) return b;
    else return gcd(b, a%b);
}

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

using namespace std;

int main(void){
    ll N, M, amax=1;
    cin>>N>>M;
    ll a[100005], d=1;
    rep(i, N){
        cin>>a[i];
        //amax=max(amax, a[i]);
        if(i==0){
            while(true){
                if(a[i]%2!=0) break;
                a[i]/=2;
                d*=2;
            }
        }
        else{
            if(a[i]%d!=0){
                cout<<0<<endl;
                return 0;
            }
            a[i]/=d;
            if(a[i]%2==0){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    d/=2;
    rep(i, N){
        a[i]*=d;
    }
    ll LCM=1;
    rep(i, N){
        LCM=lcm(LCM, a[i]);
    }
    //cout<<lcm<<endl;
    ll ans=(ll)((M/LCM)+1)/2;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n;
    cin >> n;
    string st;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        st.pb(tmp + '0');
    }
    rep(i, 101010) {
        string ser = to_string(i);
        if (st.find(ser) == string::npos) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll mod = 1e9+7;

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp)%mod;
    else
        return (((x*temp)%mod)*temp)%mod;
}


/* nCr % mod
ll fact[6*N];
ll inv[6*N],invfac[6*N];
ll mod = 998244353;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;

void Sieve(int n)
{
    vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 1e7 + 6;

bool done[Nmax];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll k;
    cin >> k;
    if(k%2==0)
    {
        cout << -1 ;
        return 0;
    }
    ll ans = 0;
    ll val  = k;
    ll num = 0;
    while(k)
    {
        num *= 10;
        num += 7;
        ans++;
        k/=10;
    }
    ans--;
    while(true)
    {
        if(num%val == 0)
        {
            ans++;
            break;
        }
        num = num%val;
        ans++;
        num *= 10 ;
        num += 7;
        if(done[num])
        {
            ans = -1;
            break;
        }
        done[num] = 1;
    }
    cout << ans;
}


Measured memory_bytes: 13376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,A;
  cin >> N;
  vector<long long> a(N,0);
  for (int i=0;i<N-1;i++) {
    cin >> A;
	a.at(A-1)++;
  }
  for (int i=0;i<N;i++) {cout << a[i] << endl;}
  
}

Measured memory_bytes: 4764
/*
ID: usaco.t3
TASK: test
LANG: C++14
*/

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _CRT_SECURE_NO_WARNINGS
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define pii pair<intt,intt>
#define vi vector<intt>
#define vii vector<pii>

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();
#define endl '\n'

#define wtfis(x) cerr << "at line " << __LINE__ << ": " << #x << " = " << (x) << endl

const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000001;
const intt INFLL = 9LL * 1000000000 * 1000000000;
/***************/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

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

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    IO;
    long double n, m, d;
    cin >> n >> m >> d;
    if (d > 0) {
        cout << fixed << setprecision(15) << 1.0 * (m - 1) / n * 2 * (n - d) / n << endl;
    } else {
        cout << fixed << setprecision(15) << 1.0 * (m - 1) / n << 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 vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))
#define asort(array) sort(array, array + len(array))

int main() {
  int n;cin>>n;
  long an[n],bn[n],cn[n];
  rep(i,n) cin>>an[i];
  rep(i,n) cin>>bn[i];
  rep(i,n) cin>>cn[i];
  asort(an);
  asort(bn);
  asort(cn);
  
  int j=0,k=0;
  long bx[n];
  rep(i,n)bx[i]=0;
  rep(j,n) {
    while (k<n and cn[k]<=bn[j]) k++;
    bx[j] = n-k;
  }

  rep(j,n-1) {
    bx[n-j-2] = bx[n-j-1] + bx[n-j-2];
  }
  long cnt=0;
  rep(i,n) {
    while (j<n and bn[j]<=an[i]) j++;
    if (j>=n) break;
    cnt += bx[j];
  }
  cout << cnt;
}


Measured memory_bytes: 3456
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int comp(const void *a, const void *b){return *(int*)b-*(int*)a;}

int main(void){
	int n, k;
	scanf("%d%d", &n, &k);
	if(k&1){
		long t = n/k;
		printf("%ld\n", t*t*t);
	}else{
		long t1=n/k;
		long t2=n/(k/2) - t1;
		printf("%ld\n", t1*t1*t1 + t2*t2*t2);
	}
}


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

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

    int C[500];
    int S[500];
    int F[500];

    for(int i = 0; i < N-1; i++) cin >> C[i] >> S[i] >> F[i];

    for(int i = 0; i < N-1; i++)
    {
        int ans = 0;
        for(int j = i; j < N-1; j++)
        {
            if(ans < S[j])
            {
                ans = S[j];
                ans += C[j];
            }
            else
            {
                for(int k = 0; k <= 100; k++)
                {
                    if((ans + k) % F[j] == 0)
                    {
                        ans += k;
                        break;
                    }
                }
                ans += C[j];
            }
        }

        cout << ans << endl;
    }
    cout << '0' << endl;

    return 0;
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

// Sccessive Shortest Path(Primal Dual): minimum cost maximum flow
struct PrimalDual
{
  struct edge
  {
    int to, capacity, cost, rev;
    edge(){}
    edge(int to, int capacity, int cost, int rev):to(to), capacity(capacity), cost(cost), rev(rev){}
  };

  vector< vector<edge> > graph;
  vector<int> potential, mincost, prevv, preve;
  PrimalDual(int V):graph(V), potential(V), mincost(V), prevv(V), preve(V){}
  void add_edge(int from, int to, int capacity, int cost)
  {
    graph[from].push_back(edge(to, capacity, cost, (int)graph[to].size()));
    graph[to].push_back(edge(from, 0, -cost, (int)graph[from].size()-1));
  }
  int min_cost_flow(int source, int sink, int f)
  {
    int res = 0;
    fill(potential.begin(), potential.end(), 0);
    fill(prevv.begin(), prevv.end(), -1);
    fill(preve.begin(), preve.end(), -1);

    while(f > 0) {
      typedef pair<int, int> Pi;
      priority_queue<Pi, vector<Pi>, greater<Pi> > que;
      fill(mincost.begin(), mincost.end(), inf);
      mincost[source] = 0;
      que.push(Pi(0, source));
      while(!que.empty()) {
	Pi p = que.top(); que.pop();
	int v = p.second;
	if(mincost[v] < p.first) continue;
	for(int i = 0; i < (int)graph[v].size(); i++) {
	  edge& e = graph[v][i];
	  int dual_cost = mincost[v] + e.cost + potential[v] - potential[e.to];
	  if(e.capacity > 0 && dual_cost < mincost[e.to]) {
	    mincost[e.to] = dual_cost;
	    prevv[e.to] = v; preve[e.to] = i;
	    que.push(Pi(mincost[e.to], e.to));
	  }
	}
      }

      if(mincost[sink] == inf) return -1;
      for(int v = 0; v < (int)graph.size(); v++) potential[v] += mincost[v];
      int d = f;
      for(int v = sink; v != source; v = prevv[v]) d = min(d, graph[prevv[v]][preve[v]].capacity);
      f -= d;
      res += d * potential[sink];
      for(int v = sink; v != source; v = prevv[v]) {
	edge& e = graph[prevv[v]][preve[v]];
	e.capacity -= d;
	graph[v][e.rev].capacity += d;
      }
    }
    return res;
  }
};


signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int M, W;
  while(cin >> M >> W, M || W) {
    int bm[M], bw[W];
    rep(i, M) cin >> bm[i];
    rep(i, W) cin >> bw[i];
    int s = M + W, t = s + 1, V = t + 1;
    PrimalDual graph(V);
    rep(i, M) graph.add_edge(s, i, 1, 0);
    rep(i, M) rep(j, W) {
      int dif = abs(bm[i]-bw[j]);
      graph.add_edge(i, M + j, 1, -dif*(dif-30)*(dif-30));
    }
    rep(i, W) graph.add_edge(M + i, t, 1, 0);
    cout << -graph.min_cost_flow(s, t, min(M, W)) << endl;
  }

  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

int main() {
  int n; string s; cin >> n >> s;
  int cnt = 1;
  rep(i, n-1) {
    if (s[i] != s[i+1]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main (){
	char S[100];
	scanf("%s",S);
	if (S[1]=='B'){
		S[1]='R';
		printf("%s", S);
	}
	else if (S[1]=='R') {
		S[1]='B';
		printf("%s", S);
	}
	
return 0;
}


Measured memory_bytes: 1724
/////////////////////////////////////////Info/////////////////////////////////////////////////
//Problem:
//Date:
//Skill:
//Bug:
/////////////////////////////////////////Definations/////////////////////////////////////////////////
//循环控制
#define CLR(a) memset((a),0,sizeof(a))
#define F(i,a,b) for(int i=a;i<=int(b);++i)
#define F2(i,a,b) for(int i=a;i>=int(b);--i)
#define RE(i,n)  for(int i=0;i<int(n);i++)
#define RE2(i,n) for(int i=1;i<=int(n);i++)
//简化敲击
#define PII pair<int,int>
#define PLL pari<long long ,long long>
#define PB push_back
#define ENDL '\n'
#define x first
#define y second
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
////////////////////////////////////////Options//////////////////////////////////////////////////////
#define stdcpph
#define CPP_IO

#ifdef stdcpph
#include<bits/stdc++.h>
#else
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>
#ifdef CPP_IO
#include<iostream>
#include<iomanip>
#include<string>
#else
#include<stdio.h>
#endif
#endif
////////////////////////////////////////Basic Functions//////////////////////////////////////////////
template<typename INint> inline void IN(INint &x)
{
	x = 0; int f = 1; char c; cin.get(c);
	while (c<'0' || c>'9') { if (c == '-')f = -1; cin.get(c); }
	while (c >= '0'&&c <= '9') { x = x * 10 + c - '0'; cin.get(c); }
	x *= f;
}
template<typename INint> inline void OUT(INint x)
{
	if (x > 9)OUT(x / 10); cout.put(x % 10 + '0');
}
////////////////////////////////////////Added Functions//////////////////////////////////////////////
const int maxn = int(20);

////////////////////////////////////////////Code/////////////////////////////////////////////////////
int main()
{
	//freopen("C:\\Users\\VULCAN\\Desktop\\data.in", "r", stdin);
	int T(1), times(0);
#ifdef CPP_IO// CPP_IO
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//cin >> T;
#else
	//IN(T);
#endif 
	/////////////////////////////////////////////////////////////////////////////////////////////////
	while (++times, T--)
	{
		ll N; cin >> N;
		ll i = 1;
		ll ans(0);
		while (i*i <= N)
		{
			if (N%i == 0 && i < (N / i -1))ans+=N/i-1;
			++i;
		}
		cout << ans << endl;
	}
	///////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,ans;
string s;
map <string,long long> mp;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s,sort(s.begin(),s.end());
		ans+=mp[s];
		mp[s]++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

bool p[MAX+1];
int a[MAX+1],l[MAX],r[MAX];

int main() {
	int q;cin>>q;
	rep(i,q) cin>>l[i]>>r[i];

	rep1(i,MAX) p[i]=true;
	p[1]=false;
	for(int i=2;i<=MAX;i++){
		if(!p[i]) continue;
		for(int j=i*2;j<=MAX;j+=i) p[j]=false;
	}

	a[0]=a[1]=a[2]=0;
	int c=0;
	for(int i=3;i<=MAX;i++) {
		if(p[i]&&p[(i+1)/2]) c++;
		a[i]=c;
	}

	rep(i,q) cout<<a[r[i]]-a[l[i]-1]<<endl;
}


Measured memory_bytes: 1920
A,B = map(int,input().split())
count = 0
i = A

while(True):
  s = i % 10 #1の位(一)
  t = i // 10 % 10 #10の位(十)
  u = i // 100 % 10 #100の位(百)
  v = i // 1000 % 10 #1000の位(千)
  w = i // 10000 % 10 #10000の位(万)
  if (s==w and t==v):
    count += 1
  if B==i:
    break
  i += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int e(int x,int y){
  if(x<y) swap(x,y); 
  int r;
  while(true){
    r=x%y;
    if(r==0)
      return y;
    x=y;
    y=r;
  }
  return 0;
}
int main()	{
  int k;
  cin>>k;
  int sum=0;
  rep(i,k){
    rep(j,k){
      rep(l,k){
        int a=e(i,j);
        int b=e(a,l);
        sum+=b;
      }
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
ll GCD(ll a,ll b){
    ll hoge;
    do{
        hoge=a%b;
        a=b;
        b=hoge;
    }while(hoge!=0);
    return a;
}
ll LCM(ll a,ll b){
    return a/GCD(a,b)*b;//overflow対策
}
int main(){
	int n,k;
	cin>>n>>k;
	vector<int>mother(n,n);
	for(int i=1;i<=n;i++){
		int hoge=i;
		while(hoge<k){
			hoge*=2;
			mother[i-1]*=2;
		}
	}
	ll lcm_num=mother[0];
	for(int i=0;i<n;i++)lcm_num=LCM(mother[i],lcm_num);
	ll son_sum=0;
	for(int i=0;i<n;i++)son_sum+=lcm_num/mother[i];
	double ans=(double)son_sum/lcm_num;
	printf("%.10f\n",ans);

}


Measured memory_bytes: 640
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 
#define MODB  998244353

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	vector<ll> a(n);
	cin >> a;
	ans += a[0]-1;
	ll bor = 2;
	REP1(i, n-1){
		if(bor == a[i]) bor++;
		else ans += (a[i] - 1) / bor;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4028
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int x = int.Parse(input[0]);
		int y = int.Parse(input[1]);
		
		//出力
		Console.WriteLine(x + y/2);
	}
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
 
int main(){
  while(1){
    int n,w,h,a[101][101]={},x,y,s,t,count,max;
    max=0;
    cin>>n;
    if(n==0)break;

    cin>>w>>h;
    for(int i=0;i<n;i++){
      cin>>x>>y;
      a[y][x]=1;
    }
    cin>>s>>t;
    for(int i=0;i<=h-t;i++)
      for(int j=0;j<=w-s;j++){
	count=0;
	for(int k=0;k<t;k++)
	  for(int l=0;l<s;l++)
	    if(a[i+k+1][j+l+1]==1)count++;
	if(max<count)max=count;
      }
    cout<<max<<endl;
  }
  return 0;
}

 

Measured memory_bytes: 1204
N = int(input())
ans = 0
dic = {'A':0, 'B':0, 'BA':0}
for i in range(N):
    tmp = input()
    if 'AB' in tmp:
        ans += tmp.count('AB')
    tmp = tmp.replace('AB','ZZ')
    if tmp[-1] == 'A' and tmp[0] == 'B':
        dic['BA'] += 1
    elif tmp[0] == 'B':
        dic['B'] += 1
    elif tmp[-1] == 'A':
        dic['A'] += 1

if dic['B'] >= 1 and dic['A'] >= 1 and dic['BA'] >= 1:
    ans += dic['BA'] + 1
    dic['BA'] = 0
    dic['B'] -= 1
    dic['A'] -= 1
if dic['BA'] >= 1:
    if dic['A'] == 0 and dic['B'] == 0:
        ans += dic['BA'] - 1
    elif dic['A'] == 0 or dic['B'] == 0:
        ans += dic['BA']
else:
    ans += min(dic['A'],dic['B'])
print(ans)

Measured memory_bytes: 3192
package main

import (
  "fmt"
  "strings"
)

func main() {
  var cnt int
  var s string
  var ss []string
  
  fmt.Scan(&s)
  ss = strings.Split(s, "")
  
  for i := 0;i < len(ss); i++ {
    if ss[i] == "1" {
      cnt++;
    }
  }
  
  fmt.Println(cnt)
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0; i<n; i++){
			arr[i] = sc.nextInt();
		}
		int totalXOR = arr[0];
		for(int i=1; i<n; i++){
			totalXOR = totalXOR ^ arr[i];
		}
		for(int i=0; i<n;i++){
			System.out.print(arr[i]^totalXOR);
			System.out.print(" ");
		}
		
	}

}

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

using namespace std;

int main()
{   int c = 0, ans = 0;
    string s;
    cin >> s;
    for (int i = 0 ; i < s.size(); ++i)
       {
            if (s[i] == 'R')
                c++, ans = max (ans, c);
            else
                c = 0;
       }
    cout << ans;
}




Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
string s;
cin>>s;
ll x=s.length(),c=0;
for(int i=0;i<x/2;i++){
if(s[i]!=s[x-1-i])
c++;
}
cout<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char na[30];
	int a,p;
	for(int i=0;i<9;i++)
	{
		cin >> na >> a >> p;
		cout << na << " " << a+p << " " << a*200+p*300 << endl;
	}
	return 0;
}

Measured memory_bytes: 2988
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	deque<char> dq;
	for (int i = 0; i < S.size(); i++) {
		dq.push_back(S[i]);
	}
	int Q;
	cin >> Q;
	bool flip = 0;
	for (int i = 0; i < Q; i++) {
		int t;
		cin >> t;
		if (t == 1) {
			flip ^= 1;
		}
		else {
			int F;
			char C;
			cin >> F >> C;
			if ((F == 1) ^ flip) {
				dq.push_front(C);
			}
			else {
				dq.push_back(C);
			}
		}
	}
	if (flip) {
		for (int i = dq.size() - 1; i >= 0; i--) cout << dq[i];
		cout << endl;
	}
	else {
		for (int i = 0; i < dq.size(); i++) cout << dq[i];
		cout << endl;
	}
}

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

using namespace std;

int A, B, C, N;
int Result[301], ListInfo[1000][4];

void solve(int row) {

	for (int i = 0; i < row; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (Result[ListInfo[i][j]] == 1 && Result[ListInfo[i][(j + 1) % 3]] == 1) {
				Result[ListInfo[i][(j + 2) % 3]] = 0;
			}
		}
	}
}

int main() {
	int row;

	while (cin >> A >> B >> C, A) {
		fill(Result, Result + 301, 2);
		row = 0;
		cin >> N;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 4; ++j) {
				cin >> ListInfo[row][j];
			}
			if (ListInfo[row][3] != 1) {
				++row;
				continue;	
			}
			for (int k = 0; k < 3; ++k) {
				Result[ListInfo[row][k]] = 1;
			}
		}
		solve(row);
		for (int i = 1; i <= A + B + C; ++i) {
			cout << Result[i] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3024
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <boost/range/adaptors.hpp>


int main() {
    std::string S;
    std::cin >> S;
    int N = S.size();

    for (int i = 0; i < (N - 1) / 2; ++i) {
        // std::cout << S[i] << "," <<  S[N - i - 1] << std::endl;
        if (S[i] != S[N - i - 1]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    for (int i = 0; i < (N - 1) / 2 / 2; ++i) {
        // std::cout << S[i] << "," <<  S[(N - 1) / 2 - i - 1] << std::endl;
        if (S[i] != S[(N - 1) / 2 - i - 1]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    for (int i = 0; i < (N - 1) / 2 / 2; ++i) {
        // std::cout << S[(N - 1) / 2 + 1 + i] << "," <<  S[N - i - 1] << std::endl;
        if (S[(N - 1) / 2 + 1 + i] != S[N - i - 1]) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;

    return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int INF = 0x3f3f3f3f;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

ll ans, tmp;
ll a, b, c;

int main() {
    cin >> a >> b >> c;
    ans = LLONG_MAX;
    if (c & 1) chkmin(ans, a * b);
    else ans = 0;
    if (b & 1) chkmin(ans, a * c);
    else ans = 0;
    if (a & 1) chkmin(ans, b * c);
    else ans = 0;
    printf("%lld\n", ans);
    return 0;
}

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

int main(){
  ll a,b,k;
  cin>>a>>b>>k;
  if(a>=k)cout<<a-k<<" "<<b<<endl;
  else if(a+b>=k)cout<<0<<" "<<a+b-k<<endl;
  else cout<<0<<" "<<0<<endl;
}

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

int main() {
  for (int x, y, z; cin >> x >> y >> z, x; ) {
      if (y > z) swap(y, z);
      if (x > y) swap(x, y);
      if (y > z) swap(y, z);

      int T; cin >> T;
      while(T--) {
          int r; cin >> r;
          if (4 * r * r > x * x + y * y)
              cout << "OK" << endl;
          else
              cout << "NA" << endl;
      }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define dblout(x) cout << setprecision(x) << fixed;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    int n;
    cin >> n;
    vector<pi> arr(n);
    for(auto &x : arr)
        cin >> x.ff >> x.ss;
    auto same = [&](pi x)
    {
        return x.ff == x.ss;
    };
    bool ok = false;
    for(int i = 0; i + 2 < n; i++)
    {
        if(same(arr[i]) && same(arr[i + 1]) && same(arr[i + 2]))
            ok = 1;
    }
    cout << (ok ? "Yes\n" : "No\n");
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)

struct event{
    int pc, time;
    bool login;
    event(int pc, int time, bool login)
        : pc(pc), time(time), login(login){}
};

typedef vector<event> ve;
typedef vector<ve> vve;

vve es;

inline pair<int, int> intersection(int l1, int r1, int l2, int r2){
    int l = max(l1, l2), r = min(r1, r2);
    return make_pair(l, r);
}

int main(){
    int N, M;
    while (cin >> N >> M && N | M){
        es.assign(M + 1, {});
        int r; cin >> r;
        rep(i, r){
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            es[m].emplace_back(n, t, s);
        }
        rep(i, M + 1)sort(all(es[i]), [](const event & a, const event& b){
            return a.time < b.time;
        });
        int q; cin >> q;
        rep(i, q){
            bool use[1260] = {};
            int ts, te, m; cin >> ts >> te >> m;
            int ans = 0;
            auto & e = es[m];
            rep(i, e.size()){
                if (e[i].login){
                    int j = i+1;
                    while (e[i].pc != e[j].pc){
                        j++;
                    }
                    auto p = intersection(ts, te, e[i].time, e[j].time);
                    loop(k, p.first, p.second){
                        use[k] = true;
                    }
                }
            }
            rep(i, 1260)ans += use[i];
            cout << ans << endl;
        }
    }
}

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

public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[][]	data = null;

		while((data = parseData()) != null) {
			int		size = data.length - 2;
			int		cnt  = 0;
			int[][]	t1   = data;
			int[][]	t2   = null;
			int[][]	c    = null;

			while (true) {
				boolean	fin = true;

				c  = new int[t1[size+1][0] - t1[size][0] + 1][1];
				t2 = new int[size+2][];

				t2[size]      = new int[1];
				t2[size+1]    = new int[1];
				t2[size][0]   = Integer.MAX_VALUE;
				t2[size+1][0] = Integer.MIN_VALUE;
				for (int l = 0; l < size; l++) {
					int	s = t1[l][0] - t1[size][0];
					c[s][0]++;
					t2[l]         = c[s];
					t2[size][0]   = Math.min(t2[size][0], t2[l][0]);
					t2[size+1][0] = Math.max(t2[size+1][0], t2[l][0]);
				}

				for (int l = 0; l < size && fin; l++) {
					fin = (t1[l][0] == t2[l][0]);
				}

				if (fin) {
					String	out = "";
					for (int l = 0; l < size && fin; l++) {
						out = (l == 0) ? ("" + t1[l][0]) : out + (" " + t1[l][0]);
					}

					System.out.println(cnt);
					System.out.println(out);

					break;
				}

				t1 = t2;
				cnt++;
			}
		}
	}

	private static int parseNum() {
		int		num = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			num = Integer.parseInt(str);
		}

		return num;
	}

	private static int[][] parseData() {
		int[][]	data = null;
		int		size = parseNum();

		if (size > 0) {
			String	str = null;
			if ((str = parseStdin()) != null) {
				String[]	lines = str.split(" ");
				data = new int[size+2][1];
				data[size][0]   = Integer.MAX_VALUE;
				data[size+1][0] = Integer.MIN_VALUE;
				for (int l = 0; l < size; l++) {
					data[l][0]      = Integer.parseInt(lines[l]);
					data[size][0]   = Math.min(data[size][0], data[l][0]);
					data[size+1][0] = Math.max(data[size+1][0], data[l][0]);
				}
			}
		}
 
		return data;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 19728
import java.io.*;

class Main{
    public static void main(String[] args) throws Exception{

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int num = 0;

       while(true){

            String num1 = br.readLine();
            String[] num2 = num1.split(" ");
            int H = Integer.parseInt(num2[0]);
            int W = Integer.parseInt(num2[1]);

            if(H == 0 && W == 0){
                break;
            }

            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    System.out.print("#");
                }
                    System.out.println("");
            }
            System.out.println("");
        }
    }
}

Measured memory_bytes: 31072
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    Robot = [[] for _ in range(N)]
    for i in range(N):
        X, L = map(int, input().split())
        Robot[i] = [X - L, X + L]
    Robot = sorted(Robot, key=lambda x: x[1])
    check = -float("inf")
    cnt = 0
    for R in Robot:
        if R[0] >= check:
            check = R[1]
        else:
            cnt += 1

    print(N - cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 22108
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int H=stdIn.nextInt();
		int W=stdIn.nextInt();
		int K=stdIn.nextInt();
		char s[][]=new char[H][W];
		int A[][]=new int[K][2];
		int map[][]=new int[H][W];
		boolean h[]=new boolean[H];
		int z=0;
		for(int i=0;i<H;i++){
			String a=stdIn.next();
			for(int j=0;j<W;j++){
				s[i][j]=a.charAt(j);
				if(s[i][j]=='#'){
					h[i]=true;
					A[z][0]=i;
					A[z][1]=j;
					z++;
				}
			}
		}
		for(int i=0;i<K;i++){
			int u=A[i][0],d=u,l=A[i][1],r=l;
			map[u][l]=i+1;
			boolean uk=false,dk=false,rk=false,lk=false;
			while(true){
				if(u!=0&&h[u-1]==false){
					u--;uk=true;
				}
				if(d!=H-1&&h[d+1]==false){
					d++;dk=true;
				}
				for(int j=l;j<=r;j++){
					if(uk)
						if(map[u][j]!=0){
							u++;uk=false;
						}
					if(dk)
						if(map[d][j]!=0){
							d--;dk=false;
						}
				}
				if(r!=W-1){
					r++;rk=true;
				}
				if(l!=0){
					l--;lk=true;
				}
				for(int j=u;j<=d;j++){
					if(rk)
						if(map[j][r]!=0||s[j][r]=='#'){
							r--;rk=false;
						}
					if(lk)
						if(map[j][l]!=0||s[j][l]=='#'){
							l++;lk=false;
						}
				}
				if(rk==false&&lk==false&&uk==false&&dk==false){
					for(int j=u;j<=d;j++){
						for(int k=l;k<=r;k++){
							map[j][k]=i+1;
						}
					}
					break;
				}
				rk=false;lk=false;uk=false;dk=false;
			}
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				System.out.println(map[i][j]);
			}
		}
	}
}


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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, ll> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 5e2 + 10;
const int INF = 1e9 + 9;
//const int B = 1e9 + 7;
int B;

void rlx(ll &a, ll b) {
    a = (a + b) % B;
}

int n, k, m;
ll d[N][N], c[N][N], p[N][N];

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> k >> B;

    forn(i, 0, n + 10)
        forn(j, 0, i)
            c[i][j] = j ? (c[i - 1][j - 1] + c[i - 1][j]) % B : 1;

    forn(i, 0, k) d[1][i] = 1;
    for1(j, k, 0)
        p[1][j] = (p[1][j + 1] + d[1][j]) % B;
    forn(i, 2, n + 1) {
        forn(j, 0, k) {
            forn(ni, 1, i - 1) {
                ll cur = p[ni][j + 1] * d[i - ni][j] % B;
                cur = cur * c[i - 2][ni - 1] % B;
                rlx(d[i][j], cur);
            }
        }
        for1(j, k, 0)
            p[i][j] = (p[i][j + 1] + d[i][j]) % B;
    }

    cout << d[n + 1][0] << "\n";

    return 0;
}


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

using namespace std;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int ans = a * b;
	for (int i = 1; i <= 3; i++) {
		if ((ans * i) & 1) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

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

public class Main {
	public static void main(String[] args) {

		Scanner cin = new Scanner(System.in);

		int n = Integer.parseInt(cin.nextLine());
		String[] array = cin.nextLine().split(" ");

		List<Long> bArray = new LinkedList<Long>();

		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				bArray.add(Long.parseLong(array[i]));
			} else {
				bArray.add(0, Long.parseLong(array[i]));
			}
		}
		if (n % 2 > 0) {
			Collections.reverse(bArray);
		}

		StringBuilder buf = new StringBuilder(bArray.size());
		for (long num : bArray) {
			buf.append(num);
			buf.append(" ");
		}
		System.out.println(buf.toString().trim());

		cin.close();
	}
}

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

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

    int ans = X.size();
    X += 'S';
    int cnt_s = 0, cnt_t = 0;

    for (int i = 0; i <= X.size() - 2; i++)
    {
        if (X[i] == 'S') cnt_s++;
        else cnt_t++;

        if (X[i] == 'T' && X[i + 1] == 'S')
        {
            if (cnt_s > cnt_t)
            {
                ans -= cnt_t * 2;
                cnt_s -= cnt_t;
                cnt_t = 0;
            }
            else
            {
                ans -= cnt_s * 2;
                cnt_s = 0;
                cnt_t = 0;
            }
        }
    }

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

Measured memory_bytes: 640
#include <iostream>
#include<cstring>
using namespace std;
const int maxn=1e5+10;
int a[maxn],b[1000000];
int main(int argc, char *argv[])
{
	int n;
	cin>>n; 
	memset(b,0,sizeof(b));
	for(int i=0;i<n;i++){
        cin>>a[i];
        b[a[i]+1]++;
	}
	int max=0;
	for(int i=0;i<n;i++){
		int h=b[a[i]]+b[a[i]+1]+b[a[i]+2];
		  if(h>max)max=h;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
using ll = long long;
using namespace std;

int main() {
	ll n,p;

	cin >> n >> p;

	if (n == 1) {
		cout << p << endl;
		return 0;
	}

	ll ans = 1;
	ll cur = 2;


	while(p > 1) {
		ll count = 0;
		while(p % cur == 0) {
			count++;
			p /= cur;
		}
		ll cur0 = count / n;
		for (ll i = 0; i < cur0; i++) {
			ans *= cur;
		}
		cur++;
		if (cur >= 1000000+ 10L) {
			break;
		}


	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  bool isok = true;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    isok ^= A & 1;
  }
  cout << (isok ? "YES" : "NO") << '\n';
  return 0;
}


Measured memory_bytes: 3684
while true
    n = gets.to_i
    break if n == 0
    arr = gets.chomp.split.map(&:to_i)
    start, prev, arr2 = arr[0], arr[0], []
    arr[1..-1].each{|x|
        if x != prev + 1
            arr2 << ((start == prev) ? start : "#{start}-#{prev}")
            start = x
        end
        prev = x
    }
    arr2 << ((start == prev) ? start : "#{start}-#{prev}")
    puts arr2.join(" ")
end


Measured memory_bytes: 6928