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

using namespace std;

#define    fastio        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define    f             first
#define    s             second
#define    ub            upper_bound
#define    lb            lower_bound
#define    pb            push_back
#define    mset(x,val)   memset(x,val,sizeof(x))
#define    all(x)        (x).begin(),(x).end()
#define    foo(i,a,b)    for(long long i=(a);i<=(b);i++)
#define    rep(i,a,b)    for(long long i=(a);i>=(b);i--)
#define    FOR(i,v)      for(auto &(i):(v))

using  ll    =   long long;
using  ld    =   long double;
using  vl    =   vector<ll>;
using  pll   =   pair<ll, ll>;
using  vll   =   vector<pll>;
using  MAP   =   map<ll, ll>;
using  sl    =   set<ll>;
using  sll   =   set<pll>;
using  MAPs  =   map<ll, sl>;
using  MAPv  =   map<ll, vl>;


const ll inf = LLONG_MAX;
const ll mod = 1e9 + 7;
const ll N   = 2e5 + 5;//change it if u have to

int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll x;

/***************************************** FUNCTION IMPLEMENTATIONS **************************************/


/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN() {
    cin >> x;
    cout << (x < 30 ? "No\n" : "Yes\n");
}

int main() {
    fastio;
    int t = 1;

    // cin>>t;
    while (t -- > 0) {
        MAIN();
    }

// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif

}


Measured memory_bytes: 3608
#include <stdio.h>
#define N 10000
#define Q 500
int S[N],T[Q],n;
int main(){
  int i,q,Sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    if(linear(T[i]))
      Sum++; 
  }    
  printf("%d\n",Sum);
  return 0;
}
int linear(int key)
{
  int i=0;
  S[n]=key;
  while(S[i]!=key)i++;
  if(i==n){
    return 0;
  }
  else return 1;
}

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

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
        tokens = lines[0].split(" ")
        n = int(tokens[0])
        m = int(tokens[1])
        c = int(tokens[2])
        lines.append(input())
        for i in range(n):
            lines.append(input())

    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        tokens = lines[0].split(" ")
        n = int(tokens[0])
        m = int(tokens[1])
        c = int(tokens[2])

    b = [int(e) for e in lines[1].split(" ")]
    
    a = []
    for i in range(n):
        a.append([int(e) for e in lines[i+2].split(" ")])

    return (n, m, c, b, a)


def solve(n, m, c, b, a):

    count = 0
    for i in range(n):
        ans = 0
        for j in range(m):
            ans =  ans + a[i][j]*b[j]
        ans = ans + c
        if ans > 0:
            count = count + 1

    return count

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int L = sc.nextInt();
		int R = sc.nextInt();
		int d = sc.nextInt();

		System.out.println(R/d - (L-1)/d);
	}

}


Measured memory_bytes: 35608
package main

import (
	"fmt"
)

func main() {
	var n, k, x, y int
	var ans int
	fmt.Scan(&n, &k, &x, &y)

	if k >= n {
		ans = n * x
	} else if k <= n {
		ans = k * x
		ans += (n - k) * y
	}
	fmt.Print(ans)
}


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

vector<int> sieve(int n){
    vector<int> prime;
    vector<int> is_prime(n+1, 1);
    int p=0;
    is_prime[0]=0;
    is_prime[1]=0;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            if(i%5 == 2) prime.push_back(i); 
            for(int j=2*i;j<=n;j+=i) is_prime[j]=0;
        }
    }
    return prime;
}

int main(void){
    int n;
    cin>>n;
    vector<int> prime = sieve(55555);
    rep(i, n) cout<<prime[i]<<" ";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
n,k = map(int, input().split())
mod=[0]*k
for a in range(1,n+1):
    mod[a%k]+=1
ans=0
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c) % k == 0:
        ans+=mod[a]*mod[b]*mod[c]
print(ans)

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

typedef long long ll;

#define int long long

int n, a, b;
int h[100000];

bool enough(int t)
{
  ll sum = 0;
  for(int i = 0; i < n; i++){
    if(t*b < h[i])
      sum += (h[i]-b*t+a-b-1) / (a-b);
  }
  return sum <= t;
}

signed main()
{
  cin >> n >> a >> b;

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

  int l = 0, r = 1e+9;
  while(l + 1 < r){
    int m = (l+r)/2;
    if(enough(m)){
      r = m; 
    }else{
      l = m;
    }
  }

  cout << r << endl;

  return 0;
}


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

int N;
vector<long> A, B;
int main() {
  cin >> N;
  A = vector<long>(N);
  B = vector<long>(N);
  long ret = 0;
  for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
  for(int i = N - 1; i >= 0; i--) {
    long tmp = (B[i] - (A[i] + ret)) % B[i];
    if(tmp < 0) tmp += B[i];
    ret += tmp;
  }
  cout << ret << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
//
int main(void){

	char str;
	int n, m, a, b, c, d, s, g, s_cost, g_cost;
	int cost[21][21];

	cin >> n >> m;

	for (int i = 1; i < n+1; i++){
		for (int j = 1; j < n+1; j++) cost[i][j] = 1001;
	}

	for (int i = 0; i < m; i++){

		cin >> a >> str >> b  >> str >> c >> str >> d;

		cost[a][b] = c;
		cost[b][a] = d;
	}

	cin >> s >> str >> g >> str >> s_cost >> str >> g_cost;

	/*for (int i = 1; i < n + 1; i++){
		for (int j = 1; j < n + 1; j++) printf("%5d",cost[i][j]);
		cout << endl;
	}
	cout << endl;*/

	for (int i = 1; i < n + 1; i++){
		for (int j = 1; j < n + 1; j++){
			for (int k = 1; k < n + 1; k++){
				cost[j][k] = min(cost[j][k], cost[j][i] + cost[i][k]);
				//printf("%5d", cost[i][j]);
			}
			//cout << endl;
		}
		//cout << endl;
	}

	cout << s_cost - g_cost - cost[s][g] - cost[g][s] << endl;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

void solve()
{
	double N;
	cin >> N;
	int count = 0;
	while(N > 1.0)
	{
		N /=  3;
		++count;
	}
	cout << count << endl;
}

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

Measured memory_bytes: 1220
import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
#import time

input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # ノードxが属する木のサイズを返す
    def size(self, x):
        return -self.root[self.find(x)]


n = ri()
d1=[tuple(rl())+tuple((i,)) for i in range(n)]
d2=d1[:]

d1.sort(key=lambda x:x[0])
d2.sort(key=lambda x:x[1])
edge=[]
for i in range(n-1):
    edge.append((d1[i+1][2], d1[i][2],d1[i+1][0]-d1[i][0]))
    edge.append((d2[i+1][2], d2[i][2],d2[i+1][1]-d2[i][1]))


    
edge.sort(key=lambda x: x[2])
res=0
uf = UnionFind(n)
for e in edge:
    if uf.same(e[0], e[1]):
        continue
    uf.unite(e[0], e[1])
    res+=e[2]
print(res)

Measured memory_bytes: 47812
/*#include<iostream>
#include<algorithm>
#include<array>
#define f(i,a,b) for(i=a;i<=b;i++)
using namespace std;
int lDigit(int x)
{
	return x % 10;
}
int fDigit(int n)
{
	
	while (n >= 10)
		n /= 10;
	return n;
}
int main()
{
	long long int n;
	long long int i, j,c=0;
	cin >> n;
	f(i, 1, n)
	{
		f(j, 1, n)
		{
			if (lDigit(i) == fDigit(j) && lDigit(j) == fDigit(i)) {
				c++;
				//cout << "HI";
			}
		}
	}
	cout << c << endl;
	
}*/
#include<iostream>
#include<algorithm>
#include<array>
#include<vector>
#define f(i,a,b) for(i=a;i<b;i++)
using namespace std;
int main()
{
	vector<int>v;
	int n, p, x;
	cin >> n;
	int i;
	f(i, 0, n)
	{
		cin >> x;
		if (i == 0) {
			v.push_back(x);
			continue;
		}		p = v.back();
		if (p!=NULL)
		{
			if (p > x)
				v.push_back(x);
		}

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

Measured memory_bytes: 1400
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long ans = 0;
      for (int i=1; i <= n; i++) {
        if (i%3 != 0 && i%5 != 0) {
          ans += i;
        }
      }
 
      System.out.println(ans);
	}
}

Measured memory_bytes: 27228
from math import gcd
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == [] and n != 1:
        arr.append([n, 1])
    return arr

n = int(input())
fact_n = factorization(n)
cnt = 0
for _, e in fact_n:
    for i in range(1, 10**3):
        if i*(i + 1) // 2 <= e < (i + 1)*(i + 2) // 2:
            cnt += i
            break
print(cnt)

Measured memory_bytes: 9484
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int R, G, B , N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  rep(r, N + 1) rep(g, N + 1)
    if (N - (R * r + G * g) >= 0 && (N - (R * r + G * g)) % B == 0)
      ++ans;
  out(ans);
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%10 == 3){
            cout << " " << i ;
        }else if (i%3==0)
        {
            cout << " " << i ;
        }else{
        bool include3 = false;
        for(int j=0;j<=to_string(i).length();j++){
            string si = to_string(i);
            if(si[j] == '3'){
               include3 = true;
            }
        }
        if(include3){
            cout << " " << i ;
        }
        }
    }
    cout << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


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

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

    if (X >= 400 && 599 >= X) {
        cout << 8 << endl;
    } else if (X >= 600 && 799 >= X) {
        cout << 7 << endl;
    } else if (X >= 800 && 999 >= X) {
        cout << 6 << endl;    
    } else if (X >= 1000 && 1199 >= X) {
        cout << 5 << endl;
    } else if (X >= 1200 && 1399 >= X) {
        cout << 4 << endl;
    } else if (X >= 1400 && 1599 >= X) {
        cout << 3 << endl;
    } else if (X >= 1600 && 1799 >= X) {
        cout << 2 << endl;    
    } else if (X >= 1800 && 1999 >= X) {
        cout << 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

# define INF 0x3f3f3f3f

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl;

using namespace std;

// 素因数分解
vector<ll> get_primes(ll n) {
  vector<ll> result;

  for (ll i = 2; i <= sqrt(n); i++) {
    while ((n % i) == 0) {
      result.push_back(i);
      n /= i;
    }
  }
  if (n > sqrt(n)) {
    result.push_back(n);
  }
  return result;
}

int counts[1001] = {};

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

  int N;
  cin >> N;

  for (int i = 1; i <= N; i++) {
    vector<ll> primes = get_primes(i);
    for (auto prime : primes) {
      counts[prime]++;
    }
  }
  ll ans = 1;
  REP(i, 1001) {
    ans *= counts[i] + 1;
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
src = list(map(lambda x : int(x), input().split(' ')))
dst = 0
k = src[3]
dst += (src[0] if src[0] <= k else k)
k -= dst
if k != 0:
  k -= (src[1] if src[1] <= k else k)
if k != 0:
  dst -= (src[2] if src[2] <= k else k)
  
print(dst)

Measured memory_bytes: 9180
import math
n = int(input())

def factor(m, p):
    step = 1 if p == 2 else 2
    for i in range(p, int(math.sqrt(m)+1), step):
        if m % i == 0:
            return i
    return m

res = str(n) + ":"
p = 2
while n != 1:
    p = factor(n,p)
    n = n//p
    res = res + " " + str(p)
print(res)

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

int main()
{
    int x, y;
    cin >> x >> y;

    for(int i=0; i<=x; i++){
        if(2*i+4*(x-i) == y) { cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 3640
n = int(input())
dp = [2]*n
dp[0]=1
ans = 1

if n == 1:
  print(1)
  quit()
  
for i in range(1, n):
  ans += (i+1)*dp[i]
  temp = (i+1)*2 #2→4
  while temp <= n: #4
    dp[temp-1]+=1
    temp += i+1 #6
#print(dp)
print(ans)
    

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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)
#define PI 3.14159265358979323846264338327950L

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

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; }

int main(){
    ios_base::sync_with_stdio(false);
    ll h,n,ma=0;
    cin >> h >> n;
    vector<ll> A(n,0);
    vector<ll> B(n,0);
    vector<ll> DP(h+1,INF);

    rep(i,n){
        cin >> A[i] >> B[i];
    }

    DP[0] = 0;

    for(int i=0;i<=h;i++){
        for(int j=0;j<n;j++){
            chmin(DP[min(i+A[j],h)],DP[i]+B[j]);
        }
    }

    cout << DP[h] << endl;

    return 0;
}


Measured memory_bytes: 3720
#include "bits/stdc++.h"
using namespace std;
     
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
     
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
  int h, w, i, j;
  cin >> h >> w;
  vs a(h);
  for (i = 0; i < h; i++) {
    cin >> a[i];
  }
  vs red(h, string(w, '.'));
  vs blue(h, string(w, '.'));
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
	red[i][j] = '#';
      }
      else {
	if (i % 4 == 2) {
	  if (j != 1) {
	    red[i][j] = '#';
	  }
	}
	else if (i % 4 == 0) {
	  if (j != w - 2) {
	    red[i][j] = '#';
	  }
	}
      }
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
	continue;
      }
      else {
	if (i % 4 == 2) {
	  if (j == 1) {
	    blue[i][j] = '#';
	  }
	}
	else if (i % 4 == 0) {
	  if (j == w - 2) {
	    blue[i][j] = '#';
	  }
	}
	else {
	  blue[i][j] = '#';
	}
      }
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (a[i][j] == '#') {
	red[i][j] = blue[i][j] = '#';
      }
    }
  }
  for (i = 0; i < h; i++) {
    cout << red[i] << endl;
  }
  cout << endl;
  for (i = 0; i < h; i++) {
    cout << blue[i] << endl;
  }
      
}



Measured memory_bytes: 1536
import sys
import copy
input = sys.stdin.readline

N=int(input())

S=input()


T=[[0] * 10 for _ in range(30000)]
for i in range(N):
    if i!=0:
        T[i]=copy.deepcopy(T[i-1])
    T[i][int(S[i])]+=1
#print(T)

dic={}
flag=[False]*10
for i in range(N-2):
    if flag[int(S[i])]==True:
        continue
    flag[int(S[i])]=True
    for j in range(i+1,N-1):
        tmp2=copy.deepcopy(T[N-1])
        tmp3=copy.deepcopy(T[j])
        tmp4=""
        for k in range(10):
            if tmp2[k]-tmp3[k]!=0:
                tmp4=S[i]+S[j]+str(k)
                #print(tmp4)
                if tmp4 in dic:
                    pass
                else:    
                    dic[tmp4]=1
           
print(len(dic))
#print(dic)

Measured memory_bytes: 102432
from itertools import accumulate
n = int(input())
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))
ans = 1
for i in range(n-2,-1,-1):
  if acc[i]*2>=a[i+1]:
    ans += 1
  else:
    break
print(ans)

Measured memory_bytes: 63856
//Walk and Teleport

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n,a,b;cin>>n>>a>>b;
    vecrep(n,x,int);
    int ans = 0;
    rep(i,1,n){
        int t = (x[i]-x[i-1])*a;
        ans+=min(t,b);
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 4020
#include <stdio.h>

int gcd_num;

void gcd(int a, int b){
	int tmp;

	if(a < b){
		tmp = a;
		a = b;
		b = tmp;
	}

	tmp = a % b;
	if(tmp == 0){
		printf("%d ", b);
		gcd_num = b;
	}else{
		gcd(b, tmp);
	}
	return;
}

void lcm(int a, int b){
	printf("%d\n", gcd_num * (a / gcd_num) * (b / gcd_num));
}

int main(void){
	int a, b;
	int tmp;

	while(scanf("%d %d", &a, &b) != -1){
		gcd(a, b);
		lcm(a, b);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int Maxn = 200005;
int main()
{
	char ans1[Maxn],ans2[Maxn],ans3[Maxn];
	int cur1=0,cur2=0;
	scanf("%s",ans1);
	int T;
	scanf("%d",&T);
	int reverse = 0;
	while(T--)
	{
		int t;
		scanf("%d",&t);
		if(t==1)
			reverse = !reverse;
		else
		{
			int a;
			char b;
			scanf("%d",&a);
			cin>>b;
			if(a == 1)
			{
				if(!reverse)
				{
					ans2[cur1++] = b;
				}
				else
				{
					ans3[cur2++] =b;
				}
			}
			else
			{
				if(reverse)
				{
					ans2[cur1++] = b;
				}
				else
				{
					ans3[cur2++] = b;
				}
			}
		}
	}
	if(!reverse)
	{
		for(int i=cur1-1;i>=0;i--)	printf("%c",ans2[i]);
		printf("%s",ans1);
		for(int i=0;i<cur2;i++) 	printf("%c",ans3[i]);
	}
	else
	{
		for(int i=cur2-1;i>=0;i--) 	printf("%c",ans3[i]);
		for(int i=strlen(ans1)-1;i>=0;i--)	printf("%c",ans1[i]);
		for(int i=0;i<cur1;i++)	printf("%c",ans2[i]);
	}
	return 0;	
}

Measured memory_bytes: 896
#include <stdio.h>
typedef long long ll;

int main(){
    int k,x;
    ll end=1000000;
    scanf("%d %d",&k,&x);
    int a=x-k+1;
    int b=x+k-1;
    for(int i=a;i<=b;i++){
        printf("%d ",i);
    }
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main()
{
    int n;
    cin >> n;
    ll lim = 1e5;
    vector<ll> d(lim,0);
    rep(i, n){
        ll x; cin >> x;
        d[x]++ ;
    }
    ll ans = 0;
    rep(i,lim){
        ans = max(ans, d[i]+d[i+1]+d[i+2]);
    }
    cout << ans << endl;

}

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

int main(){
  int L,H,hits,blow;
  string trys;
  vector<int> h,b,vi,ans;
  vector<string> t;
  vector<vector<int> > v;

  while(cin >> L >> H, L||H){
    t.clear();
    h.clear();
    b.clear();
    v.clear();
    ans.clear();

    for(int i=0;i<H;i++){
      cin >> trys >> hits >> blow;
      t.push_back(trys);
      h.push_back(hits);
      b.push_back(blow);
    }

    int comb = (1<<L) - 1;
    while(comb < (1<<10)){
      vi.clear();
      for(int i=0;i<10;i++){
	if( (comb>>i) & 1)vi.push_back(i);
      }
      v.push_back(vi);
      
      int x = comb & -comb, y = comb + x;
      comb = ( ( ( comb & ~y )/x )>>1 )|y;
    }

    for(int i=0;i<(int)v.size();i++){
      for(int j=0;j<H;j++){
	int sum = 0;
	for(int k=0;k<L;k++){
	  for(int l=0;l<L;l++){
	    if(v[i][k] == t[j][l] - '0'){
	      sum++;
	      break;
	    }
	  }
	}
	if(sum != h[j]+b[j]){
	  v.erase(v.begin()+i);
	  i--;
	  break;
	}
      }
    }

    bool flag = true;
    for(int i=0;i<(int)v.size();i++){
      do{
	bool f = true;
	for(int j=0;j<H;j++){
	  hits = 0;
	  for(int k=0;k<L;k++){
	    if(v[i][k] == t[j][k]-'0'){
	      hits++;
	      if(hits>h[j])break;
	    }
	  }
	  if(hits!=h[j]){
	    f = false;
	    break;
	  }
	}
	if(f){
	  if(ans.size()){
	    flag = false;
	    break;
	  }else{
	    ans = v[i];
	  } 
	}
      }while(next_permutation(v[i].begin(),v[i].end()));
      if(!flag)break;
    }
    
    if(flag && ans.size()){
      for(int i=0;i<L;i++)cout << ans[i];
      cout << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n = 5;
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin >> t.at(i);
  }
  int min=10,min_id=0;
  for(int i=0;i<n;i++){
    if( t.at(i)%10 < min && t.at(i)%10 != 0){
      min = t.at(i)%10;
      min_id = i;
    }
  }
  //cout << min_id << endl;
  //cout << t.at(min_id) << endl;
  
  int time=0;
  for(int i=0;i<n;i++){
    if( i == min_id){
      continue;
    }
    if( t.at(i)%10 == 0){
      time += t.at(i);
    }else{
      time += (t.at(i)/10 + 1)*10;
    }
  }
  time += t.at(min_id);
  cout << time << endl;

  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 50000000000
int main(){
  int N,x;
  vector<int> X;
  long long int min=INF,sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>x;
    X.push_back(x);
  }
  for(int i=1;i<100;i++){
    sum=0;
    for(int j=0;j<N;j++){
      sum+=(long long int)pow(i-X[j],2);
    }
    if(sum<min){
      min=sum;
    }

  }
  cout<<min<<endl;
}

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

max_dis=0
tot_dis=0
posi=a[0]
for i in range(1,len(a)):
    tmp=a[i]-posi
    if max_dis < tmp:
        max_dis=tmp
    posi=a[i]
    tot_dis+=tmp
tmp=a[0]+(k-a[-1])
if max_dis < tmp:
    max_dis = tmp
tot_dis += tmp

print(tot_dis-max_dis)


Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B;
	cin >> A >> B;
	cout << max(0, A - B * 2) << endl;

	return 0;
}


Measured memory_bytes: 256
import math
a,b,n=map(int,input().split())
max=0
pre=0
if b//a-1<=0:
    st=1
else:
    st=b//a-1
check=0
for i in range(0,n+1,st):
    f=math.floor(a*i/b)-a*math.floor(i/b)
    if f>max:
        max=f
    if f==0:
        check+=1
    if check>st+2:
        break
print(max)

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


using namespace std;


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a+b)>=c)
    cout<<"Yes";
    else
    cout<<"No";

    return 0;
}     
     

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int main(){
  char a[100],b[100],c[100];

  cin>>a>>b>>c;

  cout<<'A'<<b[0]<<'C';

  return 0;
}


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

int main()
{
  int64_t a = 2, b = 1, ans, c;
  int n;

  cin >> n;
  if (n == 1)
    ans = b;
  else
  {
    for (int i = 0; i < n - 1; i++)
    {
      c = a + b;
      a = b;
      b = c;
    }
    ans = c;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	char a, b, c;
	cin >> a >> b >> c;
	if (a == '7' || b == '7' || c == '7')
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


	
	

	
	
/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
// =================

const int mod = 1e9;
const int N = 3e5 + 1;

void solve()
{
    ll a,b; cin>>a>>b;
    char c; cin>>c;
    int d; cin>>d;
    b*=100;
    b+=d;
    ll ans=a*b;
    cout<<ans/100;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t = 1;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3620
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
const int mlog=20;
int n,len,q;
int r[maxn][mlog],l[maxn][mlog],x[maxn]; 

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,n)scanf("%d",&x[i]);
	scanf("%d%d",&len,&q);
	int p=0;
	rep(i,n){
		while(p<n&&x[p]-x[i]<=len)p++;
		r[i][0]=p-1;
	}
	p=n-1;
	for(int i=n-1;i>=0;i--){
		while(p>=0&&x[i]-x[p]<=len)p--;
		l[i][0]=p+1;
	}
	REP(j,mlog-1)rep(i,n){
		r[i][j]=r[r[i][j-1]][j-1];
		l[i][j]=l[l[i][j-1]][j-1];
	}
	while(q--){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;b--;
		int ans=0;
		if(a<b){
			for(int i=mlog-1;i>=0;i--){
				if(r[a][i]<b)a=r[a][i],ans+=(1<<i);
			}
		}
		else{
			for(int i=mlog-1;i>=0;i--){
				if(l[a][i]>b)a=l[a][i],ans+=(1<<i);
			}
		}
		printf("%d\n",ans+1);
	}
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 16896
N = int(input())
s = input()
ans = 0
for i in range(1, N-1):
    cnt = 0
    X = s[:i]
    Y = s[i:]
    alpX = [0 for j in range(26)]
    alpY = [0 for j in range(26)]
    lenX = i
    lenY = N-i
    for j in range(lenX):
        alpX[ord(X[j])-97] += 1
    for j in range(lenY):
        alpY[ord(Y[j])-97] += 1
    for j in range(26):
        if alpX[j] != 0 and alpY[j] != 0:
            cnt += 1 
    if ans < cnt:
        ans = cnt
print(str(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)

int main(){
  LL n,check=0;
  cin >> n;
  
  for(LL m=n; m>0; m/=10){
    check += (m%10);
  }
  
  if(n % check == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  return 0;
}


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

int main(){
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    bool flag = false;
    if(w >= x + r && x - r >= 0 && h >= y + r && y - r >= 0) flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

int main(void){
  int a,p; cin >> a >> p;
  p += a*3;
  cout << p/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    return ret;
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.is_err() || res.ok().unwrap() == 0 || u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = std::string::String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}
fn parse<T: std::str::FromStr>(s: &str) -> T { s.parse::<T>().ok().unwrap() }

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { parse(&get_word()) }

#[allow(dead_code)]
macro_rules! d {
    ($e:expr) => {
        {
            let a = $e;
            println!("{} = {:?}", stringify!($e), a);
            a
        }
    }
}

#[allow(dead_code)]
macro_rules! tee {
    ($e:expr) => {
        {
            let a = $e;
            println!("{:?}", a);
            a
        }
    }
}


fn dfs(g: &Vec<Vec<usize>>, r: usize, i: usize, j: usize) -> usize {
    if r == 0 {
        1            
    } else {
        1 + (&g[i]).into_iter()
            .filter(|x| **x != j)
            .fold(0, |sum, a| sum + dfs(g, r-1, *a, i))
    }
}

fn main() {
    let n: usize = get();
    let k: usize = get();
    let mut g = vec![Vec::new(); n];
    let mut e = Vec::new();
    
    for _ in 0..n-1 {
        let a = get::<usize>() - 1;
        let b = get::<usize>() - 1;
        g[a].push(b);
        g[b].push(a);
        e.push((a, b));
    }

    let ans = if k%2 == 0 {
        (0..n).map(|i| dfs(&g, k/2, i, i)).max()
    } else {
        e.into_iter().map(|(i, j)| dfs(&g, k/2, i, j) + dfs(&g, k/2, j, i)).max()
    };

    println!("{}", n - ans.unwrap());
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

const ll MAX = MOD;

struct UnionFind{
    vector<int> par,s;
    UnionFind(int N) : par(N),s(N){
        REP(i,N){
            par[i] = i;
            s[i] = 1;
        }
    }
    int root(int x){
        if(par[x]==x){ return x; }
        else{ 
          par[x]= root(par[x]);
          return par[x];
        }
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if( rx!=ry ){
            par[rx] = ry;
            s[ry] += s[rx];
        }
    }
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return (rx==ry);
    }
    int size(int x){
        int rx = root(x);
        return s[rx];
    }
};

void solve(){
  int N,M; cin>>N>>M;
  UnionFind uf(N);
  REP(i,M){
    int a,b; cin>>a>>b;
    --a; --b;
    uf.unite(a,b);
  }
  int ans = 0LL;
  REP(i,N){
    chmax(ans,uf.size(i));
  }
  cout << ans << "\n";
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}

Measured memory_bytes: 11008
$UFT = Array.new(100)
0.upto(100) do |i|
  $UFT[i] = i
end

def root(x)
  if ($UFT[x] == x)
    x
  else
    $UFT[x] = root($UFT[x])
    $UFT[x]
  end
end

def unite(x, y)
  $UFT[root(x)] = root(y)
end

if __FILE__ == $0
  n = gets.to_i
  graph = n.times.map{ gets.split.map(&:to_i) }
  bridge = []
  total = 0

  n.times do |i|
    0.upto(i-1) do |j|
      cost = graph[i][j]
      next if cost == -1
      bridge << [cost, i, j]
    end
  end

  bridge.sort!.each do |cost, i, j|
    unless root($UFT[i]) == root($UFT[j])
      total += cost
      unite(i, j)
    end
  end

  puts total
end

Measured memory_bytes: 6180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100000+10];
ll b[100000+10];
int main()
{
    int n;
    int m;
    cin>>n>>m;
    for(int i=0;i<m;i++)cin>>a[i];
    sort(a,a+m);
    for(int i=1;i<m;i++){
        b[i]=a[i]-a[i-1];
    }
    sort(b+1,b+m);
    ll ans=0;
    if(n>=m)cout<<0<<endl;
    else
    {
        for(int i=1;i<=m-n;i++)ans+=b[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <vector>

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

using namespace std;

const int inf = (int)2e7;

struct E{
	E(int t, int c, int r) :
		t(t), c(c), r(r)
	{}

	int t, c, r;
};

int n, m;
vector<E> g[100];
bool used[100];

void mf_add_edge(int a, int b, int c){
	g[a].push_back(E(b, c, g[b].size()));
	g[b].push_back(E(a, 0, g[a].size() - 1));
}

int mf_dfs(int v, int t, int f){
	if(v == t){
		return f;
	}
	used[v] = true;
	rep(i, g[v].size()){
		E& e = g[v][i];
		if(!used[e.t] && e.c > 0){
			int d = mf_dfs(e.t, t, min(e.c, f));
			if(d > 0){
				e.c -= d;
				g[e.t][e.r].c += d;
				return d;
			}
		}
	}
	return 0;
}

int mf_max_flow(int s, int t){
	int ans = 0;
	while(1){
		fill(used, used + n, false);
		int f = mf_dfs(s, t, inf);
		if(f == 0){
			return ans;
		}
		ans += f;
	}
}

int main(){
	scanf("%d%d", &n, &m);
	rep(i, m){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		mf_add_edge(a, b, c);
	}
	printf("%d\n", mf_max_flow(0, n - 1));
	return 0;
}

Measured memory_bytes: 1076
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x,cnt=0,sum=0;
  cin>>n>>d>>x;
  vector<int> a(n);
  for(int j=0;j<n;j++){
    cin>>a[j];
    for(int i=0;i<100;i++){
      if(d>=1+i*a[j])sum++;           
  }
  }
 cout<<sum+x<<endl;
}
  

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

#define FOR(i,start,end) for(int i=start; i<(int)(end); i++)
#define REP(i,n) FOR(i,0,n)


int main() {


    int h, w;
    while(1) {
        scanf("%d %d", &h, &w);
        if(h == 0 && w == 0) {
            break;
        }
        REP(i, h) {
            REP(j, w) {
                if((j + ( i % 2 )) % 2 == 0) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 3156
function swap(A, a, b) {
	var tmp = A[a-1];
	A[a-1] = A[b-1];
	A[b-1] = tmp;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

var w = lines.shift();
var arr = [];
for (var i = 0; i < w; i++) {
	arr.push(i + 1);
}

var n = lines.shift();
for (var i = 0; i < n; i++) {
	var nums = lines.shift().split(',').map(function(i){return +i;});
	swap(arr, nums[0], nums[1]);
}

arr.forEach(function(num) {
	console.log(num);
});

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

using namespace std;

int main () {
	string s;
	int cnt = 0;
	cin >> s;
	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np
from sys import setrecursionlimit
setrecursionlimit(10**8)


def get_ans(k, value, index):
    # print(k, value, index)
    if index < 0:
        return value
    if k < 2**index:
        return get_ans(k, value + (2**index) * count_array[index], index - 1)
    elif k >= 2**(index + 1) - 1:
        return value + sum_array[index]
    return max(
        get_ans(k, value + (2**index) * count_array[index], index - 1),
        get_ans(k - 2**index, value + (2**index) * (N - count_array[index]),
                index - 1))


N, K = map(int, input().split())

A_array = np.array(list(map(int, input().split())))

count_array = np.zeros(40, dtype=np.int)

for A in A_array:
    array = np.array(list(map(int, bin(A)[2:].zfill(40)))[::-1])
    count_array += array
    # print(count_array)

sum_array = np.array([], dtype=np.int64)

last_value = 0
for i in range(40):
    last_value += 2**i * max(count_array[i], N - count_array[i])
    sum_array = np.append(sum_array, last_value)
# print(count_array)
# print(sum_array)
print(get_ans(K, 0, 39))


Measured memory_bytes: 23684
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;cin>>n;
	vector<int>v;
	for(int i=0;i<n;i++)
	{
		int x;cin>>x;v.push_back(x);
	}
	int sum = 0;
	for(int i=0;i<v.size()-1;i++)
	{
		for(int k =i+1;k<v.size();k++)
		{
			sum += v[i]*v[k];
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(int argc,char *argv[]){
	int N,sum=0;
	std::cin >> N;
	std::vector<int> A(N);
	for(int i=0;i<N;++i){
		std::cin >> A[i];
		sum += A[i];
	}
	std::cout << sum-N << std::endl;
	return 0;
}

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

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;
    std::vector<int> numbers {A, B, C};
    std::sort(numbers.rbegin(), numbers.rend());
    std::cout << numbers[0] * 10 + numbers[1] + numbers[2] << std::endl;
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())

n,*x = [int(i) for i in read().split()]


ans = 10**18

for p in range(101):
    res = 0
    for xi in x:
        res += (xi-p)**2
    ans = min(res,ans)

print(ans)





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

using namespace std;

#define endl '\n'


typedef long long ll;
typedef complex<ll> point;

ll cross(point a, point b) { return imag(conj(a) * b); }

ll dot(point a, point b) { return real(conj(a) * b); }

ll area2(point a, point b, point c) { return cross(b - a, c - a); }

namespace std
{
	bool operator<(const point &a, const point &b)
	{
		return real(a) < real(b) || (real(a) == real(b) && imag(a) < imag(b));
	}
}

const ll oo = 0x3f3f3f3f3f3f3f3f;

struct dynamic_hull
{
	dynamic_hull() : hulls() {}

	void add_point(point p)
	{
		hull h;
		h.add_point(p);

		for (hull &_h : hulls)
			if (_h.empty())
			{
				h.swap(_h);
				break;
			}
			else h = merge(h, _h), _h.clear();

		if (!h.empty()) hulls.emplace_back(h);
	}

	ll max_dot(point p)
	{
		ll best = -oo;

		for (hull &h : hulls)
			if (!h.empty()) best = max(best, h.max_dot(p));

		return best;
	}

private:
	struct hull : vector<point>
	{
		void add_point(point p)
		{
			for (int s = size(); s > 1; --s)
				if (area2(at(s - 2), at(s - 1), p) < 0) break;
				else pop_back();
			push_back(p);
		}

		ll max_dot(point p)
		{
			int lo = 0, hi = (int) size() - 1, mid;

			while (lo < hi)
			{
				mid = (lo + hi) / 2;

				if (dot(at(mid), p) <= dot(at(mid + 1), p))
					lo = mid + 1;
				else hi = mid;
			}

			return dot(at(lo), p);
		}
	};

	static hull merge(const hull &a, const hull &b)
	{
		hull h;
		size_t i = 0, j = 0;

		while (i < a.size() && j < b.size())
			if (a[i] < b[j]) h.add_point(a[i++]);
			else h.add_point(b[j++]);

		while (i < a.size()) h.add_point(a[i++]);

		while (j < b.size()) h.add_point(b[j++]);

		return h;
	}

	vector<hull> hulls;
};

ll sqr(ll x){
	return x * x;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	dynamic_hull UH, LH;
	
	int n;
	cin >> n;
	ll c;
	cin >> c;
	
	vector<ll> dp(n + 1, oo), h(n + 1);
	
	for(int i = 1; i <= n; i++)
		cin >> h[i];
	
	dp[n] = 0;
	
	UH.add_point(point(dp[n] + sqr(h[n]), -2LL * h[n]));
	LH.add_point(point(-dp[n] - sqr(h[n]), 2LL * h[n]));
	
	for(int i = n - 1; i >= 1; i--){
		
		dp[i] = -UH.max_dot(point(-1LL, -h[i]));
		dp[i] = min(dp[i], -LH.max_dot(point(1LL, h[i])));
		dp[i] += sqr(h[i]) + c;
		
		
		UH.add_point(point(dp[i] + sqr(h[i]), -2LL * h[i]));
		LH.add_point(point(-dp[i] - sqr(h[i]), 2LL * h[i]));
	}
	
	cout << dp[1] << endl;

	return 0;
}

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

int main(){
int N, X, mi, ans, m, cnt;
  cin >> N >> X;
mi = 1001;
cnt = 0;  
  for(int i = 0;i < N;i++){
    cin >> m;
  cnt += m;
    mi = min(mi, m);  
  }

  ans =  (X - cnt) / mi;
  cout << ans + N << endl;
  return 0;
  
}

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

typedef struct node *t;

struct node{
	int key;
	t left,right;
};

t insert(t head,t z){
	t y=NULL;
	t x=head;
	
	while(x!=NULL)
    {
		y=x;
		if(z->key < x->key)x=x->left;
		else x=x->right;
	}
	
	if(y==NULL)head=z;
	else if(z->key < y->key)y->left=z;
	else y->right=z;
	return head;
}

void preorder(t u){
	if(u==NULL)return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

void inorder(t u){
	if(u==NULL)return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

int find(t u,int key){
	if(u==NULL)return 0;
	if(u->key==key)return 1;
	if(u->key>key)return find(u->left,key);
	return find(u->right,key);
}

int search(t u){
	if(u->left==NULL)return u->key;
	return search(u->left);
}

t delete(t u,int key){
	if(u==NULL)return NULL;
	
    if(u->key==key){
		if(u->left==NULL && u->right==NULL)return NULL;
		else if(u->right==NULL)
        {
			return u->left;
		}
        else if(u->left==NULL){
			return u->right;
		}
        else{
			u->key=search(u->right);
			u->right=delete(u->right,u->key);
		}
	}
   
    else if(u->key >key){
		u->left=delete(u->left,key);
	}
   
    else{
		u->right=delete(u->right,key);
	}
	return u;
}

int main(void){
	int m,i,key,n,r;
	char cmd[10];
	t head=NULL,z;

	scanf("%d",&m);
	
    for(i=0;i<m;i++){
		
        scanf("%s",cmd);
		
        if(!strcmp(cmd,"insert")){
			scanf("%d",&key);
			z = malloc(sizeof(*z));
			z->key=key;z->left=NULL;z->right=NULL;
			head=insert(head,z);
		}
       
        else if(!strcmp(cmd,"print")){
			inorder(head);
			printf("\n");
			preorder(head);
			printf("\n");
		}
       
        else if(!strcmp(cmd,"find")){
			scanf("%d",&key);
			if(find(head,key)!=0)printf("yes\n");
			else  printf("no\n");
		}
        
        else if(!strcmp(cmd,"delete")){
			scanf("%d",&key);
			head=delete(head,key);
		}
	}
	return 0;
}



Measured memory_bytes: 14304
#include<bits/stdc++.h>
using namespace std;
int main(){
  int minj,n,count=0;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  
  for(int i=0;i<n;i++){
    minj = i;
    for(int j=i;j<n;j++){
      if(a[j]<a[minj])
        minj = j;
    }
    if(a[i]!=a[minj])
      count++;
    swap(a[i], a[minj]);
  }
  
  for(int k=0;k<n-1;k++)
    cout << a[k] << " ";
  cout << a[n-1] << endl;
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N) {
    if (N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) {
        cout << "hon" << endl;
    }
    if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) {
        cout << "pon" << endl;
    }
    if (N % 10 == 3) {
        cout << "bon" << endl;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3764