akhauriyash/Code-Regression huggingface dataset:
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

class Node():
    def __init__(self):
        self.left = -1
        self.right = -1
        self.parent = -1
        
T = [Node() for i in range(25)]

for (idx, left, right) in A:
    T[idx].left = left
    T[idx].right = right
    if left != -1:
        T[left].parent = idx
    if right != -1:
        T[right].parent = idx

for idx in range(n):
    if T[idx].parent == -1:
        root = idx
        break
        
preorder_list = []
def preorder(u):
    preorder_list.append(str(u))
    if T[u].left != -1:
        preorder(T[u].left)
    if T[u].right != -1:
        preorder(T[u].right)
        
inorder_list = []
def inorder(u):    
    if T[u].left != -1:
        inorder(T[u].left)
    inorder_list.append(str(u))
    if T[u].right != -1:
        inorder(T[u].right)

postorder_list = []
def postorder(u):    
    if T[u].left != -1:
        postorder(T[u].left)
    if T[u].right != -1:
        postorder(T[u].right)
    postorder_list.append(str(u))
    
preorder(root)
inorder(root)
postorder(root)

print('Preorder')
print(' '+' '.join(preorder_list))
print('Inorder')
print(' '+' '.join(inorder_list))
print('Postorder')
print(' '+' '.join(postorder_list))


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int n,a[22],cnt=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n-1;i++){
		if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1])) cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    char kkkm;
    scanf("%c",&kkkm);
    if(kkkm=='A')
        printf("T\n");
    else if(kkkm=='T')
        printf("A\n");
    else if(kkkm=='C')
        printf("G\n");
    else if(kkkm=='G')
        printf("C\n");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
vector<vector<ll>> v(16,vector<ll>(16));
vector<ll> sop((1<<16)-1,-1);
vector<ll> dp1((1<<16)-1,-1);
ll solve(int s)
{
    if(s==0)
    return 0;
    ll ans=0;
    for(int m=s;m!=0;m=((m-1)&s))
    {
        // cout<<m<<" "<<dp[m]<<"\n";
        if(dp1[(~m)&s]!=-1)
        ans = max(ans,sop[m]+dp1[(~m)&s]);
        else
        ans = max(ans,sop[m]+solve((~m)&s));
    }
    return dp1[s] = ans;
}
int main() {
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>v[i][j];
        }
    }
    for(int k=1;k<(1<<n);k++)
    {
        ll ans=0;
        for(int i=0;i<16;i++)
        {
            for(int j=i+1;j<16;j++)
            {
                if(((1<<i)&k)&&((1<<j)&k))
                ans+=v[i][j];
            }
        }
        sop[k]=ans;
    }
    cout<<solve((1<<n)-1);
}


Measured memory_bytes: 4100
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int N,M,X,Y,i,xmax=-200,ymin=200,a;
	cin>>N>>M>>X>>Y;
	for (i=0;i<N;i++)
	{
		cin>>a;
		xmax=max(xmax,a);
	}
	for (i=0;i<M;i++)
	{
		cin>>a;
		ymin=min(ymin,a);
	}
	//printf("x%dy%d\n",xmax,ymin);
	if (X<Y&&xmax<ymin&&ymin>X&&xmax<Y) puts("No War");
	else puts("War");
	return 0;
}


Measured memory_bytes: 256
k = int(input())
a = [100]*15
a[0] = 1


def runrun_generater(x):
    for i in range(14):
        if(x[i]+1 - x[i+1] < 2 and (x[i] < 9 or x[i] == 100)):
            if(x[i] == 100):
                x[i] = 1
                if(i != 0):
                    x[:i] = [0]*i
            else:
                x[i] += 1
                if(i != 0):
                    k = i
                    for xx in range(i):
                        if(x[k] == 0):
                            x[k-1] = 0
                        else:
                            x[k-1] = x[k]-1
                        k -= 1
            return x


for i in range(k-1):
    a = runrun_generater(a)
ans = 0
keta = 1
for y in a:
    if(y != 100):
        ans += y * keta
        keta *= 10
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <vector>
#define lli long long int
using namespace std ;


int main(int argc, char const *argv[])
{

	int n ;
	cin>>n ;
	lli ans = 0 ;
	int carry ;
	for(int i = 0 ; i < n ; i++)
	{
		int temp ;
		cin>>temp ;
		if(i == 0)
		{
			 carry = 1 ;
			if(temp == 1) ;
			else
			{
				ans+=temp-1 ;
			}
			continue ;
		}

		if(temp <= carry) continue ;

		if(temp == carry + 1)
		{
			++carry ;
			continue ;
		}

		if(temp %(carry + 1) == 0)
		{
			++carry ;
			ans+= (temp/carry) ;
			--ans ;
			--carry ;
			continue ;
		}

		else
		{
			++carry ;
			ans+= (temp/carry) ;
			--carry ;

		}

	}

	cout<<ans<<endl ;



	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int card[3][3];
  for(int i=0;i<3;i++)
  {
    cin>>card[i][0]>>card[i][1]>>card[i][2];
  }
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int b;
    cin>>b;
    for(int x=0;x<3;x++)
    {
      if(card[x][0]==b)card[x][0]=101;
       if(card[x][1]==b)card[x][1]=101;
       if(card[x][2]==b)card[x][2]=101;
    }
  }
  bool ans = false;
  for(int i=0;i<3;i++)
  {
   ans|=(card[i][0]*card[i][1]*card[i][2]==101*101*101);
     ans|=(card[0][i]*card[1][i]*card[2][i]==101*101*101);
  }
   ans|=(card[0][0]*card[1][1]*card[2][2]==101*101*101);
   ans|=(card[2][0]*card[1][1]*card[0][2]==101*101*101);
  if(ans)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	static int[][] graph; //the graph
	static int time;
	static int[] depth,find;
	static boolean[] visited;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){//adds values one at a time and updates everything accordingly
			int n= sc.nextInt();
			if(n==0)break;
			time = 1;
			graph = new int[n+1][n+1];
			depth = new int[n+1];
			find = new int [n+1];
			visited = new boolean[n+1]; //set if node is visited
			for(int i=0;i<n;i++) {
				int s = sc.nextInt();
				int k = sc.nextInt();
				for(int j=0;j<k;j++) {
					graph[s][sc.nextInt()] =1;
				}
			}
			for(int i=1;i<=n;i++)//Updates visit list, adds time
				visit(i);
			for(int i=1;i<=n;i++)//Prints out new graph
				System.out.println(i+" "+depth[i]+" "+find[i]);
		}
	}
	static void visit(int node) {
		if(!visited[node]) {
			visited[node] = true;
			depth[node] = time++; //Adds one to the time of the current node
			for(int i=1;i<depth.length;i++) {
				if(graph[node][i]==1)
					visit(i);
			}
			find[node] = time++;//next one
		}
	}
	
}


Measured memory_bytes: 28344
#!/usr/bin/python3

import array
from fractions import Fraction
import math
import os
import sys


def main():
    N = read_int()
    P = [Vec(x, y) for x, y in [read_ints() for _ in range(N)]]
    print(solve(N, P))


def solve(N, P):
    for i in range(N):
        a = P[i]
        b = P[(i + 1) % N]
        c = P[(i + 2) % N]
        if (b - a).cross(c - b) < 0:
            return 0
    return 1


###############################################################################
# AUXILIARY FUNCTIONS
class Vec(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
        super().__init__()

    def __add__(self, other):
        return Vec(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vec(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __rmul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __truediv__(self, scalar):
        return Vec(self.x / scalar, self.y / scalar)

    def __iadd__(self, other):
        self.x += other.x
        self.y += other.y
        return self

    def __isub__(self, other):
        self.x -= other.x
        self.y -= other.y
        return self

    def __imul__(self, scalar):
        self.x *= scalar
        self.y *= scalar
        return self

    def __idiv__(self, scalar):
        self.x /= scalar
        self.y /= scalar
        return self

    def __neg__(self):
        return Vec(-self.x, -self.y)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def abs2(self):
        return self.x * self.x + self.y * self.y

    def __abs__(self):
        return math.sqrt(float(self.abs2()))

    def __str__(self):
        return '({}, {})'.format(self.x, self.y)


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6936
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, n;
  n=1;
  cin >> N >> K;
  for (int i=0; i<N; i++){
    if (n*2 < n+K){
      n *= 2;
    }
    else{
      n += K;
    }
  }
  cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
int k;
void dfs(long long x,int sz){
	v.push_back(x);
	if(sz>=10)
		return;
	long long y=x%10;
	dfs(x*10+y,sz+1);
	if(y!=0)
		dfs(x*10+y-1,sz+1);
	if(y!=9)
		dfs(x*10+y+1,sz+1);
}
int main(){
	for(long long i=1;i<10;i++)
		dfs(i,1);
	sort(v.begin(),v.end());
	cin>>k;
	cout<<v[k-1];
	return 0;
}

Measured memory_bytes: 3444
#include <stdio.h>

int main(){
    int a, b, c, t;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    
    if(b > c){
        t = b;
        b = c;
        c = t;
    }
    
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}
 

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

N = int(input())
aN = list(map(int, input().split()))

same = False
same_cnt = 0
cnt = 0
for i in range(0, N-1):

	if same == False:
		same_cnt = 0

	if aN[i] == aN[i+1]:
		same = True
		same_cnt += 1
		if i == N-2:
			cnt += (same_cnt + 1) // 2
			break
	else:
		same = False
		if same_cnt != 0:
		 	cnt += (same_cnt + 1) // 2

print(cnt)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int x,y;
    cin>>x>>y;
    cout<<x+y/2<<endl;
}

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

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

  vector<int> s;
  vector<int> ord(n+1, -1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}

Measured memory_bytes: 5824
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int h = 0,n = 0;
    int a=0, sum=0;
    scanf("%d%d",&h,&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        sum=sum+a;
    }
    if(sum>=h){
        printf("Yes");
    }else{
            printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n;
  cin >> n;
  vl a(n);
  vector<ll>vec(110000);
  rep(i,n){
    cin >> a[i];
    vec[a[i]]++;
    vec[a[i]+1]++;
    vec[a[i]+2]++;
  }
  ll sum=*max_element(vec.begin(),vec.end());
  cout << sum << endl;
  
}


Measured memory_bytes: 13824
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[,]A = new int[N,N];
		for(var i=0;i<N;i++){
			string[] str = Console.ReadLine().Split();
			for(var j=0;j<N-1;j++){
				A[i,j] = int.Parse(str[j]);
			}
		}
		int[]B = new int[N];
		int[]B2 = new int[N];
		int[,]C = new int[N,N];
		int ct = 0;
		int ans = 0;
		var list = new HashSet<int>();
      	for(var i=0;i<N;i++){
          list.Add(i);
        }
		var list2 = new HashSet<int>();
      var list3 = new HashSet<int>();
		while(true){
			ans++;
			bool flag = false;
			list2.Clear();
          list3.Clear();
			foreach(var i in list){
				if(B[i]==N-1){
                  continue;
                }
				int a1 = i;
				int a2 = A[i,B[i]]-1;
				if(C[a2,a1]==1 && B2[a1]<ans && B2[a2]<ans){
					flag = true;
                  	//Console.Error.WriteLine(ans+" "+ct+" "+i+" "+B[i]+" "+(A[i,B[i]]-1));
					B[a1]++;
					B[a2]++;
                  	B2[a1] = ans;
                  	B2[a2] = ans;
					if(B[a1]==N-1){
						ct++;
                    }
                    list3.Add(a1);
					if(B[a2]==N-1){
						ct++;
                    }
                    list3.Add(a2);
				} else if(C[a1,a2]==0){
					flag = true;
					C[a1,a2]=1;
                 	list2.Add(a1);
                  	list2.Add(a2);
				}
			}
			foreach(var i in list2){
              	list.Remove(i);
            }
			foreach(var i in list3){
              	list.Add(i);
            }
			if(ct==N){
				break;
			}
			if(!flag){
              ans = -1;
              break;
            }
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 40992
#include<stdio.h>
#include <stdlib.h>
#include<math.h>
int isprime(int );

int main(){
  int n,count=0,*data,i;

  scanf("%d",&n);
  data=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }

  for(i=0;i<n;i++){
  if(isprime(data[i])==1)
    count++;
  }

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

  free(data);
  return 0;
}


int isprime(int n){
 int  i=3;
   if(n==2){
     return 1;
      }
   else if(n%2==0||n<2){
     return 0;
}
   else while(i<=sqrt(n)){
       if(n%i==0)
         return 0;
       i=i+2;
     }
   return 1;
}




Measured memory_bytes: 2104
s=input()
A=int(s[:2])
B=int(s[2:])
if 1<=A<=12 and 1<=B<=12:
        print("AMBIGUOUS")
elif 1<=A<=12:
        print("MMYY")
elif 1<=B<=12:
        print("YYMM")
else:
        print("NA")
        

Measured memory_bytes: 2940
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);

    printf("%d\n", MAX(0,c-(a-b)));
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        int N;
        cin >> N;
        vector<ll> vec(N), sum(N + 1);

        ll ans = 0;

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

        sum[0] = 0;
        for (int i = 1; i < N + 1; i++)
        {
                sum[i] = vec[i - 1] + sum[i - 1];
        }

        map<ll, ll> mp;
        for (int i = 0; i < N + 1; i++)
        {
                mp[sum[i]]++;
        }

        for (auto v : mp)
        {
                if (v.second >= 2)
                {
                        ans += (v.second - 1) * v.second / 2;
                }
        }

        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 15872
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = N.bit_length()

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

    def lower_bound(self, x):
        sum_ = 0
        pos = 0
        v = 1 << self.depth
        for i in range(self.depth, -1, -1):
            k = pos + v
            if k <= self.size and sum_ + self.tree[k] < x:
                sum_ += self.tree[k]
                pos += v
            v >>= 1
        return pos + 1, sum_


def solve():
    n, q = nm()
    c = nl()
    m = 500010
    m2 = m * m
    g = [0]*q
    for i in range(q):
        l, r = nm()
        g[i] = ((r-1) << 40) + ((l-1) << 20) + i
    mask = (1 << 20) - 1
    g.sort()
    ans = [0] * q
    b = BIT(m)
    last = [n + 5]*(n+1)
    cr = -1
    for r in g:
        i = r & mask
        r >>= 20
        l = r & mask
        r >>= 20
        while cr < r:
            cr += 1
            b.bitadd(last[c[cr]], -1)
            last[c[cr]] = cr
            b.bitadd(cr, 1)
        ans[i] = b.bitsum(l, r+1)
    prn(ans)
    return

solve()


Measured memory_bytes: 142248
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;

void factorize(map<ll,ll>& fac, vector<ll>& sieved, ll a){
    while(a != 1){
        if(fac.find(sieved[a]) == fac.end())fac[sieved[a]] = 0;
        fac[sieved[a]]++;
        a/=sieved[a];

    }
}
void primesieve(vector<ll>& res,ll n){
    res = vector<ll>(n+1, -1);
    for(int i = 2;i <= n;i++){
        if(res[i] != -1)continue;
        res[i] = i;
        for(int j = 2;j*i <= n;j++){
            res[j*i] = i;
        }
    }
}
vector<ll> primesuntil(ll n){
    vector<ll> res;
    vector<ll> sieved;
    primesieve(sieved, n);
    for(int i = 2;i <= n;i++){
        if(sieved[i] == i)res.push_back(i);
    }
    return res;
}
int gcd(int a, int b){
    if(b == 0)return a;
    return gcd(b, a%b);
}
int main(){
    int N;cin>>N;
    vector<ll> A;
    int M = 1000010;
    for(int i = 0;i  <N;i++){
        int a;cin>>a;
        A.push_back(a);
    }
    vector<ll> sieved;
    primesieve(sieved,M);
    vector<int> nums(M,0);
    bool isPair = true;
    map<ll,ll> mp;
    for(int i = 0;i < N;i++){
        mp.clear();
        factorize(mp, sieved, A[i]);
        // cout<<A[i]<<": ";
        for(const pair<ll,ll>& p:mp){
            // cout<<p.first<<"^"<<p.second<<" ";
            nums[p.first]++;
            if(nums[p.first] >= 2){
                isPair = false;
                break;
            }
        }
        // cout<<endl;
        if(!isPair)break;
    }
    ll g = A[0];
    for(int i = 0;i < N;i++){
        g = gcd(g, A[i]);
    }
    bool isSet = g == 1;
    if(isSet && !isPair)cout<<"setwise coprime"<<endl;
    else if(isPair)cout<<"pairwise coprime"<<endl;
    else cout<<"not coprime"<<endl;



}

Measured memory_bytes: 22856
S = list(map(int, list(input())))
colors = [0, 1]
cnt_b, cnt_w = 0, 0
b_list = [colors[i % 2] for i in range(len(S))]

for i in range(len(S)):
    if S[i] == b_list[i]:
        cnt_w += 1
    else:
        cnt_b += 1
        
print(min([cnt_w, cnt_b]))

Measured memory_bytes: 4652
n,k=map(int,input().split())
d=[0]*k
a=[[0] for i in range(k) ]
for i in range(k):
  d[i]=int(input())
  if (d[i]==1):
    a[i] = [int(input())]
  else:
    a[i]=list(map(int,input().split()))
b=[1 for i in range(n)]
for i in range(k):
  for j in range(d[i]):
    b[a[i][j]-1]=0
print(sum(b))

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

const long long int MOD = 1000000007;
const int N_MAX = 1000005;
const int LOG_MOD = 30;//ceil(log2(MOD))

long long int table_n_k[LOG_MOD+1],table_k[LOG_MOD+1];
long long int kaijo[N_MAX+1];

void initKaijo(){
  kaijo[0]=1;
  for(int i=0;i<N_MAX;i++){
    kaijo[i+1]=kaijo[i]*(i+1)%MOD;
  }
}

long long int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    table_n_k[0]=kaijo[n-k];
    table_k[0]=kaijo[k];
    for(int i=0;i<LOG_MOD+1;i++){
      table_n_k[i+1]=(table_n_k[i]*table_n_k[i])%MOD;
      table_k[i+1]=(table_k[i]*table_k[i])%MOD;
    }
    long long int ruijo_kaijo_n_k=1;//n-kの階乗の(MOD-2)乗
    long long int ruijo_kaijo_k=1;//kの階乗の(MOD-2)乗
    int count = 0;
    for(long long int i=MOD-2;i!=0;i=i>>1){
      if(i&1){
        ruijo_kaijo_n_k = ruijo_kaijo_n_k*table_n_k[count]%MOD;
        ruijo_kaijo_k = ruijo_kaijo_k*table_k[count]%MOD;
      }
      count++;
    }
    return kaijo[n]*(ruijo_kaijo_n_k*ruijo_kaijo_k% MOD) % MOD;
}


int main(){
  int X,Y;
  cin >> X >> Y;
  if ((X+Y)%3!=0){
    cout << 0;
    return 0;
  }
  int r=(X+Y)/3;
  X-=r;
  Y-=r;
  initKaijo();
  cout << COM(X+Y,Y)%MOD;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<iterator>
#include<vector>
using namespace std;
typedef vector<int> vii;
#define ll long long
#define tt ll t;cin>>t;while(t--)
#define nl endl
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define vec vector<ll>
#define cinv(v) for(auto it:v)cin >> it;
#define coutv(v) for(auto it:v)cout << it <<' ';cout<<endl;
#define so ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
        so;

        float x;
        cin>>x;
        float ans=2*3.1415*x;
        cout<<setprecision(10)<<ans;


        return 0;
}



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

chars = [chr(i) for i in range(ord('a'), ord('z')+1)]

ans = []

# mx: 現時点でのmax
def dfs(s, mx):
    # print(':', s, mx)
    if len(s) == N:
        # print(s)
        ans.append(s)
        return
    
    for i in range(mx + 2):
        ns = s + chars[i]
        if i == mx + 1:
            nmx = i
        else:
            nmx = mx
        dfs(ns, nmx)

dfs('a', 0)


ans.sort()
for si in ans:
    print(si)

Measured memory_bytes: 12676
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
 
int main() {
    int n;
    cin >> n;
    ll a[n+1], b[n], ans = 0;
    rep(i, n+1) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }

    rep(i, n) {
        if(a[i] >= b[i]) {
            ans += b[i];
        }
        else {
            ll c = b[i] - a[i];

            if(a[i+1] <= c) {
                ans = ans + a[i] + a[i+1];
                a[i+1] = 0;
            }
            else {
                a[i+1] -= c;
                ans += b[i];
            }
        }
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 1792
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
K=gets.to_i
X=gets.to_i
Y=gets.to_i
if N<K
    puts N*X
else
    puts K*X+(N-K)*Y
end

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h> 
#define pt 3
#define py 3
#define psum (pt*py)
#define cnt 45
extern inline void ue();
extern inline void sita();
extern inline void hdr();
extern inline void mgi();
extern int  find(int,int,int,int);
int zero = 0,pzl[psum];
int main()
{
    int i = 0,x,y = 0;
    for(i=0;i<psum;i++)
    {
        scanf("%d",&pzl[i]);
         
        if(pzl[i] == 0) zero = i;
    }
     
    x = pt - (zero/py) -1;
    y = py - (zero%py) -1;
     
    for(i=0; i<cnt; i++)
    {
        if( find(x,y,i,4) == 1 )
        {
            printf("%d\n",i);
            break;
        }
    }     
     
    return 0;
}
 
int find(int x, int y, int mcnt, int p)
{
    int res;
    int i=0;
     
    if(mcnt < (x + y) )
    {
        return 0;
    }
    if(mcnt==0)
    {
        for(i=0; i<psum-1; i++)
        {
            if(pzl[i] != (i+1)) return 0;
        }
        return 1;
    }
    for(i=0; i<4; i++)
    {
        res = 0;
         
        switch(i)
        {
            case 0:
                if( (x>0) && (p!=3) )
                {
                    sita();
                    res = find(x-1, y, mcnt-1, 0);
                    ue();
                }
                break;
                 
            case 1:
                if((p!=2)&&(y>0))
                {
                    mgi();
                    res = find(x,y-1,mcnt-1,1);
                    hdr();
                }
                break;
                 
            case 2:
                if((p!=1)&&(y<py-1))
                {
                    hdr();
                    res = find(x,y+1, mcnt-1,2);
                    mgi();
                }
                break;
                 
            case 3:
                if((x<pt-1)&&(p!=0))
                {
                    ue();
                    res = find(x+1,y,mcnt-1,3);
                    sita();
                }
                break;
            default:
                break;
        }
         
        if(res)
        {
            return 1;
        }
    }
     
    return 0;
}
 
 
inline void sita()
{
    pzl[zero] = pzl[zero+py];
    zero += py;
}
  
inline void ue()
{
    pzl[zero] = pzl[zero-py];
    zero -= py;
}
  
inline void mgi()
{
    pzl[zero] = pzl[zero+1];
    zero += 1;
}
  
inline void hdr()
{
    pzl[zero] = pzl[zero-1];
    zero -= 1;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <functional>
#include <bitset>
#include <queue>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using string_view = boost::string_ref;

#include <boost/function_output_iterator.hpp>

using namespace std;

struct operation_t {
    int y1, x1, y2, x2;
};

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

    int h, w;
    cin >> h >> w;
    
    vector<vector<int>> a(h, vector<int>(w, 0));
    for(auto& r : a) for(auto& c : r) cin >> c;
    
    vector<operation_t> operations;

    for(int r : irange(0, h))
    {
        if(r % 2 == 0)
        {
            for(int c : irange(0, w))
            {
                if(a[r][c] % 2 == 1)
                {
                    if(c < w - 1)
                    {
                        operations.push_back({r, c, r, c+1});
                        a[r][c]--;
                        a[r][c+1]++;
                    }
                    else if(r < h - 1)
                    {
                        operations.push_back({r, c, r+1, c});
                        a[r][c]--;
                        a[r+1][c]++;
                    }
                }
            }
        }
        else
        {
            for(int c : irange(w-1, -1, -1))
            {
                if(a[r][c] % 2 == 1)
                {
                    if(c > 0)
                    {
                        operations.push_back({r, c, r, c-1});
                        a[r][c]--;
                        a[r][c-1]++;
                    }
                    else if(r < h - 1)
                    {
                        operations.push_back({r, c, r+1, c});
                        a[r][c]--;
                        a[r+1][c]++;
                    }
                }
            }
        }
    }
    
    //for(auto& r : a) { for(auto& c : r) cout << c << ' '; cout << '\n'; }
    
    cout << operations.size() << '\n';
    for(const auto& o : operations)
        cout << o.y1+1 << ' ' << o.x1+1 << ' ' << o.y2+1 << ' ' << o.x2+1 << '\n';
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
        string x;
        cin >> x;
        s.insert(x);
    }
    cout << (int)s.size() << endl;
}


Measured memory_bytes: 19276
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			for(String line = sc.next(); !line.equals("-"); line = sc.next()) {
				int m = sc.nextInt();
				for(int i = 0; i < m; i++) {
					int h = sc.nextInt();
					line = line.substring(h) + line.substring(0, h);
				}
				System.out.println(line);
			}
		}
	}
}



Measured memory_bytes: 26644
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = INF;
  repp(i, 1, (ll)sqrt(n)+1){
    if(n%i != 0) continue;
    ll a = i;
    ll b = n/i;
    if(a > b) break;
    ans = min(ans, (ll)max(to_string(a).length(), to_string(b).length()));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict, Counter


def solve():
    n = int(input())
    v = [int(i) for i in input().split()]
    d1 = Counter(v[::2])
    d2 = Counter(v[1::2])
    rd1 = defaultdict(list)
    rd2 = defaultdict(list)
    for k, v in d1.items():
        rd1[v].append(k)
    for k, v in d2.items():
        rd2[v].append(k)
    a1 = [i for i in sorted(rd1.keys(), reverse=True)]
    a2 = [i for i in sorted(rd2.keys(), reverse=True)]
    ans, half = n, (n // 2)
    la1 = len(a1) - 1
    la2 = len(a2) - 1
    for h in range(3):
        for i in range(3):
            ai1, ai2 = min(h, la1), min(i, la2)
            aa1, aa2 = rd1[a1[ai1]], rd2[a2[ai2]]
            s1, s2 = set(aa1), set(aa2)
            if len(s1) > 1 or len(s2) > 1 or (s1 - s2):
                ans = min(
                    ans, 2 * half - a1[ai1] - a2[ai2])
            else:
                ans = min(ans,
                          2 * half - a1[ai1] - a2[ai2] + min(a1[ai1], a2[ai2]))
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 107244
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll l;
    cin>>l;
    ll s=l,n=0,cnt=0;
    while(s>0){
        n++;
        if(s%2) cnt++;
        s/=2;
    }
    cout<<n<<" "<<2*(n-1)+cnt-1<<endl;
    rep2(i,1,n){
        cout<<i<<" "<<i+1<<" "<<0<<endl;
        cout<<i<<" "<<i+1<<" "<<(ll)pow(2,i-1)<<endl;
    }
    ll t=l-(ll)pow(2,n-1);
    ll now=(ll)pow(2,n-1);
    repr(bit,n+1){
        if(t>=(ll)pow(2,bit)){
            cout<<bit+1<<" "<<n<<" "<<now<<endl;
            now+=(ll)pow(2,bit);
            t-=(ll)pow(2,bit);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int dx[] = {-1,-1,-1,0,0,1,1,1},dy[] = {-1,0,1,-1,1,-1,0,1};
int ans;
int n;
char ma[300][300];

void cheak(int px,int dx,int py,int dy){
  int cnt = 1;

  while(1){
    px+=dx;
    py+=dy;
    if(!(0<=px && px < n && 0 <= py && py < n) || ma[py][px] != '1')break;
    cnt++;
  }
  ans = max(ans,cnt);
}

int main(){
  while( cin >> n,n){

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

    ans = 0;

    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ;  j < n ; j++){

	if(ma[i][j] == '1'){
	  for(int l = 0 ; l < 8; l++){
	      cheak(j,dx[l],i,dy[l]);
	  }
	}

      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X;
  cin >> X;
  long long sum = 100;
  long long ans = 0;
 
  while (sum < X) {
    sum += sum * 0.01;
    ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <sstream>

using namespace std;
int getMaxProfit(int* ary, int ary_size);

int main()
{
	string str;
	getline(cin, str);
	int num;
	stringstream num_ss(str);
	num_ss >> num;

	int counter = 0;
	int* ary = new int[num];
	for (int i = 0; i < num; i++) {
		getline(cin, str);
		stringstream tmp_ss(str);
		tmp_ss >> ary[i];
	}
	
	cout << getMaxProfit(ary, num) << endl;
	return 0;
}


int getMaxProfit(int* ary, int ary_size) {
	int max_prf = ary[1] - ary[0];
	int min_num = (ary[1] > ary[0] ? ary[0] : ary[1]);
	for (int i = 2; i < ary_size; i++) {
		int tmp = ary[i] - min_num;
		if (tmp > max_prf) {
			max_prf = tmp;
		}
		min_num = (ary[i] < min_num ? ary[i] : min_num);
	}
	return max_prf;
}

Measured memory_bytes: 3940
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <queue>

using namespace std;

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

    cout << ((a <= x) && (x - a) <= b ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
_, k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
if arr.max < k
  puts 'IMPOSSIBLE'
else
  gcd = arr[0]
  arr.each { |i| gcd = i.gcd(gcd) }
  puts k % gcd == 0 ? 'POSSIBLE' : 'IMPOSSIBLE'
end

Measured memory_bytes: 9476
def main():
    s = input().rstrip()
    f = False
    for i in range(len(s)):
        for j in range(len(s)-i):
            if s[:j]+s[j+i:] == "keyence":
                f = True
    if f:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

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

int compare(const void*a,const void *b) {
	return *(int*)a - *(int*)b;
}

int main() {
	long long int l=0,r=0,d,k,a,b,c = 0, n, x[200000],y[200000],e[100] = { 0 }, ans = 0;
	char s[3], cas[4][4] = {"AC","WA","TLE","RE"};
	scanf("%lld%lld", &n,&d);
	for (int i = 0; i < n; i++)scanf("%lld%lld", &x[i], &y[i]);
	for (int i = 0; i < n; i++) {
		long long int od = x[i] * x[i] + y[i] * y[i];
		if (od <= d * d)ans++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int x;
	cin>>x;
	cout<<(x^1)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>=13){
        printf("%d",b);
    }
    else if(a>=6 && a<=12){
        printf("%d",b/2);
    }
    else if(a<=5){
        printf("0");
    }
    return 0;
}

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

typedef long long ll;
const int INF = 1e9;

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

int c[26]; 
int tmp[26];

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

	fill( c, c + 26, INF );
	REP( i, n ) {
		fill( tmp, tmp + 26, 0 );
		REP( j, a[i].size() ) {
			tmp[a[i][j] - 'a']++;
		}
		REP( i, 26 ) {
			c[i] = min( c[i], tmp[i] );
		}
	}

	REP( i, 26 ) {
		REP( j, c[i] ) {
			cout << char( 'a' + i );
		}
	}
	cout << endl;

}

Measured memory_bytes: 256
k,n=map(int,input().split())
a=list(map(int,input().split()))
a.append(a[0])
dis=[]
for i in range(n):
    d=abs(a[i]-a[i+1])
    if d>k/2:
        d=k-d
    dis.append(d)
print(k-max(dis))

Measured memory_bytes: 26444
#define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e15)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-12)    //0.0000001 the value
#define PI (acos((ld)-1.0))
#define MAXN (100006)
#define ll long double 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < (ll)ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll((x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <char, pi> spi;
typedef pair <pi, pi> dpi;
// inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
// string to_string(char c) {string s(1,c);return s;}string to_string(bool b){return (b ? "true" : "false");}template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A>string to_string(A v) {bool first = true;string res = "{";for (const auto &x : v) {if (!first) {res += ", ";}first = false;res += to_string(x);}res += "}";return res;}void degug_out() { cerr << endl; }template <typename Head, typename... Tail>void degug_out(Head H, Tail... T) {cerr << " " << to_string(H);degug_out(T...);}inline ll gcd(ll a,ll b){if(a>b)swap(a,b);if(a==0)return b;return gcd(b%a,a);}
#ifdef LOCAL
#define degug(...) cerr << "[" << #__VA_ARGS__ << "]:", degug_out(__VA_ARGS__)
#else
#define degug(...) 42
#define cerr if(0)cout
#endif
ll n; spi A[MAXN];
ll tstar(ll x){
	ll mxx=-LLINF,mix=LLINF,may=-LLINF,miy=LLINF;
	FOR(ii,0,n){ int i=ii;
		ll movex=0,movey=0;
		if(A[i].f=='L'){
			movex-=x;
		}else if(A[i].f=='R'){
			movex+=x;
		}else if(A[i].f=='D'){
			movey-=x;
		}else if(A[i].f=='U'){
			movey+=x;
		}else assert(0);
		mxx=max(mxx,movex+A[i].s.f);
		mix=min(mix,movex+A[i].s.f);
		may=max(may,movey+A[i].s.s);
		miy=min(miy,movey+A[i].s.s);
	}
	return (mxx-mix)*(may-miy);
}
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n){
		cin>>A[(int)i].s.f>>A[(int)i].s.s>>A[(int)i].f;
	}
	ll st=0,en=2e8+100;
	FOR(i,0,150){
		ll lmid=st+(en-st)/(ld)3;
		ll umid=en-(en-st)/(ld)3;
		if(st==lmid&&en==umid)break;
		if(tstar(lmid)>tstar(umid))st=lmid;
		else en=umid;
	}
	cout<<fixed<<setprecision(15)<<tstar((st+en)/(ld)2)<<'\n';
}


Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	for(int i=0;i<3;i++)
		cin>>a[i];
	sort(a,a+3);
	cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
	return 0;
}

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

int main()
{
  string s[] = {"dreamer","eraser","erase","dream"};
  string t;
  cin>>t;
  reverse(t.begin(),t.end());
  for(string &i:s)
  {  reverse(i.begin(),i.end()); }

  int i=0;
  for(;i<t.size();)
  {
    bool flag = false;
    for(auto l:s)
    {
      //cout<<l<<"\n";

      if(i+l.length()-1<=t.size()-1&&t.substr(i,l.length())==l)
      {
        flag=true;
        i+=l.length();
        break;
        if(i>=t.size())
          break;
      }
    }
    if(!flag)
      {
        cout<<"NO\n";
        return 0;
      }
  }
  cout<<"YES\n";
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;

ll N, M, V, P, A[100000 + 100];
ll csum[100000 + 100];

int main() {
	cin >> N >> M >> V >> P;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	sort(A, A + N);
	reverse(A, A + N);

	for (int i = 1; i <= N; i++)csum[i] = csum[i - 1] + A[i - 1];

	if (P >= V) {
		int ans = P;
		for (int i = P; i < N; i++) {
			if (A[P - 1] - A[i] <= M)ans++;
			else continue;
		}
		cout << ans << endl;
		return 0;
	}

	int ans = P;
	
	for (int i = P; i < N; i++) {
		ll Diff = A[P - 1] - A[i];
		if (Diff > M)break;
		ll addprob = 0;
		addprob = (i - (P - 1)) * (A[i] + M) - (csum[i] - csum[P - 1]);
		//cout << addprob << endl;
		addprob += (N - (i + 1)) * M;
		//cout << "ap == " << addprob << endl;
		if (addprob >= M * (V - P)) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792