akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String S = next();

        if (S.equals("SUN")) {
        	println("7");
        } else if (S.equals("MON")) {
        	println("6");
        } else if (S.equals("TUE")) {
        	println("5");
        } else if (S.equals("WED")) {
        	println("4");
        } else if (S.equals("THU")) {
        	println("3");
        } else if (S.equals("FRI")) {
        	println("2");
        } else if (S.equals("SAT")) {
        	println("1");
        }
    }

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }
}

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

int L, N, X[200000];
ll r[200001], l[200001], MAX;
int main()
{
	cin >> L >> N;
	for (int i = 0; i < N; ++i)
    {
        cin >> X[i];
    }
	for (int i = 0; i < N; ++i)
    {
        l[i + 1] = l[i] + X[i] * 2;
    }
	for (int i = N - 1; i >= 0; --i)
    {
        r[i] = r[i + 1] + (L - X[i]) * 2;
    }
	for (int i = 0; i < N; ++i)
    {
		ll cnt = X[i];
		if (i >= N - (i + 1))
		{
			cnt += r[i + 1];
			cnt += l[i] - l[i - (N - (i + 1))];
		}
		else
		{
			cnt += l[i];
			cnt += r[i + 1] - r[i + 1 + i + 1];
		}
		MAX = max(MAX, cnt);

		cnt = L - X[i];
		if (i <= N - (i + 1))
		{
			cnt += l[i];
			cnt += r[i + 1] - r[i + 1 + i];
		}
		else
		{
			cnt += r[i + 1];
			cnt += l[i] - l[i - (N - (i + 1)) - 1];
		}
		MAX = max(MAX, cnt);
	}

	cout << MAX << endl;

	return 0;
}


Measured memory_bytes: 4096
<?php
fscanf(STDIN,"%d\n",$n);
$pos=0;
for($i=2;$pos<$n;$i++){
    if($i%5==1){
        $ng=0;
        for($j=2;$j<$i;$j++){
            if($i%$j==0){
              $ng=1;
              break;
            }
        }
        if($ng==0){
            $pos++;
            echo $i,"\n";
        }
    }
    echo "\n";
}
?>

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

// n! の末尾 0 の数を返す
// O(log N) くらい
ll FactorialZeroCnt(ll n) {
    ll ret = 0;
    ll cur = 5;
    while(n >= cur) {
        ret += n / cur;
        cur *= 5;
    }
    return ret;
}

// n!! の末尾 0 の数を返す
// O(log N) くらい
ll DoubleFactorialZeroCnt(ll n) {
    if(n % 2 != 0) { return 0; }
    return FactorialZeroCnt(n / 10) + n / 10;
}

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;

    ll ans = DoubleFactorialZeroCnt(N);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split(' '))
S = list(input())

passed_num = 0
limit = A + B
ranking_foreign = 1

results = []

for examinee in S:
    if passed_num < limit:
        if examinee == 'a':
            passed_num += 1
            results.append('Yes')
        elif examinee == 'b':
            if ranking_foreign <= B:
                passed_num += 1
                ranking_foreign += 1
                results.append('Yes')
            else:
                results.append('No')
        elif examinee == 'c':
            results.append('No')
    else:
        results.append('No')

for result in results:
    print(result)


Measured memory_bytes: 10388
#include<iostream>

using namespace std;

int main(){
	int n,h,w;
	cin >> n >> h >> w;
	int ans = 0;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		if(h <= a && w <= b)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)



def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def solve(H: int, W: int, M: int, _h: "List[int]", _w: "List[int]"):
    H_count = [0] * (H+1)
    W_count = [0] * (W+1)
    G = set()
    seenH = set()
    seenW = set()
    for i in range(M):
        h,w=_h[i],_w[i]
        H_count[h] += 1
        W_count[w] += 1
 
        seenH.add(h)
        seenW.add(w)
        G.add((h,w))
    
    Hs = []
    Ws = []
    for i in range(max(H,W)+1):
        if i < len(H_count):
            count = H_count[i]
            if count > 0:
                Hs.append((count,i))
 
        if i < len(W_count):
            count = W_count[i]
            if count > 0:
                Ws.append((count,i))
 
 
    Hs.sort(reverse=True)
    Ws.sort(reverse=True)
 
    # print(Hs)
    # print(Ws)
 
    h_count,h = Hs[0]
    w_count,w = Ws[0]
 
    original = h_count + w_count
    ans = original
    if (h,w) in G:
        # print("a")
        ans -= 1
 
        i = 1
        sameH = []
        while i < len(Hs) and Hs[i][0] == h_count:
            # print("h")
            h = Hs[i][1]
            i += 1
            sameH.append(h)
        
        i = 1
        sameW = []    
        while i < len(Ws) and Ws[i][0] == w_count:
            w = Ws[i][1]
            i += 1
            sameW.append(w)
           
        max_mass = (len(sameH)+1) * (len(sameW)+1)
 
        # print(max_mass)
        on_bom_count = 0
        for h,w in G:
            count = H_count[h] + W_count[w]
            if count == original:
                on_bom_count += 1
        
        if max_mass - on_bom_count > 0:
            ans += 1
 
                
    print(ans)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    h = [int()] * (M)  # type: "List[int]"
    w = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        h[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(H, W, M, h, w)



if __name__ == "__main__":
    main()


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

long long int burger(int n, long long int x) {
    if (x == 0) {
        return 0;
    }
    if (n == 0) {
        return 1;
    }
    x = std::min(x, (long long int) (1ll << (n + 2)) - 3);
    if (x < (1ll << (n + 1)) - 1) {
        return burger(n - 1, x - 1);
    }
    else {
        return (1ll << (n)) + burger(n - 1, x - (1ll << (n + 1)) + 1);
    }
}

int main() {
    int n;
    long long int x;
    scanf("%d%lld", &n, &x);
    printf("%lld", burger(n, x));
    return 0;
}


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

#define MAXN 200010
#define MAXTAM 200010

#define INF 1000000007

using namespace std;

int n;
int c[MAXN];
int z[MAXN];
int pos[MAXTAM];
int pd[MAXN];

int main() {
    scanf("%d", &n);
    int i;
    for (i=1; i<=n; i++) {
        scanf("%d", &c[i]);
    }

    memset(pos, -1, sizeof(pos));
    memset(z, -1, sizeof(z));

    for (i=1; i<=n; i++) {
        if (pos[c[i]]!=-1) {
            z[i]=pos[c[i]];
        }
        pos[c[i]]=i;
        //printf("%d: %d\n", i, z[i]);
    }
   // printf("*****\n");
    pd[0]=1;
    for (i=1; i<=n; i++) {
        if (z[i]==-1) {
            pd[i]=pd[i-1];
        }
        else {
            if (z[i]==i-1) {
                pd[i]=pd[i-1];
            }
            else {
                pd[i]=pd[i-1] + pd[z[i]];
            }
        }
        pd[i]%=INF;
        //printf("pd[%d] = %d\n", i, pd[i]);
    }

    printf("%d\n", pd[n]);

    return 0;
}


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

using namespace std;

#define debug(x) cout << "\n" << __LINE__ << " " <<  (#x) << " is " << (x) << endl

int main(){
	#ifdef EVAL	
		freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int N;
	cin >> N;
	multiset <int> S;
	S.insert(-1);
	S.insert(INT_MAX);
	for(int i = 0, x; i < N; i++){
		cin >> x;
		multiset<int>::iterator it = S.lower_bound(x);
		it--;
		if((*it) == -1){
			S.insert(x);
		}else{
			S.erase(it);
			S.insert(x);
		}
	}
	cout << S.size() - 2;
	return 0;
}

Measured memory_bytes: 4992
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-05-20 00:06:13
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , A[MAXN] , ans[MAXN] , mx = 0 , Mx[MAXN];
set<pll> st;
vector<ll> vec;

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

    cin >> n;
    for(int i = 0 ; i < n ; i++){
        cin >> A[i];
        vec.push_back(A[i]);
    }
    sort(all(vec));
    for(int i = 0 ; i < n ; i++){
        if(A[i] > mx){
            ll ind = lower_bound(all(vec) , A[i]) - vec.begin();
            ll cnt = n - ind;
            ans[i] = cnt * (A[i] - mx);
            Mx[i] = mx;
            mx = A[i];
            st.insert({A[i] , i});
        }
        else{
            auto it = (st.lower_bound({A[i] , INF}));
            if(it == st.end())  continue;
            pll x = (*it);
            ans[x.Y] += A[i] - Mx[x.Y];
        }
    }
    for(int i = 0 ; i < n ; i++)    cout << ans[i] << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 17012
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		while(true) {
			int N=sc.nextInt();
			if(N==0) {
				System.exit(0);
			}
			int zen=0;
			int ko=0;
			for(int i=0; i<N; i++) {
				int a=sc.nextInt();
				int b=sc.nextInt();
				if(a<b) {
					ko+=(a+b);
				}
				else if(a>b) {
					zen+=(a+b);
				}
				else {
					zen+=a;
					ko+=b;
				}
			}
			pl(zen+" "+ko);
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}



Measured memory_bytes: 30620
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	bool a, b, c;
	a = b = c = false;
	for (int i = 0; i < 3; i++) {
		char ch;
		cin >> ch;
		if (ch == 'a') a = true;
		if (ch == 'b') b = true;
		if (ch == 'c') c = true;
	}
	if (a && b && c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int a;
    cin >> a;
    cout << 3*pow(a,2) << endl;

    return 0;
}

Measured memory_bytes: 256
open System

module Procedure =
    let procedure a b =
        let producted = a * b
        if producted % 2 = 0 then "Even" else "Odd"

[<EntryPoint>]
let main _argv =
    let inputNumbers = stdin.ReadLine().Split(' ') |> Array.map int |> Array.toList
    let a = inputNumbers.[0]
    let b = inputNumbers.[1]
        
    Procedure.procedure a b |> printfn "%s"
    0
 

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

n = int(input())
v = list(map(int, input().split()))

former = []
latter = []
counter = 0
for node in v:
    if(counter % 2 == 0):
        former.append(node)
    else:
        latter.append(node)
    counter += 1

forlen = len(former)
latlen = len(latter)

forfreq = [0] * forlen
latfreq = [0] * latlen

former_sorted = sorted(former)
latter_sorted = sorted(latter)

# 最頻値を求める
counter = 0
for_val_num = []
next_idx = 0
for i in range(forlen):
    if(former_sorted[i] == former_sorted[next_idx]):
        counter += 1
    else:
        for_val_num.append([former_sorted[next_idx], counter])
        next_idx = i
        counter = 1
    if (i == forlen - 1):
        for_val_num.append([former_sorted[next_idx], counter])

forfreqidx1 = 0

for i in range(len(for_val_num)):
    if(for_val_num[i][1] > for_val_num[forfreqidx1][1]):
        forfreqidx1 = i

# 第1位最頻値の出現回数
forfreqnum1 = for_val_num[forfreqidx1][1]

# 最頻値を求める
counter = 0
lat_val_num = []
next_idx = 0
for i in range(latlen):
    if(latter_sorted[i] == latter_sorted[next_idx]):
        counter += 1
    else:
        lat_val_num.append([latter_sorted[next_idx], counter])
        next_idx = i
        counter = 1
    if (i == latlen - 1):
        lat_val_num.append([latter_sorted[next_idx], counter])

latfreqidx1 = 0

for i in range(len(lat_val_num)):
    if(lat_val_num[i][1] > lat_val_num[latfreqidx1][1]):
        latfreqidx1 = i

# 第1位最頻値の出現回数
latfreqnum1 = lat_val_num[latfreqidx1][1]

# 同じ数だった時
if(for_val_num[forfreqidx1][0] == lat_val_num[latfreqidx1][0]):
    # 第1位最頻値の出現回数を0にする
    for_val_num[forfreqidx1][1] = 0
    lat_val_num[latfreqidx1][1] = 0

    forfreqidx2 = 0

    for i in range(len(for_val_num)):
        if (for_val_num[i][1] > for_val_num[forfreqidx2][1]):
            forfreqidx2 = i

    # 第2位最頻値の出現回数
    forfreqnum2 = for_val_num[forfreqidx2][1]

    latfreqidx2 = 0

    for i in range(len(lat_val_num)):
        if (lat_val_num[i][1] > lat_val_num[latfreqidx2][1]):
            latfreqidx2 = i

    # 第1位最頻値の出現回数
    latfreqnum2 = lat_val_num[latfreqidx2][1]

    if(forfreqnum1 - forfreqnum2 >= latfreqnum1 - latfreqnum2):
        print((forlen - forfreqnum1) + (latlen - latfreqnum2))
    else:
        print((forlen - forfreqnum2) + (latlen - latfreqnum1))
else:
    print((forlen - forfreqnum1) + (latlen - latfreqnum1))

Measured memory_bytes: 19812
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
#include <map>
#include <list>

using namespace std;

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

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

int main()
{
	int N, M;
	while( cin >> N >> M, N || M ) {
		priority_queue< P > que;
		REP( i, N ) {
			int d, p;
			cin >> d >> p;
			que.push( P( p, d ) );
		}
		int ans = 0;
		while( !que.empty() ) {
			int d = que.top().second, p = que.top().first;  que.pop();
			if( M >= d ) M -= d;
			else if( M > 0 ) {
				ans += ( d - M ) * p;
				M = 0;
			}
			else ans += d * p;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1328
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;

int n, x, t;

int main() {
	scanf("%d%d%d", &n, &x, &t);
	int _ = ceil(1.0*n/x);
	printf("%d\n", _*t);
	return 0;
}

Measured memory_bytes: 3720
// Author: raghav_0901
#include<bits/stdc++.h>
#define int long long int
#define f(i,s,e) for(i=s;i<e;++i)
#define fr(i,s,e) for(i=s;i>=e;i--)
#define ff(i,s,e,f) for(i=s;i<e && f;++i)
#define mem(arr,val) memset(arr, val, sizeof(arr))
#define mems(arr, val, n) memset(arr, val, n)
#define vec vector<int>
#define pr pair<int,int>
#define lim 1000000
#define mod 1000000007
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

double pow(double n)
{
    return n*n*n;
}

signed main()
{
    Arena
    register int i,j,num,t=1;
    //cin>>t;
    while(t--)
    {
        double n;cin>>n;
        vec v(n);
        map<int,int> mp;
        for(int &x:v)
        {
            cin>>x;
            mp[x]++;
        }
        int ans=0;
        for(auto it:mp)
        {
            int x=it.second;
            ans+=(x*(x-1))/2;
        }
        for(int x:v)
        {
            int z = mp[x];
            int temp = ans - ((z*(z-1))/2);
            temp+=((z-1)*(z-2))/2;
            cout<<temp<<endl;
        }
    }
    return 0;
}

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

const ll INF = 1e9+5;

void solution(){
	ll n;
	cin>>n;
	vector<ll> h(n);
	for(ll& x: h){
		cin>>x;
	}
	vector<ll> dp(n,INF);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(ll i=2;i< n;++i)
		dp[i] = min(dp[i-1]+ abs(h[i-1] - h[i]),dp[i-2] + abs(h[i-2] - h[i]));
	cout<<dp[n-1]<<'\n';
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cerr.tie(0);
	solution();
	return 0;
}

Measured memory_bytes: 4672
import numpy as np

N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h = np.array(sorted(h))
diff_h = np.zeros(N, dtype=np.int32)
diff_h[1:] = np.diff(h)
# print(h)
# print(diff_h)
cum_diff_h = np.cumsum(diff_h)
# print(cum_diff_h)
s = cum_diff_h[K - 1 :] - cum_diff_h[: -K + 1]
# print(s)
print(min(s))

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

int main()
{
    char s[16];
    int i;
    int tmp = 0;

    cin >> s;

    for(i = 0; s[i]; i++)
      if(s[i] == '+')
        tmp += 1;
      else if(s[i] == '-')
        tmp -= 1;

    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var M = items[1];
            var X = items[2];
            var books = Enumerable.Range(0, N).Select(i => Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToList()).ToList();

            var answer = int.MaxValue;
            foreach (var bit in Enumerable.Range(0, 1 << N))
            {
                var totalPrice = 0;
                var algoSums = Enumerable.Range(0, M).Select(elem => 0).ToArray();
                var chooseBooks = books.Where((elem, idx) => ((bit & (1 << idx)) != 0)).ToList();
                chooseBooks.ForEach(book =>
                {
                    totalPrice += book[0];
                    algoSums = algoSums.Zip(book.Where((elem, idx) => idx >= 1), (s, c) => s + c).ToArray();
                });

                if (algoSums.All(elem => elem >= X))
                {
                    answer = Math.Min(answer, totalPrice);
                }
            }

            Console.WriteLine(answer == int.MaxValue ? -1 : answer);
        }
    }
}


Measured memory_bytes: 41360
/**
 *      purpose : ABC 116 B
 *      author  : kyomukyomupurin
 *      created : 2019-01-20 21:02:29
**/

#include <bits/stdc++.h>
using namespace std;
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

int func(int n){
    if (n & 1) return 3 * n + 1;
    else return n / 2;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int s; cin >> s;

    int used[1000001] = {};

    used[s] = 1;
    int cnt = 1;

    while (1){
        s = func(s);
        ++used[s]; ++cnt;
        if (used[s] == 2) {
            print(cnt); return 0;
        }
    }

    
    return 0;
}

Measured memory_bytes: 4224
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int H=sc.nextInt();
		int W=sc.nextInt();
		
		String v[]=new String[H];
		
		for(int i=0;i<H;i++) {
			v[i]=sc.next();
			
		}
		for(int i=0;i<H;i++) {
			p(v[i]);
			p(v[i]);
		}
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class InfiniteString
    {
        private readonly int K;
        private int n = 0;
        private Dictionary<int, int> letters = new Dictionary<int, int>();
        public InfiniteString(int K)
        {
            this.K = K;
        }
        public bool Cut(int N)
        {
            n = N;
            for (int i = n - 1; i >= 0; --i)
            {
                if (letters.ContainsKey(i))
                {
                    int k = letters[i];
                    if (k < K - 1)
                    {
                        letters[i] = k + 1;
                        return true;
                    }
                    else
                    {
                        letters.Remove(i);
                    }
                }
                else
                {
                    if (K > 1)
                    {
                        letters[i] = 1;
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            return false;
        }
        public void Expand(int N)
        {
            foreach (int key in letters.Keys.Where(i => n <= i && i < N).ToArray())
            {
                letters.Remove(key);
            }
            n = N;
        }
    }

    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }

        static bool CanMake(int[] A, int k)
        {
            int n = 0;
            var str = new InfiniteString(k);
            foreach (int a in A)
            {
                if (a <= n)
                {
                    if (!str.Cut(a)) { return false; }
                }
                else
                {
                    str.Expand(a);
                }
                n = a;
            }
            return true;
        }

        static int Solve(int N, int[] A)
        {
            if (CanMake(A, 1)) { return 1; }
            int l = 1;
            int r = N;
            while (r - l >= 2)
            {
                int i = (l + r) / 2;
                if (CanMake(A, i)) { r = i; } else { l = i; }
            }
            return r;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] A = ReadInts();
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 46508
#include <bits/stdc++.h>
#define R(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    int i,k=1500,m2=1500,m1=1500;
    char a[3000];
    string s;
    cin>>s;
    a[k]=s[0];
    for(i=1;i<s.size();i+=3){
      if(s[i]=='-')k--;
      else k++;
      a[k]=s[i+2];
      m1=max(m1,k);
      m2=min(m2,k);
    }
    for(i=m1;i>=m2;i--)cout<<a[i];
      cout<<endl;
  }
}

Measured memory_bytes: 3128
#include<stdio.h>

int search(int a[], int strt, int end, int m)
{
    for(int i = strt; i < end; i++){
        if (a[i] == m) {
            return 1;
        }
        if (search(a, i + 1, end, m - a[i]))
            return 1;       
    }
    return 0;
}

int main()
{
    int n, q;

    scanf("%d", &n);

    int a[n];

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

    scanf("%d", &q);

    int m[q];

    for(int i = 0; i < q; i++){
        scanf("%d", &m[i]);
    }

    for (int i = 0; i < q; i++){
        if (search(a, 0, n , m[i])) 
            printf("yes\n");
        else
            printf("no\n");
    
        
        
    }


}


Measured memory_bytes: 2696
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const INF = 1e9;

int main() {
  int N, M, X; std::cin >> N >> M >> X;
  int ans = INF;
  std::vector<std::vector<int>> A(N, std::vector<int>(M));
  std::vector<int> C(N);
  for(int i = 0; i < N; ++i) {
    std::cin >> C[i];
    for(int j = 0; j < M; ++j) std::cin >> A[i][j];
  }
  for(int s = 0; s < (1<<N); ++s) {
    int p = 0;
    std::vector<int> c(M, 0);
    for(int i = 0; i < N; ++i)if((1<<i)&s) {
      p += C[i];
      for(int j = 0; j < M; ++j) c[j] += A[i][j];
    }
    bool ok = true;
    for(int j = 0; j < M; ++j) if(c[j] < X) ok = false;
    if(ok) ans = std::min(ans, p);
  }
  if(ans == INF) ans = -1;
  fin(ans);
  return 0;
}


Measured memory_bytes: 3636
N = int(input())
pt, px, py = 0, 0, 0
for i in range(N):
  t, x, y = map(int, input().split())
  dt = t - pt
  d = abs(x - px) + abs(y - py)
  if d > dt or (d - dt) % 2 == 1:
    print('No')
    exit()
  pt, px, py = t, x, y
print('Yes')

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

ll X,Y;

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

	int ans = 1;
	while(X * 2 <= Y){
		X *= 2;
		ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];

            for (int i = 1; i <= 1000; i++)
            {
                if ((int)(i * 0.08) == A && (int)(i * 0.1) == B)
                {
                    Console.WriteLine(i);
                    return;
                }
            }
            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <utility>
#include <vector>
using namespace std;

char s[500001];
int main() {
  int n, q, x, l, r;
  char c[5];
  set<int> se[26];
  scanf("%d", &n);
  scanf("%s", s);
  scanf("%d", &q);
  for (int i = 0; i < n; i++) {
    se[s[i] - 'a'].insert(i);
  }
  for (int i = 0; i < q; i++) {
    scanf("%d", &x);
    if (x == 1) {
      scanf("%d %s", &l, c);
      l--;
      se[s[l] - 'a'].erase(l);
      se[c[0] - 'a'].insert(l);
      s[l] = c[0];
    } else {
      scanf("%d%d", &l, &r);
      l--;
      r--;
      int ans = 0;
      for (int j = 0; j < 26; j++) {
        set<int>::iterator it = se[j].lower_bound(l);
        if (it != se[j].end() && *it <= r) {
          ans++;
        }
      }
      printf("%d\n", ans);
    }
  }
}

Measured memory_bytes: 24192
import java.util.Scanner;

public class Main {

	public static int[] dx = { 0, 1, 0, -1 };
	public static int[] dy = { -1, 0, 1, 0 };

	public static int h, w;
	public static char[][] map;

	public static void dfs(int x, int y, char c) {
		if (map[y][x] != c) {
			return;
		}

		map[y][x] = '0';
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];

			if (nx < 0 || w <= nx || ny < 0 || h <= ny) {
				continue;
			}

			dfs(nx, ny, c);
		}
	}

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

		while (true) {
			h = sc.nextInt();
			w = sc.nextInt();
			if (h == 0 && w == 0) {
				break;
			}
			map = new char[h][];
			for (int i = 0; i < h; i++) {
				map[i] = sc.next().toCharArray();
			}

			int count = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					char cur = map[i][j];
					if (cur != '0') {
						dfs(j, i, cur);
						count++;
					}
				}
			}

			System.out.println(count);
		}

	}

}

Measured memory_bytes: 29372
N = int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(1,N+1):
    a,b=str(i)[0],str(i)[-1]
    d[(int(a),int(b))]+=1
r = 0
for i in range(1,10):
    for j in range(1,10):
        r += d[(i,j)] * d[(j,i)]
print(r)


Measured memory_bytes: 40428
#include <string>
#include <iostream>

using namespace std;

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

    int replaceIndex = -1;
    for (int i = (int) (S.size() - T.size()); i >= 0; i--) {
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] != '?' && S[i + j] != T[j]) {
                break;
            } else if (j == T.size() - 1) {
                replaceIndex = i;
            }
        }
        if (replaceIndex >= 0) {
            break;
        }
    }

    if (replaceIndex == -1) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (int i = 0; i < S.size(); i++) {
        if (i < replaceIndex || i >= replaceIndex + T.size()) {
            if (S[i] == '?') {
                cout << "a";
            } else {
                cout << S[i];
            }
        } else {
            cout << T[i - replaceIndex];
        }

    }

    return 0;
}

Measured memory_bytes: 256
import sys

def main(lines):
  if len(lines[0])+1 == len(lines[1]) and lines[0] == lines[1][:-1]:
    print("Yes")
  else:
    print("No")
  
if __name__ == "__main__":
  lines = []
  for l in sys.stdin:
    lines.append(l.rstrip("\r\n"))
  main(lines)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;

int main() {
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans = b/x;
    if(a != 0) {
        ans -= (a-1)/x;
    } else {
        ans++;
    }
    cout << ans << endl;
}

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

const long long N=200000;

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

long long i,n,ans=1e13;

cin>>n;

for(i=1;i<=sqrt(n);i++){

if(n%i==0){

ans=min(ans,i+n/i-2);}}

cout<<ans<<endl;

return 0;}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n;
    cin >> n;
    map <int, int> cnt;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        cnt[x + 1]++;
        cnt[x]++;
        cnt[x - 1]++;
    }   
    int ans = 0;
    for (auto c : cnt) ans = max(ans, c.second);
    cout << ans << '\n';
}   



Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

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

int main(){

    int N;
    cin >> N;

    vector<int> p(N);
    int i;
    for(i=0; i<N; i++) cin >> p.at(i);

    if(N == 1){
        cout << 1 << endl;
        return 0;
    }

    int ans = 1;

    for(i=1; i<N; i++){
        
        int tmp = p.at(i);

        p.at(0) = min(p.at(0), p.at(i));

        if(p.at(0) == tmp) ans++;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 179, task a, 2020/09/19
//ms,

/*
*/

int main(void){
  string S;
  cin >>S;
  if(S.at(S.size()-1)=='s') S+="es";
  else S+="s";

  cout <<S<<endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3632
from bisect import bisect_left
from operator import itemgetter

N, Q = map(int, input().split(" "))
check_points = [tuple(map(int, input().split(" "))) for _ in range(N)]
querys = [int(input()) for _ in range(Q)]
time = [-1 for _ in range(Q)]
jump = [-1 for _ in range(Q)]
check_points = sorted(check_points, key=itemgetter(2))
b_left = bisect_left

for line in check_points:
    s, f, x = line
    start = s-x
    end = f-x
    left = b_left(querys, start)
    right = b_left(querys, end)
    while left < right:
        if time[left] == -1:
            time[left] = x
            jump[left] = right
            left += 1
        else:
            left = jump[left]

for t in time:
    print(t)


Measured memory_bytes: 54024
def f(nc, nt, nq):
    t = [list(map(int, input().split())) for _ in range(nt)]
    q = [list(map(int, input().split())) for _ in range(nq)]
    dp = [[0] * (nc + 1) for _ in range(nc + 1)]
    for l, r in t:
        dp[l][r] += 1
    for i in range(1, nc + 1):
        dpi = dp[i]
        s = dpi[0]
        for j in range(1, nc + 1):
            dpi[j] = s = dpi[j] + s
    for j in range(1, nc + 1):
        s = dp[0][j]
        for i in range(1, nc + 1):
            dp[i][j] = s = dp[i][j] + s
    for l, r in q:
        print(dp[r][r] - dp[l - 1][r] - dp[r][l - 1] + dp[l - 1][l - 1])


nc, nt, nq = map(int, input().split())
f(nc, nt, nq)


Measured memory_bytes: 77068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

unsigned euclidean_gcd(unsigned a, unsigned b) {
	if (a < b) euclidean_gcd(b, a);
	if (a == 0) return b;
	if (b == 0) return a;
	unsigned r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}

//C
int main(void) {
	int n;
	cin >> n;
	vector<unsigned> a = vector<unsigned>(n);
	rep(0, n)cin >> a[i];
	vector<unsigned> l = vector<unsigned>(n+1); //a_0~a_iの最大公約数
	vector<unsigned> r = vector<unsigned>(n+1); //a_i~a_n-1の最大公約数
	l[0] = 0;
	r[n] = 0;
	rep(0, n) {
		l[i + 1] = euclidean_gcd(l[i], a[i]);
		r[n-1 - i] = euclidean_gcd(r[n - i], a[(n-1) - i]);
	}
	unsigned ans = 0;
	rep(0, n) {
		ans = max(ans, euclidean_gcd(l[i], r[i + 1]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <math.h>
#include <stack>
using namespace std;
typedef long long ll;

int dp[20020][256];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int n,m; cin >> n >> m;
		if(n==0&&m==0)break;
		vector<int> c(m),x(n);
		for(int i=0;i<m;i++){
			cin >> c[i];
		}
		for(int i=0;i<n;i++){
			cin >> x[i];
		}
		for(int i=0;i<=n;i++){
			for(int j=0;j<256;j++){
				dp[i][j]=1e9;
			}
		}
		dp[0][128]=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<256;j++){
				if(dp[i][j]==1e9)continue;
				for(int k=0;k<m;k++){
					int now=j+c[k];
					now=max(now,0);
					now=min(now,255);
					dp[i+1][now]=min(dp[i+1][now],dp[i][j]+(x[i]-now)*(x[i]-now));
				}
			}
		}
		cout << *min_element(dp[n],dp[n]+256) << endl;
	}
}


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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 100100100100100100;
const int mod = 1e9;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
vector<int> cs(vector<int> arr){vector<int> tmp;if(arr.size() == 0) return tmp;tmp.push_back(arr[0]);rep(i,1,arr.size()){tmp.push_back(tmp.back() + arr[i]);}return tmp;}



/* main */



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n = input();

    if(n == 1){
        print("Hello World");
        return 0;
    }else{
        int a, b; cin >> a >> b;
        print(a + b);
        return 0;
    }
   
    













}






    










    




    










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

int main() {
  int N;
  cin>>N;
  vector<ll> arr(N+1);
  for(int i=1;i<=N;++i) cin>>arr[i];
  for(int i=1;i<=N;++i) arr[i] += arr[i-1];
  ll ans = big;
  ll a, b;
  for(int i=1;i<N;++i) {
    a = arr[i];
    b = arr[N] - arr[i];
    ans = min(ans, abs(a-b));
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4788
from math import gcd

n = int(input())
a = list(map(int, input().split()))
g = a[0]
for aa in a:
    g = gcd(aa, g)
if g != 1:
    print('not coprime')
    exit()


def Eratosthenes_sieve(n):
    table = [True] * (n + 1)
    table[0] = False
    table[1] = False
    for i in range(n + 1):
        if table[i]:
            for j in range(2 * i, n + 1, i):  # 素数の倍数は非素数
                table[j] = False
    return table


primes = [i for i, p in enumerate(Eratosthenes_sieve(1000)) if p]
# print(primes)
s = set()
for aa in a:
    if aa == 1:
        continue
    if aa in s:
        print('setwise coprime')
        exit()
    for pp in primes:
        if aa < pp:
            break
        if aa % pp == 0:
            if pp in s:
                print('setwise coprime')
                exit()
            s.add(pp)
            aaa = aa // pp
            if aaa > 1000:
                if aaa in s:
                    print('setwise coprime')
                    exit()
                s.add(aaa)
    s.add(aa)
print('pairwise coprime')


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

//#define YYDBG

int inputs[200000];
int main(void) {
    int i,j,k;
    int N;
    int result;
    int m1, m2;
    int m1_index, m2_index;

    memset(inputs, 0, sizeof(inputs));

    scanf("%d\n", &N);
    for(i=0;i<N;i++) { 
        scanf("%d\n", &(inputs[i]));
    }

#ifdef YYDBG
    for(i=0;i<N;i++) {
        printf("%d ", inputs[i]);
    }
    printf("\n");
    printf("\n");
#endif

    m1 = 0;
    m2 = 0;
    for(i=0;i<N;i++) {
        if( m1 <= inputs[i]) {
            m1 = inputs[i];
            m1_index = i;
        }
    }
    for(i=0;i<N;i++) {
        if (i==m1_index) {continue; }

        if( m2 <= inputs[i]) {
            m2 = inputs[i];
            m2_index = i;
        }
    }

#ifdef YYDBG
    printf("%d %d, %d %d\n", m1, m1_index, m2, m2_index);
#endif

    for(i=0;i<N;i++) {
        if (i != m1_index) {
            printf("%d\n", m1);
        } else {
            printf("%d\n", m2);
        }
    }

    return 0;
}



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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

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

    ll N; cin >> N;
    vl A(N); REP(i, N) cin >> A[i];
    ll ans = 0;
    ll m = A[0];

    for(int i = 1; i < N; i++)
    {
        if(m > A[i])
        {
            ans += m - A[i];
            A[i] = m;
        }
        chmax(m, A[i]);
    }
    cout << ans << endl;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a(n, 0);
	vector<int> new_a;
	int all = 0;
	
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		all += a[i];
	}
	double temp = all / (4.0 * m);
	for (int i = 0; i < n; i++)
	{
		if (a[i] < temp)
		{
			continue;
		}
		new_a.push_back(a[i]);
	}
	if (new_a.size() >= m)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, m;
vector<int>gr[100002];
bool viz[100002][5];
int mv[100002][5];
int s, t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i)
    {
        int a, b;
        cin >> a >> b;
        gr[a].push_back(b);
    }
    cin >> s >> t;
    deque<pair<int, int> >d;
    d.push_back({s, 0});
    while(!d.empty())
    {
        pair<int, int> p = d[0];
        d.pop_front();
        int nod = p.first;
        int md = p.second;
        viz[nod][md%3] = 1;
        mv[nod][md%3] = md;
        for(int i = 0; i < gr[nod].size(); ++i)
        {
            int vecin = gr[nod][i];
            if(viz[vecin][(md+1)%3])
                continue;
            d.push_back({vecin, md+1});
            viz[vecin][(md+1)%3]=1;
        }
    }
    if(!viz[t][0])
        cout << -1;
    else
        cout << mv[t][0]/3;
    return 0;
}


Measured memory_bytes: 8192