akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<(n);++i)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    int s=S.size(),t=T.size();
    vector<vector<ll>> pos(26);
    rep(i,s){
        pos[S[i]-'a'].emplace_back(i);
        pos[S[i]-'a'].emplace_back(i+s);
    }
    rep(i,26) sort(pos[i].begin(),pos[i].end());
    ll ans=0,now=-1;
    rep(i,t){
        int n=T[i]-'a';
        if (pos[n].empty()){
            cout << -1 << endl;
            return 0;
        }
        ll next=*upper_bound(pos[n].begin(),pos[n].end(),now);
        ans=ans/s*s+next; now=ans%s;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 2756
#include<cstdio>
int n,a[100010];
long long L=2,R=2;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=n;i>=1;i--){
		L=((L-1)/a[i]+1)*a[i];
		R=R/a[i]*a[i]+a[i]-1;
	}
	if(L>R)printf("-1");else printf("%lld %lld",L,R);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>
 
#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);
 
 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}
 
void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
 
    ll q=1;
    //cin>>q;
    while(q--)
    {
        ll n;
        cin>>n;
        ll a[n],b[n],c[n];
        ll dp[n+1][3];
        REP(i,0,n)
        {
            ll t1,t2,t3;
            cin>>t1>>t2>>t3;
            a[i]=t1;
            b[i]=t2;
            c[i]=t3;
        }
        dp[0][0]=dp[0][1]=dp[0][2]=0;
        REP(i,0,n)
        {
            dp[i+1][0]=max(dp[i][1],dp[i][2])+a[i];
            dp[i+1][1]=max(dp[i][0],dp[i][2])+b[i];
            dp[i+1][2]=max(dp[i][0],dp[i][1])+c[i];
        }
        cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
    }
 
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, a, b;
  while (cin >> n >> a >> b, n+a+b) {
    vector<int> table(n+1);
    table[a] = 1;
    table[b] = 1;
    for (int i=1; i<=n; i++)
      if ((i>a&&table[i-a]) || (i>b && table[i-b]))
        table[i] = 1;
    int ans = 0;
    for(int i=1; i<=n; i++)
      if(table[i] == 0)
        ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d\n", &n);
	char s[n + 1];
	scanf("%s", s);
	int result = 0;
	REP(i, 1000) {
		char num[4];
		sprintf(num, "%03d", i);
		int c = 0;
		REP(i, n) {
			if(s[i] == num[c]) {
				c++;
				if(c == 3) {
					result++;
					break;
				}
			}
		}
	}
	printf("%d\n", result);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

void visit(vvi &g, vi &visited, int v)
{
    visited[v] = true;
    for (int u : g[v])
    {
        if (!visited[u])
        {
            visit(g, visited, u);
        }
    }
}

int main()
{
    int n, m;
    cin >> n >> m;

    vvi g(n);
    for (int i = 0; i < m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    vi visited(n);
    fill(visited.begin(), visited.end(), 0);
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (visited[i])
        {
            continue;
        }
        cnt++;
        visit(g, visited, i);
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 10752
//20200517 A
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int f=n%10;
		switch (f){
        case 2:
        case 4:
        case 5:
          case 7:
          case 9:
			System.out.println("hon");
			break;
          case 0:
          case 1:
          case 6:
          case 8:
			System.out.println("pon");
			break;
          case 3:
			System.out.println("bon");
			break;
		}
	}
}


Measured memory_bytes: 27080
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    int n, a;
    cin >> n;
    int c = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 1) c++;
    }

    cout << (c % 2 == 0 ? "YES" : "NO") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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



int main(){
    int a,b;
    cin>>a>>b;
    int ans=a+b;
    out(6-ans);
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	double a[102], avg=0, min=INF, nearest;
	
	REP(i,n){
		cin >> a[i];
		avg += a[i];
	}
	
	avg /= n;
	
	REP(i,n){
		if (min>abs(a[i]-avg)){
			nearest = i;
			min = abs(a[i]-avg);
		}
	}
	
	cout << nearest << endl;
	
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int d,c;
    cin >> d >> c;
    cout << d*c << endl;


    return 0;
}


Measured memory_bytes: 3064
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

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

#############
# Main Code #
#############

# 割り当てを一つ求める
# N回Mラウンドを行う 1ラウンドあたりの最大対戦者数はN以下になる

# 対戦者A, B, C, D...にそれぞれ１、２、３、４...を割り当てる
# 試合後、A, B, C, D...の数字は２、３、４、５...になる N + 1になったら１になる
# N, M = 4, 1の時 M1に[1, 2]を割り当てると
#   A B C D
# 1 1 2 3 4 A vs B
# 2 2 3 4 1 D vs A
# 3 3 4 1 2 C vs D
# 4 4 1 2 3 B vs C なのでok
# Nラウンドでちょうど一周するので、M = 1の時は何を入れてもok

# N, M = 5, 2の時
#   A B C D E
# 1 1 2 3 4 5
# 2 2 3 4 5 1
# 3 3 4 5 1 2
# 4 4 5 1 2 3
# 5 5 1 2 3 4

# M1には何を指定してもいい？
# 少なくともM1とM2が同じパターン(i, i+1等)はダメ
# 全てのMについて違うパターンで数字を割り当てられるか
# = 任意のMi(ai, bi), Mj(aj, bj)について abs(bi - ai) != abs(bj - aj)
N, M = getNM()
A = []
B = []
if N % 2 != 0:
    for i in range(M):
        A.append(i + 1)
        B.append(N - i)
else:
    for i in range(M):
        A.append(i + 1)
        if i <= ((N // 4) - 1):
            B.append(N - i)
        else:
            B.append(N - i - 1) # 一つずらす
for i in range(M):
    print(A[i], B[i])


# コーナーケースあり
# 前と後ろから取っていったのではダメなケース？
# ちょうどrotateしたところ
# N, M = 6, 2
# m1に[1, 6], m2に[3, 4]を指定するとダブル
#   A B C D E F
# 1 1 2 3 4 5 6
# 2 2 3 4 5 [6 1] E, F
# 3 3 4 5 6 1 2
# 4 4 5 6 1 2 3
# 5 5 6 1 2 [3 4] E, F
# 6 6 1 2 3 4 5

# rotateしてもダブらないように
# m1に[1, 6], m2に[2, 3]を指定すると
#   A B C D E F
# 1 1 2 3 4 5 6
# 2 2 3 4 5 [6 1] E vs F
# 3 3 4 5 6 1 2
# 4 4 5 6 1 2 3
# 5 5 6 1 2 3 4
# 6 6 1 2 3 4 5

# 偶奇で分かれる？
# 奇数の場合は大丈夫
# m1 間はN - 2(奇数), 0
# m2 間はN - 4(奇数), 2

# 偶数の場合はダメ
# うまくズラして
# m1 間はN - 2(偶数), 0
# m2 間はN - 4(偶数), 2

# m1 間はN - 2, 0
# m2 間はN - 4, 2
# m3 間はN - 6, 4
# ...
# mm-2 間は6, N - 6
# mm-1 間は4, N - 4
# mm 間は2, N - 2
# 関係があるのは1個目とN個目, 2個目とN-1個目...
# 小さい方から半分については１個ずらす

Measured memory_bytes: 17608
s = gets.chomp
n = s.size
ans = Array.new(n,0)
a = 0
n.times do |i|
    if s[i] == "R"
        a += 1
    elsif a != 0
        ans[i] += a/2
        ans[i-1] += (a+1)/2
        a = 0
    end
end
n.times do |j|
    i = n-j-1
    if s[i] == "L"
        a += 1
    elsif a != 0
        ans[i] += a/2
        ans[i+1] += (a+1)/2
        a = 0
    end
end
puts ans.join(" ")

Measured memory_bytes: 3196
p = 10**9+7
N,K = map(int,input().split())
tot = (((N+1)*(N+1+K)*(N-K+2))//2)%p
tot = (tot+N-K+2)%p
tot = (tot-((N+1)*(N+2)*(2*N+3))//6)%p
tot = (tot+((K-1)*K*(2*K-1))//6)%p
print(tot)

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 10, mod = 1e9 + 7;

int n;
int a[N], b[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++ ) scanf("%d", a + i);
	
	vector<int> res;
	for (int i = n; i; i -- )
	{
		int cnt = 0;
		for (int j = i; j <= n; j += i) cnt += b[j];
		
		if (cnt % 2 != a[i])
		{
			b[i] ++ ;
			res.push_back(i);
		}
	}
	
	cout << res.size() << endl;
	for (auto u : res) cout << u << ' ';
	puts("");
	return 0;
}

Measured memory_bytes: 2936
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define rep(i,n) for(int i = n-1; i >=0 ; i--)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef pair<int,int> P;
const int INF = 1000000000;

int main(){
	int n,x,m,lrs[10][3],a[6];
	scanf("%d%d%d",&n,&x,&m);
	rep(i,m)scanf("%d%d%d",&lrs[i][0],&lrs[i][1],&lrs[i][2]);
	rep(q,x+1)rep(w,x+1)rep(e,x+1)rep(r,x+1)rep(t,x+1)rep(y,x+1){
		a[0]=q;
		a[1]=w;
		a[2]=e;
		a[3]=r;
		a[4]=t;
		a[5]=y;
	for(int i=0;i<m;i++){
		int s=0;
		for(int j=lrs[i][0]; j<=lrs[i][1]; j++){
			s+=a[j-1];
		}
		if(s!=lrs[i][2])goto dame;
	}
	printf("%d",a[0]);if(n>1)for(int i=0;i<n-1;i++)printf(" %d",a[i+1]);return 0;
	dame:;
	}
	printf("-1");
	return 0;
}

Measured memory_bytes: 1028
def main():
  n = int(input())
  ans=""
  while n>0:
    if n%26==0:
      ans+='z'
      n=int(n/26)-1
    else:
      ans+=chr(ord('a')+(n%26)-1)
      n=int(n/26)
  print(ans[::-1])
main()

Measured memory_bytes: 8980
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n, k;
llint a[1005];
llint sum[1005];
vector<llint> vec, tmp;

int main(void)
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
	
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			vec.push_back(sum[j] - sum[i]);
		}
	}
	sort(vec.begin(), vec.end());
	
	llint ans = 0;
	for(int i = 50; i >= 0; i--){
		tmp.clear();
		llint num = vec.end() - lower_bound(vec.begin(), vec.end(), (1LL<<i));
		if(num >= k){
			ans += 1LL<<i;
			for(int j = 0; j < vec.size(); j++){
				if(vec[j] >= (1LL<<i)) tmp.push_back(vec[j] - (1LL<<i));
			}
		}
		else{
			for(int j = 0; j < vec.size(); j++) tmp.push_back(vec[j] % (1LL<<i));
		}
		vec = tmp;
		sort(vec.begin(), vec.end());
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 12388
#include "bits/stdc++.h"
#define MAXN 200009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int a[MAXN],b[MAXN];
vector<int>v;
int get(int l,int r){
	int x=lower_bound(all(v),l)-v.begin();
	int y=upper_bound(all(v),r)-v.begin();
	return y-x;
}
int main(){
    //~ freopen("file.in", "r", stdin);
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
		scanf("%d",a+i);
	for(int i=0;i<n;i++)
		scanf("%d",b+i);
	int res=0;	
	for(int h=0;h<29;h++){
		v.clear();int mod=(1<<(h+1));
		int T=mod/2;
		for(int i=0;i<n;i++)
			v.pb(b[i]%mod);
		sort(all(v));	
		ll ans=0;
		for(int i=0;i<n;i++){
			int res=(a[i]%mod);
			//T and 2*T
			if(res<T)
				ans+=get(T-res,2*T-1-res);	
			else if(res<2*T){
				ans+=get(0,2*T-1-res);
				ans+=get(3*T-res,4*T-1-res);
			}
			else
				ans+=get(3*T-res,4*T-1-res);
			//3*T and 4*T
		}
		if(ans&1)
			res+=T;
	}printf("%d\n",res);
	return 0;
}
	


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
pair<int,int> pii;
vector<int> vec;
int main()
{
  int n;
  double ans;
  double v[100];
  cin>>n;

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

  sort(v,v+n);

  for(int i=0; i<n-1; i++){
    v[i+1]=(v[i]+v[i+1])/2;
  }

  cout<<v[n-1]<<'\n';
  return 0;
}


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

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

            Console.WriteLine(Math.Min(N * A, B));
            Console.Read();
        }
    }
}

Measured memory_bytes: 13396
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>

using namespace std;

#define ABS(a) ((a>0)?a:-(a))
#define MIN(a,b) ((a<b)?(a):(b))
#define MAX(a,b) ((a<b)?(b):(a))
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a,b) memset((a),(b),sizeof(a))
#define FI(i,n) for (int i=0; i<(n); ++i)
#define pnt pair <int, int>
#define mp make_pair
#define LL long long
#define U unsigned

int solve(int a, int b) {
	if (ABS(a) == ABS(b)) {
		return (a != b);
	}
	if (ABS(a) < ABS(b)) {
		return (ABS(b) - ABS(a)) + (a < 0) + (b < 0);
	}
	return (ABS(a) - ABS(b)) + (a > 0) + (b > 0);
}

int main()
{
#ifdef Fcdkbear
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
        double beg = clock();
#endif

        int a,b;
        cin >> a >> b;
        cout << solve(a, b) << endl;

#ifdef Fcdkbear
        double end = clock();
        fprintf(stderr, "*** Total time = %.3lf ***\n", (end - beg) / CLOCKS_PER_SEC);
#endif
        return 0;
}


Measured memory_bytes: 256
import sys

if __name__ == '__main__':
    N, K = map(int, input().split())
    xy_list = [list(map(int, input().split())) for i in range(N)]

    all_x = sorted(list(set([xy[0] for xy in xy_list])))
    all_y = sorted(list(set([xy[1] for xy in xy_list])))

    answer = sys.maxsize
    for i in range(len(all_x)):
        x1 = all_x[i]
        for j in range(i+1, len(all_x)):
            x2 = all_x[j]
            for k in range(len(all_y)):
                y1 = all_y[k]
                for l in range(k+1, len(all_y)):
                    y2 = all_y[l]
                    if K <= len([xy for xy in xy_list if (x1 <= xy[0] <= x2) and (y1 <= xy[1] <= y2)]) and answer > (x2-x1) * (y2-y1):
                        answer = (x2-x1) * (y2-y1)

    print(answer)


Measured memory_bytes: 55388
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;


void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	vector<int> b(n);
	per(i, n) {
		int c = 0;
		for (int j = 2 * (i + 1); j <= n; j += i + 1) {
			if (b[j - 1])c ^= 1;
		}
		if (a[i] != c)b[i] = 1;
	}
	vector<int> ans; rep(i, n)if (b[i])ans.push_back(i+1);
	cout << ans.size() << endl;
	rep(i, ans.size()) {
		if (i > 0)cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}

void solve(){
    ll n;cin>>n;
    cout<<n*(n-1)/2<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n = 8;
string s[8];
string c = "ox";
int dy[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx[8] = {1, 0, -1, 1, -1, 1, -1, 0};
bool contain(int y, int x){
   return (0 <= y && y < n && 0 <= x && x < n);
}

int calc(char now, char op, int y, int x){
    int res = 0;
    rep(i, 0, 8){
        int ny = y + dy[i];
        int nx = x + dx[i];
        int cnt = 0;
        rep(j, 0, 8){
            if(!contain(ny, nx)) break;
            if(s[ny][nx] == '.') break;
            if(s[ny][nx] == now){
                res += cnt;
                break;
            }
            if(s[ny][nx] == op){
                cnt++;
            }
            ny += dy[i];
            nx += dx[i];
        }
    }
    return res;
}

void update(char now, char op, int y, int x){
    s[y][x] = now;
    rep(i, 0, 8){
        int ny = y + dy[i];
        int nx = x + dx[i];
        int cnt = 0;
        rep(j, 0, 8){
            if(!contain(ny, nx)) break;
            if(s[ny][nx] == '.') break;
            if(s[ny][nx] == now){
                int ty = y + dy[i];
                int tx = x + dx[i];
                rep(k, 0, cnt){
                    s[ty][tx] = now;
                    ty += dy[i];
                    tx += dx[i];
                }
                break;
            }
            if(s[ny][nx] == op){
                cnt++;
            }
            ny += dy[i];
            nx += dx[i];
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    rep(i, 0, n){
        cin >> s[i];
    }
    for(int ij = 0; ij < n * n; ij++){
        char now = c[ij % 2];
        char op = c[(ij + 1) % 2];
        int MAX = 0, y = -1, x = -1;
        if(ij % 2 == 0){
            rep(i, 0, n){
                rep(j, 0, n){
                    if(s[i][j] != '.') continue;
                    int tmp = calc(now, op, i, j);
                    if(tmp > MAX){
                        MAX = tmp; y = i; x = j;
                    }
                }
            }
        }else{
            repb(i, n - 1, 0){
                repb(j, n - 1, 0){
                    if(s[i][j] != '.') continue;
                    int tmp = calc(now, op, i, j);
                    if(tmp > MAX){
                        MAX = tmp; y = i; x = j;
                    }
                }
            }
        }
        if(MAX != 0){
            update(now, op, y, x);
            // cout << MAX << " " << y << " " << x << endl;
            // rep(i, 0, 8){
            //     cout << s[i] << endl;
            // }    
        }
    }
    rep(i, 0, n){
        cout << s[i] << endl;
    }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  int N,K;
  cin >> N >> K;

  string S;
  cin >> S;

  char prev=S[0];
  int ans=0;
  for(int i = 0; i < S.size()-1; i++){
    if(S[i]==S[i+1]){
      ans+=1;
    }
  }
  cout << min(ans+2*K,N-1) << endl;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  int n, q; string s; cin >> n >> q >> s;
  vector<pair<int, int>> scopes(q);
  rep(i, q){
    int l, r; cin >> l >> r;
    scopes[i] = make_pair(l, r);
  }
  vector<ll> acs(n);
  acs[0] = 0;
  rep(i, n - 1){
    if (s[i] == 'A' && s[i + 1] == 'C') acs[i + 1] = acs[i] + 1;
    else acs[i + 1] = acs[i];
  }
  rep(i, q){
    ll ans = 0;
    ans = acs[scopes[i].second - 1] - acs[scopes[i].first - 1];
    cout << ans << endl;
  }
}

Measured memory_bytes: 2688
// ※※※ 解答不能 ※※※
// 以下のソースを勉強する.
// ひふみ☆氏.
// https://arc096.contest.atcoder.jp/submissions/2391737
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

template<typename A,typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A,typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const LL INF=1001001001001001001ll;
int N;
LL C, ans;
LL X[555555], V[555555];
LL S[555555];

void solve(){
    for(int i = 0; i < N; i++) S[i + 1] = S[i] + V[i];
    LL ma = -INF;
    for(int i = N - 1; i >= 0; i--){
        chmax(ans, S[i + 1] - X[i]);
        chmax(ans, S[i + 1] - 2 * X[i] + ma - C);
        chmax(ma, S[N] - S[i] + X[i]);
    }
}

signed main(){
    
    scanf("%d %lld", &N, &C);
    vector<LL> x(N), v(N);
    for(int i = 0; i < N; i++) scanf("%lld %lld", &x[i], &v[i]);
    for(int t = 0; t < 2; t++){
        for(int i = 0; i < N; i++) X[i] = x[i], V[i] = v[i];
        solve();
        for(int i = 0; i < N; i++) x[i] = C - x[i];
        reverse(x.begin(), x.end());
        reverse(v.begin(), v.end());
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
long long n,pp,a1=0,a2=0,a3=0,a4=0;
string s;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s[0]=='A')
        {
            a1++;
        }
        else if(s[0]=='W')
        {
            a2++;
        }
        else if(s[0]=='T')
        {
            a3++;
        }
        else
        {
            a4++;
        }
    }
    cout<<"AC x "<<a1<<'\n';
    cout<<"WA x "<<a2<<'\n';
    cout<<"TLE x "<<a3<<'\n';
    cout<<"RE x "<<a4<<'\n';




}

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

int main() {
    string a, b;
    cin >> a >> b;
    float c = stoi(a + b);

    if (sqrt(c) == floor(sqrt(c)))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

n, m = map(int, input().split())

g = [[] for _ in range(n)]
edge = [{} for _ in range(n)]

for i in range(m):
    l, r, d = map(int, input().split())
    l, r  = l-1, r-1
    g[r].append(l)
    g[l].append(r)
    edge[l][r] = d
    edge[r][l] = -d

s = []
visit = [10**18]*n
for i in range(n):
    if visit[i] != 10**18:
        continue
    s.append(i)
    visit[i] = 0
    while s:
        v = s.pop()
        for u in g[v]:
            if visit[u] != 10**18:
                if visit[u] != visit[v]+edge[v][u]:
                    print('No')
                    exit()
            else:
                visit[u] = visit[v]+edge[v][u]
                s.append(u)
else:
    print('Yes')

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

using namespace std;

#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define LL long long 

const LL MOD = 1e9 + 7;
const int N = 81;
const int maxVal = (2*N) * (2 * N) + 11;

int m,n;
int a[N][N],b[N][N];
bool F[N][N][maxVal];

int main(){
    cin >> m >> n;
    FOR(i,1,m) FOR(j,1,n) cin >> a[i][j];
    FOR(i,1,m) FOR(j,1,n) cin >> b[i][j];
    //
    F[1][1][abs(a[1][1] - b[1][1])] = 1;
    FOR(i,1,m) FOR(j,1,n)
    REP(k,0,maxVal) if(F[i][j][k]){
        if(i < m){
            F[i + 1][j][abs(k + a[i + 1][j] - b[i + 1][j])] = 1;
            F[i + 1][j][abs(k + b[i + 1][j] - a[i + 1][j])] = 1;
        }
        if(j < n){
            F[i][j + 1][abs(k + a[i][j + 1] - b[i][j + 1])] = 1;
            F[i][j + 1][abs(k + b[i][j + 1] - a[i][j + 1])] = 1;
        }
    }
    //
    int x = maxVal;
    REP(i,0,maxVal) if(F[m][n][i]) x = min(x,i);
    
    cout << x;
    
    return 0;
}

Measured memory_bytes: 166400
#include<stdio.h>
#include<stdlib.h>

int main() 
{
  int *a;
  int n,i;
  
  scanf("%d",&n);
  a = (int*)malloc(sizeof(int)*n+1);
  for(i=1; i<=n; i++) scanf("%d",&a[i]);
  for(i=1; i<=n; i++) {
    printf("node %d: key = %d, ",i,a[i]);
    if(i/2>0) printf("parent key = %d, ",a[i/2]);
    if(2*i<=n) printf("left key = %d, ",a[2*i]);
    if(2*i+1<=n) printf("right key = %d, ",a[2*i+1]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    range(X, 1, N + 1) {
        if ((lint)floor(X * 1.08) == N) {
            cout << X << "\n";
            return 0;
        }
    }
    cout << ":(" << "\n";
}

Measured memory_bytes: 256
from itertools import accumulate, combinations

N, K = map(int, input().split())
X = [0] * N
Y = [0] * N
for i in range(N):
    X[i], Y[i] = map(int, input().split())
cx_to_x = sorted(list(set(X)))
x_to_cx = {k : i for i, k in enumerate(cx_to_x)}
cy_to_y = sorted(list(set(Y)))
y_to_cy = {k : i for i, k in enumerate(cy_to_y)}
nx = len(cx_to_x)
ny = len(cy_to_y)
points = [[0] * nx for _ in range(ny)]
for x, y in zip(X, Y):
    points[y_to_cy[y]][x_to_cx[x]] += 1
cum = [[0] * (nx+1)] + [list(accumulate([0] + row)) for row in points]
for i in range(1, ny+1):
    for j in range(nx+1):
        cum[i][j] += cum[i-1][j]
ans = float('inf')
for x1, x2 in combinations(range(nx), 2):
    for y1, y2 in combinations(range(ny), 2):
        cnt = cum[y2+1][x2+1] - cum[y2+1][x1] - cum[y1][x2+1] + cum[y1][x1]
        if cnt >= K:
            area = (cx_to_x[x2] - cx_to_x[x1]) * (cy_to_y[y2] - cy_to_y[y1])
            ans = min(ans, area)
print(ans)

Measured memory_bytes: 43372
import sys
sys.setrecursionlimit(10**8)
n=int(input())
a=list(map(int,input().split()))
dp=[[10**18]*(n) for _ in range(n)]
flag=[[0]*n for _ in range(n)]
accum=[a[0]]
for i in range(1,n):
    accum.append(accum[-1]+a[i])
accum=[0]+accum
def f(l,r):
    if l==r:
        return 0
    if flag[l][r]:
        return dp[l][r]
    flag[l][r]=1
    ret=10**18
    for i in range(l,r):
        ret=min(ret,f(l,i)+f(i+1,r))
    dp[l][r]=ret+accum[r+1]-accum[l]
    return dp[l][r]
f(0,n-1)
print(dp[0][n-1])

Measured memory_bytes: 79044
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main(){
  int n;
  cin >> n;
  while(n--){
    int h, m;
    scanf("%d:%d", &h, &m);
    double H = (double)h * 30 + m*0.5;
    double M = (double)m * 6;
    
    double ans = abs(H-M);
    if(180 < ans) ans = 360.0 - ans;
    
    if(0 <= ans && ans < 30) cout << "alert" << endl;
    else if(90 <= ans && ans <= 180) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
  return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
int ctoi(char c) {return c-'0';}

const int mxn=1e5+5;
vector<vector<int>> g(mxn,vector<int>());
vi visited(mxn);
vi memo(mxn);
int N,M;

int dp(int c) {
  if(g[c].size()==0) {
    return 0;
  }
  int ans=0;
  visited[c]=1;
  for(auto& x: g[c]) {
    if(!visited[x]) {
      if(memo[x]==0)
        ans=max(ans,memo[x]=dp(x)+1);
      else
        ans=max(ans,memo[x]);
    }
  }
  visited[c]=0;
  return ans;
}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

cin>>N>>M;
forn(i,M) {
  int x,y;
  cin>>x>>y;
  g[x].pb(y);
}
int mxans=0;
for(int i=1;i<=N;i++) {
  int d=dp(i);
  mxans=max(mxans,d);
}
cout<<mxans<<endl;
return 0;
}


Measured memory_bytes: 12020
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <string>
#define LL long long
#define rep(i,n) for(i=0;i<=(n);i++)
using namespace std;

string S;

int main(){
	
  	cin >> S;
  
  	if(S=="Sunny"){
    	
      cout << "Cloudy" << endl; 
	      
    }else if(S=="Cloudy"){
    		
      cout << "Rainy" << endl; 

    }else{
    	
      cout << "Sunny" << endl; 
    
    }

  return 0;

}


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

int main(void){
  int c[3][3],i,j;
  char str[100],*p;
  
  for(i=0;i<3;i++){
   fgets(str,sizeof(str),stdin);
   p=strtok(str," \n");
   c[i][0]=atoi(p);
   for(j=1;j<3;j++){
    p=strtok(NULL," \n");
    c[i][j]=atoi(p);
   }
  }
  for(i=0;i<2;i++){
   for(j=i+1;j<3;j++){
    if(c[0][j]-c[0][i]!=c[1][j]-c[1][i] 
       || c[2][j]-c[2][i]!=c[0][j]-c[0][i]) {
     printf("No\n");
      return 0;
    }
   }
  }
  
  printf("Yes\n");
  
 return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> a(N);
	vector<vector<ll>> po(2e5 + 1);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		po[a[i]].push_back(i);
		/*
		if (i == 8084) cout << a[i] << endl;
		if (i == 24084) cout << a[i] << endl;
		if (a[i] == 19734) cout << i << endl;
		*/
	}

	vector<pair<ll, ll>> B(N);
	for (int i = 0; i <= 2e5; i++) {
		for (int j = 0; j < po[i].size(); j++) {
			if (j + 1 == po[i].size()) {
				B[po[i][j]].first = (po[i][0] + (ll)1) % N;
				B[po[i][j]].second = 1;
				//cout << "i=" << i << " " << po[i][j] << endl;
			}
			else {
				B[po[i][j]].first = (po[i][j + 1] + (ll)1) % N;
				if (B[po[i][j]].first < po[i][j]) B[po[i][j]].second = 1;
			}
		}
	}

	ll now = 0, T = 0;
	vector<ll> cir(N);
	while (1) {
		cir[T] = now;
		if (B[now].second) {
			T++;
			//cout << "now=" << now << endl;
		}
		now = B[now].first;
		if (now == 0)break;
	}
	/*
	cout << "T=" << T << endl;
	cout << "cir=" << endl;

	for (int i = 0; i < N; i++) {
		cout << cir[i] << " ";
	}
	cout << endl;
	*/
	vector<pair<ll, ll>> ans(N);
	vector<ll> mp(2e5 + 1, -1);
	ll cnt = 0;

	bool fl = true;
	if (po[a[N - 1]].size() == 1) {
		T++;
		if ((K - 1) % T == T - 1)cnt = 0, fl = false;
	}


	if (fl) {
		for (int i = cir[(K - 1) % (T)]; i < N; i++) {
			//cout << "i=" << i << " cnt=" << cnt << endl;
			/*
			if (i == 24084) {
				cout << "i=" << i << a[i] << endl;
				cout << mp[a[i]] << endl;
			}
			*/
			if (mp[a[i]] != (ll)-1) {

				cnt = mp[a[i]];
				for (int j = ans[cnt].second; j <= i; j++) {
					mp[a[j]] = -1;
					ans[j].first = 0;
					ans[j].second = 0;
				}
			}
			else {
				mp[a[i]] = cnt;
				ans[cnt].first = a[i];
				ans[cnt].second = i;
				cnt++;
			}
			/*
			if (i == 8084) {
				cout << "i=" << i << a[i] << endl;
				cout << mp[a[i]] << endl;
			}
			*/
			/*
			for (int j = 0; j < N; j++) {
				cout << ans[j] << " ";
			}
			cout << endl << endl;
			*/
		}
	}

	//cout << "cnt=" << cnt << endl;
	//cout << endl << "ans=" << endl;
	for (int i = 0; i < cnt; i++) {
		cout << ans[i].first << " ";
	}


}

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

int main(){
  char b;
  cin>>b;
  if(b=='A')
    cout<<'T'<<endl;
  if(b=='T')
    cout<<'A'<<endl;
  if(b=='G')
    cout<<'C'<<endl;
  if(b=='C')
    cout<<'G'<<endl;
}

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

int main() {
	int n;
	while(cin >> n, n) {
		int jiro[32];
		for(int i = 0; i < n; i++)
			cin >> jiro[i];

		int ohajiki = 32;
		int turn = 0;

		while(ohajiki) {
			if(turn % 2) {
				ohajiki = ohajiki - jiro[(turn / 2) % n];
				ohajiki = ohajiki < 0 ? 0 : ohajiki;
			}
			else {
				ohajiki = ohajiki - (ohajiki - 1) % 5;
			}
			cout << ohajiki << endl;
			turn++;
		}
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(void)
{
    int x1=0,x2=0,x3=0,z,n;
    for(n=0;n<=9;n++){
        scanf("%d\n",&z);
        if(x1<z){
            x3=x2;
            x2=x1;
            x1=z;
        }else{
            if(x2<z){
                x3=x2;
                x2=z;
            }else{
                if(x3<z){
                    x3=z;
                }
            }
        }
    }
    printf("%d\n%d\n%d\n",x1,x2,x3);
    return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
int main() {
	int N;

	scanf("%d", &N);

	for(int A=1;A<10;A++)for(int B=1;B<10;B++) {
		if (A * B == N) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

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

int main() {
  int N;
  cin >> N;
  vector<int> g(N);
    for (int i = 0; i < N; i++) {
      cin >> g.at(i);
    }
  sort(g.begin(), g.end());
  double value = g.at(0);
  for (int i =0; i < N - 1; i++) {
    value = (value + g.at(i + 1)) / 2.0;
  }
  cout << value <<endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class A500YenCoins {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int k, x; cin >> k >> x;
      if (k*500 >= x) {
        cout << "Yes" << endl;
      } else {
        cout << "No" << endl;
      }
    }
};

signed main() {
  A500YenCoins solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

int main() {
	string a;
	cin >> a;
	
	bool last_one = false;
	int swap_one_start = 0;
	for(int i=0; i < a.length(); i++) {
		if(last_one && a[i] == '1') swap_one_start++;
		if(!last_one && a[i] == '0') swap_one_start++;
		last_one = !last_one;
	}
	
	last_one = true;
	int swap_two_start = 0;
	for(int i=0; i < a.length(); i++) {
		if(last_one && a[i] == '1') swap_two_start++;
		if(!last_one && a[i] == '0') swap_two_start++;
		last_one = !last_one;
	}
	
	cout << min(swap_one_start, swap_two_start) << endl;
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int A, B, C;
    cin >> A >> B >> C;
    if (A == B && B != C || A == C && B != C || B == C && A != B) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define pb push_back

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

const int N = 1e6 + 5;

int main(){

    string s;
        cin >> s;

    if(s[0] == 'A' && count(s.begin(),s.end(),'C') == 1){
        bool f = islower(s[1]) & islower(s[s.size()-1]);
//        cout << f << '\n';
        for(int i = 2; i < s.size()-1; i++)if(s[i] != 'C')
            f &= (islower(s[i])!=0);
        puts(f?  "AC":"WA");
    }   else puts("WA");

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L.at(i);
  
  if (N < 3) cout << "0" << endl;
  
  else {
    int ans = 0;
    for (int i = 0; i < N - 2; i++) {
      for (int j = i + 1; j < N - 1; j++) {
        for (int k = j + 1; k < N; k++) {
          int Li = L.at(i), Lj = L.at(j), Lk = L.at(k);
          if (Li == Lj || Lj == Lk || Lk == Li) continue;
          else if (Li + Lj > Lk && Lj + Lk > Li && Lk + Li > Lj) ans += 1;
        }
      }
    }
  
  cout << ans << endl;
  }
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()

using namespace std;

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

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, a[N];

int main() {
	megaRandom();
	scanf("%d", &n);
	for(int i = 1; i <= 3 * n; i ++)
		scanf("%d", &a[i]);
	sort(a + 1, a + 3 * n + 1);
	int l = 1, r = 3 * n;
	ll res = 0;
	while(l < r) {
		res += a[r - 1];
		//cout << a[l] << ' ' << a[r - 1] << ' ' << a[r] << "\n";
		l ++, r -= 2;  	
	}
	cout << res;
	return 0;         
}


Measured memory_bytes: 1408
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Text;
namespace AtC_169
{
    class Program
    {

        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long rootN = (long)Math.Sqrt(N) + 1;

            long count = 0;
            for (long i = 2; i <= rootN; i++)
            {
                long tmp = 0;
                while (N % i == 0)
                {
                    N = N / i;
                    tmp++;
                   // Console.WriteLine($"{i} {N} {tmp}");
                }
                
                count += func(tmp);
            }
            if (N > 1) count++;
            Console.WriteLine(count);

        }
        static long func(long t)
        {
            long i = 1, ans = 0;
            while (t >= i)
            {
                t = t - i;
                i++;
                ans++;
            }
            return ans;
        }
    }

    
}



Measured memory_bytes: 27540