akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    ll n; cin >> n;
    vector<ll> a(n+1);
    ll sum = 0;
    ll ans = 1;

    rep(i,n+1){
        cin >> a[i];
        sum += a[i];
    }

    if(n == 0){
        if(a[0] == 1){
            cout << 1 << endl;
        } 
        else{
            cout << -1 << endl;
        }
        return 0;
    }

    bool jud = true;
    ll tmp = 1;

    rep(i,n+1){
        if(i == 0){
            if(a[0] == 0){
                continue;
            }
            else{
                cout << -1 << endl;
                return 0;
            }
        }

        if(i == n){
            if(tmp * 2 < a[i]){
                jud = false;
                break;
            }
            else{
                ans += a[n];
                break;
            }
        }

        if(tmp*2 < a[i]){
            jud = false;
            break;
        }

        tmp = min(tmp*2-a[i], sum-a[i]);
        ans += tmp + a[i];
        sum -= a[i];

    }

    if(!jud){
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;

}

Measured memory_bytes: 4052
N,K = map(int,input().split())
S = list(input())

c = 0  #初期状態の幸せな人数
d = 0  #左から見ていって何回向きが変わるか
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        c += 1
    else:
        d += 1

if d >= 2*K:
    print(c+2*K)
else:
    print(c+d)

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

typedef long long ll;

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

    int n,k;
    cin >> n >> k;
    int num = 1;
    for(int i=0;i<n;i++){
        if(num*2<num+k) num *= 2;
        else num += k;
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := make([]int, a)
	bb := make([]int, b)
	for i := 0; i < a; i++ {
		aa[i] = getNextInt(scanner)
	}

	mb := math.MaxInt32
	for i := 0; i < b; i++ {
		bb[i] = getNextInt(scanner)
		mb = minint(mb, bb[i])
	}
	ans := make([]int, a)
	for i := 0; i < a; i++ {
		ans[i] = aa[i] + mb
	}
	for i := 0; i < m; i++ {
		x := getNextInt(scanner) - 1
		y := getNextInt(scanner) - 1
		c := getNextInt(scanner)
		ans[x] = minint(ans[x], aa[x]+bb[y]-c)
	}
	o := ans[0]
	for i := 0; i < a; i++ {
		o = minint(o, ans[i])
	}
	fmt.Fprintln(writer, o)
}

func minint(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 6528
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define po pop()
#define pu push
#define pb push_back
#define pf push_front
#define pob pop_back()
#define pof pop_front()
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL ceil2(LL a,LL b){LL c=a/b; if(a%b)c++; return c; }
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;string st,s1,s2,s3; char ch;
    while(cin>>n)
    {
        cin>>st;
        stack<char>stc;
        rep(i,st.sz)
        {
            if(stc.empty())stc.push(st[i]);
            else
            {
                ch=stc.top();
                if(ch!=st[i])stc.push(st[i]);
            }
        }
        c=0;
        while(!stc.empty())
        {
            c++;
            stc.pop();
        }
        cout<<c<<en;
    }
}




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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var z = 2*C - A;
		var T = A+C+z;
		var x = T - A -B;
		var y = T - B - C;
		var w = T - y - z;
		var s = T - A - w;
		var t = T - s - C;
		Console.WriteLine("{0} {1} {2}",A,B,x);
		Console.WriteLine("{0} {1} {2}",s,C,t);
		Console.WriteLine("{0} {1} {2}",w,y,z);
		
		
	}
	int A,B,C;
	public Sol(){
		A = ri();
		B = ri();
		C = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 100;

int visited[maxn][maxn];
int grid[maxn][maxn];
ii path[maxn][maxn];
int dist[maxn][maxn];

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

int w,h;

bool ok(int x,int y){
	return x >= 0 && x < w && y >= 0 && y < h && !visited[x][y] && grid[x][y];
}

void recovery(int x,int y){
	if(x == 0 && y == 0) return;
	grid[x][y] = 0;
	//cout << "x = " << x << " y = " << y << '\n';
	recovery(path[x][y].ff,path[x][y].ss);
}

int main(int argc,const char** argv){

	fastio;

	cin >> w >> h;

	int cont = 0;

	rep(i,0,w){
		rep(j,0,h){
			char aux;
			cin >> aux;
			if(aux == '.') grid[i][j] = 1;
			else{ grid[i][j] = 0;cont++;}
		}
	}

	//debug(cont);

	rep(i,0,maxn){
		rep(j,0,maxn){
			dist[i][j] = INF;
		}
	}

	dist[0][0] = 0;

	queue<pair<int,int>> q;
	q.push(ii(0,0));

	while(!q.empty()){
		int x = q.front().ff;
		int y = q.front(). ss;
		q.pop();
		visited[x][y] = 1;
		for(int i=0;i<4;++i){
				if(ok(x+dx[i],y+dy[i]) && dist[x][y] + 1 < dist[x+dx[i]][y+dy[i]]){
					dist[x+dx[i]][y+dy[i]] = dist[x][y] + 1;
					path[x+dx[i]][y+dy[i]] = ii(x,y);
					q.push(ii(x+dx[i],y+dy[i]));
				}
		}
	}

	//debug(dist[w-1][h-1]);


	recovery(w-1,h-1);

	int ans = 0;

	rep(i,0,w){
		rep(j,0,h){
			//cout << grid[i][j] << " \n"[j==h-1];
			ans+=grid[i][j];
		}
	}

	if(!visited[w-1][h-1]){
		cout << -1 << '\n';
		return 0;
	}

	cout << ans-1 << '\n';

	return 0;
}

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

using namespace std;

int A, B;
int main(void){
	scanf("%d %d", &A, &B);
	printf("%d %d\n", 2* (int) (ceil((double)(A == 1 ? 1 : A + 1)/50) + ceil((double)(B == 1 ? 1 : B + 1)/50)) + 2, 100);
	if(A >= B){
		int W = 100;
		int s = A;
		for(int i = 0;i < 100;++i){
			printf("#");
		}
		printf("\n");

		for(int j = 0;j < A/50 + 1;++j){
			for(int i = 0;i < 100;++i){
				if(i % 2 == 0 && s > 1){
					printf(".");
					--s;
				}else{
					printf("#");
				}
			}
			printf("\n");
			for(int i = 0;i < 100;++i){
				printf("#");
			}
			printf("\n");
		}

		for(int i = 0;i < 100;++i){
			printf(".");
		}
		printf("\n");

		int t = B-1;
		for(int j = 0;j < B/50 + 1;++j){
			for(int i = 0;i < 100;++i){
				if(i % 2 == 0 && t > 0){
					printf("#");
					--t;
				}else{
					printf(".");
				}
			}
			printf("\n");
			for(int i = 0;i < 100;++i){
				printf(".");
			}
			printf("\n");
		}
	}

	if(A < B){
		int W = 100;
		int s = B;
		for(int i = 0;i < 100;++i){
			printf(".");
		}
		printf("\n");

		for(int j = 0;j < B/50 + 1;++j){
			for(int i = 0;i < 100;++i){
				if(i % 2 == 0 && s > 1){
					printf("#");
					--s;
				}else{
					printf(".");
				}
			}
			printf("\n");
			for(int i = 0;i < 100;++i){
				printf(".");
			}
			printf("\n");
		}

		for(int i = 0;i < 100;++i){
			printf("#");
		}
		printf("\n");

		int t = A-1;
		for(int j = 0;j < A/50 + 1;++j){
			for(int i = 0;i < 100;++i){
				if(i % 2 == 0 && t > 0){
					printf(".");
					--t;
				}else{
					printf("#");
				}
			}
			printf("\n");
			for(int i = 0;i < 100;++i){
				printf("#");
			}
			printf("\n");
		}
	}

	return 0;
}

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

int main(){
  int i,j;
  int n,S,r[20000],cnt;
  while(1){
    cnt =0;

    cin >> n >> S;
    if(n==0&&S==0)break;

    for(i=0;i<n;i++)cin>>r[i];
    
for(j=0;j<n-1;j++){
    for(i=j+1;i<n;i++){
      if((r[j]+r[i])>S)cnt++;
    }
    }
    cout << cnt << endl;

}

  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <map>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef pair<int, int> PII;

int main() {
    map<int, int> Even;
    map<int, int> Odd;
    
    int N; cin >> N;
    for(int i=0; i<N; i++){
        int v; cin >> v;
        if(i%2 == 0) Even[v]++;
        else Odd[v]++;
    }
    
    vector<PII> E;
    vector<PII> O;
    
    for(auto e:Even) E.push_back(PII(e.second, e.first));
    for(auto o:Odd) O.push_back(PII(o.second, o.first));
    
    sort(E.begin(), E.end());
    sort(O.begin(), O.end());

    int max_even = E[E.size()-1].first;
    int mx_e_key = E[E.size()-1].second;
    int max2_even = E.size()==1? 0 : E[E.size()-2].first;
    
    int max_odd = O[O.size()-1].first;
    int mx_o_key = O[O.size()-1].second;
    int max2_odd = O.size()==1? 0 : O[O.size()-2].first;


    if(mx_o_key != mx_e_key){
        cout << (N/2 - max_odd) + (N/2 - max_even) << endl;
        return 0;
    }
    
    bool f = false;
    if(max_even + max2_odd > max_odd + max2_even) f = true;
    if(f){
        cout << (N/2 - max_even) + (N/2 - max2_odd) << endl;
    } else {
        cout << (N/2 - max_odd) + (N/2 - max2_even) << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 6136
#include<cstdio>
#include<iostream>
#include<ctime>
#include<string>
#include<algorithm>
#include<cmath>
int a[100010];
using namespace std;
int main()
{
	int x,y,n,ans;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d %d",&x,&y);
		for(int l=x;l<=y;l++)
		{
			a[l]=1;
		}
	}
	for(int i=0;i<100010;i++)
	{
		ans+=a[i];
	}
	printf("%d",ans);
}


Measured memory_bytes: 640
#define DEBUGGING  // Enables DEBUG macro.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifndef DEBUGGING
#define debug(...)
#define DEBUG(...)
#else
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                     \
  do {                                 \
    cerr << " (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ": ";      \
    debug(__VA_ARGS__);                \
    cerr << endl;                      \
  } while (0)
#endif

// auto mod int

const i64 MOD = 1'000'000'007;

struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

vector<mint> cache;
vector<bool> cached;

mint comb(i64 n, i64 k) {
  if (k > n) return 0;
  if (cached[n]) return cache[n];
  if (k > n - k) {
    k = n - k;
  }
  mint num = 1;
  mint den = 1;
  REP(i, k) {
    num *= (n - i);
    den *= (1 + i);
  }
  mint res = num * den.pow(MOD - 2);
  cache[n] = res;
  cached[n] = true;
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 K;
  cin >> K;
  string S;
  cin >> S;
  i64 N = S.size();
  vector<mint> pow25(N + K + 1);
  vector<mint> pow26(N + K + 1);
  pow25[0] = pow26[0] = 1;
  cache.resize(N + K + 1);
  cached.resize(N + K + 1);
  REP(i, N + K) {
    pow25[i + 1] = pow25[i] * 25;
    pow26[i + 1] = pow26[i] * 26;
  }

  mint ans = 0;
  mint comb = 1;
  for (int r = N - 1; r <= N + K - 1; ++r) {
    if (N + K - 1 - r < 0) break;
    ans += comb * pow25[r + 1 - N] * pow26[N + K - 1 - r];
    comb *= (r + 1);
    comb *= mint(r - N + 2).inv();
  }
  cout << ans << endl;
}


Measured memory_bytes: 51204
s=input()
X=int(s)

if(X==1):
    print(1)
else:
    data=[]
    for b in range(1,35):
        for p in range(2,10):
            xt=b**p
            if(xt>1000):
                break
            data.append(xt)

    dist=abs(data[0]-X)
    ans=data[0]
    for i in range(1,len(data)):
        if(data[i]<=X and abs(data[i]-X)<=dist):
            dist=abs(data[i]-X)
            ans=data[i]

    print(ans)


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

int main(){
  long int a,i,j,yaku,suu;
  cin>>a;
  for(i=1;i<=sqrt(a);i++){
    if(a%i==0){
      yaku=i;
    }
  }
  suu=a/yaku;
  cout<<yaku+suu-2;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;
const double EPS=1e-8;

const int N_MAX=100;
bool Gauss_Jordan(int n,const double A[N_MAX][N_MAX],const double *b,double *x){
	static double B[N_MAX][N_MAX+1];
	rep(i,n){
		rep(j,n) B[i][j]=A[i][j];
		B[i][n]=b[i];
	}

	rep(i,n){
		int piv=i;
		for(int j=i;j<n;j++) if(abs(B[j][i])>abs(B[piv][i])) piv=j;
		rep(j,n+1) swap(B[i][j],B[piv][j]);

		if(abs(B[i][i])<EPS) return false;

		for(int j=i+1;j<=n;j++) B[i][j]/=B[i][i];
		rep(j,n) if(i!=j) for(int k=i+1;k<=n;k++) B[j][k]-=B[j][i]*B[i][k];
	}

	rep(i,n) x[i]=B[i][n];
	return true;
}

int main(){
	for(int n,s,t;scanf("%d%d%d",&n,&s,&t),n;){
		s--; t--;

		int sign[100];
		rep(u,n) scanf("%d",sign+u);
		int d[100][100];
		rep(u,n) rep(v,n) scanf("%d",d[u]+v);
		rep(u,n) rep(v,n) if(u!=v && d[u][v]==0) d[u][v]=INF;

		int wf[100][100];
		rep(u,n) rep(v,n) wf[u][v]=d[u][v];
		rep(w,n) rep(u,n) rep(v,n) wf[u][v]=min(wf[u][v],wf[u][w]+wf[w][v]);

		if(wf[s][t]==INF){ puts("impossible"); continue; }

		static double A[100][100];
		double b[100]={},x[100];
		rep(u,n) rep(v,n) A[u][v]=0;
		rep(u,n){
			if(u==t);
			else if(!sign[u]){
				int deg=0;
				rep(v,n) if(u!=v && d[u][v]<INF) deg++;
				rep(v,n) if(u!=v && d[u][v]<INF) {
					A[u][v]=-1.0/deg;
					b[u]+=1.0*d[u][v]/deg;
				}
			}
			else{
				int deg=0;
				rep(v,n) if(u!=v && d[u][v]+wf[v][t]==wf[u][t]) deg++;
				rep(v,n) if(u!=v && d[u][v]+wf[v][t]==wf[u][t]) {
					A[u][v]=-1.0/deg;
					b[u]+=1.0*d[u][v]/deg;
				}
			}
			A[u][u]=1;
		}

		Gauss_Jordan(n,A,b,x);

		printf("%.8f\n",x[s]);
	}

	return 0;
}

Measured memory_bytes: 1300
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e6 + 123;
const ld pi = acos(-1.0);
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

ll a, b;
 
main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));

//	speed;

	cin >> a >> b;
	cout << a * b / __gcd(a, b);
  
    return 0;                                        
}

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

int n;
int x[24],y[24],r[24],c[24];
char memo[1<<25];

//dist(i,j)<r[i]+r[j]->ok
bool ok(int a,int bit){
    for(int i=0;i<a;i++){
        if(((bit>>i)&1)==0)continue;
        int dist=(x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a]);
        int sum=(r[i]+r[a])*(r[i]+r[a]);
        if(dist<sum)return false;
    }
    return true;
}

int dfs(int bit){
    if(memo[bit]!=-1)return memo[bit];

    int ret=n;
    for(int i=0;i<n;i++)if((bit>>i)&1)ret--;

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(((bit>>i)&1)==0)continue;
            if(((bit>>j)&1)==0)continue;
            if(c[i]==c[j]&&ok(i,bit)&&ok(j,bit)){
                ret=max(ret,dfs((bit^(1<<i))^(1<<j)));
            }
        }
    }
    return memo[bit]=ret;
}

void solve(){
    fill_n(memo,1<<n,-1);

    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}
int main(){

    int a=(1<<5)-1;
    while(input())solve();
    return 0;
}

Measured memory_bytes: 19588
def main():
    N = int(input())
    a_list = list(map(int, input().split()))
    rate_table = set([])
    over = 0

    for a in a_list:
        if a < 3200:
            rate_table.add(a//400)
        else:
            over += 1
            
    mini = len(rate_table)
    maxi = mini + over
    
    print(max(1,mini), maxi)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n; cin >> n;
  int a[n], b[n], x[n], y[n];
  bool used[n];
  REP(i, n){
    cin >> a[i] >> b[i];
    x[i] = y[i] = i;
    used[i] = false;
  }

  function<bool(int, int)> c1 =
    [&a, &b](int i, int j){
      return a[i] - b[j] > a[j] - b[i];
    };
  
  function<bool(int, int)> c2 =
    [&a, &b](int i, int j){
      return b[i] - a[j] > b[j] - a[i];
    };

  sort(x, x+n, c1); sort(y, y+n, c2);

  ll s1 = 0, s2 = 0;
  int i1 = 0, i2 = 0, cnt = 0;
  while(true){
    while(used[x[i1]]) i1++;
    s1 += a[x[i1]];
    used[x[i1]] = true;
    cnt++;
    if(cnt >= n) break;

    while(used[y[i2]]) i2++;
    s2 += b[y[i2]];
    used[y[i2]] = true;
    cnt++;
    if(cnt >= n) break;
  }

  cout << s1 - s2 << endl;
  
  return 0;
}


Measured memory_bytes: 1920
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def LOG(x):
    res = 0
    while x%2==0:
        res += 1
        x //= 2
    return res
def main():
    N,X = MI()
    A=sorted(LI())
    lcm = 1
    count_2 = LOG(A[0]//2)
    for a in A:
        a//=2
        lcm = a*lcm//gcd(a,lcm)
        if count_2!=LOG(a) or X<lcm:
            print(0)
            return
    print(ceil(X//lcm,2))
if __name__ == '__main__':
    main()


Measured memory_bytes: 16320
#include<bits/stdc++.h>
using namespace std;
int main(){
  long n;
  cin >> n;
  bool prime = true;
  while(1){
    for(long i = 2;i*i<=n;i++){
      if(!(n % i)){
        prime = false;
        break;
      }
    }
    if(prime)break;
    else prime = true;
    n++;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
d = [[] for _ in range(n)]
ans = [[] for _ in range(m)]
for i, _ in enumerate(range(m)):
    p, y = map(int, input().split())
    d[p-1].append([i, y])
for i in range(n):
    d[i].sort(key=lambda x:x[1])
    for j in range(len(d[i])):
        ans[d[i][j][0]].append(str(i+1).zfill(6)+str(j+1).zfill(6))
for i in ans: print(*i)

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

using namespace std;

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

    int count = 0;

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            int temp = s-i-j;

            if(temp >= 0 && temp <= n)
                count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;

const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, m,x;
	cin>>n>>m>>x;
	vi c(n);
	vector<vi> mat(n,vi(m));
	int cnt = 0;
	vi mx(m,0);
	vi mxi(m,0);
	rep(i,n){
		cin>>c[i];
		rep(j,m){
			cin>>mat[i][j];	
		}
	}
	int mn = INT_MAX;
	rep(i,(1<<n)){
		vi sum(m);
		int price = 0;
		rep(j,n){
			if(i&(1<<j)){
				price+=c[j];	
				rep(k,m){
					sum[k]+=mat[j][k];
				}
			}
		}
		bool f = 1;
		rep(j,m){
			if(sum[j]>=x){
			}
			else{
				f = 0;
			}
		}
		if(f){
				mn = min(price,mn);	
		}
	}
	if(mn == INT_MAX)
	cout<<"-1"<<nl;
	else cout<<mn<<nl;
	return 0;
}


Measured memory_bytes: 3664
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef vector< pii > vp;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }
                                   
 
  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e16+18;
  const int N=1e4+14;
  const int M=2e4;
  

 void fft()           
 { 
   int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
   vi va(a),vb(b),vc(c); tr(i,va) cin>>i;
   tr(i,vb) cin>>i; tr(i,vc) cin>>i;
   sort(rall(va)); sort(rall(vb)); sort(rall(vc));
   vi aa; rep(i,0,x) aa.pb(va[i]); rep(i,0,y) aa.pb(vb[i]);
   sort(all(aa));
   int id=0;
   for(int i=0;i<Z(aa);++i){
     if(aa[i]<vc[id]) aa[i]=vc[id++];
     else break;
     if(id==c) break;
   }

   cout<<accumulate(all(aa),0LL);

 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
       
   int tc=1;                         
 //  cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
   fft();
   if(i<tc)
   cout<<nl;
  }
 
 return 0; 
}

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

struct Edge {
  int src, dst, cost, color;
  Edge(int s, int d, int col, int c) : src(s), dst(d), color(col), cost(c) {}
  bool operator<(const Edge &e){ return cost < e.cost;}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

struct HeavyLightDecomposition {
  int n, id;
  Graph g;
  vector<int> size, head, par, vid, cost;

  HeavyLightDecomposition (int n, Graph &g) : n(n), g(g), size(n, 1), head(n), par(n), vid(n), cost(n) {
    dfs(0, -1, 0);

    id = 0;
    decompose(0, -1, 0);
  }

  void dfs(int v, int p, int c) {
    par[v]  = p;
    cost[v] = c;

    for(Edge e : g[v]) {
      if(e.dst == p) continue;
      dfs(e.dst, v, c + e.cost);
      size[v] += size[e.dst];
    }
  }

  void decompose(int v, int p, int h) {
    vid[v] = id++;
    head[v]  = h;

    pair<int, int> heavy = make_pair(-1, -1);
    for(Edge e : g[v]) {
      if(e.dst == p) continue;
      heavy = max(heavy, make_pair(size[e.dst], e.dst));
    }

    if(heavy.second != -1) decompose(heavy.second, v, h);
    for(Edge e : g[v]) {
      if(e.dst == p || e.dst == heavy.second) continue;
      decompose(e.dst, v, e.dst);
    }
  }

  int lca(int x, int y) {
    while(true) {
      if(vid[x] > vid[y]) swap(x, y);
      if(head[x] == head[y]) return x;
      y = par[head[y]];
    }
  }
  
  int dist(int x, int y) {
    int z = lca(x, y);
    return cost[x] + cost[y] - cost[z] * 2;
  }
};


struct Q {
  int id, x, y, z;
  Q(int id, int x, int y, int z) : id(id), x(x), y(y), z(z) {}
};

int n, q, a, b, c, d, ans[100010], color[100010], color_cost[100010];
vector<vector<Q>> queries;
Graph g;

void dfs(int v, int p) {
  for(Q q : queries[v]) {
    int t = color[q.x] * q.y - color_cost[q.x];
    ans[q.id] += t * q.z;
  }

  for(Edge e : g[v]) {
    if(e.dst == p) continue;
    color[e.color]++; color_cost[e.color] += e.cost;
    dfs(e.dst, v);
    color[e.color]--; color_cost[e.color] -= e.cost;
  }
}

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n >> q;
  g.resize(n);
  for(int i = 0; i < n - 1; ++i) {
    cin >> a >> b >> c >> d;
    --a, --b;
    g[a].emplace_back(a, b, c, d);
    g[b].emplace_back(b, a, c, d);
  }

  HeavyLightDecomposition hld(n, g);

  queries.resize(n);
  for(int i = 0; i < q; ++i) {
    cin >> a >> b >> c >> d;
    --c, --d;
    int e = hld.lca(c, d);
    queries[c].emplace_back(i, a, b, 1);
    queries[d].emplace_back(i, a, b, 1);
    queries[e].emplace_back(i, a, b, -2);

    ans[i] += hld.cost[c] + hld.cost[d] - hld.cost[e] * 2;
  }

  dfs(0, -1);
  for(int i = 0; i < q; ++i) cout << ans[i] << '\n';
  return 0;
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    string a, b;
    cin >> a >> b;
    if (a.size() < b.size())
    {
        cout << "LESS" << '\n';
    }
    else if (a.size() > b.size())
    {
        cout << "GREATER" << '\n';
    }
    else
    {
        cout << ((a < b) ? "LESS" : (a == b) ? "EQUAL" : "GREATER") << '\n';
    }
    return 0;
}


Measured memory_bytes: 3616
#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;

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
    cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
N,K=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)
INF=Float::INFINITY
dp=Array.new(100100){INF}
dp[0]=0

(0...N).each do |i|
  (1..K).each do |j|
    if i+j<N
      dp[i+j] = dp[i]+(h[i]-h[i+j]).abs if dp[i+j] > dp[i]+(h[i]-h[i+j]).abs
    end
  end
end

puts dp[N-1]

Measured memory_bytes: 11404
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100001];
int n;
ll dp[100001];
ll cal(int i)
{
    if(i==n)
    return 0;
    if(i>n)
    return(INT_MAX);
    if(dp[i]!=-1)
    return dp[i];
    ll ans = min(cal(i+1)+abs(a[i]-a[i+1]),cal(i+2)+abs(a[i+2]-a[i]));
    dp[i]=ans;
    return ans;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    memset(dp,-1,sizeof(dp));
    ll ans=cal(1);
    cout<<ans;
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

// A[i] : S と S[i:] の先頭が何文字共通しているか
long long int A[1000];

// O(|S|)
void Z_algorithm(string S){
	A[0] = S.size();
	int i = 1, j = 0;
	while (i < S.size()) {
		while (i + j < S.size() && S[j] == S[i + j]){
			j += 1;
		}
		A[i] = j;
		if (j == 0) {
			++i;
			continue;
		}
		int k = 1;
		while (i + k < S.size() && k + A[k] < j){
			A[i + k] = A[k];
			k += 1;
		}
		i += k; j -= k;
	}
}

int main(){
	string T, P;
	cin >> T >> P;
	string S = P + " " + T;
	Z_algorithm(S);
	int con = P.size() + 1;
	for(int i = 0; i < S.size(); i++){
		if(A[i + con] == P.size()){
			cout << i << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>

using namespace std;

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

    if(instr.size()>=4) {
        if(instr.substr(0,4) == "YAKI") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------


bool comp(P a, P b){
    if (a.second == b.second) return a.first >= b.first;
    return a.second >= b.second;
}
int main(void) {
    int N, M;
    cin >> N >> M;
    vector<P> V(N);
    for (int i = 0; i < N; i++) { 
        int a, b;
        cin >> a >> b;
        V[i] = {b, a};
    }
    sort(V.begin(), V.end(), comp);
    priority_queue<P, vector<P>, greater<P>> que;

    for (int i = 0; i < N; i++) {
        int d = que.size();
        int mi = que.top().first;
        if (d + V[i].second <= M) {
            que.push(V[i]);
        }
        else if(d != 0 && mi <= V[i].first){
            que.pop();
            que.push(V[i]);
        }
    }

    int ans = 0;
    while(que.size()!=0){
        ans += que.top().first;
        que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 3956
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = n - 1;
        if (m >= n) {
            ans++;
        } else {
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22868
def main():
    n, m = map(int, input().rstrip("\n").split(" "))

    L = [0]
    counts = {}
    for i in range(1, n + 1):
        L.append(i)
        counts[i] = 1

    edges = []
    for j in range(m):
        a_b = map(int, input().rstrip("\n").split(" "))
        edges.append(a_b)

    total = n * (n - 1) // 2

    answers = [total]
    for a, b in reversed(edges):
        current = a
        while L[current] != current:
            current = L[current]
        a_top = current
        current = b
        while L[current] != current:
            current = L[current]
        b_top = current
        if a_top == b_top:
            answers.append(total)
        else:
            total -= counts[a_top] * counts[b_top]
            answers.append(total)
            L[b_top] = a_top
            L[b] = a_top
            L[a] = a_top
            counts[a_top] += counts[b_top]

    for answer in reversed(answers[:-1]):
        print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 60580
#include <stdio.h>
#include <queue>

#define lli long long int

using namespace std;

int main() {
	lli n, m, a, ans = 0;
	priority_queue<lli> pq;
	scanf("%lld %lld", &n, &m);
	for (lli i = 0; i < n; i++) {
		scanf("%lld", &a);
		pq.push(a);
	}
	while (m--) {
		a = pq.top();
		pq.pop();
		pq.push(a / 2);
	}
	while (n--) {
		a = pq.top();
		pq.pop();
		ans += a;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll sum = 0;
    if(A >= K) cout << K;
    else if(A < K) {
        sum += A;
    if(K - A < B) {
        cout << sum;
        return 0;
    } else if(K - A >= B) {
        if(C >= K - A - B) {
        cout << sum -(K - A - B);
        return 0;
        }
    }
    }

    
    return 0;
}

Measured memory_bytes: 3632
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let n:usize = scan.next();
	let l:i64 = scan.next();
	let t:i64 = scan.next();

	let mut xw:Vec<(usize,usize,bool)> = Vec::with_capacity(n);
	let mut lx:Vec<(usize,usize)> = Vec::with_capacity(n);
	let mut rx:Vec<(usize,usize)> = Vec::with_capacity(n);

	for i in 0..n {
		let x:usize = scan.next();
		let w:char = scan.next::<String>().chars().collect::<Vec<char>>()[0];

		if w == '1' {
			rx.push((i,x));
			xw.push((i,x,true));
		} else {
			lx.push((i,x));
			xw.push((i,x,false));
		}
	}

	xw.sort_by(|a,b| a.1.cmp(&b.1));

	let mut count:i64 = 0;

	for &x in &xw {
		if x.2 {
			count -= (t + x.1 as i64) / l;
		} else {
			count += (t - (x.1 as i64 + 1) + l) / l;
		}
	}

	let offset = (count % n as i64 + n as i64) as usize;

	let n = n as usize;
	let l = l as usize;
	let t = t as usize;
	let mut all = rx.into_iter().map(|(i,x)|(i,(x+(t%l))%l)).collect::<Vec<(usize,usize)>>();
	all.append(&mut lx.into_iter().map(|(i,x)|(i,(l+x-(t%l))%l)).collect::<Vec<(usize,usize)>>());

	all.sort_by(|a,b| a.1.cmp(&b.1));

	let mut r = (0..n).map(|_| 0).collect::<Vec<usize>>();

	for i in 0..n {
		r[(i+offset)%n] = all[i].1;
	}

	println!("{}",r.into_iter().map(|x| format!("{}",x)).collect::<Vec<String>>().join("\n"));
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 16656
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int a,b; cin >> a >> b;
  string x,y;
  rep(i,b){
    x = x + to_string(a);
  }
  rep(i,a){
    y = y + to_string(b);
  }
  
  if(x > y) cout << y << endl;
  else cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
ns = list(map(int, input(). split()))

min0 = 10000000
max0 = -10000000
sum0 = 0
for x in ns:
  min0 = min(min0, x)
  max0 = max(max0, x)
  sum0 += x
  
print(min0, max0, sum0)



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

signed main(void){ 

  string s; cin >> s;
  int n = (int)s.size();
  
  if( s.back() == '1'|| s.front() == '0'){ cout <<"-1" << endl; return 0;}
  for(int i = 0; i <= n-2; i++){
    if( s[i] != s[n-i-2] ){ cout << "-1" << endl; return 0;}
  }
  
  //以下、対称性がある
  int last = 0;
  vector<int> vec;
  vector<pair<int,int>> edge;
  for(int i = 1; i < n; i++){ 
    if( s[i] == '0'){ vec.push_back(i);}
    else{ 
      //iとvecに入っていたものを全て繋げる
      edge.push_back({i,last});
      
      for(int j = 0; j < (int)vec.size(); j++){ 
        edge.push_back({i,vec[j]});
      }
      
      last = i;
      vec.clear();
    }
  }
  
  edge.push_back({last,n-1});
  
  for(auto ans : edge ){ cout << ans.first+1 << " " << ans.second+1 << endl;}
  
  return 0;
}

Measured memory_bytes: 4144
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 510000

#define f first
#define s second

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int N;
	int XOR = 0;
	static int zero[MAX];
	int a, ans = 0, max_ = 0;
	static vector<pair<pair<int,int>,int>> temp[(1<<(22))];
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>a;
		XOR ^= a;
		
		max_ = max(max_, XOR);
		// cout<<i<<" xor "<<XOR<<endl;
		
		zero[i+1] += zero[i] + !XOR;
		
		if(!XOR){
			temp[XOR].push_back(make_pair(make_pair(XOR,1),i));
		} else {
			int count = 0;
			if(temp[XOR].size()) count = (zero[i] - zero[temp[XOR][temp[XOR].size() - 1].second]);
			if(count)temp[XOR].push_back(make_pair(make_pair(0,count),i));
			temp[XOR].push_back(make_pair(make_pair(XOR,1),i));
		}
	}
	
	if(XOR){
		int t0 = 1, tx = 0;
		for(int i = 0; i < temp[XOR].size(); i++){
			if(temp[XOR][i].first.first){
				tx += t0;
				tx %= MOD;
			} else {
				t0 += tx*temp[XOR][i].first.second;
				t0 %= MOD;
			}
			// cout<<temp[XOR][i].first.first<<" "<<temp[XOR][i].first.second<<" "<<t0<<" "<<tx<<endl;
		}
		ans = t0;
	} else {
		// cout<<"zero"<<endl;
		int po = 1;
		for(int i = 1; i < zero[N]; i++){
			po <<= 1;
			po %= MOD;
		}
		// cout<<po<<" "<<zero[N]<<endl;
		
		ans += po;
		ans %= MOD;
		
		for(int i = 1; i <= max_; i++){
			int t0 = 1, tx = 0;
			for(int j = 0; j < temp[i].size(); j++){
				if(temp[i][j].first.first){
					tx += t0;
					tx %= MOD;
				} else {
					t0 += tx*temp[i][j].first.second;
					t0 %= MOD;
				}
				
			}
			ans += tx;
			// cout<<i<<" "<<tx<<endl;
			ans %= MOD;
		}
	}
	
	cout<<ans%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 134708
a, b = map(int, input().split())

def cal(a,b):
    if a < b:
        dist1 = b - a
        dist2 = abs(b + a) + 1
        return min(dist1, dist2)
    elif a > b:
        if a >= 0 and b <= 0:
            return abs(a+b) + 1

        else:
            return a - b + 2

print(cal(a,b))
    

Measured memory_bytes: 2940
n = int(input())
f=[]
for i in range(n):
    tmp = list(map(int,input().split()))
    f.append(tmp)
p=[]
for i in range(n):
    tmp = list(map(int,input().split()))
    p.append(tmp)

from itertools import *
first=True
ans=-10**12
for tmp in list(product([0,1], repeat=10)):
    if first:
        first=False
        continue

    ona=[]
    for mise in f:
        cnt=0
        for j in range(10):
            cnt+= tmp[j] & mise[j]
        ona.append(cnt)

    sm=0
    for i in range(len(p)):
        sm+=p[i][ona[i]]
    if ans < sm:
        ans=sm
print(ans)

Measured memory_bytes: 42604
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        Dice di[] = new Dice[2];

        for(int i = 0; i < 2; i++){
            di[i] = new Dice(sc);
        }
        
        boolean hantei = Dice.check(di[0],di[1]);
        if(hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

class Dice{
    int d1[] = new int[2];
	int d2[] = new int[4];
	String str[] = new String[24];
    
    Dice(Scanner sc){
    	d1[0] = sc.nextInt();
    	d2[0] = sc.nextInt();
    	d2[1] = sc.nextInt();
    	d2[2] = sc.nextInt();
    	d2[3] = sc.nextInt();
    	d1[1] = sc.nextInt();
    }
    
    void turnN(){
        int d0 = d1[0];
        d1[0] = d2[0];
        d2[0] = d1[1];
        d1[1] = d2[3];
        d2[3] = d0;
    }
    
    void turnS(){
        int d0 = d1[0];
        d1[0] = d2[3];
        d2[3] = d1[1];
        d1[1] = d2[0];
        d2[0] = d0;
    }
    
    void turnE(){
        int d0 = d1[0];
        d1[0] = d2[2];
        d2[2] = d1[1];
        d1[1] = d2[1];
        d2[1] = d0;
    }
    
    void turnW(){
        int d0 = d1[0];
        d1[0] = d2[1];
        d2[1] = d1[1];
        d1[1] = d2[2];
        d2[2] = d0;
    }
    
	static boolean check(Dice dice1,Dice dice2){
		boolean a = false;
		
		for(int x = 0; x < 6; x++){
			if(dice1.d1[0] == dice2.d1[0]){
				for(int y = 0; y < 5; y++){
					if(dice1.d2[0] == dice2.d2[0] && dice1.d2[1] == dice2.d2[1] && dice1.d2[2] == dice2.d2[2] && dice1.d2[3] == dice2.d2[3]){
						a = true;
						break;
					}else if(y == 4){
						break;
					}else{
						dice2.turnN();
						dice2.turnE();
						dice2.turnS();
					}
				}
			}
			if(x == 0 || x == 4){
				dice2.turnN();
			}else{
				dice2.turnE();
			}
		}
     	
         return a;
    }
}


Measured memory_bytes: 26404
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

class BIT():#1-indexed
	def __init__(self, size):
		self.table = [0 for _ in range(size+2)]
		self.size = size

	def Sum(self, i):#1からiまでの和
		s = 0
		while i > 0:
			s += self.table[i]
			i -= (i & -i)
		return s

	def Add(self, i, x):#
		while i <= self.size:
			self.table[i] += x
			i += (i & -i)
		return

n, q = map(int, input().split())
fw = BIT(n+2)
a = list(map(int, input().split()))
for i, x in enumerate(a):
	fw.Add(i+1, x)
for _ in range(q):
	x, y, z = map(int, input().split())
	if x == 0:
		fw.Add(y+1, z)
	else:
		print(fw.Sum(z) - fw.Sum(y))

Measured memory_bytes: 132236
using System;
using System.Collections.Generic;

namespace ABC138_A
{
    class Program
    {
        static void Main(string[] args) {
            long n = long.Parse(Console.ReadLine());
            string s = Console.ReadLine();


            long ans = 0;
            if(n >= 3200) {
                Console.WriteLine(s);
            } else {
                Console.WriteLine("red");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	int a,b;
	cin >> a >> b;
	if( a <= 8 && b <= 8 ){
		cout <<  "Yay!" << endl;
	}
	else{
		cout << ":(" << endl;
	}

	return 0;
}

Measured memory_bytes: 256