akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 1e9;

int main() {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}


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

static const int MAX = 1000;
static const int VMAX = 10000;

int A[MAX], B[MAX], T[VMAX+1];
int s, n;

int solve() {
    int ans = 0;
    bool V[MAX];
    for (int i = 0; i < n; i++){
        B[i] = A[i];
        V[i] = false;
    }
    sort(B, B + n);
    for (int i = 0; i < n; i++)
        T[B[i]] = i;
    for (int i = 0; i < n; i++) {
        if (V[i])
            continue;
        int an = 0;
        int S = 0;
        int cur = i;
        int m = VMAX;
        int v;
        while (true) {
            V[cur] = true;
            an++;
            v = A[cur];
            m = min(v, m);
            S += v;
            cur = T[A[cur]];
            if (V[cur]) break;
        }
        ans += min(S + (an - 2) * v, S + v + (an + 1) * s);
    }
    return ans;
}

int main() {
    cin >> n;

    s = VMAX;

    for (int i = 0; i < n; i++) {
        cin >> A[i];
        s = min(A[i], s);
    }
    int ans = solve();
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3176
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
    int n, a, color[9] = {}, i, ans = 0;

    cin >> n;
    for(i = 0; i < n; i++){
        cin >> a;
        color[min(a / 400, 8)]++;
    }

    for(i = 0; i < 8; i++){
        if(color[i])ans++;
    }

    cout << max(ans, 1) << ' ' << ans + color[8] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;
const ll MOD = 1e9 + 7;

ll xs[] = {-1, 1, 0, 0, -1, 1, 1, -1};
ll ys[] = {0, 0, -1, 1, -1, 1, -1, 1};

ll segtree[maxN << 2];
ll lazy[maxN << 2];
ll A[maxN];

inline ll left(ll x){
	return x << 1;
}

inline ll right(ll x){
	return (x<<1) + 1;
}

void build(ll node, ll start, ll end){
	if(start == end)
		segtree[node] = A[start];
	else{
		ll mid = (start + end)/2;
		build(left(node), start, mid);
		build(right(node), mid+1, end);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

void update(ll node, ll start, ll end, ll l, ll r, ll val){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(start > end or l > start or r < end)
		return ;
	else if(start >= l and r >= end){
		segtree[node] += val;
		if(start != end){
			lazy[left(node)] += val;
			lazy[right(node)] += val;
		}
	}
	else{
		ll mid=(start + end)/2;
		update(left(node), start, mid, l, r, val);
		update(right(node), mid+1, end, l, r, val);
		segtree[node] = segtree[left(node)] + segtree[right(node)];
	}
}

ll sums(ll node, ll start, ll end, ll l, ll r){
	if(lazy[node] != 0){
		segtree[node] += (end-start+1)*lazy[node];
		if(start != end){
			lazy[left(node)] += lazy[node];
			lazy[right(node)] += lazy[node];
		}
		lazy[node] = 0;
	}
	if(l > end or r < start or start > end)
		return 0;
	if(l <= start and r >= end)
		return segtree[node];
	ll mid = (start+end)/2;
	return sums(left(node), start, mid, l , r) + sums(right(node), mid + 1, end, l , r);
}

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll a, b;
	cin >> a >> b;
	ll A[a];
	ll cur = 0;
	for(ll i=0; i<a; i++)
		cin >> A[i];
	ll ans = 0;
	for(ll i=0; i<a; i++){
		cur += A[i];
		if(cur > b){
			break;
		}
		ans++;
	}
	cout << ans+1;
	return 0;
}

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

int main() {
	int  r, d;
	int n = 9;
	vector<int> X(11);
	cin >> r >> d >> X[0];
	for (int i = 0; i <= n; i++) {
		X[i + 1] = r * X[i] - d;
		cout << X[i + 1] << endl;
	}
	return 0;
}

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

int main(){
  int i,j,N;
  double a=0.0,sum=0.0;
   scanf("%d",&N);
  char b[3];
  for(i=0;i<N;i++){
    scanf("%lf %s",&a,&b);
  //  printf("%lf %s\n",a,b);
  if(strcmp(b,"JPY")==0)
    sum+=a;
  else if(strcmp("BTC",b)==0)
    sum+=a*380000.0;
    }
   printf("%lf",sum);
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>


int main(){
int a,b,c;
int i;
int z=0;
scanf("%d%d%d",&a,&b,&c);
for(i=a;i<=b;i++){
	if(c%i==0){
		z++;
		
		
		
	}
	
	
	
	
}
printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 596
# C
A, B, C, D, E, F = map(int, input().split())

A_limit = F // (100*A)

max_density = 0.0
max_suger = 0
max_total = 0

for a in range(A_limit + 1):
    B_limit = (F-100*A*a) // (100*B)
    for b in range(B_limit + 1):
        water = 100*A*a + 100*B*b
        
        suger_limit = min(water*E // 100, F - water)
        
        suger_ = 0
        for c in range(suger_limit // C + 1):
            d = (suger_limit - C*c) // D
            suger = C*c + D*d
            suger_ = max(suger, suger_)
        
        if (suger_ + water) > 0:
            if suger_ / (suger_ + water) >= max_density:
                max_density = suger_ / (suger_ + water)
                max_suger = suger_
                max_total = suger_ + water

print(str(max_total)+" "+str(max_suger))



Measured memory_bytes: 3064
#include<stdio.h>
int n,a,i,si,br,gr,sk,bl,ye,ol,re,t,g,p,x,y,o;
int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
			if(a<400){
				si=1;
			}else if(400<=a&&a<800){
				br=1;
			}else if(800<=a&&a<1200){
				gr=1;
			}else if(1200<=a&&a<1600){
				sk=1;
			}else if(1600<=a&&a<2000){
				bl=1;
			}else if(2000<=a&&a<2400){
				ye=1;
			}else if(2400<=a&&a<2800){
				ol=1;
			}else if(2800<=a&&a<3200){
				re=1;
			}else if(3200<=a){
				t++;
			}
	}
	g=si+br+gr+sk+bl+ye+ol+re;
	o=0;
	o=g+t;
	//o=g+t-(((g+t)/8)/(g+t)/8)*(g+t-8);
	if(g==0&&t>0){
		g=1;
	}
	printf("%d %d\n",g,o);
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	// Code for B - Go to Jail
	var N int
	fmt.Scan(&N)

	var count int
	var D1, D2 int
	var flag int
	for i := 0; i < N; i++ {
		fmt.Scan(&D1, &D2)
		if D1 == D2 {
			count++
		} else {
			count = 0
		}

		if count == 3 {
			flag++
		}
	}

	if flag == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using Lint=long long;

Lint calc(Lint N,Lint K)
{
   Lint res=0;
   while(N/K>0){ res+=N/K; N/=K; }
   return res;
}

Lint func(Lint N)
{
   if(N<=1) return 0;
   if(N%2==1){
      return 0;
   }else{
      return min(calc(N,2),calc(N/2,5));
   }
}

int main()
{
   Lint N; cin>>N;
   cout<<func(N)<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    // 一の位は9
    if (N % 10 == 9) {
        cout << "Yes" << endl;
        return 0;
    }

    N /= 10;

    // 十の位は9
    if (N % 10 == 9) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 1000000000 + 7;
vector<ll> results;
ll result;

ll pot(ll a, int b) {
	ll res = 1;
	while (b) {
		if (b & 1) {
			res = (res * a) % mod;
		}
		a = (a*a) % mod;
		b >>=1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	result=0;
	results.resize(k + 1, 0);
	FORD(x, k + 1, 1) {
		int nums = k / x;
		results[x] = pot(nums, n);
		for (int j=2 * x; j <= k; j += x) {
			results[x] = (results[x] - results[j] + mod) % mod;
		}
		result = (result + results[x]*x) % mod;
	}
	cout << result << endl;
}

Measured memory_bytes: 3976
N = int(input())

shisuu = [0] * (N+1)

for i in range(2,N+1):
    x = i
    for j in range(2,N+1):
        while x%j == 0:
            x //= j
            shisuu[j] += 1
        
ans = 1
mod = 10**9+7

for s in shisuu:
    ans *= (s+1)
    ans %= mod

print(ans)
            
        


Measured memory_bytes: 3060
mod = 10 ** 9 + 7
x, y = map(int, input().split())
if (x + y) % 3 != 0 or x * 2 < y or y * 2 < x:
    print(0)
    exit()
l = [1]
for i in range(1, (x + y) // 3 + 100):
    l.append(l[-1] * i % mod)
def comb(n, r, m):
    return l[n] * pow(l[r], m - 2, m) * pow(l[n - r], m - 2, m) % m
a, b = y - (x + y) // 3, x - (x + y) // 3
print(comb(a + b, a, mod) % mod)

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

int main(){
    string str;
    while(cin >> str){
        if(str[0] == 'x' && str[str.size()-1] == 'x') cout << 'x' << endl;
        else cout << 'o' << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
// #define int long long
#define ll long long
#define sz(a) (int)(a.size())
#define pb push_back
#define all(c) c.begin(),c.end()
#define tr(it,c) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n)	for(int i=0;i<n;i++)
#define present(c,x) (c.find(x)!=c.end()) //for set/map etc.
#define cpresent(c,x) (find(all(c),x)!=c.end())
typedef pair<int,int> pi;
	typedef vector<int> vi;
	typedef vector<vector<int>> vvi;
	typedef vector<long long> vll;
	typedef vector<pair<int,int>> vp;
int N=100001;
int mod=1e9+7;
int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
bool comp(int a, int b) 
{ 
    return (a > b); 
} 

// string s,t,s1,t1;
// int ans()
// {
// 	// string s1,t1;
// 	s1.erase(all(s1));
// 	t1.erase(all(t1));
// 	int n= s.size();
// 	char c = s[0];
// 	if(n==1)return 0;
// 	// int n_s= s.size(),n_t = t.size();
// 	fr(i,n-1)
// 	s[i]=s[i+1];
// 	s[n-1]=c;
// 	fr(i,n)
// 	{
// 		if(t[i]!=s[i])
// 		{
// 			s1.pb(s[i]);
// 			t1.pb(t[i]);
// 		}
// 	}
// // 	s.clear();
// // 	t.clear();
// 	s=s1;
// 	t=t1;
// 	if(s1.size()==0)return 0;
// 	else
// 	{
// 		return ans()+1;
// 	}
// }

void solve()
{
	int n;
	cin>>n;
	vi v(n);
	ll sum=0;
	fr(i,n)
	{
		cin>>v[i];
	}
	sort(all(v),comp);
	if(n>1){
		sum=v[0];
		if(n<4)
		{
			if(n==3)sum=sum + v[1];
		}
		else
		{
			int i=0;
			for(i=0;i<(n-2)/2;i++)
			{
				sum=sum + 2*(v[i+1]);
			}
			if(n%2==1)
			{
				sum=sum + v[i+1];
			}
		}
	}
	cout<<sum;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin>>t;
	// while(t--)
	// {
	// 	solve();
	// 	cout<<endl;
	// }
	solve();
	return 0;
	
}



Measured memory_bytes: 4048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A,B;
	cin >> A >> B;

	if ((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0))
	{
		cout<<"Possible"<<endl;
	}
	else
	{
		cout << "Impossible" << endl;
	}
	
	
	
	return 0;

	


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void solve(){

	string s;
	cin>>s;

	string d[4];
	d[0] = "dream";
	d[1] = "dreamer";
	d[2] = "erase";
	d[3] = "eraser";

	reverse(s.begin(),s.end());
	REP(i,0,4)reverse(d[i].begin(),d[i].end());

	lli now = 0;
	while(now<s.size()){
		bool ok=false;
		REP(i,0,4){
			if(s.substr(now,d[i].size()) == d[i]){
				ok = true;
				now += d[i].size();
				break;
			}
		}
		if(!ok){
			cout<<"NO"<<endl;
			return;
		}
	}

	cout<<"YES"<<endl;
	return ;
}

int main(){

	lli q;
	q=1;
	while(q--)solve();

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){

    int a,b,c,temp,flag=0;

    scanf("%d %d %d",&a,&b,&c);

    do{
      if(a>b){
        flag=0;
        temp=a;
        a=b;
        b=temp;
      }else{
        flag=1;
      }

      if(b>c){
        flag=0;
        temp=b;
        b=c;
        c=temp;
      }else{
        flag=1;
      }
    }while(flag==0);

    printf("%d %d %d\n",a,b,c);

    return 0;

}


Measured memory_bytes: 2048
from itertools import combinations as comb
def get_ans(m, n):
	ans = 0
	for nums in comb(list(range(1, min(m+1,n-2))), 3):
		if sum(nums) == n:
			ans += 1
	print(ans)
	
while True:
	m, n = (int(x) for x in input().split())
	if m==0 and n==0:
		quit()
	get_ans(m, n)


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/b.in", "r", stdin);
//  freopen("../IO/b.in", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int n, m;
  in >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for (int &i : a) in >> i, sum += i;
  sort(a.rbegin(), a.rend());
  bool ok = true;
  for (int i = 0; i < m; ++i) {
    ok &= a[i] * 4 * m >= sum;
  }
  out << (ok ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> a = new ArrayList();

        for (int i = 0; i < N; i++) {
            a.add(sc.nextInt());
        }
        sc.close();
        a.sort(Collections.reverseOrder());

        int Alice = 0;
        int Bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                Alice += a.get(i);
            } else {
                Bob += a.get(i);
            }
        }

        System.out.println(Alice - Bob);
    }
}

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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    int ss = 0 - 100 - N;
    vector<vector<int>> data(N, vector<int>(N, 0));
    for(int i=0;i<N;i++){
        int inc, dec, incs=ss, decs=ss;
        inc = i+1;
        dec = i-1;
        if(i==X){
            incs = Y;
            decs = Y;
        }else if(i==Y){
            incs = X;
            decs = X;
        }
        for(int dis=1;dis<N+1;dis++){
            if(0<=inc && inc<N){
                // inc++;
                if(data[i][inc]==0){
                    data[i][inc] = dis;
                    // inc++;
                }else{
                    // inc++;
                }
            } 
            if(0<=dec && dec<N){
                // dec--;
                if(data[i][dec]==0){
                    data[i][dec] = dis;
                    // dec--;
                }else{
                    // dec--;
                }
            } 
            if(0<=decs && decs<N){
                // decs--;
                if(data[i][decs]==0){
                    data[i][decs] = dis;
                    // decs--;
                }else{
                    // decs--;
                }
            } 
            if(0<=incs && incs<N){
                // incs++;
                if(data[i][incs]==0){
                    data[i][incs] = dis;
                    // incs++;
                }else{
                    // incs++;
                }
            }
            if(incs!=ss) incs++;
            if(decs!=ss) decs--;
            if(inc==X || dec==X){
                // incs = Y;
                // decs = Y;
                if(incs==ss) incs = Y;
                if(decs==ss) decs = Y;
            }else if(inc==Y || dec==Y){
                // incs = X;
                // decs = X;
                if(incs==ss) incs = X;
                if(decs==ss) decs = X;
            }
            inc++;
            dec--;
        }
    }
    // /// test
    // for(int i=0;i<N;i++){
    //     for(int j=0;j<N;j++){
    //         cout << "i, j = " << i << ", " << j << " data = " << data[i][j] << endl;
    //     }
    // }
    vector<int> disC(N, 0);
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            disC[data[i][j]]++;
        }
    }
    for(int i=1;i<N;i++){
        cout << disC[i] << endl;
    }

    return 0;
}


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

using namespace std;

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

string s;

lli binpow(lli a,lli b,lli mod)
{
    if(b==0)
        return 1;
    lli ans=(binpow(a,b/2,mod))%mod;
    ans=(ans*ans)%mod;
    if(b%2)
        return (ans*a)%mod;
    else
        return ans;
}

lli solve(lli a)
{
    if(a==0)
        return 0;
    lli temp=a,ct=0;
    while(temp>0)
    {
        if(temp%2)
            ct++;
        temp/=2;
    }
    return 1+solve(a%ct);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i,j,tt=1;
    //cin>>tt;
    while(tt--)
    {
        lli n,o=0,z=0;
        cin>>n;
        cin>>s;
        for(i=0;i<n;i++)
        {
            if(s[i]=='1')
                o++;
            else
                z++;
        }
        vector<lli> possible;
        if(o==0)
        {
            possible.push_back(1);
            for(i=0;i<n;i++)
            {
                cout<<"1\n";
            }
            continue;
        }
        else if(z==0)
        {
            possible.push_back(n-1);
        }
        else
        {
            possible.push_back(o-1);
            possible.push_back(o+1);
        }
        lli rem[(int)possible.size()]={0};
        for(i=0;i<(int)possible.size();i++)
        {
            for(j=0;j<n;j++)
            {
                if(s[j]=='1' && possible[i]>0)
                {
                    rem[i]=(rem[i]+binpow(2LL,n-j-1,possible[i]))%possible[i];
                }
            }
        }
        for(i=0;i<n;i++)
        {
            if(s[i]=='1')
            {
                if(possible[0]==0)
                {
                    cout<<"0\n";
                    continue;
                }
                lli temp=binpow(2LL,n-1-i,possible[0]);
                temp=(rem[0]+possible[0]-temp)%possible[0];
                lli ans=1+solve(temp);
                cout<<ans<<"\n";
            }
            else
            {
                if(possible[possible.size()-1]==0)
                {
                    cout<<"0\n";
                    continue;
                }
                lli temp=binpow(2LL,n-1-i,possible[possible.size()-1]);
                temp=(rem[possible.size()-1]+temp)%possible[possible.size()-1];
                lli ans=1+solve(temp);
                cout<<ans<<"\n";
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
signed main(){
    fast_io();
    int N,K,S; cin >> N >> K >> S;
    vector<int>v(K,S);
    int maxi = 1e9;
    rep(i, N - K)v.push_back((S == maxi ? 1 : maxi));
    out(v);
}




Measured memory_bytes: 2292
fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b.clone(), a % b)
    }
}

fn main () {
    let mut nx = String::new();
    let mut xi = String::new();
    std::io::stdin().read_line(&mut nx).unwrap();
    std::io::stdin().read_line(&mut xi).unwrap();
    let nx: Vec<usize> = nx.trim().split_whitespace().flat_map(str::parse).collect();
    let mut xi: Vec<usize> = xi.trim().split_whitespace().flat_map(str::parse).collect();
    let X = nx[1];
    let mut r = 0;
    for x in xi.iter().map(|&a| if a > X { a - X } else { X - a }) {
        r = if r == 0 { x } else { gcd(x, r) };
    }
    println!("{}", r);
}


Measured memory_bytes: 6396
#include <algorithm>
#include <cassert>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

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

    auto split = [](const string& s, char delimiter) {
        stringstream ss;
        ss << s;
        string t;
        vector<string> r;
        while (getline(ss, t, delimiter)) {
            if (!t.empty()) {
                r.push_back(t);
            }
        }
        return r;
    };

    auto encode = [](const string& s) {
        const auto c = s[0];
        const auto len = s.size() - 1;
        if (c == '1') {
            switch (len % 5) {
            case 0:
                return '.';
            case 1:
                return ',';
            case 2:
                return '!';
            case 3:
                return '?';
            case 4:
                return ' ';
            }
        }
        else if (c == '2') {
            switch (len % 3) {
            case 0:
                return 'a';
            case 1:
                return 'b';
            case 2:
                return 'c';
            }
        }
        else if (c == '3') {
            switch (len % 3) {
            case 0:
                return 'd';
            case 1:
                return 'e';
            case 2:
                return 'f';
            }
        }
        else if (c == '4') {
            switch (len % 3) {
            case 0:
                return 'g';
            case 1:
                return 'h';
            case 2:
                return 'i';
            }
        }
        else if (c == '5') {
            switch (len % 3) {
            case 0:
                return 'j';
            case 1:
                return 'k';
            case 2:
                return 'l';
            }
        }
        else if (c == '6') {
            switch (len % 3) {
            case 0:
                return 'm';
            case 1:
                return 'n';
            case 2:
                return 'o';
            }
        }
        else if (c == '7') {
            switch (len % 4) {
            case 0:
                return 'p';
            case 1:
                return 'q';
            case 2:
                return 'r';
            case 3:
                return 's';
            }
        }
        else if (c == '8') {
            switch (len % 3) {
            case 0:
                return 't';
            case 1:
                return 'u';
            case 2:
                return 'v';
            }
        }
        else if (c == '9') {
            switch (len % 4) {
            case 0:
                return 'w';
            case 1:
                return 'x';
            case 2:
                return 'y';
            case 3:
                return 'z';
            }
        }
        assert(false);
    };

    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;

        auto r = split(s, '0');
        string rr;
        transform(begin(r), end(r), back_inserter(rr), encode);

        cout << rr << endl;
    }
}

Measured memory_bytes: 3168
// abc151_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

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

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    REP(i, H) cin >> S[i];

    vector<vector<int>> dp(H*W, vector<int>(H*W, INF));
    REP(i, H) REP(j, W) {
        if (S[i][j] == '#') continue;

        dp[i*W+j][i*W+j] = 0;

        REP(k, 4){
            int ni = i + dy[k];
            int nj = j + dx[k];
            if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue;

            if (S[ni][nj] == '.') {
                dp[i*W+j][ni*W+nj] = 1;
            }
        }
    }

//    REP(i, H*W) print(dp[i]);

    REP(k, H*W) REP(i, H*W) REP(j, H*W)  {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    }

//    print("----");
//    REP(i, H*W) print(dp[i]);

    int ans = 0;
    REP(i, H*W) REP(j, H*W) {
        if (dp[i][j] != INF) ans = max(ans, dp[i][j]);
    }

    print(ans);


    return 0;
}


Measured memory_bytes: 896
import math
a=int(input())
a_max=math.ceil(math.sqrt(a))
ans_1=1
for i in range(a_max):
  x=i+1
  if a%x==0 :
    ans_1=x
ans_2=a/ans_1
ans=int(ans_1+ans_2-2)
print(ans)
    

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

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


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

#define inf  1000000007
#define ll long long
#define PA pair<int,int>
#define PPAP pair<int,PA>
#define  MP make_pair
#define  PB push_back

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> p(n);
	for(int i=0;i<n;i++){
		cin >> p[i];
		p[i]--;
	}
	vector<int> a(n),b(n);
	for(int i=1;i<=n;i++){
		a[i-1] = 33000*i;
		b[n-i] = 33000*i;
	}
	for(int i=0;i<n;i++){
			a[p[i]] += i;
	}
	for(int i=0;i<n-1;i++){
		cout << a[i] << " ";
	}
	cout << a[n-1] << endl;
	for(int i=0;i<n-1;i++){
		cout << b[i] << " ";
	}
	cout << b[n-1] << endl;
	return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
    class Program
    {
        static double Area(int a, int b, int c)
        {
            return 0.5f * (double)a * (double)b * Math.Sin(c*(Math.PI/180));
        }

        static double Circuit(int a,int b, int c)
        {
            return a + b + Math.Sqrt(a * a + b * b - 2 * a * b * Math.Cos(c * (Math.PI / 180)));
        }

        static double High(double area,int a)
        {
            return (area / a) * 2;
        }


        static void Main(string[] args)
        {
            int[] abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = abc[0];
            int b = abc[1];
            int c = abc[2];
            Console.WriteLine(Program.Area(a,b,c));
            Console.WriteLine(Program.Circuit(a,b,c));
            Console.WriteLine(Program.High(Program.Area(a,b,c),a));

        }
    }
}

Measured memory_bytes: 9464
import itertools
a = int(input())
b = int(input())
c = int(input())
x = int(input())
R = [i for i in range(60)]
num = 0
for i, j, k in itertools.product(R[:a + 1], R[: b + 1], R[: c + 1]):
    if 500 * i + 100 * j + 50 * k == x:
        num += 1

print(num)

Measured memory_bytes: 3060
N = int(input())
S = input()
r = g = b = 0
for s in S:
    if s == 'R':
        r += 1
    if s == 'G':
        g += 1
    if s == 'B':
        b += 1

ans = r * g * b
for i in range(N - 1):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 73792
k = int(input())

if k <= 9:
    print(k)
k -= 9

lst = list(range(1, 10))
while k > 0:
    new = []
    for num in lst:
        amari = num % 10
        if amari == 0:
            new.append(num*10)
            new.append(num*10+1)
        elif amari == 9:
            new.append(num*10+8)
            new.append(num*10+9)
        else:
            new.append(num*10+(amari-1))
            new.append(num*10+amari)
            new.append(num*10+(amari+1))
    if len(new) >= k:
        print(new[k-1])
        exit()
    else:
        k -= len(new)
        lst = new

Measured memory_bytes: 79072
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
using namespace std;
const int N=200005;
const int inf=1e9+7;
typedef long long ll;
typedef long double lb;
inline void read(int &x){x=0; char ch=getchar();while(ch<'0') ch=getchar();while(ch>='0'){x=x*10+ch-48; ch=getchar();}}
//------------------------------------------head---------------------------------------------------//
int dis[N];
int main()
{
	ll ans=0;
	int n;read(n); int a,b; read(a);read(b);
	rep(i,1,n)
	{
		read(dis[i]);
		if(i>1)
		{
			int xx=dis[i]-dis[i-1];
			if((ll)xx*a>=(ll)b) ans+=b;
			else ans+=(ll)xx*a;
		}
	}
	printf("%lld\n",ans);return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    
    long long int n,sum=0;
    
    cin>>n;
    
    
    for(int a=1;a<=n;a++)
    {
    
          if(a%3==0 or a%5==0)
          {
    
              continue;
    
          }
    
        sum+=a;
    
    }
    
    cout<<sum;
    
}


Measured memory_bytes: 3636
//    https://youtu.be/N3oCS85HvpY

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,temp,flag,ans=1,mod=1000000007;
    string s1,s2;
    cin>>n>>s1>>s2;
    vector<ll>v;
    for(i=0;i<n-1;i++){
        if(s1[i]==s1[i+1]){
            v.push_back(0);
            i++;
        }else{
           v.push_back(1);
        }
    }
    if(s1[n-1]==s2[n-1]) v.push_back(1);
    if(v[0]==1) ans*=3;
    else ans*=(3*2);
    for(i=1;i<v.size();i++){
        if(v[i]==0){
            if(v[i-1]==0){
                ans*=3;
                ans%=mod;
            }else{
                ans*=2;
                ans%=mod;
            }
        }else{
            if(v[i-1]==1){
                ans*=2;
                ans%=mod;
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
n = int(input())
c = input()
rl = [ i for i,_ in enumerate(c) if _ == 'R' ]

cnt = 0
loc = 0
rid = -1
while True:
	try:
		if c[loc] == 'W':
			rloc = rl[rid]
			rid -= 1
			if rloc < loc:
				break
			else:
				cnt += 1
		loc += 1
		if loc == n:
			break
		#print(c,cnt)
	except:
		break
print(cnt)

Measured memory_bytes: 17208
using System;
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            Console.WriteLine(new Calu().calu(input));
        }
        public class Calu{
            public uint calu(int input){

                uint temp = 0;
                for (uint i = 0; i < input + 1; i++){
                    temp += i;
                    if(temp>=input){
                        return i;
                    }
                }
                return 0;

                
            }
        }
    }

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long
main(){
    int n,m;
    cin>>n>>m;
    multiset<int>s;
    for(int i=1;i<=n;++i){
        int x;
        scanf("%d",&x);
        s.insert(-x);
    }
    while(m--){
        int big=*s.begin();
        if(big==0)break;
        s.erase(s.begin());
        big/=2;
        s.insert(big);
    }
    int sum=0;
    for(auto i:s){
        sum+=-i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 4992
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;	
	cin >> a >> b >> c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size() == 2) {
		cout << "Yes";
	}
	else cout << "No";
	return 0;
}


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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if ( a+b > c+d ) {
    cout << "Left" << endl;
  }
  
  else if ( a+b == c+d ) {
    cout << "Balanced" << endl;
  }

  else if ( a+b < c+d ) {
    cout << "Right" << endl;
  }
}

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

int main()
{
	int a,b,c,d,e,k;

	cin >> a >> b >> c >> d >> e >> k;

	if (e-a<=k) {
		cout << "Yay!" << endl;
	}

	else {
		cout << ":(" << endl;
	}

	return 0;
}

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

using ll = long long;
const ll INF = 1e18, MAX_COST = 2500;
typedef pair<ll, ll> P;
using edge = pair<ll, P>;


signed main() {
    ll N, M, S;
    cin >> N >> M >> S;
    S = min(S, MAX_COST);
    vector<vector<edge>> G(N);
    for (int i = 0; i < M; ++i) {
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        G[u].push_back(edge(v, P(a, b)));
        G[v].push_back(edge(u, P(a, b)));
    }
    vector<ll> c(N), d(N);
    for (ll i = 0; i < N; ++i) {
        cin >> c[i] >> d[i];
    }
    vector<vector<ll>> dist(N, vector<ll>(MAX_COST + 1, INF));
    priority_queue<edge, vector<edge>, greater<edge>> que;

    dist[0][S] = 0;
    que.push(edge(0, P(0, S)));

    while (que.size()) {
        edge e = que.top();
        que.pop();
        ll time = e.first, now = e.second.first, money = e.second.second;
        if (dist[now][money] < time) continue;
        if (money + c[now] <= MAX_COST) {
            ll ntime = time + d[now], nmoney = money + c[now];
            if (dist[now][nmoney] > ntime) {
                dist[now][nmoney] = ntime;
                que.push(edge(ntime, P(now, nmoney)));
            }
        }

        for (auto e : G[now]) {
            if (money < e.second.first) continue;
            ll nxt = e.first, ntime = time + e.second.second, nmoney = money - e.second.first;
            if (dist[nxt][nmoney] > ntime) {
                dist[nxt][nmoney] = ntime;
                que.push(edge(ntime, P(nxt, nmoney)));
            }
        }
    }

    for (ll i = 1; i < N; ++i) {
        ll ans = INF;
        for (ll j = 0; j <= MAX_COST; ++j) {
            ans = min(ans, dist[i][j]);
        }
        cout << ans << endl;
    }
    return 0;
} 

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

int main() {
  int N;
  cin >> N;
  vector <int> a(N);
  vector <int> count(N, 0) ;
  int mx = 100 ;
  for ( int i=0 ;i< N ; i++){
    cin >> a.at(i) ;
    for ( int j = a.at(i) ; j%2 == 0 ; j/=2){
      count.at(i) ++ ;
    }
    mx = min ( mx , count.at(i)) ;
  }
  cout << mx << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
      int a,b,c,r;
      Scanner  sc =new Scanner(System.in);
      a=sc.nextInt();
      b=sc.nextInt();
      if (a<b) {
          c=a;
          a=b;
          b=c;
      }  
      r=a%b;
while(r!=0){
a=b;
b=r;
r=a%b;
}
System.out.println(b);
    }
}


Measured memory_bytes: 26268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int h,w,k;
  cin >> h >> w >> k;
  vstring S(h);
  rep(i,h) cin >> S[i];
  int g = 0,p = 1,q = 1;
  string a = "";
  for(int i = 0;i < h;i++){
    int g = -1;
    for(int j = w-1;j >= 0;j--){
      if(S[i][j] == '#'){
        g = j;
        break;
      }
    }
    if(g == -1){
        q++;
        continue;
    }
    a = "";
    rep(j,w){
      a += to_string(p) + " ";
      if(S[i][j] == '#' && j != g) p++;
    }
    rep(j,q){
      cout << a << endl;
    }
    p++;
    q = 1;
  }
  rep(j,q-1){
    cout << a << endl;
  }

}


Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  
  //偶数番目が正
  ll sum1 = 0, ans1 = 0;
  for (int i = 0; i < n; i++) {
    sum1 += a[i];
    if (i % 2 == 0 && sum1 <= 0) {
      ans1 += 1 - sum1;
      sum1 = 1;
    }
    if (i % 2 == 1 && sum1 >= 0) {
      ans1 += 1 + sum1;
      sum1 = -1;
    }
  }
  
  //偶数番目が負
  ll sum2 = 0, ans2 = 0;
  for (int i = 0; i < n; i++) {
    sum2 += a[i];
    if (i % 2 == 1 && sum2 <= 0) {
      ans2 += 1 - sum2;
      sum2 = 1;
    }
    if (i % 2 == 0 && sum2 >= 0) {
      ans2 += 1 + sum2;
      sum2 = -1;
    }
  }
  cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 1024
let N = stdin.ReadLine() |> int
let mutable c = 0;
let mutable b = false;
for i in 0..N-1 do
    let In = stdin.ReadLine().Split(' ') |>Array.map int
    if In.[0] = In.[1] 
        then
            c <- c + 1
            if c = 3 then b <- true
        else 
            c <- 0

let ans = if b = true then "Yes" else "No"
ans |> printfn "%s"

Measured memory_bytes: 29720
n = int(input())
a = list(map(int, input().split()))

sum_a = sum(a)
a = sorted(a)

if n % 2 == 1:
    if sum(a) % 2 == 0:
        print("Second")
    else:
        print("First")
    
else:
    if sum_a % 2 == 0 and a[0] % 2 == 0:
        print("Second")
    else:
        print("First")



Measured memory_bytes: 28348
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	ins := strings.Split(readLine(), " ")

	// , _ := strconv.Atoi(ins[0])
	x, _ := strconv.Atoi(ins[1])

	var l []int
	ls := strings.Split(readLine(), " ")
	for _, v := range ls {
		a, _ := strconv.Atoi(v)
		l = append(l, a)
	}

	var c int
	var i int

	for _, v := range l {
		if x >= i {
			c++
		}
		i += v
	}

	if x >= i {
		c++
	}

	fmt.Println(c)
}


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

string triangle(int x,int y,int z){
  if(x*x==y*y+z*z) return "YES";
  else if(y*y==z*z+x*x) return "YES";
  else if(z*z==x*x+y*y) return "YES";
  else return "NO";
}

int main()
{
  int n,a,b,c;
  cin >> n;
  
  for(int i=0;i<n;i++){
    cin >> a >> b >> c;
    string str=triangle(a,b,c);
    cout << str << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
a,b,c,d=gets.split(" ").map{|n|n.to_i}
cup = c.lcm(d)
a = a-1
a_sum = a-( (a/c) + (a/d) - (a/cup))
b_sum = b-( (b/c) + (b/d) - (b/cup))
puts (b_sum-a_sum)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N,sum = 0;
    cin >> N;
    vector<ll> A(N),D;
    rep(i,N){
        cin >> A[i];
        sum += A[i];
    }
    rep(i,N){
        if(i == N-1) D.push_back(A[0] - A[i]);
        else D.push_back(A[i+1] - A[i]);
    }
    if((2 * sum) % (N * (N+1)) != 0){
        cout << "NO" << endl;
        return 0;
    }
    ll U = (2*sum) / (N * (N+1)),cnt = 0;
    rep(i,N){
        if(U - D[i] < 0){
            cout << "NO" << endl;
            return 0;
        }
        if((U - D[i]) % N == 0){
            cnt += (U - D[i]) / N;
        }else{
            cout << "NO" << endl;
            return 0;
        }
    }
    /*if(cnt != U){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }*/
    cout << "YES" << endl;
}


Measured memory_bytes: 2168
# ABC117C - Streamline
def main():
    n, m = list(map(int, input().rstrip().split()))
    lst = sorted(set(map(int, input().rstrip().split())))
    dis = []
    for i, j in zip(lst, lst[1:]):
        dis += [j - i]
    print(sum(sorted(dis, reverse=True)[n - 1 :]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 18960
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int a,b;
    cin >> a >> b;
    cout <<max(a+b,max(a-b,a*b)) << endl;
    return 0;
}

Measured memory_bytes: 256