akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;
  vector<int> b(m);
  cin >> b;

  vector<vector<ll> > dp(n, vector<ll>(m));
  vector<vector<ll> > sum(n + 1, vector<ll>(m + 1));

  rep(i, n) rep(j, m) {
    if (a[i] == b[j]) {
      (dp[i][j] = sum[i][j] + 1) %= mod;
    }
    sum[i + 1][j + 1] = (sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + dp[i][j] + mod) % mod;
  }
  // cout << endl; rep(i, n) cout << dp[i] << endl;
  // cout << endl; rep(i, n + 1) cout << sum[i] << endl;
  cout << (sum[n][m] + 1) % mod << endl;
}


Measured memory_bytes: 62976
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 5e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
char str[MAXN];

int main() {
	int i, j;
	int a, b;
	scanf("%d%d", &a, &b);
	if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
		printf("%d", a * b);
	}
	else printf("-1");
	return 0;
}

Measured memory_bytes: 256
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int X, A;
  cin >> X >> A;
  if (X < A) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n; cin >> n;
    vector<int> joshi(n+1, 0);
    int tmp;
    rep(i, n-1){
        cin >> tmp;
        joshi[tmp] += 1;
    }
    REP(i, n){
        cout << joshi[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3972
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

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

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

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for {
		if b == 0 {
			return a
		} else {
			a, b = b, a%b
		}
	}
}

func main() {
	line := readBigLine()

	spl := intSprit(line)
	N := spl[0]
	X := spl[1]

	x := intSprit(readBigLine())

	diffs := make([]int, N)

	for i, v := range x {
		diffs[i] = intAbs(v - X)
	}

	ret := diffs[0]
	for i := 1; i < len(diffs); i++ {
		ret = gcd(ret, diffs[i])
	}

	fmt.Println(ret)
}


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

using namespace std;

bool test(int n){
    int res = 0, nn = n;
    while(nn > 0) {
        res = 10* res + nn % 10;
        nn /= 10;
    }
    return res == n;
}
int main(){
    int N = 0, A, B;
    cin >> A >> B;
    for(int i = A; i <= B; i++)
        N += test(i);
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 256
V = input().split()
N = int(V[0])
K = int(V[1])
Q = int(V[2])
A = [0 for i in range(Q)]
P = [K for i in range(N)]
for i in range(Q):
    A[i] = int(input())

for i in range(Q):
    P[A[i]-1] += 1

for i in range(N):
    if P[i] - Q <=0:
        print("No")
    if P[i] - Q > 0:
        print("Yes")

Measured memory_bytes: 10488
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X!=b.X) ? a.X<b.X : a.Y<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return +1; //ccw
    if(cross(b,c) < -EPS) return -1; //cw
    if(dot(b,c) < -EPS) return +2; //c-a-b
    if(abs(c)-abs(b) > EPS) return -2; //a-b-c
    return 0; //a-c-b
}

P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}
VP convex_cut(const VP& p, const L& l){
    VP ret;
    int n = p.size();
    for(int i=0; i<n; i++){
        P curr = p[i];
        P next = p[(i+1)%n];
        if(ccw(l[0], l[1], curr) != -1) ret.push_back(curr);
        if(ccw(l[0], l[1], curr) *ccw(l[0], l[1], next) == -1){
            ret.push_back(crosspointLL(L(curr, next), l));
        }
    }
    return ret;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        VP p(n);
        for(int i=0; i<n; i++){
            int x,y;
            cin >> x >> y;
            p[i] = P(x,y);
        }

        VP con{P(0,0), P(1e4,0), P(1e4,1e4), P(0,1e4)};
        for(int i=0; i<n; i++){
            con = convex_cut(con, L(p[i], p[(i+1)%n]));
        }
        cout << !con.empty() << endl;
    }
    return 0;
}



Measured memory_bytes: 3008
fun main(args: Array<String>) {
    val (x, n) = readLine()!!.split(' ').map { it.toInt() }
    val p = readLine()?.split(' ')?.map { it.toIntOrNull() } ?: emptyList()

    if (n == 0) {
        println(x)
        return
    }

    for (i in 0..100) {
        if (p.contains(x - i).not()) {
            println(x - i)
            break
        }
        if (p.contains(x + i).not()) {
            println(x + i)
            break
        }
    }
}

Measured memory_bytes: 36504
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
 int p,n,m,a,sum=0;
 scanf("%d%d",&n,&m);
 for(int i=0;i<m;i++){
   cin>>p;
   sum +=p;
 }
  int ans = n-sum;
 if(ans<0) cout<<"-1"<<endl;
  else printf("%d\n",ans);
return 0;
}


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

typedef long long lint;
const int maxn = 200005;

int n, w[maxn], fa[maxn];

struct edge1
{
	int to, next, w;
} e[maxn * 2];
int h[maxn], tot;

struct edge2
{
	int u, v;
	lint w;
	bool operator < (const edge2 &a) const {
		return w < a.w;
	}
} E[maxn * 25];
int cnt;

int Siz, siz[maxn], mxsz[maxn], p, rt, vis[maxn];
lint dis[maxn];

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline void add(int u, int v, int w)
{
	e[++tot] = (edge1) {v, h[u], w}; h[u] = tot;
	e[++tot] = (edge1) {u, h[v], w}; h[v] = tot;
}

void getroot(int u, int fa)
{
	siz[u] = 1; mxsz[u] = 0;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa && !vis[v]) {
			getroot(v, u); siz[u] += siz[v];
			mxsz[u] = max(mxsz[u], siz[v]);
		}
	mxsz[u] = max(mxsz[u], Siz - siz[u]);
	if (mxsz[u] < mxsz[rt]) rt = u;
}

void dfs(int u, int fa)
{
	if (dis[u] + w[u] < dis[p] + w[p]) p = u;
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa && !vis[v]) dis[v] = dis[u] + e[i].w, dfs(v, u);
}

void link(int u, int fa)
{
	if (u != p) E[++cnt] = (edge2) {u, p, w[u] + w[p] + dis[u] + dis[p]};
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (v != fa && !vis[v]) link(v, u);
}

void solve(int u)
{
	rt = 0; getroot(u, 0); u = rt; vis[u] = 1;
	p = u; dis[u] = 0; dfs(u, 0); link(u, 0);
	for (int i = h[u], v; v = e[i].to, i; i = e[i].next)
		if (!vis[v]) Siz = siz[v], solve(v);
}

inline int find(int x)
{
	if (!fa[x]) return x;
	return fa[x] = find(fa[x]);
}

int main()
{
	n = gi();
	for (int i = 1; i <= n; ++i) w[i] = gi();
	for (int u, v, i = 1; i < n; ++i) u = gi(), v = gi(), add(u, v, gi());
	
	Siz = n; mxsz[0] = n; solve(1);

	lint ans = 0;
	sort(E + 1, E + cnt + 1);
	for (int i = 1, j = 1; i < n; ++i) {
		while (find(E[j].u) == find(E[j].v)) ++j;
		fa[find(E[j].u)] = E[j].v; ans += E[j].w;
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 70016
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<cmath>

using namespace std;

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	int k,x;
	cin>>k>>x;
	//vector<int>a;
	int limit=x+(k-1);
	int start=x-(k-1);
	for( ;start<=limit;start++) cout<<start<<" ";
	cout<<endl;
	return 0;


}

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

int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<< "Cloudy";
    else if(s=="Cloudy")
        cout<< "Rainy";
    else
        cout<< "Sunny";
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> pa;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=2e5+5;
int n;
int minip[maxn],maxip[maxn];
pa w[maxn];
bool cmp(pa a,pa b){return a.w2<b.w2;}
int main(){
	read(n);
	if(n==1)return puts("0"),0;
	rep(i,1,n){
		read(w[i].w1),read(w[i].w2);
		if(w[i].w1>w[i].w2)swap(w[i].w1,w[i].w2);
	}
	sort(w+1,w+n+1);
	int dlt=w[n].w1-w[1].w1;
	sort(w+2,w+n+1,cmp);
	rep(i,1,n)maxip[i]=max(maxip[i-1],w[i].w2);
	minip[0]=1e9+10;rep(i,1,n)minip[i]=min(minip[i-1],w[i].w2);
	ll ans=1ll*dlt*(maxip[n]-minip[n]);
	int mini=w[n].w1,maxi=w[n].w1;
	per(i,n-1,2){
		ans=min(ans,1ll*(w[n].w2-w[1].w1)*(max(maxi,maxip[i])-min(mini,minip[i])));
		mini=min(mini,w[i].w1);
		maxi=max(maxi,w[i].w1);
	}
	mini=min(mini,w[1].w2);
	maxi=max(maxi,w[1].w2);
	ans=min(ans,1ll*(maxi-mini)*(w[n].w2-w[1].w1));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#define ll long long
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, x;

    cin >> n;
    
    for (int cnt = 0, i = 1; i <= n; i++)
    {
        cin >> x;
        if (x != i)
        {
            cnt++;
            if (cnt > 2)
            {
                cout << "NO";
                return 0;
            }
        }
    }
    cout << "YES";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
claim = [[] for _ in range(n)]

for i in range(n):
    a = int(input())
    for _ in range(a):
        claim[i].append(list(map(int, input().split())))

max_kind = 0
for i in range(2**n):
    state = str(format(i, 'b').zfill(n))
    flag = True
    for j in range(n):
#        print(state, j)
        if (i >> j) & 1:
            for statement in claim[j]:
                person, type = statement
#                print(claim, statement, len(state)-1-person-1, state[len(state)-person], type)
                if int(state[len(state)-person]) != type:
                    flag = False
                    break
        if flag != True: break
    if flag:
        max_kind = max(max_kind, list(state).count('1'))
print(max_kind)


Measured memory_bytes: 47212
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<cmath>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 200050
#define ll long long
#define inf int(1e9)
#define mm 1000000007
#define low(x) x&(-x)
using namespace std;
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int n,m,a[maxn],s[maxn],sum[maxn],x[maxn],l[maxn];
int main(){
//	freopen("in.txt","r",stdin);
	n=read(); m=read();
	rep(i,1,n) a[i]=read(),sum[a[i]]++;
	rep(i,1,n) {
		if (sum[i]) x[max(1,i-sum[i]+1)]++,x[i+1]--;
		l[i]=i-sum[i]+1;
	}	
	rep(i,1,n) s[i]=s[i-1]+x[i];
	int ans=0;
	rep(i,1,n) if (!s[i]) ans++;
	rep(i,1,m) {
		int x=read(),y=read();
		if (l[a[x]]>0 && s[l[a[x]]]==1) ans++;
		s[l[a[x]]]--;
		l[a[x]]++;
		
		a[x]=y;
		l[y]--;
		if (l[y]>0 && s[l[y]]==0) ans--;
		s[l[y]]++;
		printf("%d\n",ans); 
	}
    return 0;
}

Measured memory_bytes: 5376
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

ans = 0
score = 0
last = [[-1] for i in range(26)]
schedule = []

for d in range(D):
  t = d%26
  last[t].append(d)
  score += S[d][t]
  schedule.append(t)

for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

count = 2000000
import random
while count:
  count -= 1
  prev = score
  d,q = random.choice(range(D)),random.choice(range(26))
  p = schedule[d]
  schedule[d] = q
  score -= S[d][p]
  score += S[d][q]
  
  pos = last[p].index(d)
  score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
  last[p].remove(d)
  
  pos = bisect.bisect(last[q],d)
  score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
  bisect.insort(last[q],d)
  if score<prev:
    score = prev
    bisect.insort(last[p],d)
    last[q].remove(d)
    schedule[d] = p
    
for i in schedule:
  print(i+1)


Measured memory_bytes: 83208
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll a[200500];
const ll INF = 1e10;

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

  int n, k;
  cin >> n >> k;
  REP(i, n)cin >> a[i];

  //相対的にずらしていく, 0からの相対位置に応じて足す
  ll ans = INF;
  for(int i=0; i+k-1<n; i++){
    ll tmp = a[i+k-1]-a[i];
    //両方とも左
    if((a[i]<0) && (a[i+k-1]<0)) tmp += abs(a[i+k-1]);
    //両方とも右
    if((a[i]>0) && (a[i+k-1]>0)) tmp += a[i];
    //間
    if((a[i]<0) && (a[i+k-1]>0)) tmp += min(-a[i], a[i+k-1]);
    ans = min(ans, tmp);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){
    int flag(0);
    string str;
    cin >> str;
    if(str[0]=='A'){
        for(int i=2;i<str.size()-1;i++){
            if(str[i]=='C'){
                flag++;
            }
        }
        if(flag==1){
            if(islower(str[1])){
                for(int i=2;i<str.size()-1;i++){
                    if(isupper(str[i]) && str[i]!='C'){
                        cout << "WA";
                        exit(0);
                    }
                }
                if(islower(str[str.size()-1])){
                    cout << "AC";
                    exit(0);
                }
            }

        }
    }
    cout << "WA";
}

Measured memory_bytes: 256
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (ll i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (ll i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int n; cin >> n;

    vi v1, v2;

    vi a(n);
    REP(i, n) cin >> a[i];

    REP(i, n) {
        if (i & 1) {
            v1.pb(a[i]);
        } else {
            v2.pb(a[i]);
        }
    }

    if (n & 1) {
        swap(v1, v2);
    }
    reverse(ALL(v1));
    REP(i, v1.size()) {
        if (i > 0) cout << " ";
        cout << v1[i];
    }

    REP(i, v2.size()) {
        cout << " " << v2[i];
    }

    print("");
}


Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define p printf("bug\n");
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = 1000003;
const int MAX = 1e6;
#define pi acos(-1)
#define FastRead     ios_base::sync_with_stdio(false);cin.tie(NULL);
ll arr[MAX];
int main()
{
//freopen("output.txt", "w", stdout);

    int n,N,R,mx=INT_MAX;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    N=arr[n-1];
    for(int i=0;i<n-1;i++)
   {
       int a=N-arr[i];
       int b=arr[i];
       int c=max(a,b);
       if(c<mx){
        mx=c;
        R=arr[i];
       }
   }
   cout<<N<<" "<<R<<endl;


    return 0;
}


Measured memory_bytes: 4304
using System;
class Program
{
	static void Main()
	{
	string s = Console.ReadLine();
	//出力
      int a = 0;
      for(int i = 0; i < 3; i++)
      {
        if(s[i]=='1')
          a++;
      }
	Console.WriteLine(a);//WriteLineをWriteとすると、改行なしで出力。
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

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

	int l=S.length();
	vi v(l,0);
	vi ans(l,0);
	int countR=0;
	int countL=0;
	int i;
	for(i=0; i<l; i++){
		if(S[i]=='L'){
			v[i]=countL;
			countL--;
		}else{
			countL=0;
		}

		if(S[l-1-i]=='R'){
			v[l-1-i]=countR;
			countR++;
		}else{
			countR=0;
		}
	}

	for(i=0; i<l; i++){
		if(abs(v[i])>0){
			if(S[i]=='L'){
				if(v[i]%2==0){
					ans[i+v[i]]++;
				}else{
					ans[i+v[i]-1]++;
				}
			}else if(S[i]=='R'){
				if(v[i]%2==0){
					ans[i+v[i]]++;
				}else{
					ans[i+v[i]+1]++;
				}
			}
		}else{
			ans[i]++;
		}
	}

	for(i=0; i<l; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}

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

using namespace std;

int solve(const int stones_height[], int memo[], const int &n){
    int ans;
    if(memo[n] != -1) ans = memo[n];
    else if(n == 1) return 0;
    else{
        ans = abs(stones_height[n] - stones_height[n - 1]) + solve(stones_height, memo, n - 1);
        if(n - 2 >= 1){
            ans = min(ans, abs(stones_height[n] - stones_height[n - 2]) + solve(stones_height, memo, n - 2));
        }
    }
    return memo[n] = ans;
}

int main(){
    int n;
    while(scanf("%d", &n) != EOF){
        int stones_height[n + 1], memo[n + 1];
        for(int i = 0; i < n; i++){
            scanf("%d", &stones_height[i + 1]);
            memo[i + 1] = -1;
        }
        printf("%d\n", solve(stones_height, memo, n));
    }
    return 0;
}

Measured memory_bytes: 12280
#include <iostream>
#include <cstring>
#define N 4001
using namespace std;
typedef long long ll;
struct tree{
	ll lf,rt;
}a[N];
ll head[N];
bool vis[N];
ll n,k;
ll num,ans,tot;
inline void fstart(ll lf,ll rt){
	num++;
	a[num].rt=rt;
	a[num].lf=head[lf];
	head[lf]=num;
}
inline void dfs(ll x,ll step){
	register int i,j;
	if(step>k/2)return ;
	for(i=head[x];i!=0;i=a[i].lf){
		ll p=a[i].rt;
		if(!vis[p])vis[p]=true,dfs(p,step+1),tot++;
	}
}
main(){
	register int i,j;
	cin>>n>>k;
	for(i=1;i<n;i++){
		ll lf,rt;
		cin>>lf>>rt;
		fstart(lf,rt);
		fstart(rt,lf);
	}
	if(k%2==0){
		for(i=1;i<=n;i++){
			memset(vis,false,sizeof(vis));
			vis[i]=true;
			tot=1;
		    dfs(i,1);
		    ans=max(ans,tot);
		}
	}
	else{
		k--;
		for(i=1;i<=n;i++){
			for(j=head[i];j!=0;j=a[j].lf){
				memset(vis,false,sizeof(vis));
				ll p=a[j].rt;
				vis[i]=true;vis[p]=true;
				tot=2;
				dfs(i,1);dfs(p,1);
				ans=max(ans,tot);
			}
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 384
n=int(input())
A=list(map(int,input().split()))

x=0
y=0
for a in A:
    if a%2==0:
        if a%4==0:
            x+=1
        else:
            y+=1
if x+y//2>=n//2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14252
def ProgramB():
    
    num = int(input())
    
    count = 0
    max_count = 0

    for i in range(num):
        data = list(map(int,input().split()))

        if num == 0:

            if data[0] == data[1]:
                count = count + 1
                
                if count > max_count:
                    max_count = count
    
            else:
                count = 0

        else:
            if data[0] == data[1]:
                count = count + 1
                
                if count > max_count:
                    max_count = count
    
            else:
                count = 0
            
            
    if max_count >= 3:        
        print('Yes')
        
    else:
        print('No')
        
        
if __name__ == '__main__':
    ProgramB()



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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/11  Problem: ABC 091 B / Link: http://abc091.contest.atcoder.jp/tasks/abc091_b  ----- */


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

	LL N; cin >> N;
	map<string, LL>Map;
	for (int i = 0; i < N; ++i) {
		string s; cin >> s;
		Map[s]++;
	}
	LL M; cin >> M;
	for (int i = 0; i < M; ++i) {
		string s; cin >> s;
		Map[s]--;
	}
	LL ans = 0;
	for (auto it : Map) {
		ans = max(ans, it.second);
	}
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    int tan;
    tan=n;
    int i;
    i=0;
    while(i<=n){
        string z1,z2;
        for(int j=0;j<n-i;j++){
            z1+=s.at(i+j);
            z2+=t.at(j);
        }
        if(z1==z2)break;
        else tan--;
        i++;
    }
    cout << 2*n-tan << endl;
    return 0;
}

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

int main(){
  ll n,i,ans=0,arr[5]={0,0,0,0,0};
  cin>>n;
  string s;
  for(i=0;i<n;i++)
   {
    cin>>s;
    if(s[0]=='M') arr[0]++;
    else if(s[0]=='A')arr[1]++;
    else if(s[0]=='R')arr[2]++;
    else if(s[0]=='C')arr[3]++;
    else if(s[0]=='H')arr[4]++;
  }
    for(i=0;i<3;i++){
        for(ll j=i+1;j<4;j++){
            for(ll k=j+1;k<5;k++)
            ans+=arr[i]*arr[j]*arr[k];
        }
    }
    cout<<ans;
return 0;
}


Measured memory_bytes: 256
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]

n,m=MI()

g=[[] for i in range(n)]
v=[0]*n
f=[0]*n
e=[]

for i in range(m):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    g[a].append(b)
    g[b].append(a)
    e.append((a,b))

def get_tree(st):
    p,q=[],[]
    q.append(st)
    v[st]=1
    
    while q:
        cur=q.pop()
        for nb in g[cur]:
            if v[nb]!=1:
                q.append(nb)
                p.append((cur,nb))
                v[nb]=1
    return p

def solve():
    tr=get_tree(0)
    st=set(tr)
    rt=[]
    for a,b in e:
        if (a,b) in st or (b,a) in st:
            pass
        else:
            rt.append((a,b))
            f[a]=1-f[a]
    for a,b in tr[::-1]:
        if f[b]==0:
            rt.append((a,b))
            f[a]=1-f[a]
        else:
            rt.append((b,a))
            f[b]=1-f[b]
    return rt

if m%2==1:
    print(-1)
else:
    for a,b in solve():
        print(a+1,b+1)

Measured memory_bytes: 89504
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

Int S[51];
Int P[51];

Int calc(int n, Int x){
    if (x == 1 || x == 0){
        return 0;
    }
    if (x == S[n-1] + 1){
        return P[n-1];
    }

    if (x >= (S[n]+1) / 2) return P[n] - calc(n, S[n] - x);
    else return calc(n-1, x-1);
}


int main(){
    cin.tie(0);

    Int N, X; cin >> N >> X;
    
    P[0] = 1LL;
    S[0] = 1LL;

    for (int i = 1; i <= N; i++){
        S[i] = S[i-1]*2LL+3LL;
        P[i] = P[i-1]*2LL+1LL;
    }

    cout << calc(N, X) << endl;
}


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

int main() {
    int A,B,result;
    string op;
    cin >> A >> op >> B;
    if(op == "+")
    {
        result = A + B;
    }
    else
    {
        result = A - B;
    }
    
    cout << result << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 201010
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<Edge>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

struct edge{
  ll v,c,w;
};

int main(){
  map<ll,vector<edge>> ADJ[MAX];
  map<ll,ll> DIS[MAX];
  
  ll N,M;
  cin>>N>>M;
  REP(i,M){
    ll U,V,C;
    cin>>U>>V>>C;
    
    ADJ[U][C].push_back({V,C,0});
    ADJ[U][C].push_back({U,0,0});
    ADJ[U][0].push_back({U,C,1});
    DIS[U][C]=MAX;
    
    ADJ[V][C].push_back({U,C,0});
    ADJ[V][C].push_back({V,0,0});
    ADJ[V][0].push_back({V,C,1});
    DIS[V][C]=MAX;
  }
  
  RREP(i,N) DIS[i][0]=MAX;
  
  deque<pair<ll,ll>> Q;
  Q.emplace_back(1,0);
  DIS[1][0]=0;
  
  while(!Q.empty()){
    auto[u,c]=Q.front();
    Q.pop_front();
    
    for(auto e:ADJ[u][c]){
      if(DIS[u][c]+e.w<DIS[e.v][e.c]){
        DIS[e.v][e.c]=DIS[u][c]+e.w;
        if(e.w==0) Q.emplace_front(e.v,e.c);
        else Q.emplace_back(e.v,e.c);
      }
    }
  }
  
  cout<<(DIS[N][0]==MAX ? -1 : DIS[N][0])<<endl;
  return 0;
}

Measured memory_bytes: 133572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dropping_Ink
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] table = new int[10,10];

            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                string[] input1 = input.Split(',');
                int x = int.Parse(input1[0]);
                int y = int.Parse(input1[1]);
                int s = int.Parse(input1[2]);
                ++table[x, y];
                if (x > 0) ++table[x - 1, y];
                if (x < 9) ++table[x + 1, y];
                if (y > 0) ++table[x, y - 1];
                if (y < 9) ++table[x, y + 1];
                switch (s)
                {                   
                    case 2:
                        if (x > 0 && y > 0) ++table[x - 1, y - 1];
                        if (x > 0 && y < 9) ++table[x - 1, y + 1];
                        if (x < 9 && y > 0) ++table[x + 1, y - 1];
                        if (x < 9 && y < 9) ++table[x + 1, y + 1];
                        break;
                    case 3:
                        if (x > 0 && y > 0) ++table[x - 1, y - 1];
                        if (x > 0 && y < 9) ++table[x - 1, y + 1];
                        if (x < 9 && y > 0) ++table[x + 1, y - 1];
                        if (x < 9 && y < 9) ++table[x + 1, y + 1];
                        if (x > 1) ++table[x - 2, y];
                        if (x < 8) ++table[x + 2, y];
                        if (y > 1) ++table[x, y - 2];
                        if (y < 8) ++table[x, y + 2];
                        break;
                }
            }
            int count = 0;
            int ink = -1;
            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    if (table[i, j] == 0) ++count;
                    if (table[i, j] > ink) ink = table[i, j];
                }
            }
            Console.WriteLine(count);
            Console.WriteLine(ink);
        }
    }
}



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

// http://algoogle.hadrori.jp/algorithm/segment-tree.html
struct SegTreeMin {
    ll N, dat[4 * 1000];

    SegTreeMin() {}

    SegTreeMin(ll n) {
        N = 1;
        while (N < n) N *= 2;
        for (ll i = 0; i < 2 * N - 1; i++)
            dat[i] = INF;
    }

    // update k th element
    void update(ll k, ll 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)
    ll query(ll a, ll b) { return query(a, b, 0, 0, N); }

    ll query(ll a, ll b, ll k, ll l, ll r) {
        if (r <= a or b <= l) return INF;
        if (a <= l and r <= b) return dat[k];
        ll m = (l + r) / 2;
        return min(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
    }
};


struct SegTreeMax {
    ll N, dat[4 * 1000];

    SegTreeMax() {}

    SegTreeMax(ll n) {
        N = 1;
        while (N < n) N *= 2;
        for (ll i = 0; i < 2 * N - 1; i++)
            dat[i] = -INF;
    }

    // update k th element
    void update(ll k, ll a) {
        k += N - 1; // leaf
        dat[k] = a;
        while (k > 0) {
            k = (k - 1) / 2;
            dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }

    // max [a, b)
    ll query(ll a, ll b) { return query(a, b, 0, 0, N); }

    ll query(ll a, ll b, ll k, ll l, ll r) {
        if (r <= a or b <= l) return -INF;
        if (a <= l and r <= b) return dat[k];
        ll m = (l + r) / 2;
        return max(query(a, b, k * 2 + 1, l, m), query(a, b, k * 2 + 2, m, r));
    }
};

typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    int q;
    cin >> q;
    rep(i, q) {
        int b, m, e;
        cin >> b >> m >> e;

        for (int j = b; j < m; j++) {
            swap(a[j], a[j + e - b]);
        }

    }

    print_line(a);

}


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  ll k;
  cin >> k;

  int n = 50;
  vector<ll> v(n);
  for(int i=0;i<50;++i) {
    v[i] = 49 + k / n;
  }
  k %= 50;

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

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


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

int main()
{
    int A, B;
    cin >> A >> B;
    if(A >= 13) {
        cout << B << endl;
    } else if(A >= 6) {
        cout << B/2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int a,b,c,i,x,ans=0;

    while(scanf("%d",&a)!=EOF){
    x=600/a;
    c=a;
    for(i=0;i<x-1;i++){
        b=c*c;
        ans+=a*b;
        c+=a;
    }
    printf("%d\n",ans);
    ans=0;
    c=0;
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int max = n;
  for(int i = 0;i <= n;i++){
    int count = 0; // 6の階乗と9の階乗の引き出される数の合計(最大maxは全て一円で払うときでn回)
    int m = i; //6の階乗で払う分
    while(m > 0){
      count += m % 6; //一円で払う回数
      m /= 6;
    }
    m = n - i; //9の階乗で払う分
    while(m > 0){
      count += m % 9; //一円で払う回数
      m /= 9;
    }
    if(max > count) max = count;
  }
  cout << max << endl;
}
    
    
  
  
  
    

Measured memory_bytes: 256
if __name__ == '__main__':
    n,m = list(map(int, input().split()))
    a = []
    for i in range(m):
        a.append(int(input()))
    a.append(0)
    ac = 0

    step0 = 0
    step1 = 1
    for i in range(1, n+1):
        temp = step0 + step1
        step0 = step1
        step1 = temp
        if(i == a[ac]):
            step1 = 0
            ac += 1

    print(step1 % 1000000007)


Measured memory_bytes: 7080
io = STDIN
n=io.gets.to_i
$len={}
$hash=Hash.new{|h,k|h[k]={}}
(n-1).times do
  a,b,c=io.gets.split.map(&:to_i)
  $hash[a][b]=c
  $hash[b][a]=c
end
q,k=io.gets.split.map(&:to_i)
$dis={}

def bfs(node)
  queue=[[node,0]]  #node,len
  while(nn=queue.shift)
    nd,len=nn
    $dis[nd]=len
    $hash[nd].keys.each do |child|
      next if $dis[child]
      queue.unshift([child,len+$hash[nd][child]])
    end
  end
end
bfs(k)

q.times do
  x,y=io.gets.split.map(&:to_i)
  puts $dis[x]+$dis[y]
end


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

int n;
int l[200];

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < 2 * n; i++) cin >> l[i];
	sort(l, l + 2 * n);
	
	int ans = 0;
	for (i = 0; i < 2 * n; i += 2) {
		ans += l[i];
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 5;

int N, M;
multiset<int> S;

void solve()
{
  scanf("%d", &M);
  for (int i = 0; i < M; ++i) {
    int a;
    scanf("%d", &a);
    auto it = S.find(a);
    if (it == S.end()) {
      printf("NO\n");
      return;
    } else {
      S.erase(it);
    }
  }
  printf("YES\n");
}

int main()
{
#ifdef linjia
freopen("C:\\Users\\linjian\\Documents\\in.txt", "r", stdin);
#endif
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    int a;
    scanf("%d", &a);
    S.insert(a);
  }
  solve();
  return 0;
}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define maxn 100005
#define ll long long
using namespace std;
inline int read(){
	int x=0,c;while(!isdigit(c=getchar()));
	while(x=x*10+c-'0',isdigit(c=getchar()));
	return x;
}
int b[maxn],a[maxn],n,vis[maxn],v[2];
ll ans;
void calc(){
	int mid=n/2,l=1,r=n,L,R;b[mid]=a[l++];L=mid,R=mid;int opt=0,tmp=0,last=1;
	while(l<=r){
		if(opt==0)
			b[++R]=last==0?a[l++]:a[r--],last^=1;
			else b[--L]=last==0?a[l++]:a[r--],last^=1;
		tmp++;
		if(tmp==2)opt^=1,tmp=0;
	}
	ll res=0;
//	for(int i=L;i<=R;i++)printf("%d ",b[i]);printf("\n");
	for(int i=L+1;i<=R;i++)res+=abs(b[i]-b[i-1]);
	ans=max(ans,res);
}
int main(){
	n=read();if(n==1){printf("0\n");return 0;}
	for(int i=1;i<=n;i++)a[i]=read();
	if(n==2){printf("%d\n",abs(a[1]-a[2]));return 0;}
	sort(a+1,a+n+1);calc();
	reverse(a+1,a+n+1);calc();
	printf("%lld\n",ans);
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i(0);i<n;i++)
using namespace std;
typedef long long ll;

int main(){
 	int n;
 	cin >> n;
 	set<int> st;
 	rep(i,n){
 		ll num;
 		cin >> num;
 		int cnt(0);
 		while(num%2 == 0){
 			cnt++;
 			num /= 2;
 		}
 		st.insert(cnt);
 	}
 	cout << *st.begin() << endl;

    return 0;
}






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

using ll = long long;

ll MOD = 1000000007;

int N; string S;

map<pair<string, string>, int> memo;

int main(void) {
    cin >> N >> S;
    for (int i = 0; i < (1 << N); ++i) {
        string s, t;
        for (int j = 0; j < N; ++j)
            (((i >> j) & 1) == 0 ? s : t) += string(1, S[j]);
        memo[make_pair(s, t)] ++;
    }
    ll ans = 0;
    for (int i = 0; i < (1 << N); ++i) {
        string s, t;
        for (int j = 2*N-1; j >= N; --j)
            (((i >> (j-N)) & 1) == 0 ? s : t) += string(1, S[j]);
        ans += memo[make_pair(s, t)];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 91904
#include<iostream>
#include<string>
#include<unordered_map>
#include<algorithm>


using namespace std;


void solve()
{
	unordered_map<string, int> mp;

	string str;
	cin >> str;

	for (int i = 0; i < str.length(); ++i)
	{
		string s1, s2, s1r, s2r;
		s1 = s1r = str.substr(0, i);
		s2 = s2r = str.substr(i, string::npos);
		reverse(s1r.begin(), s1r.end());
		reverse(s2r.begin(), s2r.end());

		mp[s1 + s2] = 1;
		mp[s1 + s2r] = 1;
		mp[s1r + s2] = 1;
		mp[s1r + s2r] = 1;
		mp[s2 + s1] = 1;
		mp[s2 + s1r] = 1;
		mp[s2r + s1] = 1;
		mp[s2r + s1r] = 1;
	}

	cout << mp.size() << endl;
}


int main()
{
	int m;
	cin >> m;
	
	for (int i = 0; i < m; ++i)
	{
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 3240
s = str(input())
n = len(s)

L = []
c = 0
ans = 0
for i in range(n):
    if c-1 >= 0:
        if s[i] == 'g':
            ans += 1
            c -= 1
        else:
            c -= 1
    else:
        if s[i] == 'g':
            c += 1
        else:
            ans -= 1
            c += 1
print(ans)

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

int main()
{
   string a;
   cin>>a;
   int n =0, s=0 , w=0, e=0;
   for( int  i=0;i<a.length();i++)
   {
       if( a[i] == 'N')
           n++;
       if( a[i] == 'S')
           s++;
       if( a[i] == 'W')
           w++;
       if( a[i] == 'E')
           e++;

   }
   int hmin   = min( w,e);
   int hmax = max( w,e);
   int vmin = min(n,s);
   int vmax = max( n,s);
   if( hmin == 0 && hmax!=0 )
   {
       cout<<"No";

   }
   else if( vmin==0 && vmax != 0 )
   {
       cout<<"No";
   }
   else cout<<"Yes";



}

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


int main(){

    int N;
    int T;

    cin >> N;
    cin >> T;

    int ci[N];
    int ti[N];
    int min_c;
    int min_t;

    min_c = 1001;

    for( int n = 0 ; n < N ; n++ ){

        cin >> ci[n];
        cin >> ti[n];

        if(ti[n] <= T){
            if(ci[n] < min_c){
                min_c = ci[n];
            }
        }
    }

    if(min_c == 1001){
        cout << "TLE";
    }else{
        cout << min_c;
    }




}

Measured memory_bytes: 256