akhauriyash/Code-Regression huggingface dataset:
N = int(input())
V = list(map(int,input().split()))

import collections

if len(set(V)) == 1:
  print(N//2)
else:
  evens = [V[n] for n in range(0,N,2)]
  odds = [V[n] for n in range(1,N,2)]
  
  c_evens = collections.Counter(evens).most_common()
  c_odds = collections.Counter(odds).most_common()
  
  mode_in_evens = c_evens[0][0]
  mode_number_in_evens = c_evens[0][1]
  
  mode_in_odds = c_odds[0][0]
  mode_number_in_odds = c_odds[0][1]
  
  ans = N - (mode_number_in_evens+mode_number_in_odds)
  
  if mode_in_evens == mode_in_odds:
    if len(c_evens) != 1:
      second_mode_number_in_evens = c_evens[1][1]
    else:
      second_mode_number_in_evens = 0
    ans_candidate_1 = N - (second_mode_number_in_evens+mode_number_in_odds)      
      
    if len(c_odds) != 1:
      second_mode_number_in_odds = c_odds[1][1]
    else:
      second_mode_number_in_odds = 0
    ans_candidate_2 = N - (mode_number_in_evens+second_mode_number_in_odds) 
    
    ans = min(ans_candidate_1,ans_candidate_2)
    
  print(ans)

Measured memory_bytes: 25464
int a[200010];
int ans[200010];
int main(){
int n;
scanf("%d",&n);
for(int i=2;i<=n;i++)scanf("%d",&a[i]);
for(int i=2;i<=n;i++)ans[a[i]]++;
for(int i=1;i<=n;i++)printf("%d\n",ans[i]);
}


Measured memory_bytes: 3240
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (k <= a) {
    cout << k << endl;
  } else if (k <= a + b) {
    cout << a << endl;
  } else {
    cout << a - (k - (a + b)) << endl;
  }
}

Measured memory_bytes: 3648
import java.io.*;
import java.util.ArrayList;

public class Main {
	
	
    public static void main(String[] args) {
       
    	try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
          
            String str;
            ArrayList<Character> array = new ArrayList<Character>();
            
            while((str = br.readLine()) != null)
            {
            	for(int i = str.length()-1; i>=0; i--)
            	{
            	array.add(str.charAt(i));
            	}
            	
            	for(int i = 0; i<array.size();i++)
            	{
            	System.out.print(array.get(i));
            	}
            	System.out.println();
            }
    	}catch (Exception e) {
            e.printStackTrace();
        }
       
    }
    
   
}

Measured memory_bytes: 24292
X,K,D=map(int,input().split())
kk=(abs(X)//D)
#print(kk)
l=K-kk
#print(l)
if kk >= K:
  print(abs(abs(X)-K*D))
elif(l%2==0):
  print(abs(abs(X)-kk*D))
else:
  print(abs(abs(X)-(kk+1)*D))


Measured memory_bytes: 9120
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int k ; 
    int s ;
    cin >> k >> s ;
    int  z ,ans= 0;
    for(int i = 0 ; i <= k ; i++){
       for(int j = 0 ; j <= k ; j++ ){
           z = s - i - j ;
           if(0<= z && z <= k){
               ans ++ ;
           }
       }
    }
    cout << ans << endl;
    return 0;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int X;
  cin >> X;
  if (X ==3) {
    cout << "YES" << endl;
  } else if (X == 5) {
    cout << "YES" << endl;
  } else if (X == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  } 
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

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

    string s,t;
    cin >> s >> t;
    int tot=0;
    F0R(i,3)
    {
        if(s[i]==t[i])
            tot++;
    }
    cout << tot;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define MOD 1000000007

using namespace std;
typedef long long ll;

ll sumOfDiffs(vector<ll> ns) {
	int N = ns.size();
	vector<ll> sumAt(N, 0);
	for (int i = 0; i < N; ++i) {
		sumAt[i] = (ns[i] * (2*i - N + 1)) % MOD;
	}
	ll res = 0;
	for (ll sum : sumAt) {
		//printf("elem is %lld\n", sum);
		res = (res + sum) % MOD;
	}
	return res;
}

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

	vector<ll> cols(n, 0);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", &cols[i]);
	}

	vector<ll> rows(m, 0);
	for (int i = 0; i < m; ++i) {
		scanf("%lld", &rows[i]);
	}

	ll ans = (sumOfDiffs(cols) * sumOfDiffs(rows)) % MOD;

	printf("%lld", (ans < 0 ? ans + MOD : ans));
	return 0;
}

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

int main()
{
    int N,sum,stamina=INT_MAX;
    int X[101];
    cin >> N;
    for(int i=1;i<=N;i++)
    {
        cin >> X[i];
    }
    for(int i=1;i<=100;i++)
    {
        sum = 0;
        for(int j=1;j<=N;j++)
        {
            sum += (X[j]-i)*(X[j]-i);
        }
        stamina = min(sum,stamina);
    }
    cout << stamina << endl;
    return 0;
}

Measured memory_bytes: 256
// Indrajeet Mishra

/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/
 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=0,k=0,count=0,dp[1000000]={0};cin>>n>>k;
    vll v;
    rep(i,0,n){
        ll temp=0;cin>>temp;
        v.pb(temp);
    }
    dp[1]=abs(v[1]-v[0]);
    rep(i,2,n){
        dp[i]=dp[i-1]+abs(v[i]-v[i-1]);
        for(ll j=i-2;j>=0;j--){
            if(count==k-1)break;
            dp[i]=min(dp[i],(dp[j]+abs(v[j]-v[i])));
            count++;
        }
        count=0;
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 12068
#include <stdio.h>

int B[4001][4001], W[4001][4001];

int main(void) {
	int N, K;
	int i, j, dx, dy;
	int answer = 0;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		int x, y, c;
		char sumipe[4];
		if (scanf("%d%d%3s", &x, &y, sumipe) != 3) return 1;
		c = sumipe[0];
		for (dy = 0; dy <= 1; dy++) {
			for (dx = 0; dx <= 1; dx++) {
				(c == 'B' ? B : W)[y % (K * 2) + (K * 2) * dy + 1][x % (K * 2) + + (K * 2) * dx + 1]++;
			}
		}
	}
	for (i = 1; i <= K * 4; i++) for (j = 1; j <= K * 4; j++) B[i][j] += B[i][j - 1];
	for (i = 1; i <= K * 4; i++) for (j = 1; j <= K * 4; j++) B[i][j] += B[i - 1][j];
	for (i = 1; i <= K * 4; i++) for (j = 1; j <= K * 4; j++) W[i][j] += W[i][j - 1];
	for (i = 1; i <= K * 4; i++) for (j = 1; j <= K * 4; j++) W[i][j] += W[i - 1][j];
	for (i = 0; i < K * 2; i++) {
		for (j = 0; j < K * 2; j++) {
			int w1 = W[i + K][j + K] - W[i][j + K] - W[i + K][j] + W[i][j];
			int w2 = W[i + K + K][j + K + K] - W[i + K][j + K + K] - W[i + K + K][j + K] + W[i + K][j + K];
			int b1 = B[i + K + K][j + K] - B[i + K][j + K] - B[i + K + K][j] + B[i + K][j];
			int b2 = B[i + K][j + K + K] - B[i][j + K + K] - B[i + K][j + K] + B[i][j + K];
			int score = w1 + w2 + b1 + b2;
			if (score > answer) answer = score;
		}
	}
	printf("%d\n", answer);
	return 0;
}


Measured memory_bytes: 125184
"use strict"

const compare = (sum, ps, i) => {
    const start = ps[i];
    const center = ps[i + 1];
    const end = ps[i + 2];
    if (start < center && center < end) {
        sum += 1;
    } else if (start > center && center > end) {
        sum += 1;
    }
    return sum;
};

const main = (input) => {
    input = input.split("\n");
    const ps = input[1].split(" ").map(p => Number(p));
    let sum = 0;
    for (let i = 0; i < ps.length; i++) {
        sum = compare(sum,ps,i);
    }
    console.log(sum);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.StringTokenizer;

public class Main {
    private static void solve() throws Exception {
        int n = fs.nextInt(), x = fs.nextInt(), t = fs.nextInt();
        out.println(((n+x-1)/x)*t);
    }

    private static FastScanner fs = new FastScanner();
    private static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        int T = 1;
        for (int t = 0; t < T; t++) {
            solve();
        }
        out.close();
    }

    static void debug(Object... O) {
        System.err.print("DEBUG ");
        System.err.println(Arrays.deepToString(O));
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextString() {
            return next();
        }
    }
}


Measured memory_bytes: 32900
#include<iostream>
#include<ios>
using namespace std;
int get(){
	int h,m,s;
	scanf("%d:%d:%d",&h,&m,&s);
	return h*3600+m*60+s;
}
int n;
int cnt[90000];
int 
main()
{
	while(cin>>n,n)
	{
		for(int i=0;i<90000;i++)cnt[i]=0;
		for(int i=0;i<n;i++)
		{
			cnt[get()]++;cnt[get()]--;
		}
		int ans=cnt[0];
		for(int i=1;i<90000;i++)
		{
			cnt[i]+=cnt[i-1];
			ans=ans<cnt[i]?cnt[i]:ans;
		}
		cout<<ans<<endl;
	}
}



Measured memory_bytes: 3460
#include "bits/stdc++.h"
using namespace std;

int main() {
        int i, j;
        while (true) {
                int n, p;
                cin >> n >> p;
                if (n == 0 && p == 0) break;
                int wan = p;
                int turn = 0;
                vector<int> have(n, 0);
                while (true) {
                        if (wan != 0) {
                                wan --;
                                have[turn] ++;
                                if (have[turn] == p) {
                                        cout << turn << endl;
                                        break;
                                }
                        } else {
                                wan = have[turn];
                                have[turn] = 0;
                        }
                        turn ++;
                        if (turn == n) turn = 0;
                }
        }
        return 0;
}

Measured memory_bytes: 2976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[] = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);
        int l = Integer.parseInt(str[2]);
        int[][] a = new int[n][m];
        int[][] b = new int[m][l];
        long result;
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<n;i++){
            str = br.readLine().split(" ");
            for(int j=0;j<m;j++){
                a[i][j] = Integer.parseInt(str[j]);
            }
        }
        for(int i=0;i<m;i++){
            str = br.readLine().split(" ");
            for(int j=0;j<l;j++){
                b[i][j] = Integer.parseInt(str[j]);
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                result = 0;
                for(int k=0;k<m;k++){
                    result += a[i][k] * b[k][j];
                }
                if(j<l-1) sb.append(result).append(" ");
                else sb.append(result).append("\n");
            }
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 32212
#include<bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;
ll a , b  , cnt , n , m , ans , mn;
int main(){
    cin >> n;
    for( int i = 1;i <= n;i ++ ){
        for( int j = 1;j <= n;j ++ ){
            for( int h = 1;h <= n;h ++ )
                cnt+=__gcd(i , __gcd(j , h));
        }
    }
    cout << cnt;
}
/// ab#c ad#c
/// ab## c#d#

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

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

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var queue = new Queue<int>(ai.OrderByDescending(x => x));
            var alice = 0;
            var bob = 0;
            var flag = true;
            while (queue.Any())
            {
                if (flag) alice += queue.Dequeue();
                else bob += queue.Dequeue();
                flag = !flag;
            }
            Console.WriteLine(Math.Abs(alice - bob));
        }
    }
}


Measured memory_bytes: 13524
import sys
input = sys.stdin.readline

N = int(input())
v = list(map(int, input().split()))
v.sort(reverse=True)
while len(v) != 1:
    a = v.pop()
    b = v.pop()
    v.append((a+b)/2)
    v.sort(reverse=True)
print(v[0])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();

		int sum = 100 * r + 10 * g + b;
		String ans = "";

		if ( sum % 4 == 0 ) {
			ans = "YES";
		} else {
			ans = "NO";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import numpy as np


def main():
    n = int(input())
    a = [int(x) for x in input().split()]

    best, solution = int(-1e10), []
    for p in range(2):
        c = a.copy()

        indexes = list(range(p, n, 2))
        if len(indexes) == 0:
            continue

        maks = max([c[i] for i in indexes])
        pick = next(filter(lambda i: c[i] == maks, indexes))
        chosen = set([pick] if maks <= 0 else filter(lambda i: c[i] > 0, indexes))
        is_chosen = [(i in chosen) for i in range(n)]

        tot, res = sum([c[i] for i in chosen]), []
        for i in reversed(range(n)):
            if not is_chosen[i]:
                if i == 0 or i + 1 == len(c):
                    res += [i]
                    del c[i], is_chosen[i]
                elif is_chosen[i - 1] == is_chosen[i + 1]:
                    res += [i]
                    c[i - 1] += c[i + 1]
                    del c[i + 1], c[i], is_chosen[i + 1], is_chosen[i]

        if len(c) > 1 and not is_chosen[0]:
            res += [0]
            del c[0], is_chosen[0]

        if tot > best:
            best, solution = tot, np.array(res) + 1

    print(best, len(solution), *solution, sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 20992
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt(); 
    //AはBより場所が1つ多い
    int a[] =new int[n];
    int b[] =new int[n-1];
    int ans = 0;
//配列B格納
    for(int i=0; i<b.length; ++i){
      b[i] = sc.nextInt();
    }
//とりあえずAにBを格納
   for(int i=0; i<b.length; ++i){
		    a[i]=b[i];
		}
    //AのラストにBのラストを格納
		a[(n-1)]=b[(n-2)];
    //Aに入ってるやつより、直前のBのほうが小さかったら更新
		for(int i=1; i<a.length; ++i){
		    if(a[i]>b[(i-1)]){
		        a[i]=b[(i-1)];
		    }
		}
    
    
    for(int i = 0; i < a.length; ++i){
      ans = ans + a[i];
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 35740
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

W, H, x, y = map(int, input().split())
print(H * W / 2, 1 if x * 2 == W and y * 2 == H else 0)



Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#include<algorithm>

using namespace std;
typedef long long ll;

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

    vector<ll> e(1000000+1, 0);

    for (auto i : a){

        if (e[i] > 0){
            e[i] = 2;
            continue;
        }
        for (ll j = i; j < 1000001; j += i) e[j]++;
    }

    ll ans = 0;

    for(ll j : a){
        if (e[j] == 1) ans++;
    }
    cout << ans << endl;

}

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

using namespace std;
typedef long long ll;

int n, m;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    priority_queue<int> pq;
    cin >> n >> m;
    while (n--) {
        int a;
        cin >> a;
        pq.push(a);
    }
    while (m--) {
        int x = pq.top();
        pq.pop();
        pq.push(x / 2);
    }
    ll ans = 0;
    while (!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 892
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n,i,j;
    cin>>n;
    vector<ll> a(n),v(n);
    // multiset<ll> s;
    map<ll,ll> m;
    f(i,0,n)
    {
        cin>>a[i];
        v[i]=a[i];
        a[i]=i-a[i]; 
        m[a[i]]++;
        // s.insert(a[i]);
    }
    ll ans=0;
    f(i,0,n)
    {
        ll key=v[i]+i;
        ans+=m[key];
        m[a[i]]--;
        // ans+=s.count(key);
        // s.erase((a[i]));
    }
    cout<<ans<<'\n';

}

int32_t main()
{
    IOS();
    
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 29072
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int n; cin>>n;
  int cnt=0;
  bool f=false;
  rep(i,n){
    int d1,d2;
    cin>>d1>>d2;
    if(d1==d2) cnt++;
    else cnt=0;
    if(cnt==3) f=true;
  }
  YesNo(f);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 3584
n = int(input())

L = []
dp = [[0] * n for _ in range(2)]

L.append(list(map(int,input().split())))
L.append(list(map(int,input().split())))

if len(L[0]) == 1 and len(L[1]) == 1:
    #pass
    print(L[0][0] + L[1][0])
    exit()

dp[0][0] = L[0][0]

for i in [0,1]:
    for j in range(n-1):
        if i == 0:
            # 縦に動く処理
            dp[i+1][j] = max(dp[i][j] + L[i+1][j],dp[i+1][j])

            # 横に動く処理
            dp[i][j+1] = max(dp[i][j] + L[i][j+1],dp[i][j+1])
        else:
            dp[i][j+1] = max(dp[i][j] + L[i][j+1],dp[i][j+1])

#print(dp[1][n])
print(dp[1][n-1])


Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		
		for (int x = 1; x <= n; x++) {
			int t = ((1 + x) * x) / 2;
			if (t >= n) {
				System.out.println(x);
				System.exit(0);
			}
		}
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = signed long long int;
using P = pair<int, int>;
int main (void) {
    int N;
    cin >> N;
    vector<vector<ll>> abc(3, vector<ll>(N));
    rep(i, 3) rep(j, N) cin >> abc.at(i).at(j);
    rep(i, 3) sort(abc.at(i).begin(), abc.at(i).end());
    
    ll ans = 0;
    rep(i, N)  {
        ll key = abc.at(1).at(i);
        ll x = upper_bound(abc.at(0).begin(), abc.at(0).end(), key-1) - abc.at(0).begin();
        ll y = abc.at(2).end() - upper_bound(abc.at(2).begin(), abc.at(2).end(), key);
        ans += x * y;

    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#define MH 20
#define MW 20
using namespace std;
char f[MH][MW];
bool v[MH][MW];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
int w, h;
int c = 0;

void search(int x, int y) {
	++c;
	v[y][x] = true;
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i]; int ny = y + dy[i];
		if (0 <= nx && nx < w && 0 <= ny && ny < h && v[ny][nx] == false && f[ny][nx] != '#') {
			search(nx, ny);
		}
	}
	return;
}

int main() {
	int sx, sy;

	while (cin >> w >> h, !(w == 0 && h == 0)) {
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> f[i][j];
				if (f[i][j] == '@') {
					sx = j;
					sy = i;
				}
			}
		}
		c = 0;
		fill(v[0], v[MH], false);
		search(sx, sy);
		cout << c << endl;
		
	}
	return 0;
}

Measured memory_bytes: 1168
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		char[] c = line.toCharArray();
		String ans = "Yes";
		int n = c.length;
		for(int i = 0; i < n; i++){
			if(c[i] != c[(n - 1) - i]){
				ans = "No";
			}
		}
		for(int i = 0; i < (n/2); i++){
			if(c[i] != c[((n - 1)/2 - 1) - i]){
				ans = "No";
			}
			if(c[(n + 1)/2 + i] != c[(n - 1) - i]){
				ans = "No";
			}
		}
		System.out.println(ans);
 	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,aa[220000],ab[2200],cntl=0;
pair<int,int> p[220000];
string s,ss[110000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>ss[i];
    }
    rep(i,n){
        rep(j,i){
            if(ss[i]==ss[j]){
                cout<<"No";
                return 0;
            }
        }
    }
    rep(i,n-1){
        if(ss[i][ss[i].size()-1]!=ss[i+1][0]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

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

int main() {
  string S; cin >> S;
  vector<int> cnt(3);
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'a') cnt.at(0)++;
    else if (S.at(i) == 'b') cnt.at(1)++;
    else cnt.at(2)++;
  }
  bool can = true;
  if (abs(cnt.at(0) - cnt.at(1)) > 1) can = false;
  if (abs(cnt.at(1) - cnt.at(2)) > 1) can = false;
  if (abs(cnt.at(2) - cnt.at(0)) > 1) can = false;
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	double dk = (a + b) / 2.0;
	if (dk == (int)(dk + 0.5)) {
		cout << (int)(dk + 0.5) << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;
ll solve() {
    ll X, Y;
    cin >> X >> Y;
    ll t = (ll)1e18 / X - (ll)1e18 / X / Y;
    if (t <= 0 || X % Y == 0) return -1;
    return X * (Y + 1);
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
	if(a<b)swap(a,b);
	if(b==0)return a;
	else return gcd(b,a%b);
}
const int MAX=100500;
int main()
{
	int n;
	int a[MAX],left[MAX],right[MAX],cnt[MAX];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	left[0]=a[0];
	for(int i=1;i<n;i++)
		left[i]=gcd(left[i-1],a[i]);
	right[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
		right[i]=gcd(right[i+1],a[i]);
	cnt[0]=right[1];
	cnt[n-1]=left[n-2];
	for(int i=1;i<n-1;i++)
		cnt[i]=gcd(left[i-1],right[i+1]);
	int res=0;
	for(int i=0;i<n;i++)
		res=max(res,cnt[i]);
	cout<<res<<endl;
	return 0;
}	


Measured memory_bytes: 1792
import Foundation


func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let n = Int(readLine()!)!

    let points = (1...n).map { _ -> (Int, Int) in
        let xy = readWords { Int($0)! }
        let x = xy[0]
        let y = xy[1]

        return (x, y)
    }

    var distances = [[Int]: Int]()
    for (p, q) in points {
        for (b, d) in points {
            if (p, q) == (b, d) {
                continue
            }
            let pb = p - b
            let qd = q - d
            distances[[pb, qd], default: 0] += 1
        }
    }
    let v = distances.values.max()!
    print(n - v)
}


main()

Measured memory_bytes: 13792
w,h,n = map(int,input().split())
x1,y1,x2,y2 = 0,0,w,h
for i in range(n):
    b,c,d = map(int,input().split())
    if d == 1:
        x1 = max(x1,b)
    elif d == 2:
        x2 = min(x2,b)
    elif d == 3:
        y1 = max(y1,c)
    else:
        y2 = min(y2,c)
if x2-x1 <= 0 or y2 <= 0:
    print(0)
else:
    print((x2-x1)*(y2-y1))

Measured memory_bytes: 3064
from collections import Counter

n = int(input())
v_list = tuple([int(elem) for elem in input().split(' ')])
v_list_odd = v_list[::2]
v_list_even = v_list[1::2]
ctr_odd = Counter(v_list_odd)
ctr_even = Counter(v_list_even)

# O(NlogN)
most_commons_odd = ctr_odd.most_common()
most_commons_even = ctr_even.most_common()
if len(most_commons_odd) == 1 and len(most_commons_even) == 1 \
and most_commons_odd[0][0] == most_commons_even[0][0]:
    print(len(v_list_even))
    exit(0)

odd_cand = []
even_cand = []
distinct_num = set()
i = 0
while len(distinct_num) < 2:
    try:
        odd_elem = most_commons_odd[i]
        distinct_num.add(odd_elem[0])
        odd_cand.append(odd_elem)
    except:
        pass
    try:
        even_elem = most_commons_even[i]
        distinct_num.add(even_elem[0])
        even_cand.append(even_elem)
    except:
        pass
    i += 1

min_cost = 2**32 - 1
len_allodds = len(v_list_odd)
len_allevens = len(v_list_even)
for odd_elem in odd_cand:
    for even_elem in even_cand:
        if odd_elem[0] == even_elem[0]:
            continue
        else:
            min_cost = min(min_cost, \
            (len_allodds - odd_elem[1]) + (len_allevens - even_elem[1]))
print(min_cost)


Measured memory_bytes: 21936
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
field=[0]+["#"+input()+"#" for i in range(h)]+[0]
field[0],field[-1]="#"*(w+2),"#"*(w+2)
l,r,u,d=[[0 for i in range(w+2)] for i in range(h+2)],[[0 for i in range(w+2)] for i in range(h+2)],[[0 for i in range(w+2)] for i in range(h+2)],[[0 for i in range(w+2)] for i in range(h+2)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if field[i][j]=="#":continue
    l[i][j]=l[i][j-1]+1
    u[i][j]=u[i-1][j]+1
for i in range(1,h+1)[::-1]:
  for j in range(1,w+1)[::-1]:
    if field[i][j]=="#":continue
    r[i][j]=r[i][j+1]+1
    d[i][j]=d[i+1][j]+1
ans=0
for i in range(h+2):
  for j in range(w+2):
    c=l[i][j]+r[i][j]+u[i][j]+d[i][j]-3
    if c>ans:ans=c
print(ans)


Measured memory_bytes: 180488
H,W = map(int,input().split())
S = [input() for _ in range(H)]

for i in range(H):
    A = ""
    for j in range(W):
        if S[i][j] == "#":
            A += "#"
        else:
            C = 0
            for SS in S[max(0,i-1):min(H,i+2)]:
                C += SS[max(0,j-1):min(W,j+2)].count("#")
            A += str(C)
    print(A)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String n = sc.nextLine();
		for (int i = 0; i < Integer.parseInt(n); i++) {
			String[] str = sc.nextLine().split(" ");
			int[] list = new int[10];
			ArrayList<Integer> listA = new ArrayList<Integer>();
			ArrayList<Integer> listB = new ArrayList<Integer>();
			listA.add(0);
			listB.add(0);
			for (int j = 0; j < str.length; j++) {
				list[j] = Integer.parseInt(str[j]);
			}
			for (int j = 0; j < list.length; j++) {
				if(list[j] - listA.get(listA.size() - 1) > 0){
					listA.add(list[j]);
				} else if(list[j] - listB.get(listB.size() - 1) > 0){
					listB.add(list[j]);
				} else {
					System.out.println("NO");
					break;
				}

				if(list.length - 1 == j){
					System.out.println("YES");
				}
			}
		}
	}
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N, person;
    ll ans=1;
    int hat_num[3]={0,0,0};
    cin >> N;
    REP(i,0,N){
        cin >> person;
        int num=0;
        REP(j,0,3){
            if(hat_num[j]==person) num++;
        }
        ans = (ans * num) % MOD;
        REP(j,0,3){
            if(hat_num[j]==person){
                hat_num[j]++;
                break;
            }
        }
    }
    P(ans);
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n');
  const N = Number(s[0]);
  const buttons = s.slice(1, -1).map(n => Number(n));

  let ans = -1;

  for (var i = 1, j = 0; i <= N; i++) {
    j = buttons[j] - 1;

    if (j === 1) {
      ans = i;
      break;
    }
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 16740
import java.util.Scanner;

class Circle {
	public float xx;
	public float yy;
	public float rr;
	public void Cricle(float x, float y, float r) {
		if(x<-1000||x>1000||y<-1000||y>1000) {
			System.out.println("error");
		}
		else if(r>1000||r<1) {
			System.out.println("error");
		}else {
			this.xx=x;
			this.yy=y;
			this.rr=r;
		}
	}
	public float getx() {
		return xx;
	}
	public float gety() {
		return yy;
	}
	public float getr() {
		return rr;
	}	
}

public class Main {
	static Circle C1,C2;
	public static void main(String[] args) {
		C1= new Circle();
		C2= new Circle();
		listenC();
		judge();
	    
	}
	public static void listenC() {
		Scanner scanner=new Scanner(System.in);
		float c1x=scanner.nextFloat();
		float c1y=scanner.nextFloat();
		float c1r=scanner.nextFloat();
		float c2x=scanner.nextFloat();
		float c2y=scanner.nextFloat();
		float c2r=scanner.nextFloat();
		C1.Cricle(c1x, c1y, c1r);
		C2.Cricle(c2x, c2y, c2r);
		if (C1==C2)System.out.println("error");
	}
	private static void judge() {
		double i;
		i=Math.sqrt((C1.getx()-C2.getx())*(C1.getx()-C2.getx())+(C1.gety()-C2.gety())*(C1.gety()-C2.gety()));
		if(i>C1.getr()+C2.getr())    
			System.out.println(4);
		else if(i==Math.abs(C1.getr()+C2.getr()))    
			System.out.println(3);
		else if(i>Math.abs(C1.getr()-C2.getr())&&i<C1.getr()+C2.getr())   
			System.out.println(2);
		else if(i==Math.abs(C1.getr()-C2.getr()))     
			System.out.println(1);
		else             
			System.out.println(0);
	}
}


Measured memory_bytes: 28068
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a, b, c,k;
  cin >> a>> b >>c >> k;
  for(int i=0;i<k;i++){
    if((a>b)&&(a>c)){
      a*=2;
    }
    else if((b>c)&&(b>a)){
      b*=2;
    }
    else{
      c*=2;
    }
  }
  int d=(a+b+c);
  cout << d << endl;
}


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

int main() {
  std::vector<int> v(5);
  for(int i=0;i<5;i++) cin >> v.at(i);
  for(int i=0;i<5;i++){
    if(v.at(i) == 0) cout << i+1 << endl;
  }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int (i)=0;(i) < (N); (i)++)
#define all(V) V.begin(), V.end()
using i64 = int_fast64_t;
using P = pair<int,int>;

int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    rep(i,N) cin >> W[i];
    int low = 0,high = 0;
    rep(i, N) high += W[i];

    int ans = high;
    for(int i = 0; i < N; i++){
        low += W[i];
        high -= W[i];
        ans = min(ans, abs(high - low));
    }

    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 FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;

VLL dp(8,0);


int main() {
	int h, w, k;
	cin >> h >> w >> k;
	dp[0] = 1;
	if (w == 1) {
		cout << 1 << endl;
		return 0;
	}
	REP(l, h) {
		VLL dpp(8, 0);
		REP(i, (1 << w - 1)) {
			bool b = true;

			REP(j, 8) if (i&(1 << j) && i&(1 << (j + 1))) {
				b = false;
				break;
			}
			if (!b)continue;
			REP(j, w) {
				if (i&(1 << j)) {
					dpp[j + 1] += dp[j];
					dpp[j] += dp[j + 1];
					dpp[j + 1] %= mod;
					dpp[j] %= mod;
					j++;
				}
				else {
					dpp[j] += dp[j];
					dpp[j] %= mod;
				}

			}

		}
		dp = dpp;
	}
	cout << dp[k - 1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
const ll mod=1e9+7;
const ll N=200005;
int main()
{
    ll n;
    cin>>n;
    int a[N],b[N];
    ll ans=0;
    a[0]=0;
    b[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        b[i]=(b[i-1]+a[i])%mod;
    }
    for(int i=1;i<n;i++){
        ans=(ans+((b[n]-b[i]+mod)%mod)*a[i])%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5212
#include <iostream>
#include <cstdio>
#define MAX 30
using namespace std;

int main(void)
{
	int lot[MAX], w, n;
	cin >> w >> n;
	for (int i = 0; i < w; i++) lot[i] = i+1;
	for (int i = 0; i < n; i++) {
		int a, b, tmp;
		scanf("%d,%d", &a, &b);
		tmp = lot[a-1];
		lot[a-1] = lot[b-1];
		lot[b-1] = tmp;
	}
	for (int i = 0; i < w; i++) cout << lot[i] << endl;
	
	return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 1e5+5;
const ll INF = 1e13+7;

ll N,M,S,T;
vector<vector<ll> > node;

ll dijkstra(ll s, ll e){
  priority_queue<tuple<ll,ll,ll>, vector<tuple<ll,ll,ll> >, greater<tuple<ll,ll,ll> >  > PQ;
  vector< vector<ll> > d(N, vector<ll>(3,INF));

  // start, mod, cost
  d[s][0] = 0;
  // start, mod, cost
  PQ.push(make_tuple( s, 0, 0));

  while(!PQ.empty()){
    tuple<ll ,ll, ll> f = PQ.top(); PQ.pop();
    ll now = get<0>(f);
	ll mod = get<1>(f);
	ll cost = get<2>(f);
    for(int j=0;j<node[now].size();j++){
      ll next = node[now][j];
	  ll nmod = (mod+1) % 3;
	  ll ncost = cost + 1;
      if(d[next][nmod] > d[now][mod] + 1){
        d[next][nmod] = d[now][mod] + 1;
        PQ.push(make_tuple(next, nmod, ncost) );
      }
    }
  }
  return (d[e][0] == INF) ? -1 : (d[e][0]/3);
}

signed
main(){
	cin >> N >> M;
	node = vector<vector<ll> >(N+4);
	for(int i=0;i<M;i++) {
		ll u,v;
		cin >> u >> v;
		u--, v--;
		node[u].push_back(v);
	}
	cin >> S >> T;
	S--, T--;

	cout << dijkstra(S,T) << endl;
}

Measured memory_bytes: 14316
import java.util.Scanner;

public class Main {

	public static void main(String... nui) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();

		int[] n = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		
		System.out.println(n[k - 1]);
		
	}

}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  for (int i=0;i<n;i++){
    cin >> a[i];
  }
  int count = 0;
  for (int i=0;i<n;i++) {
    int minj = i;
    for (int j=i;j<n;j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    if (i != minj) {
      int tmp = a[i];
      a[i] = a[minj];
      a[minj] = tmp;
      count += 1;
    }
  }
  cout << a[0];
  for (int i=1;i<n;i++){
    cout << ' ' << a[i];
  }
  cout << endl << count << endl;
}


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

int main(){

	int N, L;
	char **S;
	int i,j,mini;
	int res;
	int *check;
	scanf("%d %d", &N, &L);
	
	check = (int*)malloc(sizeof(int) * N);
	
	S = (char**)malloc(sizeof(char*) * N);
	for(i = 0; i<N; i++){
		S[i] = (char*)malloc(sizeof(char) * (L+1));
	}

	for(i = 0; i<N; i++){
		check[i] = 0;
		scanf("%s",S[i]);
	}
/*
	for(i=0; i<N; i++)
		printf("%s\n", S[i]);
*/
	mini=0;
	for(j=0; j<N; j++){
		for(i =0; i<N; i++){
			if(check[i] == 0){
				res = strcmp(S[i],S[mini]);
				if(res < 0)
					mini = i;
			}
		}
		// ここでminiはチェックされてない単語で最小のものを指して胃rる
		printf("%s", S[mini]);
		check[mini] = 1;
		
		for(i=0; i<N; i++){
			if(check[i] == 0){
				mini = i;
				break;
			}			
		}
	}

	return 0;


}	


Measured memory_bytes: 128
<?php
  list($s) = explode(" ", trim(fgets(STDIN)));

  $s = strrev($s);

  while($s != ""){
    if(substr($s, 0, 5) == 'maerd'){
      $s = substr($s, 5);
      continue;
    }
    if(substr($s, 0, 7) == 'remaerd'){
      $s = substr($s, 7);
      continue;
    }
    if(substr($s, 0, 5) == 'esare'){
      $s = substr($s, 5);
      continue;
    }
    if(substr($s, 0, 6) == 'resare'){
      $s = substr($s, 6);
      continue;
    }
    echo "NO";
    exit;
  }
  echo "YES";

Measured memory_bytes: 16548
#include <stdio.h>

void Do(int N, int M){
  int i, j, c, A, K;
  int C[M];
  for(i = 0;i < M;i++) C[i] = 0;
  for(i = 0;i < N;i++){
    scanf("%d", &K);
    for(j = 0;j < K;j++){
      scanf("%d", &A);
      C[A-1]++;
    }
  }
  c = 0;
  for(i = 0;i < M;i++) if(C[i] == N) c++;
  printf("%d\n", c);
}

int main(void){
  int N, M;
  scanf("%d %d", &N, &M);
  Do(N, M);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n[3]={};
  int a=0,b=0,c=0;
  
  for(int i=0;i<3;i++){
    cin>>n[i];
    if(a<n[i]){
      c=b;
      b=a;
      a=n[i];
    }
    else if(a>=n[i] && b<n[i]){
      c=b;
      b=n[i];
    }
    else c=n[i];
  }
  int cnt=0,cnt2=0;
  if(a-b!=0){cnt=a-b;c+=cnt;}
  cnt2+=(a-c)/2;
  c+=cnt2*2;
  if(c!=a)cnt+=2;
  cnt+=cnt2;
  cout<<cnt<<endl;
  return 0;
}


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

using namespace std;

#define roop(i, n) for(int i = 0;i < n;i++)
#define ll long long int

int main(void){

    vector<int> h, w;

    int count = 0;
    while(1){
        int a, b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        h.push_back(a);
        w.push_back(b);
        count++;
    }

    for(int i = 0;i < count;i++){
        for(int j = 0;j < h[i];j++){
            for(int k = 0;k < w[i];k++){
                if(0 < j && j < h[i]-1 && 0 < k && k < w[i]-1) cout << '.';
                else cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }



    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int L[M], R[M];
    for (int i = 0; i < M; i++) {
        cin >> L[i] >> R[i];
    }

    int MIN = 1000000;
    int MAX = 0;

    for (int i = 0; i < M; i++) {
        MIN = min(MIN, R[i]);
    }

    for (int i = 0; i < M; i++) {
        MAX = max(MAX, L[i]);
    }

    if (MAX > MIN) cout << 0 << endl;
    else {
        int ans = MIN-MAX+1;
        cout << ans << endl;
    } 
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cassert>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

ll pibot;

ll nibutan(ll l, ll u, ll search_num){
//	cout<<"nsn"<<search_num<<endl;
	ll low = l;
	ll up = u;

	pibot = (low + up) / 2;
//	cout<<"a"<<endl;
	while(low < up){
		pibot = (low + up) / 2;
		//cout<<pibot<<endl;
//		if(abs(pibot) > 8000){//8192
//			return 0;
//		}
		ll number = pibot * pibot * pibot * pibot * pibot;
//		cout<<"num : "<<number<<endl;
		if( number == search_num){
			return 1;
		}else if(number < search_num){
			low = pibot+1;
		}
		else{
			up = pibot-1;
		}
//		cout<<low<<" "<<up<<endl;
	}
	return 0;
}

int main(){
	ll X;
	cin>>X;
	ll ans;
	ll i = 0;

	ll ansA,ansB;

	for(ll A = -8000; A <=8000;A++){
		for(ll B = -8000; B <=8000; B++){
			ll sum = A*A*A*A*A - B*B*B*B*B;
			if(sum == X){
				ansA = A;
				ansB = B;
				break;
			}
		}
	}

	cout<<ansA<<" "<<ansB<<endl;
	return 0;
//	ll A,B;
//	while(i < INT_MAX){
//		//assert(i < 2);
//		ll sn = X + i*i*i*i*i;
//		A = nibutan(-1000,1000,sn);
//		if(A != 0){
//			A = pibot;
//			B = i;
//			break;
//		}
//		sn = X - i*i*i*i*i;
//		//cout<<"sn"<<sn<<endl;
//		A = nibutan(-1000,1000,sn);
//		if(A != 0){
//			A = pibot;
//			B = -i;
//			break;
//		}
//		i++;
//	}

//	cout<<A<<" "<<B<<endl;
//	return 0;
}


Measured memory_bytes: 3600
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
m1 = [-1 for i in range(n)]
j = 0
for i in range(n):
    while j < n:
        if a[j] < b[i]:
            m1[i] = j
            break
        j += 1
m3 = [-1 for i in range(n)]
j = 0
for i in range(n):
    while j < n:
        if b[j] < c[i]:
            m3[i] = j
            break
        j += 1
temp = 0
m2 = []
for i in m1[::-1]:
    if i == -1:
        m2.append(0)
    else:
        m2.append(temp + (n-i))
        temp = m2[-1]
m2.reverse()
ans = 0
for i in m3:
    if i != -1:
        ans += m2[i]
print(ans)
# print(m1)
# print(m2)
# print(m3)


Measured memory_bytes: 28340
#include<bits/stdc++.h>
using namespace std;
int main () {
  int sx, sy, gx, gy;
  int N;
  cin >> gx >> gy >> N;
  sx = sy = 0;
  for (int i = 0; i < N; i ++) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) sx = max(sx, x);
    if (a == 2) gx = min(gx, x);
    if (a == 3) sy = max(sy, y);
    if (a == 4) gy = min(gy, y);
  }
  if (sx >= gx || sy >= gy) {
    cout << 0 << endl;
    return 0;
  }
  cout << (gx - sx) * (gy - sy) << endl;
}


Measured memory_bytes: 256