akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

void solve(int n, int m, int t, int p) {
    vector<int> d(t), c(t), _x(p), _y(p);
    vector<vector<int>> before(m, vector<int>(n, 1)), after;
    REP(i, t) {
        int d, c;
        cin >> d >> c;
        if (d == 1) {
            int _n = max(n - c, c);
            after = vector<vector<int>> (m, vector<int> (_n));
            REP(y, m) {
                REP(x, n - c) {
                    after[y][x] = before[y][x + c];
                }
            }

            REP(y, m) {
                REP(x, c) {
                    after[y][c - x - 1] += before[y][x];
                }
            }
            n = _n;
        } else {
            int _m = max(m - c, c);
            after = vector<vector<int>> (_m, vector<int> (n));
            REP(x, n) {
                REP(y, m - c) {
                    after[y][x] = before[y + c][x];
                }
            }

            REP(x, n) {
                REP(y, c) {
                    after[c - y - 1][x] += before[y][x];
                }
            }
            m = _m;
        }
        before = after;
    }

    REP(i, p) {
        int x, y;
        cin >> x >> y;
        cout << before[y][x] << endl;
    }
}

int main() {
    int n, m, t, p;
    while(cin >> n>> m >> t >> p && n) {
        solve(n, m, t, p);
    }
}


Measured memory_bytes: 3172
x = int(input())

s = x // 11
m = x % 11

if m == 0:
    p = 0
elif m in [1, 2, 3, 5, 4, 6]:
    p = 1
elif m in [7, 8, 9, 10]:
    p = 2
ans = s*2 + p
print(ans)

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

using ll = long long;

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

  cout << r*r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e9;
const int mod=1e9+7;
const ll aaaa=1e18;
ll s;
ll Sqrt(ll x)
{
    ll l=sqrt(x),r=sqrt(x)+1;
    return r*r<=x?r:l;
}
int main()
{
    scanf("%lld",&s);
    if(s==aaaa)
    {
        printf("0 0 1000000000 0 0 1000000000");
        return 0;
    }

    if(s<=maxn)
    {
        printf("0 0 1 0 0 %d",s);
        return 0;
    }
    ll x=Sqrt(s);
    x+=1;
    if(x>maxn)
        x=maxn;
    ll t=x;
    x=x*x-s;
    printf("0 0 %lld %lld 1 %lld",t,x,t);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

struct edge{int from, to, cost;};
int n, d[100005];
vector<edge> g;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) {
        int u, k;
        cin >> u >> k;
        rep(j, 0, k) {
            int v, c;
            cin >> v >> c;
            edge e;
            e.from = u, e.to = v, e.cost = c;
            g.pb(e);
        }
    }
    rep(i, 0, n) d[i] = INF;
    d[0] = 0;
    while (1) {
        bool flag = false;
        rep(i, 0, g.size()) {
            edge e = g[i];
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                flag = true;
            }   
        }
        if (!flag) break;
    }
    rep(i, 0, n) {
        cout << i << " " << d[i] << endl;
    } 
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define eb emplace_back
#define pb push_back
#define mk make_pair
#define mt make_tuple

#define Umap unordered_map
#define graph vector<vector<int>>

#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl

#define INF 1e9+5
#define N 40001
#define MAXN   100001


bool sortbysec(const tuple<int, int, int>& a,  
               const tuple<int, int, int>& b) 
{ 
    return (get<1>(a) < get<1>(b)); 
}
void dfs(int s, graph &g, bool vis[]){
	vis[s] = true;
	for(int i=0;i<g[s].size();i++){
		if(!vis[g[s][i]]) dfs(g[s][i],g,vis);
	}
}

string common_prefix(vector<string>& strings){
	string prefix;
	for(string s : strings){
		for(int i=0;i<s.size() && s[i]!='*';++i){
			if(i<prefix.size()){
				if(s[i]!=prefix[i]) return "*";
			}
			else prefix+=s[i];
		}
	}
	return prefix;
}

void reverse(vector<string>& strings){
	for(string& s : strings){
		reverse(s.begin(),s.end());
	}
}

int spf[0];
void sieve(){
	spf[1] = 1;
	for(int i=2;i<MAXN;i++) spf[i] = i;

	for(int i=4;i<MAXN;i+=2) spf[i] = 2;

	for(int i=3; i*i<MAXN;i++){
		if(spf[i]==i){
			for(int j=i*i;j<MAXN;j+=i){
				if(spf[j]==j) spf[j] = i;
			}
		}
	}
}
vector<int> getFactorization(int x){

	vector<int> primeFactors;
	while(x>1){
		primeFactors.pb(spf[x]);
		x /= spf[x];
	}
	return primeFactors;
}



void solve(){
	// sieve(); 
	int n; cin>>n;
	vector<int>ans(3,0);

	for(int day=0;day<n;day++){
		vector<int>dp(3,0);
		vector<int>cost(3);

		for(int i=0;i<3;i++) cin>>cost[i];

		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j)
				dp[i] = max(dp[i],ans[j]+cost[i]);
			}
		}
		ans = dp;
	}
	cout<<max({ans[0],ans[1],ans[2]})<<endl;

	





}

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

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	for i := 1; i <= 1009; i++ {
		if i*8/100 == a && i*1/10 == b {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        final int N = in.nextInt();
        final int k = in.nextInt();
        final String s = in.next();

        int res = 0;
        int len = s.length();
        int left = 0;
        int countZeros = 0;

        for (int right = 0; right < len; ++right) {
            if (s.charAt(right) == '0') {
                countZeros++;
                for (int j = right; j < len && s.charAt(j) == '0'; j++) {
                    right = j;
                }
                while (countZeros > k) {
                    if (s.charAt(left) == '0') {
                        --countZeros;
                        for (int j = left; j < len && s.charAt(j) == '0'; j++) {
                            left = j;
                        }
                    }
                    left++;
                }

            }
            res = Math.max(res, right - left + 1);
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 23856
#include<cstdio>
#include<cstring>
#include<algorithm>

int main()
{
    int n,x,y,a,z;
    while (scanf ("%d",&n) != EOF)
    {
        x = y = z = 0;
        for (int i=0;i<n;i++)
        {
            scanf ("%d",&a);
            if (a%4 == 0)
            {
                x++;
            }
            else if (a&1)
            {
                y++;
            }
            else
            {
                z++;
            }
        }
        if (z ^ n && z & 1)
        {
            y++;
        }
        printf ("%s\n",x+1>=y?"Yes":"No");
    }
    return 0;
}


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

int n;
int counter[30];
int maxN, nextN;
char winner;

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    for (int i = 0; i < 30; i++) counter[i] = 0;
    bool ok = false;
    for (int i = 0; i < n; i++) {
      char c;
      scanf(" %c", &c);
      if (ok) continue;
      int num = (int) c - 'A';
      counter[num]++;
      maxN = counter[0], nextN = 0, winner = 'A';
      for (int j = 1; j <= (int)'Z' - 'A'; j++) {
        if (counter[j] > maxN) winner = (char)j + 'A', nextN = maxN, maxN = counter[j];
        else if (counter[j] > nextN) nextN = counter[j];
      }
      int dif = maxN - nextN, rest = n - i - 1;
      if (n == i + 1) {
        if (dif > 0) printf("%c %d\n", winner, i + 1);
        else printf("TIE\n");
      } else if (dif > rest) {
        printf("%c %d\n", winner, i + 1);
        ok = true;
      }
    }
  }
}



Measured memory_bytes: 2620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			if (n == 0)
				break;
			nx = new int[n][n];
			ny = new int[n][n];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++) {
					nx[i][j] = scanner.nextInt();
					ny[i][j] = scanner.nextInt();
				}
			map = new int[n][n];
			int ans = 0;
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++) {
					if (map[i][j] == 2)
						continue;
					ans += dfs(i, j);
				}
			System.out.println(ans);
		}
	}

	private int dfs(int y, int x) {
		if (map[y][x] == 1)
			return 1;
		if (map[y][x] == 2)
			return 0;
		int ret = 0;
		int hx = nx[y][x];
		int hy = ny[y][x];
		map[y][x] = 1;
		ret = dfs(hy, hx);
		map[y][x] = 2;
		return ret;
	}

	int n, nx[][], ny[][];
	int[][] map;
}

Measured memory_bytes: 62408
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}
    while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}
    return s*w;
}
const int maxn=1e5+10;
struct edge{
    int to,nxt;
}e[maxn*2];
int head[maxn],tot,col[maxn];
ll c1,c2;
int flag;
void addedge(int u,int v){
    e[++tot].to=v;
    e[tot].nxt=head[u];
    head[u]=tot;
}
void dfs(int u,int color){
    if(flag) return;
    col[u]=color;
    if(color==1) ++c1;
    else ++c2;
    for(int i=head[u];i;i=e[i].nxt)
    {
        int v=e[i].to;
        if(!col[v]) dfs(v,3-color);
        else if(col[v]==color){
            flag=true;
            return;
        }
    }
}
ll n,m;
int main(){
    n=read(),m=read();
    for(int i=1;i<=m;i++){
        int u,v;
        u=read(),v=read();
        addedge(u,v);
        addedge(v,u);
    }
    dfs(1,1);
    if(flag) printf("%lld",1LL*n*(n-1)/2-m);
    else printf("%lld",c1*c2-m);

    return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>
 
int main()
{
    int N;
    int A[1000] = { 0 };
    int i, j, k;
    int v = 0;
 
    scanf("%d", &N);
    for (i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }
 
 
 
    for (i = 0; i < N; i++)
    {
        if (i == N - 1){
            printf("%d", A[i]);
        }
        else printf("%d ", A[i]);
    }
 
    printf("\n");
 
 
    for (i = 1; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j]>v)
        {
            A[j + 1] = A[j];
            j--;
        }
 
        A[j + 1] = v;
 
        for (k = 0; k < N; k++)
        {
            if (k == N - 1){
                printf("%d", A[k]);
            }
            else printf("%d ", A[k]);
        }
        printf("\n");
 
    }
    return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

public class Main {

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

		int h = sc.nextInt();
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int board[][] = new int[h][w];

		for(int i = 0; i < h - b; i++){
			for(int j = 0; j < w - a; j++){
				board[i][j] = 1;
			}
		}

		for(int i = h - b; i < h; i++){
			for(int j = w - a; j < w; j++){
				board[i][j] = 1;
			}
		}

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				System.out.print(board[i][j]);
			}
			System.out.println();
		}

	}

}


Measured memory_bytes: 50908
n = int(input())
p = list(map(int, input().split()))
ans = False
for i in range(n):
    for j in range(i, n):
        p[i], p[j] = p[j], p[i]
        if all(p[k] < p[k + 1] for k in range(n - 1)):
            ans = True
        p[i], p[j] = p[j], p[i]
print(["NO", "YES"][ans])


Measured memory_bytes: 8944
def main():
    n, m = map(int, input().split())
    s = []
    c = []
    for i in range(m):
        ss, cc = map(int,input().split())
        s.append(ss)
        c.append(cc)

    for i in range(0, 1000):
        flg = True
        if len(str(i)) != n:
            flg = False
            continue
        tmp_list = list(str(i))
        for j in range(m):
            if s[j] -1 > len(tmp_list):
                flg = False

                break
            if tmp_list[s[j] - 1] != str(c[j]):
                flg = False
                break
        if flg :
            print(i)
            return
    print(-1)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

ll dp[20][2];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S;
    cin >> S;
    int N = S.size();
    rep(i,N+1)rep(j,2)dp[i][j] = -INFLL;
    dp[0][0] = 0;
    rep(i,N)rep(j,2){
        for(int nx = 0; nx <= (j ? 9: S[i] - '0');nx++){
            chmax(dp[i+1][j || nx < S[i] - '0'], dp[i][j] + nx);
        }
    }
    ll ans = max(dp[N][0], dp[N][1]);
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 5e5 + 5;

class Q
{
public:
	ll l,r,b,i;
};

ll n,q,sz,ans = 0;
ll cnt[max_n+1] = {0},c[max_n],a[max_n];
Q qry[max_n];

void add(ll pos)
{
	if(!cnt[c[pos]])
		++ans;
	++cnt[c[pos]];
}

void remove(ll pos)
{
	--cnt[c[pos]];
	if(!cnt[c[pos]])
		--ans;
}

bool cmp(Q &a,Q &b)
{
	if(a.b != b.b)
		return a.b < b.b;
	return (a.r < b.r)^(a.b&1);
}

int main()
{
	io;
	cin >> n >> q;
	takearr0(c,n);
	sz = sqrt(n);
	ll x,y;
	rep(i,0,q,1)
	{
		cin >> x >> y;
		qry[i].l = x-1;
		qry[i].r = y-1;
		qry[i].i = i;
		qry[i].b = (x-1) / sz;
	}
	sort(qry,qry+q,cmp);
	ll cr = -1,cl = 0;
	// printf("here\n");
	rep(i,0,q,1)
	{
		ll l = qry[i].l,r = qry[i].r;
		while(cr < r)
			add(++cr);
		while(cl > l)
			add(--cl);
		while(cl < l)
			remove(cl++);
		while(cr > r)
			remove(cr--);
		a[qry[i].i] = ans;
	}
	rep(x,0,q,1) cout << a[x] << endl;
	return 0;
}

Measured memory_bytes: 31068
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
int n,k;
void cur(int bit, vector <int> b, int ma){
    //cout<<bit<<endl;
    int c = 1LL<<(bit);
    int sz = b.size();
    vector <int> tmp; 
    rep(i,sz){
        if(b[i]&c) tmp.push_back(b[i]);
    }
    if(bit == 0) {
        if(tmp.size()>=k) ma|=1; 
        cout<<ma<<endl;
        exit(0);
    }
    if(tmp.size()>=k) cur(bit-1, tmp, ma+c);
    else cur(bit-1, b, ma);
}
signed main(void){
    cin>>n>>k;
    vector <int> a(n); 
    rep(i,n) cin>>a[i];
    vector <int> sum(n+1); 
    rep(i,n) sum[i+1] = sum[i] + a[i];
    vector <int> b; 
    rep(i,n) for(int j=i+1;j<=n;j++) b.push_back(sum[j] - sum[i]);
    
    sort(b.begin(),b.end(),greater <int>());
    
    cur(60, b, 0);
}


Measured memory_bytes: 112624
A,B,K = (int(i) for i in input().split())
turn = 0
for i in range(K):
    if turn%2  == 0:
        if A%2 == 1 :
            A = (A-1)//2
        else:
            A = A//2
        B = B+A
    else:
        if B%2 == 1 :
            B = (B-1)//2
        else:
            B = B//2
        A = B+A
    turn += 1
print(str(A)+" "+str(B))


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

set<ll> divisor(ll n){
    set<ll> s;
    for(ll i = 1; i*i <= n; i++){
        if(n % i == 0){
            s.insert(i);
            s.insert(n/i);
        }
    }
    return s;
}


int main(){
    ll N; cin >> N;
    set<ll> div = divisor(N);
    ll ans = LINF;
    for(ll u : div){
        ans = min(ans,(u-1)+(N/u-1));
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<cwctype>
#include<algorithm>
#include<math.h>

using namespace std;

struct okashi{
	int i;
	int p;
	int q;
	int r;
	int c;
};
int main(){
	okashi data[1001];
	int n;
	while(cin>>n && n){
	for(int i=0;i<n;i++){
		cin>>data[i].i>>data[i].p>>data[i].q>>data[i].r;
		data[i].c=4*data[i].p+9*data[i].q+4*data[i].r;
	}

	int P,Q,R,C;
	cin>>P>>Q>>R>>C;
	bool na=false;
	for(int i=0;i<n;i++){
		if(data[i].p<=P && data[i].q<=Q && data[i].r<=R && data[i].c<=C){
			cout<<data[i].i<<endl;
			na=true;
		}
		
	}
	if(!na)cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, l = inintm()

s = []

for _ in range(n):
    s.append(input())

s.sort()

print("".join(s))

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

int main () {

    int A, B, C;
    cin >> A >> B >> C;

    if ((A < C && C < B) || (B < C && C < A)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

using namespace std;

queue<string> q1;
queue<int> q2;
int n,q,T,x;
int t=0;
string N,y;

int main()
{
    cin >> n >> q;
    for(int i=0;i<n;i++)
    {
        cin >> N >> T;
        q1.push(N);
        q2.push(T);
    }
    while(!q1.empty())
    {
        x=q2.front();
        if(x<=q)
        {
            t+=x;
            cout << q1.front() << " " << t << endl;
            q1.pop();
            q2.pop();
        }
        else
        {
            t+=q;
            y=q1.front();
            q1.pop();
            q1.push(y);
            q2.pop();
            q2.push(x-q);
            
        }
    }
    return 0;
}



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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n >> s; 
	vector<int> black(1) , white(1);
	black[0] = white[0] = 0 ;
	int B = 0 ;
	int W = 0 ;
	rep(i,n){
		if(s[i] == '#'){
			B ++ ;
		}
		else W ++ ;

		black.push_back(B);
		white.push_back(W);
	}
	int ans = 5005001;
	rep(i,n+1){
		int cost = black[i] + white[n] - white[i];
		chmin(ans,cost);
	} 
	cout << ans << endl;
}


Measured memory_bytes: 2288
def insort(n,A):
    for i in range(n):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        L=[str(a) for a in A]
        L=" ".join(L)
        print(L)

n = int(input())
A = list(map(int,input().split()))

insort(n,A)



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/

int main() {
  ll N,M,a,x;
  cin >> N >> M;
  priority_queue<ll> A;
  REP(i,N) {
    cin >> a;
    A.push(a);
  }


  REP(i,M) {
    x = A.top()/2;
    A.pop();
    A.push(x);
  }

  ll ans = 0;
  while (!A.empty()){
    ans+=A.top();
    A.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define N 10000000+5
using namespace std;
char s[N];
int a[N],sum;
int main()
{
    scanf("%s",s);
    int len = strlen(s);
    for(int i=1;i<=len;i++) a[i] = (s[len-i]-'0') * 9;
    for(int i=1;i<=len;i++) a[i+1] += a[i]/10,a[i]%=10;
    if(a[len+1]) len++;
    for(int i=1;i<=len;i++) sum += a[i];
    for(int i=1;i<=len*10;i++)
	{
        a[1] += 9,sum += 9;
		int k = 1;
        while(k <= len)
		{
			if(a[k] < 10) break;
			sum -= 10,a[k] -= 10;
			sum++,a[k+1]++,k++;
			if(k==len && a[k+1]) len++;
		}
		if(sum <= 9*i)
		{
			printf("%d",i);
			return 0;
		}
    }
    return 0;
}

Measured memory_bytes: 4224
n = int(input())
A = list(map(int, input().split()))
d = {}
for a in A:
    d[a] = d.get(a, 0) + 1
ans = 0
for k, v in d.items():
    if k < v:
        ans += v - k
    elif k > v:
        ans += v
print(ans)

Measured memory_bytes: 17780
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

/*
ベルマンフォード法(bellman ford) 単一始点最短経路問題
この問題では入力のコストの符号を反転すること ”最大距離” を計算している
*/

type edge struct {
	from int
	to   int
	cost int64
}

func main() {
	n := readInt()
	m := readInt()
	edges := make([]edge, m)
	for i := range edges {
		edges[i] = edge{
			from: readInt(),
			to:   readInt(),
			cost: -readInt64(),
		}
	}
	d := make([]int64, n+1)
	for i := range d {
		d[i] = math.MaxInt64
	}
	d[1] = 0

	var score int64
	for i := 0; i < 2*n; i++ {
		for j := 0; j < m; j++ {
			e := edges[j]
			if d[e.from] == math.MaxInt64 {
				continue
			}
			if d[e.to] > d[e.from]+e.cost {
				d[e.to] = d[e.from] + e.cost
			}
		}
		if i == n-1 {
			score = -d[n]
		}
	}

	if score != -d[n] {
		fmt.Println("inf")
	} else {
		fmt.Println(score)
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
    
	int r;
	cin >> r;
	cout << r * r << endl;
    return 0;
}


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

#define ll long long int
#define rep(i,n) for(int (i)=0;(i) < (n);(i)++)
#define INF 1000000000000000000

using namespace std;

bool is_integer(double x){
    return floor(x) == x;
}

int main(void){
    int X,Y;
    double turu,kame;
    cin >> X >> Y;

    turu = (double)(4*X - Y)/2;
    kame = (double)(-2*X + Y)/2;
    if(is_integer(turu) && is_integer(kame) && turu >= 0 && kame >= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(){
  while(1){
	int n,i,j,k,x,ans = 0;
    scanf("%d %d",&n, &x);
	if(n == 0 && x == 0) break;
	  for(i = 1; i <= n - 2; i++){
	    for(j = i + 1; j <= n - 1; j++){
		  for(k = j + 1; k <= n; k++){
		    if(x == i + j + k) ans++;
		  }
	    }
	  }
  	  printf("%d\n",ans);
    }
	return 0;
}

Measured memory_bytes: 600
import java.math.*;
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int t = 1;
		while (t-->0) {
		    long[] cnt = new long[200001];
		    int n = sc.nextInt();
		    int[] a = new int[n];
		    for(int i=0;i<n;i++){
		        a[i] = sc.nextInt();
		        cnt[a[i]]++;
		    }
		    long sum = 0;
		    for(int i=0;i<=200000;i++){
		        if(cnt[i]<=1) continue;
		        sum+=(cnt[i]*(cnt[i]-1))/2;
		    }
		    //System.out.println(sum);
		    for (int i=0;i<n ;i++ ){
		        if(cnt[a[i]]<2){
		            System.out.println(sum);
		        }
		        else{
		            long p = cnt[a[i]];
		            System.out.println(sum-(p*(p-1))/2+((p-1)*(p-2))/2);
		        }
		    } 
		}
	}
	static boolean isPalin(String s){
	    int n = s.length();
	    boolean ok = true;
		for(int i=0;i<n/2;i++){
		     if(s.charAt(i)!=s.charAt(n-i-1)){
		            ok = false;
		            break;
		    }
		}
		return ok;
	}
	static class Query {
		int x1, x2, y, id;
		public Query(int c, int d, int e, int a){
			x1 = c;
			x2 = d;
			y = e;
			id = a;
		}
	}
	static class Compare1 implements Comparator<Query>{
		@Override
		public int compare(Query q1, Query q2){
			if(q1.x2==q2.x2) return q1.x1-q2.x1;
			return q1.x2-q2.x2;
		}
	}
	static class Pair implements Comparable<Pair>{
		int a, b;
		public Pair(int c, int d){
			a = c;
			b = d;
		}
		public int compareTo(Pair p){
		    return a-p.a;
		}
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}
		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				return null;
			}
		}
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

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

int main(){
  string N;
  char c;
  cin >> N;
  int size;
  size = N.size() - 1;
  
  c = N[size];
    
  switch(c){
    case '2':
    case '4':
    case '5':
    case '7':
    case '9':
      cout << "hon" << endl;
      break;
    case '0':
    case '1':
    case '6':
    case '8':
      cout << "pon" << endl;
      break;
    case '3':
      cout << "bon" << endl;
      break;
  }  
}  


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

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

vector<P> s;
vector<P> t;
int main() {
    int n;
    scanf("%d", &n);
    int v[n];
    rep(i,0,n) {
        cin >>v[i];
        v[i]--;
    }
    rep(j,0,100000){
        s.push_back(P(0,j));
        t.push_back(P(0,j));
    }
    rep(i,0,n){
        if (i%2==0){
            s[v[i]].first++;
        }
        else t[v[i]].first++;
    }
    sort (s.begin(), s.end());
    sort (t.begin(), t.end());
    reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    if (s[0].second!=t[0].second){
        printf("%d\n", n-s[0].first-t[0].first);
    }
    else {
        int a=max(s[1].first,t[1].first);
        printf("%d\n", n-s[0].first-a);
    }
}


Measured memory_bytes: 2420
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
	char buf[100];
	int n;
	scanf("%d", &n);
	string s, t;
	scanf("%s", buf);
	s = string(buf);
	scanf("%s", buf);
	t = string(buf);
	string z = "";
	int i = 0, j = 0;
	while (j < (int)t.size()) {
		if (i == j) z += s[i++];
		else z += t[j++];
	}
	printf("%s\n", z.c_str());
}



Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn dfs(start: usize, graph: &Vec<Vec<usize>>, cur_color: i32, color: &mut Vec<i32>) -> bool {
    if color[start] != 0 {
        return cur_color == color[start];
    }
    color[start] = cur_color;
    for &to in graph[start].iter() {
        if !dfs(to, &graph, -1 * cur_color, color) {
            return false;
        }
    }
    true
}

fn is_biparate(graph: &Vec<Vec<usize>>) -> bool {
    let mut color = vec![0; graph.len()];
    for i in 0..graph.len() {
        if color[i] == 0 {
            if !dfs(i, graph, 1, &mut color) {
                return false;
            }
        }
    }
    true
}

const INF: i64 = 1000000;

fn main() {
    let n = read::<usize>();
    let mut graph = vec![vec![]; n];
    let mut edges = vec![vec![INF; n]; n];
    for i in 0..n {
        let s = read::<String>().chars().collect::<Vec<_>>();
        for j in 0..n {
            if s[j] == '1' {
                graph[i].push(j);
                edges[i][j] = 1;
            }
        }
    }

    if !is_biparate(&graph) {
        println!("-1");
        return;
    }

    let mut ans = 0;
    warshall_floyd(n, &mut edges);
    for i in 0..n {
        for j in i + 1..n {
            ans = max(edges[i][j], ans);
        }
    }
    println!("{}", ans + 1);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn warshall_floyd(n: usize, edges: &mut Vec<Vec<i64>>) {
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                edges[i][j] = std::cmp::min(edges[i][j], edges[i][k] + edges[k][j]);
            }
        }
    }
}


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

using namespace std;

int main(){
    int n, ans = 1e9;
    scanf("%d", &n);
    for(int i = 1, j = n - 1; i <= j; i++, j--){
        int sum = 0;
        for(int x = i; x; sum += x % 10, x /= 10);
        for(int y = j; y; sum += y % 10, y /= 10);
        ans = min(ans, sum);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
// #include "dkp.h"
#define foreach(it,a)		for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b)			for(int i=(a),_ed=(b);i<_ed;i++)
#define boost				ios_base::sync_with_stdio(0);cin.tie(0);
#define v(T)				vector<T>
#define p(T1, T2)			pair<T1, T2>
#define m(T1, T2)			map<T1, T2>
#define ll					long long int
#define sz(a)				(int) a.size()
#define ms(s, n) 			memset(s, n, sz(s))
#define mp					make_pair
#define pb					push_back
#define ff					first
#define ss					second
#define all(a)				a.begin(), a.end()
#define uni(a)				(a).erase(unique(all(a)), (a).end())
const int inf = 1001001001, mod = (int)1e9+7;
const ll llinf = 1e18;
const double eps = 1e-10, pi = acos(-1.0);
//....................//....................dkp....................//....................//
int ncases = 1;

int main(){
	int n;
	cin >> n;
	int ans=1;
	while(ans < n+1){
		ans = ans << 1;
	}
	ans = ans >> 1;
	cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
n,m,q = map(int,input().split())
lr = [[0 for _ in range(0,n+1)] for _ in range(0,n+1)]
ans = []
for i in range(0,m):
    L,R = map(int,input().split())
    lr[R][L] += 1
for r in range(0,n+1):
    for l in range(0,n):
        lr[r][n-l-1] += lr[r][n-l]
for l in range(0,n+1):
    for r in range(0,n):
        lr[r+1][l] += lr[r][l]
for i in range(0,q):
    P,Q = map(int,input().split())
    ans.append(lr[Q][P])
for i in range(0,q):
    print(ans[i])


Measured memory_bytes: 10560
use std::io;
use std::io::Read;

fn main() {
    let mut stdin = io::stdin();
    let mut lines_str = String::new();
    let _ = stdin.read_to_string(&mut lines_str);
    let mut lines = lines_str.lines();
    let mut line0itr = lines.next().expect("").split_whitespace();
    let n :usize = line0itr.next().expect("").trim().parse().unwrap();
    let a :usize = line0itr.next().expect("").trim().parse().unwrap();
    let b :usize = line0itr.next().expect("").trim().parse().unwrap();
    if a > b {
        println!("0");
        return;
    }
    if n == 1 {
        if a < b {
            println!("0");
            return;
        } else {
            println!("1");
            return;
        }
    }
    let min = a * (n-1) + b;
    let max = a + b * (n-1);
    let ans = max - min + 1;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    if (s1.size() < s2.size()) {
        cout << "LESS" << endl;
    } else if (s1.size() > s2.size()) {
        cout << "GREATER" << endl;
    } else {
        if (s1 < s2)
            cout << "LESS" << endl;
        else if (s1 > s2)
            cout << "GREATER" << endl;
        else
            cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
s = input()

def func(i, s_temp): #iは何回判断したかで，s_tempはそこまでの結果
    #s_tempには最初sの最初も文字を入れておく
    
    #ベースラインとして，３回判断したら，結果を確かめる
    if i == 3:
        #もし結果が７ならそれを表示する
        if eval(s_temp) == 7:
            print("{}=7".format(s_temp))
            exit()
    
    #そうでなければ，左からi+1番目の間に+を入れたものと-を入れたものを実行する
    else:
        func(i+1, s_temp+"+"+s[i+1])
        func(i+1, s_temp+"-"+s[i+1])

func(0, s[0])

Measured memory_bytes: 38256
N, M = map(int, input().split())
MODN = 1000000000 + 7

fact = [1] * 100010
for i in range(len(fact)-1):
  fact[i+1] = fact[i] * (i+1) % MODN

if abs(N-M) >= 2:
  print(0)
elif abs(N-M) == 1:
  print(fact[N] * fact[M] % MODN)
else:
  print(fact[N] * fact[M] * 2 % MODN)


Measured memory_bytes: 7028
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max(min(b,d)-max(a,c),0)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {
	int X,A,B; cin >> X >> A >> B;

	X -= A;
	int b = X / B;

	cout << X - b * B << endl;

	return 0;
}


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

int main(){
   string s; cin>>s;
   int ans=0;
   int n=s.length();
   for(int i=0;i<n/2;i++){
      if(s[i]!=s[n-1-i]) ans++;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
	val n = (readLine() ?: return).toLong()
	val input = LongArray(5) { (readLine() ?: return).toLong() }

	var time = n / input[0] + if (n % input[0] > 0) 1 else 0
	var min = input[0]
	for (i in 1 until 5) {
		if (input[i] > min) {
			time++
			continue
		}
		min = input[i]
		val rest = n - input[i] * (time - i)
		time += rest / input[i] + if (rest % input[i] > 0) 1 else 0
	}
	println(time)
}

Measured memory_bytes: 33404
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

signed main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	
	int i, j;
	int ans = 0;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= n; j++) {
			int rem = n - r * i - g * j;
			if (rem < 0) continue;
			if (rem % b == 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 200'000 + 5;

i64 a, b, c, k;

bool check(vector<i64>& q) {
    i64 r = a;
    i64 g = b;
    i64 b = c;
    for (auto e : q) {
        if (e == 0) {
            r *= 2;
        }
        if (e == 1) {
            g *= 2;
        }
        if (e == 2) {
            b *= 2;
        }
    }
    bool R = r < g && g < b;
    if (R) {
        return R;
    }

    if (q.size() == k) {
        return false;
    }

    for (i64 i = 0; i < 3; i++) {
        q.push_back(i);
        if (check(q)) {
            return true;
        }
        q.pop_back();
    }
    return false;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    cin >> a >> b >> c >> k;
    vector<i64> q;

    bool R = check(q);
    if (R) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> t3;

int main(void) {
    ll a,b,k;
    cin >> a >> b >> k;
    auto a1 = min(a,k);
    a = a - a1;
    b = max(0LL, b - (k-a1));
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
 
using namespace std;
 
int main(){
 int N;
 int D;
 cin >> N >> D;
 int hito;
 if(N%(2*D+1)==0){hito = N/(2*D+1);}
  else{hito=(N/(2*D+1))+1;}
 cout << hito << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int x,d, k;
   cin>>x>>k>>d;
   x=abs(x);
  
   	long long int steps=k-min(k,x/d);
    x-=(min(k,x/d)*d);
  	k=steps;
    if(k%2==0) cout<<abs(x)<<endl;
    else cout<<abs(x-d)<<endl;
  
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std; 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define length size()
#define int long long
template<typename T> string join(vector<T> &vec ,const string &sp){
    int si = vec.length;
    if(si==0){
        return "";
    }else{
        stringstream ss;
        rep(i,si-1){
            ss << vec[i] << sp;
        }
        ss << vec[si - 1];
        return ss.str();
    }
}
signed main(void){
    string n;
    cin >> n;
  if(n == "RRR"){
  cout << 3;
  }else if(n=="RRS"||n=="SRR"){
  cout << 2;
  }else if(n == "SSS"){
  cout << 0;
  }else{
  cout << 1;
  }
  cout << endl;
}


Measured memory_bytes: 3580
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;
static const bool DEBUG = false;

signed main() {
	for (int n, m; cin >> n >> m;) {
		if (n % 2) {
			rep(i, 0, n / 2) { if (i == 0)cout << 0; else cout << " " << 0; }
			rep(i, n / 2, n) { if (i == 0)cout << m; else cout << " " << m; }
			cout << endl;
		}
		else {
			rep(i, 0, n / 2 - 1) { if (i == 0)cout << 0; else cout << " " << 0; }
			rep(i, n / 2 - 1, n) { if (i == 0)cout << m; else cout << " " << m; }
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3112
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *X = map(int, read().split())

    ans = 0
    for x in X:
        ans += min(abs(x), abs(x - K)) * 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180