akhauriyash/Code-Regression huggingface dataset:
#![allow(clippy::needless_range_loop)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [usize1; n]
    }
    let mut cnt = vec![0; n];
    for x in a.iter() {
        cnt[*x] += 1;
    }
    let sum: usize = cnt.iter().filter(|x| **x > 0).map(|x| x * (x - 1) / 2).sum();
    for index in a.iter() {
        let x = cnt[*index];
        if x >= 2 {
            println!("{}", sum + (x - 1) * (x - 2) / 2 - x * (x - 1) / 2);
        } else {
            println!("{}", sum);
        }
    }
}


Measured memory_bytes: 6356
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    ll n; cin >> n;
    vector<pair<ll,ll>> pos(n);
    rep(i, n){
        ll x, l; cin >> x >> l;
        pos[i].first = x + l;
        pos[i].second = x - l;
    }
    sort(pos.begin(), pos.end());

    int ans = 0;
    int X = -INFINITY;
    rep(i, n){
        if(X <= pos[i].second){
            ans++;
            X = pos[i].first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
N=int(input())
A=[(int(a),i) for i,a in enumerate(input().split())]
A.append((0,float("inf")))
A.sort()
k=A[-1][1]
ans=[0]*N
for i in range(N)[::-1]:
  ans[k]+=(A[i+1][0]-A[i][0])*(N-i)
  k=min(k,A[i][1])
for i in range(N):
  print(ans[i])

Measured memory_bytes: 68196
#include <iostream>
#include <bits/stdc++.h> 
#include <string>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const pi dir[4] = {{1,0}, {0,1}, {-1,0}, {0,-1}};

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

struct job{
    int duration;
    int deadline;
};

bool cmp(job j1, job j2){
    return j1.deadline < j2.deadline;
}

int n;
job jobs[200002];

int main(){
    IOS;
    cin >> n;
    F0R(i,n){
        cin >> jobs[i].duration >> jobs[i].deadline;
    }
    sort(jobs,jobs+n,cmp);
    int currTime = 0;
    F0R(i,n){
        currTime += jobs[i].duration;
        if(currTime > jobs[i].deadline){
            cout << "No"; return 0;
        }
    }
    cout << "Yes";
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

Measured memory_bytes: 1920
n = list(input())
counter = 1
directions = []
list = []
def add_up(x):
    added = (1/2) * x * (x + 1)
    return added
for i in range(len(n)-1):
    if n[i] == n[i+1]:
        counter += 1
    else:
        directions.append(counter)
        counter = 1
directions.append(counter)
if n[0] == "<":
    for i in range(0,len(directions)-1,2):
        if directions[i] >= directions[i+1]:
            directions[i+1] -= 1
        else:
            directions[i] -= 1
else:
    for i in range(1,len(directions)-1,2):
        if directions[i] >= directions[i+1]:
            directions[i+1] -= 1
        elif directions[i] < directions[i+1]:
            directions[i] -= 1
for direction in directions:
    list.append(add_up(direction))
print(round(sum(list)))


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

int main() {
    while (true) {
        int w; cin >> w;
        if (w == -1) return 0;

        int cost = 1150;
        if (10 < w && w <= 20) cost += 125*(w-10);
        if (20 < w && w <= 30) cost += 1250+140*(w-20);
        if (30 < w) cost += 2650+160*(w-30);

        int ans = 4280-cost;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std ;
int main()
{
  int a,b,c,d ;
  cin>>a>>b>>c ;
  d = a - b ;
  d = c-d ;
  if(d<0)
  {
      d = 0 ;
  }
  cout<<d ;
 return(0) ; 
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;
const double eps = 1e-6;

int n, m;
PII store[N];

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        store[i] = {a, b};
    }
    sort(store + 1, store + 1 + n);

    LL res = 0;
    for(int i = 1; i <= n; i++)
    {
        int t = min(m, store[i].second);
        res += (LL)t *  store[i].first;
        m -= t;
        if(!m) break;
    }

    printf("%lld\n", res);
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false); cin.tie(NULL);
  string s;
  cin >> s;
  ll k;
  cin >> k;
  if (s == string(s.size(), s[0])) {
    cout << s.size() * k / 2 << endl;
    return 0;
  }
  ll ans = 0;
  for (ll i = 0; i < s.size(); ) {
    ll j;
    for (j = i; j < s.size() && s[i] == s[j]; j++) ;
    ans += (j - i) / 2;
    i = j;
  }
  if (k == 1) cout << ans << endl;
  else {
    ll cnt1 = 0, cnt2 = 0;
    for (ll i = 0; i < s.size(); i++) {
      if (s[i] == s[0]) ++cnt1;
      else break;
    }
    for (ll i = s.size() - 1; i >= 0; i--) {
      if (s[i] == s.back()) ++cnt2;
      else break;
    }
    if (cnt1 % 2 == 0 || cnt2 % 2 == 0 || s[0] != s.back()) cout << ans * k << endl;
    else cout << ans * k + (k - 1) << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long int lli;

int g[2000][2000], vert[2001][2001] = { 0 }, hori[2001][2001] = { 0 };

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

    int h, w;
    string s;

    cin >> h >> w;
    for (int i=0; i<h; i++) {
        cin >> s;
        for (int j=0; j<w; j++) {
            g[i][j] = (s[j]=='.') ? 0 : 1;
        }
    }

    // hori
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (g[i][j]) continue;
            hori[i+1][j+1] = hori[i+1][j] + 1;
        }
    }
    for (int i=0; i<h; i++) {
        for (int j=w-1; j>0; j--) {
            if (g[i][j-1]) continue;
            hori[i+1][j] = max(hori[i+1][j], hori[i+1][j+1]);
        }
    }

    // vert
    for (int j=0; j<w; j++) {
        for (int i=0; i<h; i++) {
            if (g[i][j]) continue;
            vert[i+1][j+1] = vert[i][j+1] + 1;
        }
    }
    for (int j=0; j<w; j++) {
        for (int i=h-1; i>0; i--) {
            if (g[i-1][j]) continue;
            vert[i][j+1] = max(vert[i][j+1], vert[i+1][j+1]);
        }
    }

    // for (int i=0; i<h; i++) {
    //     for (int j=0; j<w; j++) {
    //         cout << vert[i+1][j+1] << " ";
    //     }
    //     cout << endl;
    // }

    int ans = 0;
    for (int i=1; i<=h; i++) {
        for (int j=1; j<=w; j++) {
            ans = max(ans, hori[i][j]+vert[i][j]-1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 47232
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
 
#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define SZ(a) ((int)a.size())
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl


#ifdef CHEN_PC
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
 
const int N = 200010;
const int M = 200010 * 2;
 
int n, m;
char s[N];
 
struct graph {
    int e, head[N];
    int ev[M], nxt[M];
	int vis[N];
	int del[N];
	int a[N];
	int b[N];
 
    void init() { e = 0; clr(head, -1); } 
    void addedge(int u, int v) {
        ev[e] = v; nxt[e] = head[u]; head[u] = e++;
    }
 
	void dfs(int u) {
		// printf("%d\n", u);
        vis[u] = 1;
        for (int i = head[u]; ~i; i = nxt[i]) { 
            int v = ev[i];
            if (!vis[v]) dfs(v);
			if (!del[v]) {
				if (s[v-1] == 'A') {
					a[u] = 1;
				} else {
					b[u] = 1;
				}
			}
			// printf("%d %d %d A%d B%d\n", u, v, del[v], a[u], b[u]);
        } 
		// printf("%d A%d B%d\n", u, a[u], b[u]);
		if (a[u] == 0 || b[u] == 0) {
			del[u] = 1;
		}
	}
 
	void handle(queue<int> &q1, queue<int> &q2, int mk) {
		while (!q1.empty()) {
			int u = q1.front(); q1.pop();
			// printf("%d\n", u);
        	for (int i = head[u]; ~i; i = nxt[i]) { 
            	int v = ev[i];
				if (del[v]) continue;
				if (s[v-1] == 'A') {
					a[u] = mk;
				} else {
					b[u] = mk;
				}
			}
			if (a[u] < mk || b[u] < mk) {
				debug("-- %d,\n", u);
				del[u] = 1;
        		for (int i = head[u]; ~i; i = nxt[i]) { 
            		int v = ev[i];
					if (del[v]) continue;
					q2.push(v);
				}
			}
		}
		// printf("[%d]\n", mk);
	}
 
	bool solve() {
		clr(vis, 0);
		clr(del, 0);
		clr(a, 0);
		clr(b, 0);
		int mk = 1;
		queue<int> q1, q2;
		forab (u, 1, n + 1) {
			q1.push(u);
		}
		while (true) {
			if (!q1.empty()) {
				handle(q1, q2, mk++);
			}
			if (!q2.empty()) {
				handle(q2, q1, mk++);
			}
			if (q1.empty()) {
				break;
			}
		}
		forab (i, 1, n + 1) {
			if (!del[i]) {
				return true;
			}
		}
		return false;
	}
 
};
 
 
int main(int argc, char *argv[]) {
#ifdef CHEN_PC
	freopen("C.in", "r", stdin);
#endif
	graph g;
	while (scanf("%d%d", &n, &m) != EOF) {
		scanf("%s", s);
		g.init();
		forn (i, m) {
			int a, b;
			scanf("%d%d", &a, &b);
			g.addedge(a, b);
			g.addedge(b, a);
		}
		bool ret = g.solve();
		if (ret) {
			puts("Yes");
		} else {
			puts("No");
		}
		// printf("%d\n", ret);
		// break;
	}
	return 0;
}

Measured memory_bytes: 8192
// AOJ ALDS1_2_B Selection Sort
// 2018.4.27 bal4u
 
#include <stdio.h>
 
int selection_sort(int n, int *a)
{
    int i, j, minj, x;
int ans = 0;
 
    for (i = 0; i < n; i++) {
        minj = i;
        for (j = i; j < n; j++) {
            if (a[j] < a[minj]) minj = j;
        }
        if (i != minj) {
            x = a[i], a[i] = a[minj], a[minj] = x;
ans++;
        }
    }
return ans;
}
 
//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0, c = getchar_unlocked();
    do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
    return n;
}
 
int a[102];
 
int main()
{
    int N, i, k;
 
    N = in();
    for (i = 0; i < N; i++) a[i] = in();
    k = selection_sort(N, a);
    printf("%d", a[0]);
    for (i = 1; i < N; i++) printf(" %d", a[i]);
    putchar('\n');
    printf("%d\n", k);
    return 0;
}


Measured memory_bytes: 2056
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class C
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var L = Scanner.Scan<double>();
            var e = L / 3;
            Console.WriteLine(e * e * e);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 27892
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // cout << fixed << setprecision(10);

    LL n;
    cin >> n;

    string ret = "No";
    if(n % 10 == 7)
        ret = "Yes";
    n = n / 10;
    if(n % 10 == 7)
        ret = "Yes";

    n = n / 10;
    if(n % 10 == 7)
        ret = "Yes";

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3656
#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(){
    int n;
    cin>>n;
    vector<ll>a(n),mx(n),mn(n);
    rep(i,n)cin>>a[i];
    reverse(a.begin(),a.end());
    if(a[0]>2){cout<<-1<<endl; return 0;}
    if(a[0]==2)mx[0]=3,mn[0]=2;
    for(int i=1; i<n; ++i){
        mx[i]=(mx[i-1]/a[i])*a[i]+a[i]-1;
        mn[i]=((mn[i-1]+a[i]-1)/a[i])*a[i];
        if(mx[i]<mn[i]){cout<<-1<<endl; return 0;}
    }
    cout<<mn[n-1]<<" "<<mx[n-1]<<endl;
}

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

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    long long n, x, y, d, i, c = 0;

    scanf("%lld %lld", &n, &d);

    for (i = 0; i < n; i++) {
        scanf("%lld %lld", &x, &y);

        if (sqrtl(powl(x, 2) + powl(y, 2)) <= d) {
            c++;
        }
    }

    printf("%lld", c);

    return 0;
}



Measured memory_bytes: 2120
Q = 10**9+7
#import sys
#input = sys.stdin.readline
from collections import deque
def main():
    N, K = map( int, input().split())
    E = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map( lambda x: x-1, map( int, input().split()))
        E[a].append(b)
        E[b].append(a)
    V = [0]*N
    V[0] = K
    d = deque()
    for i in range( len(E[0])):
        t = E[0][i]
        V[t] = K - 1 - i
        if K == i+1:
            print(0)
            return
        cnt = 0
        for v in E[t]:
            if V[v] == 0:
                d.append(v)
                if K == cnt+2:
                    print(0)
                    return
                V[v] = K-2-cnt
                cnt += 1
    while d:
        t = d.popleft()
        cnt = 0
        for v in E[t]:
            if V[v] == 0:
                d.append(v)
                if K == cnt+2:
                    print(0)
                    return
                V[v] = K-2-cnt
                cnt += 1
    ans = 1
    for v in V:
        ans *= v
        ans %= Q
    print(ans)
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 27024
object Main {
	def main(args: Array[String]): Unit = {
		val len = io.StdIn.readInt()
		val numsAsStr = io.StdIn.readLine().split(" ")
		val numsAry = new Array[Int](len)
		
		for (str <- numsAsStr) {
			numsAry(numsAsStr.indexOf(str)) = str.toInt
		}
		
		var count = 0
		
		for (num <- 0 until len - 2) {
			if (returnBoolean(Array(numsAry(num), numsAry(num + 1), numsAry(num + 2)))) count += 1
		}
		
		println(count)
	}
	
	def returnBoolean(array: Array[Int]): Boolean = {
		array(1) == array.sortWith((x: Int, y: Int) => x < y)(1)
	}
}

Measured memory_bytes: 27192
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n, k;
  cin >> n >> k;
  int res = 1;
  for(int i = 0; i < n; i++){
    res = min(res * 2, res + k);
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>
using namespace std;

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

void Main()
{
	int N;
	cin >> N;

	int count = 0;
	rep(i, N)
	{
		int l, r;
		cin >> l >> r;
		count += r - l + 1;
	}

	cout << count << endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);

	Main();
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            string[] bs = Console.ReadLine().Split(' ');

            int[] b = new int[M];

            for(int i=0;i<M;i++)
            {
                b[i] = int.Parse(bs[i]);
            }

            for(int i=0;i<N;i++)
            {
                string[] a = Console.ReadLine().Split(' ');
                int buf = C;

                for (int j = 0; j < M; j++)
                    buf += b[j] * int.Parse(a[j]);

                if (buf > 0)
                    ans++;
                
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 13140
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from collections import deque
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


INF = float("inf")
MOD = 10**9 + 7
EPS = 1e-6
KETA = 10**7


def main():
    H, W, K = MAP()
    x1, y1, x2, y2 = LIST()
    c = [[-1] + [0 if c == "." else -1 for c in input()] + [-1]
         for i in range(H)]
    c = [[-1] * (W + 2)] + c + [[-1] * (W + 2)]
    c[x1][y1] = 0

    # 0123: 上下左右
    stack = deque([((x1 * KETA + y1) << 2) + 0, ((x1 * KETA + y1) << 2) + 1,
                   ((x1 * KETA + y1) << 2) + 2, ((x1 * KETA + y1) << 2) + 3])
    DX = (1, 0, -1, 0)
    DY = (0, 1, 0, -1)
    head = 0
    while stack:
        b = stack.popleft()
        head += 1
        d = b % 4
        x, y = divmod(b >> 2, KETA)
        flag = True
        a = c[x][y] + 1
        for k in range(1, K + 1):
            xx, yy = x + k * DX[d], y + k * DY[d]
            if c[xx][yy] == 0:
                stack.append(((xx * KETA + yy) << 2) + (d - 1) % 4)
                stack.append(((xx * KETA + yy) << 2) + (d + 1) % 4)
                c[xx][yy] = a
            elif c[xx][yy] != a:
                flag = False
                break
        if flag:
            stack.append(((xx * KETA + yy) << 2) + d)
        if c[x2][y2] > 0:
            print(c[x2][y2])
            return

    print(-1)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
    int n; cin >> n;
    vector <int> a(n, 0);
    for(int i = 0; i < n-1; i++) {
        int x; cin >> x;
        a[x - 1] += 1;
    }

    for(int i = 0; i < n; i++) {
        cout << a[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 4004
#include<stdio.h>
#include<math.h>

int main(){

  int n,i,j,count,sum=0,num[10000];
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&num[i]);

    for(j=2,count=0;j<=sqrt(num[i]);j++)
      if(num[i]%j==0)count++;

    if(count==0) sum++;
  }

  printf("%d\n",sum);

  return 0;

}

Measured memory_bytes: 632
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iterator>

using namespace std;

int main(){
	int n,k;
	scanf("%d%d", &n, &k);

	vector<int> li(n);

	for(; n>0; n--){
		int t;
		scanf("%d", &t);
		li.push_back(t);
	}

	sort(li.begin(), li.end());
	auto it = lower_bound(li.begin(), li.end(), k);
	int t = distance(it, li.end());

	printf("%d", t);
}


Measured memory_bytes: 1024
import collections
h,c,k = map(int,raw_input().split(' '))
res = 0
mat = [raw_input() for ii in range(h)]
for mii in range(2 ** h):
	for mjj in range(2 ** c):
		count = 0
		for i in range(len(mat)):
			for j in range(len(mat[0])):
				if (mii >> i) & 1 == 0 and (mjj >> j) & 1 == 0:
					count += 1 if mat[i][j] == '#' else 0
		if count == k:
			res += 1
print res


Measured memory_bytes: 73084
N = int(input())
A_arr = [int(x) for x in input().split()]

tmp = [0]*(N+1)

for i,A in enumerate(A_arr):
    if i%2 == 0:
        tmp[i+1] = tmp[i]+A
    else:
        tmp[i+1] = tmp[i]-A

for i in range(N):
    tmp2 = -tmp[i]+(tmp[N]-tmp[i])
    if i%2 == 1:
        tmp2 *= -1
    print(tmp2, end=" ")
print()


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int a, b;
	cin >> a >> a >> b;

	cout << ((a * 10 + b) % 4 ? "NO" : "YES") << endl;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>

const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N;
    cin>>N;
    string S;
    cin>>S;
    int ans=1;
    char cur=S.at(0);
    for(int i=1;i<N;i++){
        if(cur!=S.at(i)){
            cur=S.at(i);
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define ll long long

int main()
{
    ll n,s=0,a=1;
    cin >> n;
    while(n)
    {
        s+=a;
        a*=2;
        n=n/2;
    }
    cout << s;
    return 0;
}


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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int h,a;
    cin >> h >> a;
    cout << ((h+a-1)/a) << endl;
    return 0;
}






























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

long long dp[100001];

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

	int n, w;
	cin >> n >> w;
	int a[n], b[n];
	for(int i=0; i<n; ++i)
		cin >> a[i] >> b[i];
	for(int i=0; i<n; ++i)
		for(int j=w-a[i]; j>=0; --j)
			dp[j+a[i]]=max(dp[j]+b[i], dp[j+a[i]]);
	cout << dp[w];
}

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

int main(){
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s == u) {
    cout << a-1 << " " << b << endl;
  } else {
    cout << a << " " << b-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){
  int h, n;
  std::cin >> h >> n;

  std::vector<int> A(n), B(n);
  
  for(int i=0; i<n; i++){
    std::cin >> A[i] >> B[i];
  }

  int MAGIC = 30000;
  std::vector<int> dp(MAGIC, -1);
  dp[0] = 0;
  for(int i=0; i<n; i++){
    for(int j=0; j<h; j++){
      if(dp[j]==-1) continue;
      int tmp = dp[j]+B[i];
      int idx = std::min(j+A[i], h);
      if(dp[idx] == -1 || dp[idx] > tmp)
	dp[idx] = tmp;
    }
  }

  /**
  for(int i=0; i<=h; i++){
    std::cout << dp[i] << " ";
  }
  std::cout << std::endl;
  **/
  
  std::cout << dp[h] << std::endl;
  

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  ll ans = INF;
  FOR(i, -100, 101) {
    ll sum = 0;
    REP(j, n) { sum += (a[j] - i) * (a[j] - i); }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
maze = []
for _ in range(h):
    maze.append(list(input()))

def clear_maze(sx, sy, maze):
    INF = -float('infinity')
    field_x_length = len(maze)
    field_y_length = len(maze[0])
    distance = [[INF for i in range(field_y_length)] for j in range(field_x_length)]

    queue = deque([(sx, sy)])
    distance[sx][sy] = 0
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    while queue:
        x, y = queue.pop()
        # if x == gx and y == gy:
        #     break
        for i in range(0, 4):
            nx, ny = x + dx[i], y + dy[i]
            if (0 <= nx < field_x_length) and (0 <= ny < field_y_length):
                if maze[nx][ny] != '#' and distance[nx][ny] == INF:
                    queue.appendleft((nx, ny))
                    distance[nx][ny] = distance[x][y] + 1
    MAX = 0
    for row in range(field_x_length):
        for col in range(field_y_length):
            MAX = max(MAX, distance[row][col])
    return MAX
    # return distance[gx][gy]

pairs = []
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            pairs.append([i, j])

MAX = 0
for sx, sy in pairs:
    r = clear_maze(sx, sy, maze)
    MAX = max(MAX, r)
print(MAX)

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

long long q, a, b;

long long solve();

int main() {
  cin >> q;
  for(int i = 0; i < q; ++i) {
    cin >> a >> b;
    cout << solve() << endl;
  }
  return 0;
}

long long solve() {
  if(a > b) swap(a, b);
  long long cnta = 0, cntb = 0, root = sqrtl(a * b);
  // if(root * root == a * b) --root;
  cnta = max(0LL, min(root, a - 1));
  cntb = max(0LL, min(root, b - 1));
  if(cntb * (a + 1) >= a * b)
    --cntb;
  else
    cntb += max(0LL, (a * b / root) -
                         ((a * b % root) == 0) - 1 - a);
  return cnta + cntb + min(a - cnta - 1, b - cntb - 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char s[5010],t[5010];
int A[5010],B[5010],a,b;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();scanf("%s",s+1);scanf("%s",t+1);
	int ans=INT_MAX;
	A[++a]=0,B[++b]=0;
	if(s[1]=='1')A[++a]=0;if(t[1]=='1')B[++b]=0;
	for(int i=1;i<n;++i)if(s[i]!=s[i+1])A[++a]=i;
	for(int i=1;i<n;++i)if(t[i]!=t[i+1])B[++b]=i;
	A[++a]=n,B[++b]=n;
	if(s[n]=='1')A[++a]=n;if(t[n]=='1')B[++b]=n;
	for(int i=1;i<=b;i+=2){
		int res=0,c=std::min(b,a+i-1);
		for(int j=1;j<i;++j)res+=B[j];
		for(int j=i;j<=c;++j)res+=abs(A[j-i+1]-B[j]);
		for(int j=i+a;j<=b;++j)res+=std::min(B[j],n-B[j]);
		for(int j=c-i+2;j<=a;++j)res+=std::min(A[j],n-A[j]);
		ans=std::min(res,ans);
	}
	for(int i=1;i<=a;i+=2){
		int res=0,c=std::min(a,b+i-1);
		for(int j=1;j<i;++j)res+=A[j];
		for(int j=i;j<=c;++j)res+=abs(B[j-i+1]-A[j]);
		for(int j=i+b;j<=a;++j)res+=std::min(A[j],n-A[j]);
		for(int j=c-i+2;j<=b;++j)res+=std::min(B[j],n-B[j]);
		ans=std::min(res,ans);
	}
	return printf("%d\n",ans),0;
}


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

int main(void){
  int h1, h2, k1, k2, a, b, c, d, H, K;

  cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
  H = h1*a + (h1/10)*c + h2*b + (h2/20)*d;
  K = k1*a + (k1/10)*c + k2*b + (k2/20)*d;

  if ( H > K ) cout << "hiroshi" << endl;
  else if ( H < K ) cout << "kenjiro" << endl;
  else cout << "even" << endl;

  return 0;
}


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

int main()
{
    int A,B,C;
    cin>>A>>B>>C;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define mp            make_pair
#define PI            3.14159265
#define M             1000000007
#define MM            998244353
#define fr            first
#define sc            second
#define all(v)        (v).begin(),(v).end()
#define rall(v)       (v).rbegin(),v.rend()
#define vc            vector
#define vi            vector<int>
#define pii           pair<int,int>
#define psi           pair<string,int>
#define pis           pair<int,string>
#define mii           map<int,int>
#define msi           map<string,int>

int solve(){
    int n,s=0; cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1];
}

signed main() {
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> p(A), q(B), r(C);
    priority_queue<ll> pq;
    rep(i,A) cin >> p[i];
    rep(i, B) cin >> q[i];
    rep(i, C) cin >> r[i];

    sort(ALL(p));
    reverse(ALL(p));
    sort(ALL(q));
    reverse(ALL(q));
    sort(ALL(r));
    reverse(ALL(r));

    rep(i, X) pq.push(p[i]);
    rep(i, Y) pq.push(q[i]);
    rep(i, C) pq.push(r[i]);

    ll ans = 0;

    rep(i, X + Y) ans += pq.top(), pq.pop();

    print(ans);

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int r,g,b;cin >>r>>g>>b;
    int k=g*10+b;
    if(k%4==0)puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
  string n;
  cin >> n;
  int m=n.size();
  ll f=0;
  ll x=0;
  rep(i,m){
    f+=n.at(i)-'0';
    x+=(n.at(i)-'0')*pow(10,m-1-i);
  }
  if(x%f==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    while(cin >> n){
        int mi = 1e9;
        int ans = 0;
        f1(n){
            int add;
            cin >> add;
            if(add <= mi){
                ans++;
            }
            mi = min(mi,add);
        }
        cout << ans << '\n';
    }
}

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

int main(){
   int a,b;
   string s;
   cin >> a >> b;
   if (b >= a) cout << "unsafe" << endl;
   else cout << "safe" << endl;
   return 0;

}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	long long int res = 0;
	const int mod = 1e9 + 7;
	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}
	vector<long long int> v(1, 1);
	for (int i = 1; i <= max(n, m); i++) {
		v.push_back(v.back() * i % mod);
	}
	res = v[m] * v[n] % mod;
	if (m == n) res = res * 2 % mod;
	cout << res << endl;
}


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

int main(){
    int n,max;
    long long a,cou=0;
    vector<long long> Arr,Vec;
    cin>>n;
    for(int i=0;i<n+1;i++){
        cin>>a;
        Arr.push_back(a);
    }
    for(int j=0;j<n;j++){
        cin>>a;
        Vec.push_back(a);
    }
    for(int i=0;i<n;i++){
        if(Arr[i]<=Vec[i]){
            cou+=Arr[i];
            Vec[i]-=Arr[i];
            if(Arr[i+1]<=Vec[i]){
                cou+=Arr[i+1];
                Arr[i+1]=0;
            }else{
                cou+=Vec[i];
                Arr[i+1]-=Vec[i];
            }
        }else{
            cou+=Vec[i];
            
        }
    }
    cout<<cou<<endl;
    return 0;
}






Measured memory_bytes: 2548
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll a, b;
	cin >> a >> b;
	cout << (a + b) / 2 << endl;
}



Measured memory_bytes: 3104
/*     *******************Bismillahir Rahmanir Rahim************************
                          **************************
                          #    MD. ASFAKUL GHANI   #
                          #       *ProMAGFAT*      #
                          #         CSE-25         #
                          #JAHANGIRNAGAR UNIVERSITY#
                          #    Dhaka,Bangladesh    #
                          &&&&&&&&&&&&&&&&&&&&&&&&&#
*/

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

#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define Im int main(int argc, char *argv[])
#define ll long long
#define sc scanf
#define pf printf
#define rn0 return 0
#define rn return
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define f2(i,n) for(ll i=n-1;i>=0;i--)
#define pi 2*acos(0.0)
#define modulo 1000003
#define dd double
#define PI 3.14159265358979
#define pi 2*acos(0.0)
#define p_b push_back
#define ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/


Im
{
    fasterIO;

    string a,b;
    cin>>a>>b;
    ll sz1=a.size();
    ll sz2=b.size();
    string c;
    ll i,j;
    for (i=0,j=0;i<sz1&&j<sz2; i++,j++) {
        c+=a[i],c+=b[j];
    }

    if (i<sz1) c+=a[i];
    if (j<sz2) c+=b[j];

    cout << c << endl;

   // main();

    rn0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    bool cards[4][13] = {{}, {}, {}, {}};
    
    // 0: S
    // 1: H
    // 2: C
    // 3: D
    
    int n;
    char suit;
    int rank;

    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> suit >> rank;

        switch (suit)
        {
            case 'S':
                cards[0][rank - 1] = true;
                break;
            case 'H':
                cards[1][rank - 1] = true;
                break;
            case 'C':
                cards[2][rank - 1] = true;
                break;
            case 'D':
                cards[3][rank - 1] = true;
                break;
            default:
                break;
        }
    }


    for (int x = 0; x < 4; x++)
    {
        for (int y = 0; y < 13; y++)
        {
            switch (x)
            {
                case 0:
                    suit = 'S';
                    break;
                case 1:
                    suit = 'H';
                    break;
                case 2:
                    suit = 'C';
                    break;
                case 3:
                    suit = 'D';
                    break;
                default :
                    break;
            }

            if (!cards[x][y])
            {
                cout << suit << " " << y + 1 << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
vector<int> divisor(int n)
{
	vector<int> ret;
	for (int i = 0; i * i <= n; ++i) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n)	ret.push_back(n / i);
		}
	}
	return ret;
}
void prime_factorize(int n, map<int, int> &prime)
{
	if (n <= 1)	return;
	int last = sqrt(n);
	for (int i = 2; i <= last; i++) {
		if (n % i == 0) {
			prime_factorize(i, prime);
			prime_factorize(n / i, prime);
			return;
		}
	}
	prime[n]++;
	return;
}
int main()
{
	int n;
	cin >> n;
	map<int, int> mp;
	ll ans = 1;
	for (int i = 1; i <= n; ++i) {
		prime_factorize(i, mp);
	}
	for (auto a : mp) {
		ans *= (a.second + 1);
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,f=0;cin>>n;
  for(long long  i =1;i<=n;i++)
  {
    if((i%3==0)||(i%5==0))
       continue;
     f=f+i;
  }
 cout<<f;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<double, double > pi; 
typedef pair<pair<ll ,ll >,ll > pii; 
//辞書順最小
//なるべく後ろにあるハテナに文字列を入れる

ll ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main(){
    
    string input; cin >> input;
    
    for(ll i = 0; i < (1<<3); i++){
        vector<ll > fugou(3, 1);
        for(ll j = 0; j < 3; j++){
            if(i >> j & 1){
                fugou[j] = -1;
            }
        }
        ll sum = ctoi(input[0]);
        for(ll j = 0; j < 3; j++){
            if(fugou[j] == 1){
                sum += ctoi(input[j + 1]);
            }else{
                sum -= ctoi(input[j + 1]);
            }
        }

        if(sum == 7){
            cout << input[0];
            for(ll j = 0; j < 3; j++){
                if(fugou[j] == 1){
                    cout << "+" << input[j + 1];
                }else{
                    cout << "-" << input[j + 1];
                }
            }
            cout << "=7" << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,ma,mb;
  cin >> n >> ma >> mb;
  vec a(n);
  vec b(n);
  vec c(n);
  for(ll i=0;i<n;i++) cin >> a[i] >> b[i] >> c[i];
  mat dp(401,vec(401,inf));
  dp[0][0]=0;
  for(ll i=0;i<n;i++) {
    for(ll j=400;j>-1;j--) {
      for(ll k=400;k>-1;k--) {
        if(j-a[i]>-1&&k-b[i]>-1) {
          dp[j][k]=min(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
        }
      }
    }
  }
  ll ans=inf;
  for(ll i=1;ma*i<401&&mb*i<401;i++) {
    ans=min(ans,dp[ma*i][mb*i]);
  }
  if(ans==inf) {
    ans=-1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

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

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;
  int D[K]; rep(i,K) cin >> D[i];

  while(true) {
    int tmp_N = N;
    bool ok = true;
    while(tmp_N!=0) {
      if (binary_search(D,D+K,tmp_N%10)) ok = false;
      tmp_N /= 10;
    }
    if (ok) break;
    N++;
  }
  cout << N << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	int k = 0;
	ll ans = 0, mi = 1e9 + 7;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		if (a[i] < 0)
		{
			k++;
		}
		ans += abs(a[i]);
		mi = min(mi, abs(a[i]));
	}
	if (k & 1)
	{
		ans -= 2 * mi;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void){
  int x;
  int k = 0;
  scanf("%d",&x);
  
  if(0 <= x && x <= 1000000000){
 	k += (x/500) * 1000;
  	x = x % 500;
  	k += (x/5) * 5;
  
	printf("%d",k);
  }
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()

const int inf=2e9+5;


int main(){
    bool ok=true;
    int n,m; cin>>n>>m;
    vector<int> l(m), r(m), d(m);
    rep(i,m) cin>>l[i]>>r[i]>>d[i];
    map<int,vector<P>> mp;
    map<int,int> mp2;
    rep(i,m){
        mp2[l[i]]=inf; mp2[r[i]]=inf;
    }
    rep(i,m){
        mp[l[i]].push_back({r[i],d[i]});
        mp[r[i]].push_back({l[i],-d[i]});
    }
    for(auto &v:mp){
        if(mp2[v.first]==inf){
            mp2[v.first]=1;
            deque<int> che;
            che.push_back(v.first);
            while(!che.empty()){
                for(auto & w: mp[che[0]]){
                    if(mp2[w.first]==inf){
                        mp2[w.first]=mp2[che[0]]+w.second;
                        che.push_back(w.first);
                    }else if(mp2[w.first]==mp2[che[0]]+w.second){
                    }else{
                        ok=false;
                    }
                }
                che.pop_front();
            }
        }
    }
    cout<<(ok?"Yes":"No") <<endl;
    return 0;
}

Measured memory_bytes: 24728
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
#define MAXN 100000
int n;
int main()
{
    scanf("%d",&n);
    if(n<1200)printf("ABC");
    else if(n<2800)printf("ARC");
    else printf("AGC");
}


Measured memory_bytes: 256