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

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

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

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL K; cin >> K;
	VL dist(K, LINF);
	priority_queue<PLL, vector<PLL>, greater<PLL>>pq;
	FOR(i, 1, 10) {
		dist[i%K] = min(dist[i%K], (LL)i);
		pq.push(PLL(dist[i%K], i%K));
	}
	while (!pq.empty()) {
		auto n = pq.top(); pq.pop();
		if (dist[n.second] < n.first)continue;
		FOR(i, 0, 10) {
			LL nxn = (10 * n.second + i) % K;
			LL nxw = n.first + i;
			if (dist[nxn] > nxw) {
				dist[nxn] = nxw;
				pq.push(PLL(nxw, nxn));
			}
		}
	}


	LL ans = dist[0];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6896
until (n, r = gets.split.map(&:to_i)) == [0, 0]
  d = (1..n).to_a.reverse
  r.times do
    p, c = gets.split.map(&:to_i)
    t = d.slice!(p - 1, c)
    t.reverse.each{|i|d.unshift(i)}
  end
  puts d[0]
end

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int A,B,C;
  cin>>A>>B>>C;
  int K;
  cin>>K;
  int c=0;
  while(A>=B){
    B*=2;
    c++;
  }
  while(B>=C){
    C*=2;
    c++;
  }
  if(c<=K)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int count = 0, countx = 10, sum = 0;
    vector<int> terro(5);
    vector<int> one(5);
    for(int i = 0; i < 5; i++){
        cin >> terro.at(i);
    }
    for(int i = 0; i < 5; i++){
        one.at(i) = terro.at(i) % 10;
        if(one.at(i) != 0){
            count++;
            if(one.at(i) < countx){
                countx = one.at(i);
            }
        }
    }
    for(int i = 0; i < 5; i++){
        sum = sum + terro.at(i) - one.at(i);
    }
    sum += 10 * (count - 1) + countx;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[100000],t[100000],ch[100000],wa[200002],sum[200002];
int main(void){
	int n,c,i,j,max;
	cin>>n>>c;
	for(i=0;i<n;i++) cin>>s[i]>>t[i]>>ch[i];
	for(i=0;i<=100001;i++) sum[i]=0;
	for(i=1;i<=c;i++){
		for(j=0;j<=100001;j++) wa[j]=0;
		for(j=0;j<n;j++){
			if(ch[j]==i){
				wa[s[j]]++; wa[t[j]+1]--;
			}
		}
		for(j=1;j<=100001;j++) wa[j]+=wa[j-1];
		for(j=0;j<=100001;j++){
			if(wa[j]>0) sum[j]++;
		}
	}
	max=0;
	for(i=0;i<=100001;i++){
		if(max<sum[i]) max=sum[i];
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;

namespace CF2016B_C
{
    class Program
    {
        static long W, H;
        static List<Edge> L = new List<Edge>();

        static void Main(string[] args)
        {
            var t = scan;
            W = t[0]; H = t[1];

            long a = W + 1;
            long b = H + 1;


            for (long i = 0; i < W; i++)
            {
                var p = int.Parse(Console.ReadLine());
                L.Add(new Edge(false, true, p));
            }
            for (long i = 0; i < H; i++)
            {
                var q = int.Parse(Console.ReadLine());
                L.Add(new Edge(true, false, q));
            }
            var A = L.ToArray();
            Array.Sort(A);
            long ans = 0;

            foreach (var k in A)
            {
                if (a == 1 && b == 1) break;
               

                if (k.tate && b > 1)
                {
                    ans += k.cost * a;
                    b--;
                }
                else if (k.yoko && a > 1)
                {
                    ans += k.cost * b;
                    a--;
                }
            }
            Console.WriteLine(ans);

        }
        static long[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } }
    }
    public class Edge : IComparable
    {
        public long cost;
        public bool tate;
        public bool yoko;
   
        public Edge(bool tate, bool yoko, long cost)
        {
            this.tate = tate;
            this.yoko = yoko;
            this.cost = cost;
        }

        public int CompareTo(object obj)
        {
            Edge cast = (Edge)obj;
            return cost.CompareTo(cast.cost);
        }
    }
}

Measured memory_bytes: 18376
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

map<int,int> cnt;
int ar[200005];

int32_t main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		cnt[ar[i]]++;
	}
	int ans = 0;
	for(auto x: cnt){
		int t = x.second;
		ans += (t*(t-1))/2;
	}
	for(int i=1;i<=n;i++){
		int y = cnt[ar[i]];
		int z = y-1;
		y = (y*(y-1))/2;
		z = (z*(z-1))/2;
		cout<<ans-y+z<<"\n";
	}
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N,C;
  cin>>N>>C;
  vector<vector<ll>> v(N,vector<ll>(2));
  for(ll i = 0LL; i < N; i++) cin>>v[i][0]>>v[i][1];
  ll ans = 0LL;
  ll cnt = 0LL;
  ll cal = 0LL;
  vector<vector<ll>>  turna,turnb;
  for(ll i = 0LL; i < N; i++){
    cnt = v[i][0];
    cal+=v[i][1];
    if(chmax(ans,cal-cnt))turna.push_back({i,ans});
  }
  ans=0LL;
  reverse(v.begin(),v.end());
  cnt = 0LL;
  cal = 0LL;
  for(ll i = 0LL; i < N; i++){
    cnt = C-v[i][0];
    cal+=v[i][1];
    if(chmax(ans,cal-cnt)) turnb.push_back({i,ans});
  }
  ll ansa = 0LL;
  cnt = 0LL;
  cal=0LL;
  reverse(v.begin(),v.end());
  for(ll i = N-1; i > 0; i--){
    cal+=v[i][1];
    cnt=2LL*(C-v[i][0]);
    vector<ll> s = {i,0};
    auto ite = lower_bound(turna.begin(),turna.end(),s);
    if(ite==turna.begin()) continue;
    chmax(ansa,cal-cnt+(*(ite-1))[1]);
  }
  ll ansb = 0LL;
  cnt = 0LL;
  cal=0LL;
  reverse(v.begin(),v.end());
  for(ll i = N-1; i>0; i--){
    cal+=v[i][1];
    cnt=2LL*v[i][0];
    vector<ll> s = {i,0};
    auto ite = lower_bound(turnb.begin(),turnb.end(),s);
    if(ite==turnb.begin()) continue;
    chmax(ansb,cal-cnt+(*(ite-1))[1]);
  }
  if(turna.empty()) turna.push_back({0,0});
  if(turnb.empty()) turnb.push_back({0,0});
  cout<<max(max((*(turna.end()-1))[1],(*(turnb.end()-1))[1]),max(ansa,ansb))<<endl;
}

Measured memory_bytes: 17328
from collections import deque

N, M = map(int, input().split())
dist = [-1] * N
dist[0] = 0
G = [[] for i in range(N)]
prev = [0] * N

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

que = deque([0])

while que:
    v = que.popleft()
    d = dist[v]
    for w in G[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
        prev[w] = v
print("Yes")
for i in range(1, len(prev)):
    print(prev[i]+1)
    

Measured memory_bytes: 34924
import java.util.*;
import java.math.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int ct = 0;
			for(int i = sc.nextInt(); i>=1; --i){
				BigInteger b = new BigInteger(sc.next());
				if(b.isProbablePrime(5)) ++ct;
			}
			System.out.printf("%d\n", ct);
		}
	}
}


Measured memory_bytes: 55176
n = int(input())
li = [int(x) for x in input().split()]
ans = 1
if 0 in li:
    print("0")
else:
    for i in range(n):
        ans = ans * li[i]
        if ans > 1000000000000000000:
            print("-1")
            exit()
    print(ans)


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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
s = input()
t = input()

mx = 0
for i in range(1, N+1):
    # sの後ろとtの前が一致する最大文字数を出す
    if s[-i:] == t[:i]:
        mx = i
# その分は重複させられるので引く
print(len(s)+len(t)-mx)


Measured memory_bytes: 5792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int H;
    static int W;
    static int[][] C;
    static int[][] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        C = new int[10][10];
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                C[i][j] = sc.nextInt();
            }
        }
        A = new int[H][W];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        System.out.println( solve() );
    }

    private static long solve() {
        for (int k = 0; k < 10; k++) {
            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    int ikj = C[i][k] + C[k][j];
                    int ij = C[i][j];
                    if( ikj < ij ) {
                        C[i][j] = ikj;
                    }
                }
            }
        }

        long ans = 0;
        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {
                int a = A[h][w];
                if ( a != -1 ) {
                    ans += C[a][1];
                }
            }
        }
        return ans;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

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

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 26068
#include <iostream>
#include <queue>
#include <list>
#include <vector>

using namespace std;

#define MIN(x, y) x<y?x:y
#define ABS(x, y) x<y?(y-x):(x-y)

typedef long long Long;

int main()
{
	Long n, m;
	int a, b, total=0;

	cin>>n>>m;

	Long h[n];
	int bad[n];

	for(int i=0 ; i<n ; i++){
		cin>>h[i];
		bad[i]=0;
	}
	for(int i=0 ; i<m ; i++){
		cin>>a>>b;
		a--;
		b--;
		if(h[a]>=h[b]) {
			bad[b]=1;
		}
		if(h[a]<=h[b]) {
			bad[a]=1;
		}
	}

	for(int i=0 ; i<n ; i++){
		//printf("%d: %d\n", i, bad[i]);
		total += bad[i];
	}

	cout<<n-total<<endl;

	return 0;
}


Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
int h,w;
vector <vector<char>> a;
vector <vector<long long>> dp;
const long long mod = pow(10,9)+7; 
int main(){
    cin >> h >> w;
    a = vector<vector<char>>(h,vector<char>(w));
    dp = vector<vector<long long>>(h,vector<long long>(w,0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }
    dp[0][0]=1;
    for(int i = 1; i < h; i++){
        if(a[i][0]=='.'){
            if(a[i-1][0]=='.'){
                dp[i][0]=dp[i-1][0];
            }else{
                dp[i][0]=0;
            }
        }else{
            dp[i][0]=0;
        }
    }
    for(int i = 1; i < w; i++){
        if(a[0][i]=='.'){
            if(a[0][i-1]=='.'){
                dp[0][i]=dp[0][i-1];
            }else{
                dp[0][i]=0;
            }
        }else{
            dp[0][i]=0;
        }
    }

    for(int i = 1; i < h; i++){
        for(int j = 1; j < w; j++){
            if(a[i][j]=='#'){
                dp[i][j]=0;
            }else{
                long long tmp = 0;
                if(a[i-1][j]=='.')tmp+=dp[i-1][j];
                tmp%=mod;
                //if((i==1)&&(j==2))cout << tmp << endl;
                if(a[i][j-1]=='.')tmp+=dp[i][j-1];
                tmp%=mod;
                //if((i==1)&&(j==2))cout << tmp << endl;
                dp[i][j]=tmp;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    #if 0
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    #endif
    return 0;
}

Measured memory_bytes: 12144
#include <stdio.h>
#include <stdlib.h>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a<c&&c<b)||(a>c&&c>b)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
set<string> st;
bool used[10];
string ans,card[10];
int n,k;
void rec(int k){
	string tmp;
	if(k==0){st.insert(ans);return;}
	for(int i=0;i<n;i++){
		if(used[i])continue;
		tmp=ans;
		ans+=card[i];
		used[i]=true;
		rec(k-1);
		ans=tmp;
		used[i]=false;
	}
}
int main()
{
	while(cin>>n>>k&&(n!=0||k!=0)){
		for(int i=0;i<n;i++){
			cin>>card[i];
			used[i]=false;
		}
		st.clear();
		rec(k);
		cout<<st.size()<<endl;
	}
}

Measured memory_bytes: 1456
import bisect
from collections import deque
from collections import defaultdict
from fractions import gcd
#from math import factorial
from math import sqrt
from math import ceil
from itertools import permutations
from heapq import *

N=int(input())
A=[]
B=[]
for _ in range(N):
    a=int(input())
    A.append(a)
    B.append(a)
A.sort()
B.sort()
A=deque(A)
B=deque(B)
L=deque()
L.append(A.popleft())
num=0
while(A):
    if num==0:
        L.appendleft(A.pop())
        num+=1
    elif num==1:
        L.append(A.pop())
        num+=1
    elif num==2:
        L.appendleft(A.popleft())
        num+=1
    elif num==3:
        L.append(A.popleft())
        num=0
sum1=0
for i in range(N-1):
    sum1+=abs(L[i]-L[i+1])
R=deque()
R.append(B.pop())
num=2
while(B):
    if num==0:
        R.appendleft(B.pop())
        num+=1
    elif num==1:
        R.append(B.pop())
        num+=1
    elif num==2:
        R.appendleft(B.popleft())
        num+=1
    elif num==3:
        R.append(B.popleft())
        num=0
sum2=0
for i in range(N-1):
    sum2+=abs(R[i]-R[i+1])

print(max(sum1,sum2))


Measured memory_bytes: 96212
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    cout << ((d2 == 1 && (m1 < m2)) ? 1 : 0) << endl;
}

Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int y,m,d;
		cin>>y>>m>>d;

		int cnt=0;

		while(1){
			d++;
			cnt++;

			if(y%3==0){
				if(d==21){
					d=1;
					m++;
				}
			}
			else{
				if(m%2==0){
					if(d==20){
						d=1;
						m++;
					}
				}
				else{
					if(d==21){
						d=1;
						m++;
					}
				}
			}

			if(m==11){
				y++;
				m=1;
			}
			//cout<<"y="<<y<<" m="<<m<<" d="<<d<<endl;
			if(y==1000&&m==1&&d==1)break;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

for i in range(n):
  if a[i] == 0:
    print(0)
    quit()
    
ans = 1
for v in a:
  ans *= v
  if ans > 10**18:
    print(-1)
    quit()
print(ans)

Measured memory_bytes: 21656
package main

import "fmt"

func main() {
	var Xs, Ys []float32
	Xs = make([]float32, 0)
	Ys = make([]float32, 0)
	var cnt int
	for {
		var a, b, c, d, e, f, x, y float32
		fmt.Scanf("%f %f %f %f %f %f", &a, &b, &c, &d, &e, &f)
		if a == 0 {
			break
		}
		y = (((a * f) - (d * c)) / ((a * e) - (b * d)))
		x = ((c - (b * y)) / a)
		Xs = append(Xs, x)
		Ys = append(Ys, y)
		cnt++
	}
	for i := 0; i < cnt; i++ {
		fmt.Printf("%.3f %.3f\n", Xs[i], Ys[i])
	}
}


Measured memory_bytes: 1124
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

#define INF 100000

int main(){
  string s;
  cin >> s;
  long long n = s.length();
  long long count = 0;
  long long num = 0;
  long long ans = 0;
  for(int i=0;i<n;i++){
    if(s[i] == 'B'){
      count += i+1;
      num += 1;
    }
  }
  ans = (n+n-num+1)*num/2 - count;
  cout << ans << endl;

  return 0;
}


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



int main() {
  int n, k;
  cin >> n >> k;
  vector<int> scores(n);
  rep(i, n) cin >> scores[i];
  ll tmp=1;
  rep(i, k) tmp += scores[i];
  int j=0;
  for(int i=k; i<n; i++){
    ll score = tmp-scores[j]+scores[i];
    if(score > tmp) cout << "Yes" << endl;
    else cout << "No" << endl;
    tmp = score;
    j++;
  }
  
  return 0;
}


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

int main(){

    int h,w;

    while(1){
        cin >> h >> w;
        if((h==0)&&(w==0)) break;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout << "#" ; 
            }
            cout << endl;
        }
        cout << endl;
    }
    
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N-1) cin >> C[i];
  int ans = 0;
  rep(i, N) {
    ans += B[A[i]-1];
    if(i != 0 && A[i] == A[i-1]+1)
      ans += C[A[i-1]-1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(V) V.begin(),V.end()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);


int main(){
  string s;
  cin >> s;
  string t=s;
  reverse(all(t));
  if(s!=t){
    puts("No");
    return 0;
  }
  t=s.substr(0,s.size()/2);
  reverse(all(t));
  if(t!=s.substr(0,s.size()/2)){
    puts("No");
    return 0;
  }
  t=s.substr(s.size()/2+1,s.size()/2);
  reverse(all(t));
  if(t!=s.substr(s.size()/2+1,s.size()/2)){
    puts("No");
    return 0;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
 
public class Main {
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    void solve() throws IOException {
    	int N = ni();
    	int[] a = nia(N);
    	boolean[] used = new boolean[N];
    	
    	int ans=0;
    	
    	for (int i=0; i<N; i++) {
    		if (used[i]) continue;
    		if (i + 1 == a[a[i] - 1]) {
    			ans++;
    			used[a[i] -1 ] = true;
    		}
    	}
    	
    	out.println(ans);
    }
 
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

namespace AtCoder_Project_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());
            var g = int.Parse(Console.ReadLine());

            Console.WriteLine(2*g-r);
        }
    }
}


Measured memory_bytes: 11092
N = int(input())
L = list(map(int,input().split()))
if N < 3:
    print(0)
    exit()
count = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i] == L[j]:
            continue
        else:
            for k in range(j+1,N):
                if L[i]==L[k] or L[j]==L[k]:
                    continue
                elif abs(L[i]+L[j])>L[k]and abs(L[i]-L[j])<L[k]:
                    count += 1
print(count)

Measured memory_bytes: 9196
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n,k,l[100010],r[100010];
int dp[110][100010];
signed main() {
	cin>>n>>k;
	int m=2*(int)sqrt(n);
	if(n/(m/2)==(m/2))m--;
	REP(i,m){
		if(i<=(m+1)/2)l[i]=r[i]=i;
		else {
			l[i]=r[i-1]+1;
			r[i]=n/(m-i+1);
		}
	}
	REP(i,m)dp[0][i]=1;
	REP(i,k){
		REP(j,m){
			dp[i][j]=dp[i-1][m-j+1]*(r[j]-l[j]+1);
			dp[i][j]%=mod;
		}
		REP(j,m){
			dp[i][j]+=dp[i][j-1];
			dp[i][j]%=mod;
		}
	}
	cout<<dp[k][m]<<endl;
	return 0;
}

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

signed main(){
	int n,c;cin>>n>>c;
	vector<int> x(n+1,0),v(n+1,0),s(n+1,0),a(n+1,0),b(n+1,0);
	for(int i=1;i<=n;i++){
	cin>>x[i]>>v[i];
	s[i]=s[i-1]+v[i];
	a[i]=max(a[i-1],s[i]-2*x[i]);
	b[i]=max(b[i-1],s[i]-x[i]);
	}
	int ans=b[n];
	int a0=0,b0=0;
	for(int i=n;i>0;i--){
		a0=max(a0,s[n]-s[i-1]-2*(c-x[i]));
		b0=max(b0,s[n]-s[i-1]-(c-x[i]));
		ans=max({ans,a[i-1]+b0,b[i-1]+a0});
	}
	cout<<ans<<endl;

}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>

using namespace std;

int convertToInt(const string& str){
    stringstream ss;
    ss << str;

    int ret;
    ss >> ret;

    return ret;
}

void convertToIntVec(const string& str, vector<int>& ret){
    stringstream ss;
    ss << str;

    int a, b, c;
    ss >> a >> b >> c;

    ret.resize(3);
    ret[0] = a; ret[1] = b; ret[2] = c;
}



void readData(vector<string>& input_data){
    string buff;
    getline(cin, buff);

    int lines = convertToInt(buff);

    for(int i = 0; i < lines; ++i){
        getline(cin, buff);
        input_data.push_back(buff);
    }
}

bool isRightTriangle(vector<int>& edge){
    sort(edge.begin(), edge.end(), [](int a, int b)->bool{ return a < b; });
    return (edge[0]*edge[0] + edge[1] * edge[1] == edge[2] * edge[2]);
}


void mainRoutine(){
    vector<string> input_data;

    readData(input_data);

    for(int i = 0; i < input_data.size(); ++i){
        vector<int> edge;
        convertToIntVec(input_data[i], edge);
        cout << (isRightTriangle(edge) ? "YES" : "NO") << endl;
    }
}


int main(){
    mainRoutine();

    return 0;
}



Measured memory_bytes: 3188
n = int(input())
a, b = map(int, input().split())
p = map(int, input().split())
problems = [0] * 3
for pi in p:
    if pi <= a:
        problems[0] += 1
    elif pi <= b:
        problems[1] += 1
    else:
        problems[2] += 1
print(min(problems))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int c[100005];
int time1(0);
bool win(long int a,long int *b)
{
	time1++;
	if(b[a]==2)
	return true;
	else
	if(c[a]!=1)
	{
		c[a]=1;
		a=b[a];
		win(a,b);
	}
	else
	return false;
}
int main()
{
	int a;
	long int b[100005];
	cin>>a;
	for(int i=1;i<=a;i++)
	{
		cin>>b[i];
	}
	if(win(1,b))
	cout<<time1;
	else
	cout<<"-1";
	return 0;
	
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, l, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    int n = s.length();
    vector<int> v(n+1);
    int tmp = 0;
    int keta = 1;
    for(int i = n ; i >= 1 ; i--){
        tmp = tmp + keta*(s[i-1] - '0');
        keta *= 10;
        keta %= 2019;
        tmp %= 2019;
        v[n+1-i] = tmp;
    }
    map<int, int> mp;
    ll ans = 0;
    for(auto e : v){
        mp[e]++;
        ans += mp[e]-1;
    }
    cout << ans;
}

Measured memory_bytes: 4384
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();
        BigDecimal h = sc.nextBigDecimal();
        BigDecimal m = sc.nextBigDecimal();

        // 角度を求める
        BigDecimal hangle = new BigDecimal(360).divide(new BigDecimal(12)).multiply(h).add(m.multiply(new BigDecimal(0.5)));
        BigDecimal mangle = new BigDecimal(360).divide(new BigDecimal(60)).multiply(m);
        BigDecimal diffangle = hangle.subtract(mangle).abs();
        if(diffangle.compareTo(new BigDecimal(180)) > 0){
            diffangle = new BigDecimal(360).subtract(diffangle);
        }

        BigDecimal cpow;
        if(diffangle.compareTo(new BigDecimal(90)) == 0) {
            BigDecimal apow = a.pow(2);
            BigDecimal bpow = b.pow(2);
            cpow = apow.add(bpow);
        } else {
            BigDecimal cos = new BigDecimal(Math.cos(Math.toRadians(diffangle.doubleValue())));
            BigDecimal apow = a.pow(2);
            BigDecimal bpow = b.pow(2);
            cpow = apow.add(bpow).subtract(new BigDecimal(2).multiply(a).multiply(b).multiply(cos));
        }
        System.out.println(Math.sqrt(cpow.doubleValue()));
    }
}


Measured memory_bytes: 37764
#include <cstdio>
#include <vector>
#include <cstdint>
#include <string>

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string S=buf;
  uintmax_t K;
  scanf("%ju", &K);

  for (uintmax_t i=0; i<K; ++i) {
    if (S[i] != '1') 
      return !printf("%c\n", S[i]);
  }
  printf("1\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main()
{
    char r, g, b;
    cin >> r >> g >> b;
    int num = 0;
    num = (r - '0') * 100 + (g - '0') * 10 + (b - '0');
    if (num % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int main(){
    const ll maxv = 100000;
    ll n, w; cin >> n >> w;
    P a[n];
    rep(i, n) cin >> a[i].first >> a[i].second;

    ll dp[n+1][maxv+1];
    memset(dp, 1, sizeof(dp));
    dp[0][0] = 0;
    loop(i, 1, n+1){
        rep(j, maxv+1){
            if(j-a[i-1].second >= 0)
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-a[i-1].second] + a[i-1].first);
            else dp[i][j] = min(dp[i-1][j], a[i-1].first);
        }
    }

    ll ans = -1;
    rep(i, maxv+1) if(dp[n][i] <= w) ans = i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79104
eval'A=[#'+`tr ' ' ,`+?];f=->a{l=[[0,i=-1]];a.map{|x|l.pop while(t=l[-1])[0]>x;l<<[x,i+=1];i-t[1]}}
r=0;A.zip(f[A],f[A.reverse].reverse){|a,b,c|r+=a*b*c};p r

Measured memory_bytes: 48688
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, K,nagasa[60],i,sum;
	sum = 0;
	cin >> N >> K;
	for (i = 0;i < N;i++) {
		cin >> nagasa[i];
	}
	sort(nagasa,nagasa+N,greater<int>());
	for (i = 0;i < K;i++) {
		sum += nagasa[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**10
mod = 10**9 + 7


def f():
    n = int(input())
    s = int(math.sqrt(n))
    while (s+1)*s/2 < n:
        s += 1
    sa = (s+1)*s/2 - n
    for i in range(1,s+1):
        if i == sa:
            continue
        print(i)


f()


Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
const ll mod=1e9+7;
vector<ll> neg,pos;
int main() {
    int n,k;cin>>n>>k;
    for(int i=1;i<=n;i++) {
        int tem;cin>>tem;
        if(tem>0) pos.push_back(tem);
        if(tem<0) neg.push_back(tem);
    }
    bool ok=0;int mn=0;
    sort(neg.begin(),neg.end());
    sort(pos.begin(),pos.end(),greater<int>());
    for(int i=0;i<=neg.size()&&i<=k;i+=2)
        if(pos.size()+i>=k) {
            ok=1;mn=i;break;
        }
    ll ans=1;
    if(!ok) {
        if(pos.size()+neg.size()<n) {cout<<0<<endl;return 0;}
        sort(neg.begin(),neg.end(),greater<int>());
        for(int i=0;i<min(k,(int)neg.size());i++) (ans*=neg[i])%=mod;
        sort(pos.begin(),pos.end());
        for(int i=0;i<k-(int)neg.size();i++) (ans*=pos[i])%=mod;
    }
    else {
        for(int i=mn+2;i<=neg.size()&&i<=k;i+=2) {
            if(neg[i-1]*neg[i-2]>pos[k-i]*pos[k-i+1]) mn=i;
                else break;
        }
        for(int i=0;i<mn;i++) (ans*=neg[i])%=mod;
        for(int i=0;i<k-mn;i++) (ans*=pos[i])%=mod;
    }
    (ans+=mod)%=mod;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n,i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector <int> h(n);
    vector <int> dp(n,INF);
    for(int &x:h){cin>>x;}
    dp[0]=0;
    for (int i=0;i<n;i++)
    {
        for(int j:{i+1,i+2})
            {if(j<n){dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));}}

    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pl;
#define pi pair<int,int>
#define MM 1000000000
#define MOD MM+7
#define initial_value -1
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[8] = {-1,0,1,0,1,-1,1,-1};
int dy[8] = {0,-1,0,1,1,1,-1,-1};
struct edge{ll to,cost;};
ll N,M,a[100010],b,c;
vector<pl> p;
int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    for(int i = 0; i < M; i++){
        cin >> b >> c;
        p.push_back(pl(c,b));
    }
    ll ans = 0;
    sort(a,a+N);
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());

    ll maker = 0;
    for(int i = 0; i < M; i++){
        while(p[i].second){
            if(p[i].first > a[maker]){
                a[maker] = p[i].first;
                p[i].second--;
            }
            ans += a[maker];
            //cout << ans << ", ";
            maker++;
            if(maker == N){
                i = M;
                break;
            }
        }
    }
    //cout << maker << "," << endl;
    if(maker < N){
        for(int i = maker; i < N; i++){
            ans += a[i];
        }
    }
    //cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3188
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);

    if (a >= b){
        for (int i =1;i <= a;i++){
            printf("%d",b );
        }
    }
    else{
        for (int i =1;i <= b;i++){
            printf("%d",a);
        }
        
    }

    return 0;
}

/**/

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

   int A,B;
   
   scanf("%d%d",&A,&B);
   
   int i,ans;
   
   ans = 0;
   for(i = 0;i < 2;i++){
      if(A > B) {
         ans = ans + A;
         A = A - 1;
      }
      else {
         ans = ans + B;
         B = B - 1;
      }
   }

   printf("%d\n",ans);
   
  return 0;
}


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

using namespace std;
using ll = long long;


const int MAX_N = 1;


int K;
int sum = 0;
int gcd(int a, int b, int c)
{
     while (b != 0) {
         int t = a % b;  a = b;  b = t;

     }
     while (c != 0) {
         int t = a % c;  a = c;  c = t;
         
     }
     return a;
    
}


int solve()
{
    for (int i = 1; i <= K; i++)
    {
        for (int j = 1; j <= K; j++)
        {       
            for(int k = 1; k <= K; k++){
                sum += gcd(i, j, k);
            }
        }
        
    }

    return sum;
    
}

int main()
{
    cin >> K;
    
    cout << solve() << endl;


    return EXIT_SUCCESS;
}

Measured memory_bytes: 3624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <bitset>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef unsigned long long ull;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const double EPS = 1e-8;
const double INF = 1e12;
//////////////////////////////
// UnionFind
vector<int> v, parent, depth;
int find(int a){
  if(parent[a] == a) return a;
  else return parent[a] = find(parent[a]);
}
void merge(int a, int b){
  int pa = find(a), pb = find(b);
  if(pa == pb) return ;

  if(depth[pa] > depth[pb]) swap(pa, pb);
  if(depth[pa] == depth[pb]) ++depth[pa];
  parent[pb] = pa;
}
bool same(int a, int b){
  return find(a) == find(b);
}
void init_union_find(int V){
  v = vector<int>(V);
  parent = vector<int>(V);
  depth = vector<int>(V, 1);
  REP(i, V) parent[i] = i;
}
int main() {
	int n, q; cin >> n >> q;
	init_union_find(n);
	while(q--) {
		int a,b,c;
		cin >> a >> b >> c;
		if(a == 0)
			merge(b, c);
		else if(a == 1)
			cout << same(b, c) << endl;
	}

	return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a==b && a!=c)
        cout << "Yes";
    else if (a==c && a!=b)
        cout << "Yes";
    else if (b==c && a!=b)
        cout << "Yes";
    else 
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;
const int mod = 1000000007;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    unordered_map<ll, ll> m;
    bool pairwise = true;
    bool setwise = false;
    rep(i, N){
        vector<pair<ll, ll>> res = prime_factorize(A[i]);
        int cnt = 0;
        for(auto x:res){
            if(m[x.first] != 0){
                pairwise = false;
                break;
            }else m[x.first]++;
        }
    }
    if(pairwise){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    int setw = A[0];
    rep(i, N - 1){
        setw = __gcd(setw, A[i + 1]);
    }
    // cout << setw << endl;
    if(setw == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 10380
N=int(input())
*A,=map(int,input().split())

B=[0]+A+[0]
count=[0]*N
S=abs(B[1]-0)
i=1
while i<=N:
    if B[i-1]<=B[i]<=B[i+1] or B[i-1]>=B[i]>=B[i+1]:
        count[i-1]=0
    else:
        count[i-1]=2*min(abs(B[i]-B[i-1]),abs(B[i+1]-B[i]))
    S+=abs(B[i+1]-B[i])
    i+=1

for c in count:
    print(S-c)

Measured memory_bytes: 20448
dp = [0]*3
N, = map(int, input().split())
for i in range(N):
    a, b, c = map(int, input().split())
    dp[0], dp[1], dp[2] = a + max(dp[1], dp[2]), b + max(dp[0], dp[2]), c + max(dp[1], dp[0])
print(max(dp))


Measured memory_bytes: 47592
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    int i, j;
    
    while (1) {
        scanf("%d %d", &H, &W);
        
        if(H==0 && W==0){
            break;
        }
        else{
            for(i=0;i<H;i++){
                for(j=0; j<W; j++){
                    if(i==0 || i==H-1 || j==0|| j==W-1){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> f(n+1, 0);
  rep2(i, 1, 100)rep2(j, 1, 100)rep2(k, 1, 100){
    int num = i * i + j * j + k * k + i * j + j * k + k * i;
    if (num > n) break;
    f[num]++;
  }
  rep2(i, 1, n+1) cout << f[i] << endl;
  
  return 0;
}

Measured memory_bytes: 3536
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

card = [[False] * 3 for _ in range(3)]

for i, bi in enumerate(b):
    for y in range(3):
        for x in range(3):
            if A[y][x] == bi: card[y][x] = True

ans = 'No'

# horizontal
for y in range(3):
    if card[y].count(True) == len(card[y]):
        ans = 'Yes'

# vertical
for x in range(3):
    if card[0][x] == card[1][x] == card[2][x] == True:
        ans = 'Yes'

# diagonal
if card[0][0] == card[1][1] == card[2][2] == True:
    ans = 'Yes'

if card[2][0] == card[1][1] == card[0][2] == True:
    ans = 'Yes'

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll A, B, X;
    cin >> A >> B >> X;
    if (A <= X &&  X <= A + B) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll n,m; cin >> n >> m;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
		a[i]/=2;
	}
	sort(a.begin(),a.end());
	int ans=0;
	map<int,int> mp;
	int num;
	for(int i=0;i<n;i++){
		int cnt=0;
		int cp=a[i];
		while(cp%2==0){
			cnt++;
			cp/=2;
		}
		if(mp[cnt]==0&&i){
			cout << 0 << endl;
			return 0;
		}
		else{
			mp[cnt]++;
			num=cnt;
		}
	}
	ll p=1;
	ll q=pow(2,num);
	for(int i=0;i<n;i++){
		a[i]/=q;
		p=p/__gcd(p,a[i])*a[i];
		if(p>m){
			cout << 0 << endl;
			return 0;
		}
	}
	//cout << p << endl;
	if(p>m){
		cout << 0 << endl;
		return 0;
	}
	else{
		cout << (m/(p*q)+1)/2 << endl;
	}
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define REP(i, b, e) for ( int i = b; i < (int)e; i++ )
#define rep(i, n) REP(i, 0, n)

static const int MAX = 1001;

main(){
  int H, W, N, D[MAX][MAX], dp[MAX][MAX], k;
  
  while(1){
    cin >> H >> W >> N;
    if ( H == 0 && W == 0 && N == 0) break;
    rep(i, H) rep(j, W) {
      cin >> D[i][j];
      dp[i][j] = 0;
    }
    
    dp[0][0] = N-1;
    rep(i, H) rep(j, W) {
      if ( i ){
	k = dp[i-1][j];
	if ( k % 2 == 0 ){
	  dp[i][j] += dp[i-1][j]/2;
	} else {
	  if ( D[i-1][j] == 0 ) dp[i][j] += (dp[i-1][j] + 1)/2;
	  else dp[i][j] += (dp[i-1][j] - 1)/2;
	}
      } 
      if ( j ){
	k = dp[i][j-1];
	if ( k % 2 == 0 ){
	  dp[i][j] += dp[i][j-1]/2;
	} else {
	  if ( D[i][j-1] == 1 ) dp[i][j] += (dp[i][j-1] + 1)/2;
	  else dp[i][j] += (dp[i][j-1] - 1)/2;
	}
      }
    }

    int pi, pj;
    pi = pj = 0;
    while(1){
      if ( pi == H || pj == W ) break;
      if ( (dp[pi][pj] + D[pi][pj]) % 2 == 1 ) pj++;
      else pi++;
    }

    cout << pi+1 << " " << pj+1 << endl;

  }
}

Measured memory_bytes: 8692
import Control.Applicative
import Data.List

main :: IO ()
main = do
  [n, t, e] <- f
  solve t e <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> [Int] -> Int
solve t e xs = case find f (zip xs [1..]) of
                Just (_, i) -> i
                Nothing -> (-1)
  where
    f (x, _) = let l = (t - e) `div` x * x
                   u = (t + e) `div` x * x
               in not . null $ intersect [l, l+x .. u] [t-e .. t+e]



Measured memory_bytes: 4248