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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000

#define MAX_V 100005
#define MAX_N MAX_V

int N;
struct edge{ int to, cost; };
typedef pair<int, int> P;   // first は最短距離、 second は頂点の番号
int V;
vector<edge> G[MAX_V];
int d[MAX_V];
int prev_p[MAX_V];

void dijkstra(int s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    fill(prev_p, prev_p + V, -1);
    d[s] = 0;
    que.push(P(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first){ continue; }
        REP(i, G[v].size()) {
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                prev_p[e.to] = v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

vector<int> get_path(int t) {
    vector<int> path;
    for(; t != -1; t = prev_p[t]) { path.push_back(t); }  // t が s になるまで prev_p[t] を辿っていく
    // このままだと t->s の順になっているので逆順にする
    reverse(path.begin(), path.end());
    return path;
}

// node 以下のノード数をカウント
int count(int node, int ng1, int ng2) {
    int ret = 1;
    REP(i, G[node].size()) {
        if(G[node][i].to != ng1 && G[node][i].to != ng2) {
            ret += count(G[node][i].to, node, -1);
        }
    }
    return ret;
}

int main()
{
    cin >> N;
    V = N;
    REP(i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edge e1, e2;
        e1.to = b;
        e1.cost = 1;
        G[a].push_back(e1);
        e2.to = a;
        e2.cost = 1;
        G[b].push_back(e2);
    }
    dijkstra(0);
    vector<int> path = get_path(N-1);

    // DEBUG
    //printf("\n");
    //REP(i, path.size()) {
    //    printf("%d ", path[i]);
    //}
    //printf("\n");
    //printf("%d\n", d[N-1]);

    int sunuke_reg, fenec_reg;
    if((path.size() - 2) % 2 == 0) {
        sunuke_reg = fenec_reg = (path.size() - 2) / 2;
    } else {
        fenec_reg = (path.size() - 2) / 2 + 1;
        sunuke_reg = (path.size() - 2) / 2;
    }
    int fenec_have = 0;
    int sunuke_have = 0;
    for(int i = 1; i < path.size()-1; ++i) {
        // 各頂点が持つ子ノードの数を取得
        if(i <= fenec_reg) {
            fenec_have += count(path[i], path[i-1], path[i+1]);
        } else {
            sunuke_have += count(path[i], path[i-1], path[i+1]);
        }
    }
    fenec_have += (count(0, path[1], -1) - 1);
    sunuke_have += (count(N-1, path[path.size()-2], -1) - 1);
    if(fenec_have > sunuke_have) { printf("Fennec\n"); }
    else { printf("Snuke\n"); }
    return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int M, D;
    cin >> M >> D;
    int ans = 0;
    REP(i, M+1) {
        FOR(j, 22, D+1) {
            if((j%10) > 1 && (j/10)*(j%10) == i) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include<math.h>
#include<stdio.h>


int main()
{
	std::string n;
	std::cin >> n;
	for (int i = 0; i < 3; i++) {
		if (n[i] == '7') {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}std::cout << "No" << std::endl;
	
	
}

Measured memory_bytes: 3620
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll K, N;
  cin>>K>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  ll dist = 0;
  for(int i=0;i<N;++i) {
    if(i<N-1) {
      dist = max(dist, A[i+1]-A[i]);
    }
    else {
      dist = max(dist, (K-A[N-1]+A[0]));
    }
  }
  cout<<K-dist<<endl;
}



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

int main(){
    int n;
    int alice=0,bob=0;

    cin >>n;
    int data[n];
    for (int i = 0; i < n; i++){
        cin >> data[i];
    }

    sort(data,data+n,greater<int>());
    
    for (int i = 0; i < n; i++){
        if(i%2==0)alice+=data[i];
        else bob += data[i];
    }
    
    //cout << ans <<endl;
    cout << alice - bob <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
#define LL long long
using namespace std;

int a, b;
bool flag;
int weishu(int x)
{
	int res = 0;
	while(x)
	{
		x /= 10;
		res++;
	}
	return res;
}

int main() {
	cin >> a >> b;
	
	LL s = a;
	int k = weishu(b);
	
	while(k--) a *= 10;
	a += b;
	
	for(int i = 1; i * i <= a; i++)
		if(i * i == a)
		{
			flag = 1;
			break;
		}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;		
}

Measured memory_bytes: 256
// AOJ 2640 Prowler
// 2018.3.17 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define QMAX 1000000
typedef struct { char r, c, d; int n; } Q;
Q q[QMAX + 4]; int top, end;
int H, W, SR, SC, GR, GC, D;
char vis[52][52];
char sta[52][52][5];
char map[52][52];
char cd[128];
char pat[5][4][3][4] = { {0},
   {{"   ",	 " ^>",	 "  #"},
	{" ^ ",	 " ^#",	 "   "},
	{" # ",	 "<^#",	 "   "},
	{" # ",	 "#^#",	 " v "}},

   {{"   ",  " > ",  "#v "},
	{"   ",  " >>",  " # "},
	{" ^ ",  " >#",  " # "},
	{" # ",  "<>#",  " # "}},

   {{"#  ",  "<v ",  "   "},
	{"   ",  "#v ",  " v "},
	{"   ",  "#v>",  " # "},
	{" ^ ",  "#v#",  " # "}},

   {{" ^#",  " < ",  "   "},
	{" # ",  "<< ",  "   "},
	{" # ",  "#< ",  " v "},
	{" # ",  "#<>",  " # "}} };

int next(int *r0, int *c0, int *d0)
{
	int i, r, c, d, x;
	int rr, cc, dd;

	dd = 0;
	for (i = 0; i < 4; i++) {
		for (r = -1; r <= 1; r++) for (c = -1; c <= 1; c++) if (r != c) {
			x = pat[*d0][i][r + 1][c + 1];
			if ((d = cd[x]) & 0xf) {
				if (map[*r0 + r][*c0 + c] == '#') { dd = 0; goto NT; }
				dd = d, rr = *r0 + r, cc = *c0 + c;
			}
			else if (x == '#' && map[*r0 + r][*c0 + c] != '#') { dd = 0; goto NT; }
		}
		if (dd) break;
NT:     ;
	}
	if (!dd) return 0;
	*r0 = rr, *c0 = cc, *d0 = dd;
	return 1;
}

int bfs()
{
	int r, c, d, n;

	top = 0, end = 1;
	q[0].r = SR, q[0].c = SC, q[0].d = D, q[0].n = 1;
	sta[SR][SC][D] = 1, vis[SR][SC] = 1;
	while (top != end) {
		r = q[top].r, c = q[top].c, d = q[top].d, n = q[top].n;
		++top;

		if (!next(&r, &c, &d)) continue;
		if (r == GR && c == GC) return n + 1;
		if (sta[r][c][d]) continue;
		sta[r][c][d] = 1;
		if (!vis[r][c]) n++, vis[r][c] = 1;

		q[end].r = r, q[end].c = c, q[end].d = d, q[end].n = n;
		++end;
	}
	return -1;
}

int main()
{
	int r, c, d;

	cd['^'] = 1, cd['>'] = 2, cd['v'] = 3, cd['<'] = 4, cd['#'] = 16;
	scanf("%d%d", &H, &W);
	for (r = 1; r <= H; r++) {
		scanf("%s", map[r]+1);
		for (c = 1; c <= W; c++) {
			if (map[r][c] == 'G') GR = r, GC = c;
			else if ((d = cd[map[r][c]]) & 0xf) SR = r, SC = c, D = d;
		}
	}
	// 周りを壁"#"で囲んでおく
	memset(map[0], '#', W+2), memset(map[H + 1], '#', W+2);
	for (r = 1; r <= H; r++) map[r][0] = map[r][W + 1] = '#';

	d = 0;
	for (r = -1; r <= 1; r++) for (c = -1; c <= 1; c++) {
		if (map[GR + r][GC + c] == '#') { d = 1, r = 2; break; }
	}
	if (!d) { puts("-1"); return 0; }

	printf("%d\n", bfs());
	return 0;
}


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

int main(){
  int N;
  long long K;
  cin >> N >> K;
  vector<vector<int>> ab(N,vector<int>(2));
  for (int i=0;i<N;i++){
    cin >> ab[i][0] >> ab[i][1];
  }
  sort(ab.begin(),ab.end());
  for (int i=0;i<N;i++){
    if (K<=ab[i][1]){
      cout << ab[i][0] << endl;
      break;
    }
    else {
      K-=(long long)ab[i][1];
    }
  }
}

Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#define FOR(i, n) for(int i = 0; i < n; i++) 
using namespace std;

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

void load() {
}

void solve() {
	ll a, b; scanf("%lld%lld", &a, &b);
	ll g = __gcd(a, b);
	int cnt = 1;
	for (ll x = 2; x * x <= g; x++) {
		if (g % x == 0) {
			cnt++;
			while (g % x == 0) g /= x;
		}
	}
	if (g != 1) cnt++;
	printf("%d\n", cnt);
}

int main() {
	load();
	solve();
	return 0;
}


Measured memory_bytes: 128
s = list(input())
cnt = 0
for i in range(len(s)):
    if i % 2 == 0 and s[i] in ['R', 'U', 'D']:
        cnt += 1
    elif i % 2 == 1 and s[i] in ['L', 'U', 'D']:
        cnt += 1
print('Yes' if cnt == len(s) else 'No')

Measured memory_bytes: 8968
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1e9+7 ;
//long double pie = acos(-1) ;
//ll INF = 1e15 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	cout << min(n%k,k-n%k) << endl ;
}


Measured memory_bytes: 3596
#include<iostream>
#include<math.h>
#include<cassert>
// assert( ) ??????assert.h ????????則??????????????即????????贈?即??????????????????????assert( ) ???????????????????????其????????????????????????????????????expression ????????????????????属????即??????即??????????????? stderr ??????????????????????????即????????????abort( ) ??????????????????????????属???????????属?????????????????????expression ??????????????\???????????属???assert( ) ???????????????????????????

using namespace std;
 
bool isPrime(int x){
  if ( x < 2 ) return false;
  else if ( x == 2 ) return true;
  if ( x % 2 == 0 ) return false;
  int limit = (int)sqrt((double)x) + 1;
  for ( int i = 3; i <= limit; i+=2 ){
    if ( x % i == 0 ) return false;
  }
  return true;
}
 
int main(void){
  int n, x;
  int cnt = 0;
  cin >> n;
  assert(1 <= n && n <= 10000);
  for ( int i = 0; i < n; i++ ){
    cin >> x;
    assert(2 <= x && x <= 1000000000);
    if ( isPrime(x) ) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main()
{
    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    ll t;
    cin >> t;
    if (a > b)
    {
        if (a - b <= t * (v - w))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    else
    {
        if (b - a <= t * (v - w))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 3644
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		String s = sc.next();
		int len = s.length();
		long total = Long.parseLong(s);
		for (int i = 1; i < len; i++) {
			for (int j = 0; j <= len - i; j++) {
				if (j == 0 || j == len - i) {
					total += Long.parseLong(s.substring(j, j + i)) * (1 << (len - i - 1));
				} else {
					total += Long.parseLong(s.substring(j, j + i)) * (1 << (len - i - 2));
				}
			}
		}
		
		out.println(total);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
}

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

#ifdef DBG
    #define D(y) y
#else
    #define D(y)
#endif

using namespace std;

struct pt {
    int x, y;
};

struct edge_pt {
    int x, y, i;
};

bool verify(vector<edge_pt> &pts, int l, int r, vector<int> &first, vector<int> &last) {
    if (l > r) return true;

    int j = l;
    while (j <= r) {
        int i = pts[j].i;
        if (j == first[i]) {
            if (last[i] > r) return false;

            if (!verify(pts, j + 1, last[i] - 1, first, last)) return false;
        } else {
            return false;
        }

        D(printf("successful pairing %d %d\n", first[i], last[i]));

        j = last[i] + 1;
    }

    return true;
}

int main() {
    int R, C, N;
    scanf("%d %d %d", &R, &C, &N);

    auto is_edge_pt = [&](pt p) -> bool {
        return p.x == 0 || p.x == R || p.y == 0 || p.y == C;
    };

    vector<pair<pt, pt>> v(N);
    vector<edge_pt> edge_pts;
    for (int i = 0; i < N; ++i) {
        scanf("%d %d %d %d", &v[i].first.x, &v[i].first.y, &v[i].second.x, &v[i].second.y);

        if (is_edge_pt(v[i].first)) {
            edge_pts.push_back({v[i].first.x, v[i].first.y, i});
        }

        if (is_edge_pt(v[i].second)) {
            edge_pts.push_back({v[i].second.x, v[i].second.y, i});
        }
    }

    auto edge_idx = [&](edge_pt p) -> pair<int, int> {
        if (p.y == 0) return {0, p.x};
        else if (p.x == R) return {1, p.y};
        else if (p.y == C) return {2, -p.x};
        else if (p.x == 0) return {3, -p.y};
        else assert(false);
    };
    sort(edge_pts.begin(), edge_pts.end(), [&](edge_pt a, edge_pt b) {
        return edge_idx(a) < edge_idx(b);
    });

    vector<int> freq(N, 0);
    for (int i = 0; i < edge_pts.size(); ++i) {
        freq[edge_pts[i].i]++;
    }

    vector<edge_pt> edge_pts_filtered;
    copy_if(edge_pts.begin(), edge_pts.end(),
        back_inserter(edge_pts_filtered),
        [&](edge_pt p) { return freq[p.i] == 2; }
    );

    vector<int> first(N, 2 * N + 10);
    vector<int> last(N, -1);
    for (int i = 0; i < edge_pts_filtered.size(); ++i) {
        first[edge_pts_filtered[i].i] = min(i, first[edge_pts_filtered[i].i]);
        last[edge_pts_filtered[i].i] = i;
    }

    D(
        for (int i = 0; i < edge_pts_filtered.size(); ++i) {
            printf("%d ", edge_pts_filtered[i].i);
        }
        printf("\n");
    );

    if (verify(edge_pts_filtered, 0, edge_pts_filtered.size() - 1, first, last)) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }

    return 0;
}


Measured memory_bytes: 11760
#include <iostream>
#include <cstdio>
#include <cstring> 
using namespace std;
int n, m, k;
int cnt[15][1005];
char mp[15][1005];
bool vis[1005];
int cut[20], top;
int ans = 0x7f7f7f7f;
int cal(int x1, int x2, int y1, int y2) {
	return cnt[x2][y2] - cnt[x2][y1 - 1] - cnt[x1 - 1][y2] + cnt[x1 - 1][y1 - 1];
}
void dfs(int pos) {
	cut[++top] = pos;
	if (pos == n) {
		memset(vis, 0, sizeof(vis)); 
		int sx, sy, lst = 0, tmp = 0;
		for (int j = 1; j <= m; j++) {
			for (int i = 1; i <= top; i++) {
				sx = cut[i - 1] + 1, sy = lst + 1;
				if (cal(sx, cut[i], sy, j) > k) {
					if (lst == j - 1) {
						top--;
						return;
					} else {
						sy = j;
						if (!vis[j - 1]) tmp++, vis[j - 1] = 1;
					}
				}
			}
			if (vis[j - 1]) lst = j - 1;
		}
		ans = min(ans, tmp + top - 1);
		top--;
		return;
	}
	for (int i = pos + 1; i <= n; i++) {
		dfs(i);
	}
	top--;
}
int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; i++) {
		scanf("%s", mp[i] + 1); 
		for (int j = 1; j <= m; j++) {
			cnt[i][j] = cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1] + mp[i][j] - '0';
		}
	}
	for (int i = 1; i <= n; i++) {
		dfs(i);
	}
	cout << ans;
	return 0;
}

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

ans = 0
n = 0
for i in range(N):
    a = int(input())
    if(a != 0 and n > 0):
        ans += 1
        a -= 1
        n = 0
    elif(a == 0):
        n = 0
        
    if(a > 1):
        ans += a//2
        n = a%2
    
print(ans)

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

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13) cout << b << endl;
	else if (a > 5) cout << b / 2 << endl;
	else cout << 0 << endl;

}

Measured memory_bytes: 256
# ABC052C - Factors of Factorial (ARC067C)
def count_divisors(num: int) -> int:
    """
    Compute how many divisors a number has.
    arr (2D array): prime factors and how many times used
    e.g. n = 2^a * 3^b -> [(2, a), (3, b)]
         res = (a + 1) * (b + 1)
    """
    max_prime = 0
    dic = {}  # {prime factor: count}

    # Divide num by 2 as much as possible
    cnt = 0
    while num % 2 == 0:
        num //= 2
        cnt += 1
    if cnt > 0:
        max_prime = 2
        dic[max_prime] = cnt

    # num must be odd -> skip even numbers
    cnt = 0
    for i in range(3, int(num ** 0.5) + 1, 2):
        cnt = 0
        while num % i == 0:
            num //= i
            max_prime = i
            cnt += 1
        if cnt > 0:
            dic[max_prime] = cnt

    # To handle the case when n is prime greater than 2
    if num > 2:
        max_prime = num
        dic[max_prime] = 1

    return dic


def main():
    n = int(input())
    MOD = 10 ** 9 + 7
    f = {}
    for i in range(2, n + 1):
        for j, k in count_divisors(i).items():
            if j not in f:
                f[j] = 0
            f[j] += k
    ans = 1
    for i in f.values():
        ans = (ans * (i + 1)) % MOD
    print(ans)


if __name__ == "__main__":
    main()

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    string s;cin>>s;
    bool jdg=true;
    rep(i,s.size()){
        if((i+1)%2!=0){
            if(s[i]=='L'){
                jdg=false;
            }
        }
        else {
            if(s[i]=='R'){
                jdg=false;
            }
        }
    }
    if(jdg){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    string n;
    cin>>n;
    bool f = false;
    rep(i, 3) {
        if (n[i] - '0' == 7) f = true;
    }
    if (f) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;

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

ll N;
vector<ll> h;

ll memo[100001];

ll func(ll pos)
{
	if (memo[pos] != -1) return memo[pos];

	if (pos == 0) return 0;
	if (pos == 1) return abs(h[1] - h[0]);

	memo[pos] = min(func(pos - 1) + abs(h[pos-1] - h[pos]), func(pos - 2) + abs(h[pos - 2] - h[pos]));

	return memo[pos];
}

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

	cin >> N;
	h.resize(N);

	for (ll i = 0; i < N; ++i) cin >> h[i];
	for (auto& e : memo) e = -1;

	cout << func(N - 1) << endl;

	//system("pause");
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
enum POSITION{ONLINE_BACK = -2, CLOCKWISE = -1, ON_SEGMENT = 0,
              COUNTER_CLOCKWISE = 1, ONLINE_FRONT = 2};
struct Point{
    double x;
    double y;
    Point(double x, double y) : x(x), y(y){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double get_cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double get_dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}
struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2){}
};
POSITION get_pos(Point p, Segment s){
    Vector base = s.p2 - s.p1;
    Vector obj  = p    - s.p1;
    double cross = get_cross(base, obj);
    if (cross >  1e-10) return CLOCKWISE;
    if (cross < -1e-10) return COUNTER_CLOCKWISE;
    if (get_dot(base, obj) < 0) return ONLINE_BACK;
    if (get_dot(base, base) < get_dot(obj, obj)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool is_intersection(Segment s1, Segment s2){
    if (get_pos(s2.p1, s1) * get_pos(s2.p2, s1) > 0) return false;
    if (get_pos(s1.p1, s2) * get_pos(s1.p2, s2) > 0) return false;
    return true;
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3;
        cin >> x_p0 >> y_p0 >> x_p1 >> y_p1;
        cin >> x_p2 >> y_p2 >> x_p3 >> y_p3;
        Point p0(x_p0, y_p0);
        Point p1(x_p1, y_p1);
        Point p2(x_p2, y_p2);
        Point p3(x_p3, y_p3);
        Segment s1(p0, p1);
        Segment s2(p2, p3);
        int ans = 0;
        if (is_intersection(s1, s2)) ans = 1;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n,a[N];
long long ans,cnt[N];
int main() {
	scanf("%d",&n);
	for(int i = 1;i <= n;++i)
		scanf("%d",a+i),++cnt[a[i]],ans += cnt[a[i]]-1;
	for(int i = 1;i <= n;++i)
		cout << ans - cnt[a[i]] + 1 << endl;
	return 0;
}



Measured memory_bytes: 3968
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
using data = pair<lint, vector<lint>>;
#define all(x) (x).rbegin(), (x).rend()
#define pb push_back
int main()
{
    vi num(3);
    int k;
    cin >> num[0] >> num[1] >> num[2] >> k;
    vvi v(3);
    rep(i, 3)
    {
        v[i].resize(num[i]);
        rep(j, num[i])
        {
            cin >> v[i][j];
        }
        sort(all(v[i]));
    }
    priority_queue<data> que;
    set<data> s;
    que.push(data(v[0][0] + v[1][0] + v[2][0], vi({0, 0, 0})));
    rep(i, k)
    {
        auto q = que.top();
        que.pop();
        cout << q.first << endl;
        for (int j = 0; j < 3; j++)
        {
            if (q.second[j] + 1 < num[j])
            {
                auto vec = q.second;
                vec[j]++;
                lint sum = q.first - v[j][q.second[j]] + v[j][q.second[j]+1];
                auto d = data(sum, vec);
                if (!s.count(d))
                {
                    s.insert(d);
                    que.push(d);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>
 
// #include <unordered_set>
// #include <unordered_map>
 
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
 
#define pb push_back
#define mp make_pair
 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
 
typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;
 
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
using namespace std;
 
// #define int long long

const int MAX_V=1000;
int memo[1000001]={0};
int dist[MAX_V][MAX_V];



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cin高速化
    
    // int start[100001]={0};
    // int end[100001]={0};
    // int channel[100001]={0};

    int table[31][200002]={0};
    int count_arr[200002]={0};
    // int cha[200002]={0};



    int n,m;
    int a,b,c;
    int count;

    cin>>n>>m;

    REP(i,n){
        cin>>a>>b>>c;
        c--;


        table[c][a-1]++;
        table[c][b]--;

        // cin>>start[i]>>end[i]>>channel[i];
    }

    // REP(i,3){
    //     REP(j,10){
    //         cout<<" "<<table[i][j];
    //     }cout<<endl;
    // }


    REP(i,m){
        REP(j,200002){
            if(table[i][j]>=0)table[i][j+1]+=table[i][j];
        }
    }

    // REP(i,3){
    //     REP(j,10){
    //         cout<<" "<<table[i][j];
    //     }cout<<endl;
    // }
    int ans=-1;
    int tmp;
    REP(j,200002){
        tmp=0;
        REP(i,m){
            if(table[i][j]>0)tmp++;
        }
        ans=max(ans,tmp);
    }

    // REP(i,200002){
    //     cout<<" "<<count_arr[i];
    // }

    cout<<ans<<endl;


    // REP(i,n){
    //     REP(j,m){
    //         table[start[j]*2-1]++;
    //         table[end[j]*2]++;
    //     }
    // }


    
    return 0;
    
}




Measured memory_bytes: 24448
from bisect import bisect_left

n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

ans = 0

for t in T:
    # 左から見ていった時に新たにtが入る位置
    left = bisect_left(S, t)
    if left < len(S) and S[left] == t:
        ans += 1

print(ans)



Measured memory_bytes: 16736
#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;


int main(){
	int n;
	int a,b;
	cin >> n >> a >> b;
	cout << min(n*a,b) << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  char a; cin>>a;
  if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string S;
	cin >> S;
	vector<int> R_cnt(S.length(), 0);
	vector<int> L_cnt(S.length(), 0);
	rep1(i, S.length()) {
		if (S[i] == 'L') {
			L_cnt[i] += L_cnt[i - 1] + 1;
		}
	}
	for (int i = S.length() - 2; i >= 0; i--) {
		if (S[i] == 'R') {
			R_cnt[i] += R_cnt[i + 1] + 1;
		}
	}
	vector<int> final_cnt(S.length(), 0);
	rep(i, S.length()) {
		if (S[i] == 'R') {
			if (R_cnt[i] % 2 != 0) {
				final_cnt[i + R_cnt[i] - 1]++;
			}
			else {
				final_cnt[i + R_cnt[i]]++;
			}
		}
		else {
			if (L_cnt[i] % 2 != 0) {
				final_cnt[i - L_cnt[i] + 1]++;
			}
			else {
				final_cnt[i - L_cnt[i]]++;
			}
		}
	}
	rep(i, S.length()) {
		if (i != S.length() - 1) {
			cout << final_cnt[i] << " ";
		}
		else {
			cout << final_cnt[i] << endl;
		}
	}
	return 0;
}

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

int main() {
  string  a, b, c;
  cin >> a >> b >> c;
  string d = a + b + c;
  if(d == "575"){
    cout << "YES" <<endl;
  }
  else if(d == "755"){
    cout << "YES" <<endl;
  }
  else if(d == "557"){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a+b >= 10){
		cout << "error" << endl;
		return 0;
	}else{
		cout << a+b << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta (bas + (son-bas)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1e18
#define N 1000005

using namespace std;
 
typedef long long ll;

int n,m,d,ans;

int main()
{

	cin >> n >> m;

	for(int i = 0; i < n; i++)
	{
		cin >> d;
		if (d >= m)
		{
			ans++;
		}
	}

	cout << ans;
	
    return 0;
}


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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int A, B;
	
	cin>>A>>B;
	
	if((A+B)%2 == 1) cout<<"IMPOSSIBLE"<<endl;
	else {
		cout<<(A+B)/2<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n, x, max_;
  int dp[5000];
  while(1){
    cin >> n;
    if(!n) break;
    cin >> x;
    max_=x; dp[0]=x;
    for(int i=1; i<n; ++i){
      cin >> x;
      dp[i] = max(x, dp[i-1]+x);
      max_ = max(max_, dp[i]);
    }
    cout << max_ << endl;
  }
  return 0;
}

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

int main(){
 int a , b;
  cin >> a >> b;
  int c = a * b;
  if(c % 2 == 0){
  cout << "Even" << endl;
  }else {
  cout << "Odd" << endl;  
  }
  
  
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<ll,ll> pii;
template<typename T> using vec=std::vector<T>;

const ll inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const ll dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct segtree{
    int n;
    vector<int> dat;
    segtree(int size,int x){
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,x);
    }
    // update k th element
    void update(int k, int a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a,int b) { return query(a,b,0,0,n); }
    int query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return (1LL<<31)-1;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return min(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};

void solve(){
    int n,q;
    cin >> n >> q;
    segtree seg(n,(1LL<<31)-1);
    rep(i,0,q){
        int com,x,y;
        cin >> com >> x >> y;
        if(com==0) seg.update(x,y);
        else cout << seg.query(x,y+1) << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {
 

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy";
    else if(s=="Cloudy")cout<<"Rainy";
    else
        cout<<"Sunny";
    return 0;  
}

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

int main() {
	int d;
	while (cin >> d) {
		int cnt = 0;
		for (int i = d; i < 600; i += d) {
			cnt += i*i*d;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3028
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
bool seen[10010];
int count[10010];

int main(){
    int N,X,Y;
    cin >>N>>X>>Y;
    Graph G(N+1);
    queue<int> que;
    vector<int> dist(N+1,-1);
    vector<int> init(N+1,-1);
    for(int i=1;i<N;i++){
        G[i].push_back(i+1);
        G[i+1].push_back(i);
        seen[i]=false;
        count[i]=0;
    }
    G[X].push_back(Y);
    G[Y].push_back(X);
    for(int i=1;i<N;i++){
        que.push(i);
        dist[i]=0;
        while(!que.empty()){
            int r=que.front();
            que.pop();
            for(auto v:G[r]){
                if(dist[v]==-1){
                    dist[v]=dist[r]+1;
                    if(v>=i){
                        count[dist[v]]++;
                    }
                    que.push(v);
                }
            }
        }
        dist=init;
    }
    for(int i=1;i<N;i++){
        cout <<count[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)

void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

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

    int x, y, z;
    cin >> x >> y >> z;
    swap(&x, &y);
    swap(&x, &z);
    cout << x << ' ' << y << ' ' << z;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())

ans = 0
for i in range(1, n):
    f = s[:i]
    b = s[i:]
    cnt = 0
    for c in [chr(j + ord('a')) for j in range(26)]:
        if c in f and c in b:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }





int main() {
    int N;
    while (cin >> N) {
        int num = (N+1)/2;
        cout << fixed << setprecision(10) << (double)(num) / N << endl;
    }

}










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

using namespace std;

void output(vector<int> v) {
  int n = v.size();

  for (int i = 0; i < n; i++) {
    if (i)
      cout << " ";
    cout << v[i];
  }
  cout << endl;
}

template <typename IteratorType>
IteratorType next_element(int ref, IteratorType begin, IteratorType end) {
  int min = 1000000;
  auto next_itr = begin;
  for (auto itr = begin; itr != end; itr++) {
    if (*itr > ref && *itr < min) {
      min = *itr;
      next_itr = itr;
    }
  }
  return next_itr;
}

template <typename IteratorType>
IteratorType prev_element(int ref, IteratorType begin, IteratorType end) {
  int max = 0;
  auto prev_itr = begin;
  for (auto itr = begin; itr != end; itr++) {
    if (*itr<ref&& * itr> max) {
      max = *itr;
      prev_itr = itr;
    }
  }
  return prev_itr;
}

bool next_permutation(vector<int>& pv) {
  for (auto itr = pv.rbegin(); next(itr, 1) != pv.rend(); itr++) {
    if (*next(itr, 1) < *itr) {
      iter_swap(next_element<decltype(itr)>(*next(itr), pv.rbegin(), next(itr)), next(itr, 1));
      sort(pv.rbegin(), next(itr), greater<int>());
      return 1;
    }
  }
  return 0;
}

bool prev_permutation(vector<int>& pv) {
  for (auto itr = pv.rbegin(); next(itr, 1) != pv.rend(); itr++) {
    if (*next(itr, 1) > *itr) {
      iter_swap(prev_element<decltype(itr)>(*next(itr), pv.rbegin(), next(itr)), next(itr, 1));
      sort(pv.rbegin(), next(itr), less<int>());
      return 1;
    }
  }
  return 0;
}

int factorial(int n) {
  return (n == 1 || n == 0) ? 1 : factorial(n - 1) * n;
}

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

  int n;
  cin >> n;

  vector<int> pv(n), v(n), nv(n);

  for (int i = 0; i < n; i++) {
    v[i] = i + 1;
  }

  output(v);

  int num_loop = factorial(n);
  nv = v;
  for (int i = 0; i < num_loop; i++) {
    if (next_permutation(nv) == true) {
      output(nv);
    }
  }

  return 0;
}



Measured memory_bytes: 3204
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s,t = input().split()
    for i in range(2*n):
        if not i%2:
            print(s[i//2],end ="")
        else:
            print(t[i//2],end = "")
    print()
    return

#Solve
if __name__ == "__main__":
    solve()


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

typedef long long ll;

const int MAXN = 5000;
const ll INF = (1LL << 60);

ll dp[MAXN + 5];

int p[MAXN + 5], N, A, B;
int main() {
	scanf("%d%d%d", &N, &A, &B);
	for(int i=1;i<=N;i++) scanf("%d", &p[i]);
	p[N + 1] = N + 1;
	
	for(int i=1;i<=N+1;i++) {
		dp[i] = INF; int nw = 0; ll del = 0;
		for(int j=i-1;j>=1;j--) {
			if( p[j] < p[i] ) {
				if( nw < p[j] )
					dp[i] = min(dp[i], dp[j] + del), nw = p[j];
				del += B;
			}
			else del += A;
		}
		if( !nw ) dp[i] = del;
	}
	
	printf("%lld\n", dp[N + 1]);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;



int main(void) {
	int N, A, B, C, D = 0;
	string S;
	cin >> N >> A >> B >> C >> D;
	cin >> S;

	bool ans = true;
	if (C < D) {
		// ふぬけを先に動かす
		int iCheck = A + 1;
		while ((S[iCheck-1] != '#') || (S[iCheck] != '#')) {
			if (iCheck == D - 2) {
				break;
			}
			iCheck++;
		}
		if (iCheck != D - 2) {
			ans = false;
		}


		if (ans) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (D < C) {
		int iSunuke = A;
		int iFunuke = B;
		// すぬけを先に動かす

		// ふぬけの前後に岩がない状態までふぬけを動かす
		int iNextFunuke = B;
		while (S[iNextFunuke - 2] == '#' || S[iNextFunuke - 1] == '#' || S[iNextFunuke] == '#') {
			if (iNextFunuke == D){
				ans = false;
				break;
			}
			iNextFunuke++;
		}
		iFunuke = iNextFunuke;

		// 2マス連続岩もふぬけもいないところを探す
//		int iCheck = A+1;
//		while (!((S[iCheck] != '#' || iFunuke != iCheck) && (S[iCheck+1] != '#' || iFunuke != (iCheck+1)))) {
//			iCheck++;
//			if (iCheck == S.length()) {
//				ans = false;
//				break;
//			}
//		}
		// 2マス連続岩がいないことを確認する
		if (ans) {
			int iCheck = A+1;
			while ((S[iCheck-1] != '#') || (S[iCheck] != '#')) {
				if (iCheck == C - 2) {
					break;
				}
				iCheck++;
			}
			if (iCheck != C - 2) {
				ans = false;
			}
		}

		if (ans) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (C == D) {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fastAF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define pll pair<ll,ll>
#define mapll map<ll,ll>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
void swap(auto*,auto*);
const ll N=5e5;
vll adj[N+1]; bool visited[N+1]; ll c[N+1];
vll bfs(ll node)
{
    visited[node]=1;
    queue<ll> q; q.push(node); vll ans;
    while(!q.empty())
    {
        node=q.front(); q.pop();
        ans.pb(c[node]);
        for(ll x:adj[node])
        {
            if(visited[x]) continue;
            visited[x]=1; q.push(x);
        }
    }
    return ans;
}
int32_t main()
{
    fastAF
    ll n,k; cin>>n>>k;
    ll p[n+1]; for(ll i=1;i<=n;i++) cin>>p[i];
    for(ll i=1;i<=n;i++) cin>>c[i];
    for(ll i=1;i<=n;i++)
    {
        adj[i].pb(p[i]);
    }
    vll valArr[n+1];
    for(ll i=1;i<=n;i++)
    {
        ms(visited,0);
        valArr[i]=bfs(i);
    }
    ll sum[n+1]; ms(sum,0);
    for(ll i=1;i<=n;i++) for(ll x:valArr[i]) sum[i]+=x; 
    ll maxScore=INT_MIN;
    for(ll i=1;i<=n;i++)
    {
        ll preSum=0; ll c=0; ll len=valArr[i].size();
        for(ll x:valArr[i]){
            c++; preSum+=x;
            if(c>k) break;
            ll times=(k-c)/len;
            maxScore=max(maxScore,preSum+times*max((ll)0,sum[i]));
        }
    }
    cout<<maxScore<<endl;
    return 0;
}
void swap(auto &a,auto &b)
{
    auto temp=a; a=b; b=temp;
}

Measured memory_bytes: 231524
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int k, n, max=0, ex, ans = 0;
    cin >> k >> n;
    
    int a[n], b[n];
    
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    
    ex = k - a[n-1] + a[0];
    
    //cout << "ex = " << ex << " a[n-1] = " << a[n-1] << " a[n-2]= " << a[n-2] << endl;
    
    for(int i=1; i<=n; i++)
    {
//        if(i != n-1){
//        ans += a[i] - a[i-1];
//            //cout << ans << endl;
//
//        } else {
//            if(ex < a[n-1] - a[n-2]){
//                ans += ex;
//                //ans += a[0];
//                //cout << "ex " <<  ans << endl;
//
//            } else {
//                ans += a[i] - a[i-1];
//            }
//        }
        if(i != n){
        b[i] = a[i] - a[i-1];
            //cout << "b[i] = " << b[i] << endl;
        }else{
            b[i] = ex;
            //cout << "b[i] ex = " << b[i] << endl;

        }
        
        if(b[i] > max)
        {
            max = b[i];
        }
    }
    
    ans = k - max;
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1920