akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  string S;
  cin>>S;
  ll N=S.size(),DP[N+1][13];
  
  REP(i,N+1){
    REP(j,13){
      DP[i][j]=0;
    }
  }
  
  DP[0][0]=1;
  
  REP(i,N){
    if(S[i]=='?'){
      REP(j,13){
        REP(k,10){
          DP[i+1][(j*10+k)%13]+=DP[i][j];
        }
      }
    }
    else{
      REP(j,13){
        DP[i+1][(j*10+S[i]-'0')%13]=DP[i][j];
      }
    }
    REP(j,13){
      DP[i+1][j]%=MOD;
    }
  }
  
  co(DP[N][5]);
  return 0;
}

Measured memory_bytes: 13840
from functools import reduce
n=int(input())
data=[]
for i in range(n):
    data.append(int(input()))
def gcd(a, b):
    while a != 0:
        a, b = b%a, a
    return b
def lcm(x, y):
    return (x * y) // gcd(x, y)
print(reduce(lcm,data))


Measured memory_bytes: 3572
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>


#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector<vector<int>> A(N, vector <int>(N-1));
	for (int ii = 0; ii < N; ++ii){
		for (int jj = 0; jj < N-1; ++jj){
			cin >> A[ii][jj];
			A[ii][jj]--;
		}
	}

	int ans = 0;
	while (true) {
		//処理
		vector <int> skip(N, 0);
		bool OK = false;
		bool allZero = true;
		for (int ii = 0; ii < N; ++ii){
			if (A[ii].size() == 0){
				skip[ii] = 1;
			} else {
				allZero = false;
			}
			if (skip[ii] == 1){
				continue;
			}

			int teki = A[ii].front();
			if ( (A[teki].front() == ii) && (skip[teki] == 0) ){
				OK = true;
				A[ii].erase(A[ii].begin());
				A[teki].erase(A[teki].begin());
				skip[ii] = 1;
				skip[teki] = 1;
			}
		}

		if (allZero){
			break;
		}
		ans++;
		if (OK == false){
			ans = -1;
			break;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6272
s = input()
q = int(input())
q_list = [list(input().split()) for _ in range(q)]

top_list = []
end_list = []

flag = 1

for q in q_list:
    if q[0] == '1':
        flag *= -1
    else:
        if flag == 1:
            if q[1] == '1':
                top_list.append(q[2])
            else:
                end_list.append(q[2])
        else:
            if q[1] == '2':
                top_list.append(q[2])
            else:
                end_list.append(q[2])
if flag == 1:            
    print(''.join(top_list[::-1]) + s + ''.join(end_list))
else:
    print(''.join(end_list[::-1]) + s[::-1] + ''.join(top_list))

Measured memory_bytes: 33024
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] a = new int[N];

        for (int i=0; i<N; i++) {
            a[i] = sc.nextInt();
        }

        int[] ans = solve(N, a);
        System.out.println(ans[0] + " " + ans[1]);
    }

    private static int[] solve(int N, int[] a) {
        int[] ans = new int[2];
        int max = 0;
        int mid = -1;

        for (int i=0; i<N; i++) {
            max = Math.max(max, a[i]);
        }

        for (int i=0; i<N; i++) {
            if (a[i] == max) continue;
            if (mid == -1) mid = a[i];


            if ( Math.abs(0.5 - (double)mid/max) > Math.abs(0.5 - (double) a[i]/max)) {
                mid = a[i];
            }
        }
        ans[0] = max;
        ans[1] = mid;

        return ans;
    }
}


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

J=[0]*N
j=0
while j<N:
    J[j]=j-A[j]
    j+=1

import collections
C = collections.Counter(J)

ans=0
i=0
while i<N:
    ans+=C[i+A[i]]
    i+=1

print(ans)

Measured memory_bytes: 42636
#include<bits/stdc++.h>
using namespace std;
typedef struct node
{
	char str[110];
	int t;
}NODE,*PNODE;
NODE arr[60];
char x[110];
int main()
{
	int n,i,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s %d",arr[i].str,&arr[i].t);
	}
	scanf("%s",x);
	i=0;
	while(strcmp(arr[i].str,x)!=0)
	{
		i++;
	}
	for(i=i+1;i<n;i++)
	{
		s+=arr[i].t;
	}
	printf("%d",s);
	return 0;
}

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

using namespace std;

int main()
{
long long a=99999999999,b=99999999999;
    int n; cin>>n;
    for(int i=0;i<n;i++)
    {
        int j,k; cin>>j>>k;
        if(k<b)b=k, a=j;
    }
cout<<b+a;

    return 0;
}


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

int main() {
	int m,f,r;
	while(true){
		char c;
		cin >> m >> f >> r;
		if(m==-1&&f==-1&&r==-1)break;
		//cout << m <<" "<< f <<" "<< r << endl;
		if(m+f>=30)c='D';
		if(m+f>=50||r>=50)c='C';
		if(m+f>=65)c='B';
		if(m+f>=80)c='A';
		if(m==-1||f==-1||m+f<30)c='F';
		cout << c << endl;
	}
	// your code goes here
	
	return 0;
}

Measured memory_bytes: 1152
N=int(input())
A=[int(i) for i in input().split()]
def GCD(x,y):
	if x>y:
		a=x
		b=y
	else:
		a=y
		b=x
	while(True):
		c=a%b
		if c==0:
			return b
		else:
			a,b=b,c
 

if N==2:
	print(max(A))
else:
	B=[]
	a0=A[-1]
	for aa in A[0:-1]:
		B.append(GCD(aa,a0))
	gomikamo=B.index(min(B))
	g0=A[0]
	for i in range(0,N-1):
		g0=GCD(A[i],g0)
	del A[gomikamo]
	g1=A[0]
	for i in range(N-1):
		g1=GCD(A[i],g1)
	print(max(g0,g1))

Measured memory_bytes: 14400
#include<algorithm>//sort(all(変数),greater<型名>())で降順に、*max_element(all(変数))で最大値を獲得
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric>
// xとyのgcdは__gcd(x,y),xとyのlcmは(x*y)/__gcd、accumulate(all(変数),0)で要素の全加算
#include<queue>//priority_queue<型名> 変数
#include<set>
#include<stack>
#include<string>//変数.substr(どこから,いくつ)
#include<vector>
#define rep(i,n)  for(ll i=0; i<n; i++)
#define rrep(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e9
using ll = long long;
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; }


int main(){
  string s; cin >> s;
  bool ans = false;
  rep(i,s.size()+1){
    for(int j = i; j <s.size()+1; j++){
      string t = s.substr(0,i) + s.substr(j);
      if(t == "keyence") ans = true;
    }
  }
  cout << (ans ? "YES" : "NO");
  cout << "\n";
  return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = [0] * (N + 1)

cnt = 0
for i in range(N):
    D[i+1] = D[i] + L[i]
    if D[i+1] <= X:
        cnt += 1

print(cnt + 1)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K;
  cin >> K;
  vl num{1,2,3,4,5,6,7,8,9};
  while(sz(num)<K) {
    vl num2;
    rep(i,sz(num)) {
      int c = num[i]%10;
      if(c>0&&c<9) {
        num2.push_back(num[i]*10+c-1);
        num2.push_back(num[i]*10+c);
        num2.push_back(num[i]*10+c+1);
      } else if(c==0) {
        num2.push_back(num[i]*10+c);
        num2.push_back(num[i]*10+c+1);
      } else {
        num2.push_back(num[i]*10+c-1);
        num2.push_back(num[i]*10+c);
      }
    }
    uni(num2);
    K -= sz(num);
    num = num2;
  }
  cout << num[K-1] << endl;
  return 0;
}

Measured memory_bytes: 2720
# -*- coding: utf-8 -*-
c = [0] * 3
for i in range(3):
    c[i] = list(map(int,input().split()))

a = [0,0,0]
b = [0,0,0]

a[0] = 0
for i in range(3):
    b[i] = c[0][i] - a[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

ans = True

for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            ans = False
            break

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import sys
z=sys.stdin.readline
class SegmentTree:
    def __init__(self, data, default=0, func=max):
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()
        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])
    def __delitem__(self, idx):
        self[idx] = self._default
    def __getitem__(self, idx):
        return self.data[idx + self._size]
    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1
    def __len__(self):
        return self._len
    def query(self, start, stop):
        start += self._size
        stop += self._size
        res_left = res_right = self._default
        while start < stop:
            if start & 1:
                res_left = self._func(res_left, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res_right = self._func(self.data[stop], res_right)
            start >>= 1
            stop >>= 1
        return self._func(res_left, res_right)
    def __repr__(self):
        return "SegmentTree({0})".format(self.data)
M=300001
n,k=map(int,z().split())
s=SegmentTree([0]*M)
for i in range(n):
    a=int(z())
    s[a]=1+s.query(max(0,a-k),min(a+k+1,M))
print(s.query(0,M))

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

int N;
vector<pair<int, int>> RC;
map<int, int> mp;

signed main() {

    cin >> N;

    vector<int> test(N, 0);

    int cnt = 0;

    RC.resize(N);
    REP(i, N) {
        int R, C;
        cin >> R >> C;
        --R, --C;
        RC.emplace_back(make_pair(R, C));
        test[R]++;
        test[C]++;
        mp[R] = C;
    }

    REP(i, N) {
        if (test[i] != 2) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll res = 0;
    vector<bool> flag(N, false);
    REP(i, N) {
        if (flag[i]) continue;
        int cur = i;
        int cnt = 0;
        while (true) {
            if (flag[cur]) break;
            flag[cur] = true;
            cnt += 1;
            cur = mp[cur];
        }
        res += cnt - 1;
    }

    cout << res << endl;

}


Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
int main() {
int n;
cin>>n;
int check=0,count=0;
for(int i=1;i<=n;i++){
   if(i%2==0)continue;
   check=0;
   for(int j=1;j<=i;j++){
      if(i%j==0){
         check++;
      }
      if(check>8)break;
   }
   if(check==8){
        count++;    
         }
}
cout<<count<<endl;
}


Measured memory_bytes: 256
N = 3
ARR = [
    [10, 40, 70],
    [20, 50, 80],
    [30, 60, 90]
]

N = 1
ARR = [
    [
        100, 10, 1
    ]
]


N = 7
ARR = [
    [6, 7, 8],
    [8, 8, 3],
    [2, 5, 2],
    [7, 8, 6],
    [4, 6, 8],
    [2, 3, 4],
    [7, 5, 1]
]

N = int(input())
ARR = []

for i in range(N):
    ARR.append(list(map(int,input().split())))


def calculate(n, arr):
    result = []



    for index, value in enumerate(arr):
        if index == 0:
            result.append(value)
        else:
            s0 = max(value[0] + result[index - 1][1], value[0] + result[index - 1][2])
            s1 = max(value[1] + result[index - 1][0], value[1] + result[index - 1][2])
            s2 = max(value[2] + result[index - 1][0], value[2] + result[index - 1][1])
            result.append([s0, s1, s2])


    print(max(result[-1]))


calculate(N, ARR)


Measured memory_bytes: 47336
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include<iomanip>
using namespace std;

int N, K;

int main() {
    int A, B;
    cin >> A >> B;
    cout << 6 - A - B << endl;
}


Measured memory_bytes: 256
# 部分リストのリスト
def all_sublist(lst):
    lstlst = []
    for i in range(2**len(lst)):
        sublst = []
        for j in range(len(lst)):
            if (i >> j) & 1 == 1:
                sublst.append(lst[j])
        lstlst.append(sublst)
    return lstlst


# 入力
H, W, K = map(int, input().split())
S = [[int(x) for x in list(input())] for h in range(H)]

# 横方向にカットする位置の列挙
cutlst = all_sublist(list(range(1, H)))

# 横方向の切り方を動かして切る数の合計の最小値を求める
cnt_min = 10**9 + 7
for cut in cutlst:
    # 横方向に切って圧縮したものをSSとする
    SS = []
    cut.append(H)
    start = 0
    for stop in cut:
        T = []
        for w in range(W):
            tmp = 0
            for h in range(start, stop):
                tmp += S[h][w]
            T.append(tmp)
        SS.append(T)
        start = stop
    H0 = len(SS)
    # K以上の成分があったらこのcutはパス
    if any([SS[h][w] > K for h in range(H0) for w in range(W)]):
        continue
    # 縦方向に切る数を数える
    cnt = len(cut) - 1
    left = [0 for h in range(H0)]
    right = [SS[h][0] for h in range(H0)]
    for w in range(1, W):
        left, right = right, [right[h] + SS[h][w] for h in range(H0)]
        leftOK = all([left[h] <= K for h in range(H0)])
        rightNG = any([right[h] > K for h in range(H0)])
        # すべての成分がK以下になるギリギリのところで切る
        if leftOK and rightNG:
            left = [0 for h in range(H0)]
            right = [SS[h][w] for h in range(H0)]
            cnt += 1
    cnt_min = min(cnt_min, cnt)
print(cnt_min)


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

using namespace std;

const int N = 1e5+5;
int arr[N];
int n, a, b;

bool valid2(long long trials, long long trial, long long cpy){
	return (trial * a + (trials - trial) * b) >= cpy;
}

bool valid(long long trials){
	long long needA = 0;
	for(int i = 0; i < n; ++i){
		long long cpy = arr[i], low = 0, high = trials, mid;
		if(trials * a < cpy)
			return 0;
		while(low < high){
			mid  = low + (high - low) / 2;
			if(valid2(trials, mid, cpy)){
				high = mid;
			}
			else{
				low = mid+1;
			}
		}
		needA += high;
	}
	return needA <= trials;
}

int main() {
	cin >> n >> a >> b;
	for(int i = 0; i < n; ++i)
		cin >> arr[i];
	int low = 0, high = 1e9+2, mid;
	while(low < high){
		mid  = low + (high - low) / 2;
		if(valid(mid)){
			high = mid;
		}
		else{
			low = mid+1;
		}
	}
	cout << high;
	return 0;
}


Measured memory_bytes: 3980
/*
doge
░░░▄░░░░░░░░░░░░░░▄
░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌
░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐
░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌
░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌
░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌
░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌
▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒
*/
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>

using namespace std;

#define ll long long
#define ld long double
#define null NULL


int s[100100], p[100100];

vector<int> g[100100];


void dfs(int v, int par = 1) {
	s[v] = 1;
	p[v] = par;
	for (int u : g[v]) {
		if (u == par) continue;
		dfs(u, v);
		s[v] += s[u];
	}
}


signed main() {
	int n;
	scanf("%d", &n);
	for (int edge = 0; edge < n - 1; ++edge) {
		int u, v;
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1);
	int _v = n;
	int cnt = 0;
	while (_v != 1) {
		++cnt;
		_v = p[_v];
	}
	cnt = (cnt - 1) / 2;
	int v = n;
	for (int i = 0; i < cnt; ++i) {
		v = p[v];
	}
	int s1 = s[v], s2 = n - s[v];
	if (s1 >= s2) {
		puts("Snuke");
	} else {
		puts("Fennec");
	}
    return 0;
}













Measured memory_bytes: 11136
def main():
    import sys
    import bisect

    read = sys.stdin.buffer.read
    bisect_right = bisect.bisect_right

    N, *A = map(int, read().split())

    dp = [A[-1]]
    for a in reversed(A[:-1]):
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a

    print(len(dp))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 55796
n = int(input())
lst = [int(i) for i in input().split()]

while lst.count(0) != len(lst)-1:
    lst.sort()
    m = None
    for i in range(len(lst)):
        if lst[i]!=0 and m==None:
            m = lst[i]
        elif lst[i]!=0:
            lst[i] %= m
else:
    print(sum(lst))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 

int main()
{
    in(m);
    in(d);

    ll ans = 0;
    for(ll i = 1;i<=m;i++){
        for(ll j = 1;j<=d;j++){
            if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i)
                ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	double n;
	cin >> n;
	for (int i = 1; i < 3501; i++) {
		for (int j = 1; j < 3501; j++) {
			int A = n * i * j, B = 4 * i * j - n * i - n * j;
			if (B <= 0) continue;
			if (!(A % B) && A / B > 0) {
				cout << i << " " << j << " " << A / B << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
//swapping.cpp
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int i,x,y;
    for ( i = 0; i < 3000; i++)
    {
        cin>>x>>y;
        if (x != 0 || y!=0)
        {
            cout<<min(x,y)<<" "<<max(x,y)<<endl;
        }
        else
        {
            break;
        }
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  a+=b;
  if(a>=c){
    cout<<"Yes"<<"\n";
  }
  else{
    cout<<"No"<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3636
import math
h, w = map(int, input().split())

ans = 0
if h == 1 or w == 1:
    ans = 1
elif h % 2 == 1 and w % 2 == 1:
    ans = (h - 1) * w // 2 + (w + 1) // 2
else:
    ans = h * w // 2
print(ans)


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(long long H, long long W, long long N){
    cout<<min(RUP(N,H),RUP(N,W))<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long N;
    scanf("%lld",&N);
    solve(H, W, N);
    return 0;
}


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> bs(M);
  for(int i = 0; i < M; ++i) {
    cin >> bs[i];
  }
  vector<int> anss(N, 0);
  int a;
  for(int i = 0; i < N; ++i) {
    int ans = 0;
    for(int j = 0; j < M; ++j) {
      cin >> a;
      ans += a * bs[j];
    }
    anss[i] = ans + C;
  }
  auto count = count_if(anss.begin(), anss.end(), [](auto x) { return x > 0; });
  cout << count << endl;
  return 0;
}


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

int main(){
    long long n, k, cnt[100002]{}, ans = 0, sum = 0;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        long long a, b;
        cin >> a >> b;
        cnt[a] += b;
    }
    while(k > sum){
        ans++;
        sum += cnt[ans];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Task.solve(in, out);
        out.close();
    }

    static class Task {

        public static void solve(FastReader in, PrintWriter out) {
            String a = in.next();
            String b = in.next();

            for(int i=0;i<b.length();i++){
                String c = b.substring(i);
                c += b.substring(0,i);
                if(a.equals(c)){
                    System.out.println("Yes");
                    return;
                }
            }
            System.out.println("No");
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
 
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
 
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int m = 1 << n;
  vector <int> arr(m);
  for (int& elem: arr) cin >> elem;
  multiset <int> st(all(arr));
  vector <int> prev = {*(--end(st))};
  st.erase(--end(st));
  while (not st.empty()) {
    vector <int> cur = prev;
    for (int elem: prev) {
      auto it = st.lower_bound(elem);
      if (begin(st) == it) {
        cout << "No\n";
        return (0);
      }
      it--;
      cur.pb(*it);
      st.erase(it);
    }
    sort(rall(cur));
    prev = cur;
  }
  cout << "Yes\n";
  return (0);
}


Measured memory_bytes: 15668
import sys
from collections import defaultdict as dd
from collections import deque as dq
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)


d = [10 ** 6 for _ in range(N + 1)]
d[1] = 0
Q = dq([1])
while len(Q):
  p = Q.popleft()
  for q in e[p]:
    if d[q] > d[p] + 1:
      Q.append(q)
      d[q] = d[p] + 1
c = [[0] * 2 for _ in range(N + 1)]
wh = 0
gr = 0
for x in range(1, N + 1):
  for y in e[x]:
    dy = d[y] % 2
    c[x][dy] = 1
  cc = (c[x][0] & c[x][1])
  wh += c[x][0]
  gr += cc

if gr:
  print(N * (N - 1) // 2 - M)
  exit(0)

res = 0
for x in range(1, N + 1):
  res += wh * c[x][1]

  #print(res, x)
#print(res)
print(res - M)

Measured memory_bytes: 80348
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <tuple>
#include <stdlib.h>
using namespace std;
typedef long long int ll;

int main()
{
	int N,ans=1;
	string S; char mae = 'A';
	cin >> N >> S;
	for (int i = 0; i < N; i++)
	{
		if (i != 0 && S[i] != mae)ans++;
		mae = S[i];
	}
	cout << ans;
}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
  int H,W,h,w;
 
while(1)
{
  scanf("%d %d",&H,&W);
  if(H==0&&W==0){
   break;
}

for(h=0;h<H; h++)
{
for(w=0;w<W;w++){
 if(h==0 || h==H-1 || w==0 || w==W-1){
printf("#");
}
else{
printf(".");
}
}
printf("\n");
}
printf("\n");
}
return 0;
}


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

int main() {
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
    int a,b,ans;
    scanf("%d%d",&a,&b);   //输入两个整数
    ans=max(a+b,max(a-b,a*b)); //等价于取a+b,a-b,a*b的最大值并存入ans中
    printf("%d",ans);    //打印答案
    return 0;
}


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

int main() {
	int n, h;
	cin >> n >> h;
	vector<pair<int, int>> a(n);
	int mx = 0;
	rep(i, n) {
		int s, t;
		cin >> s >> t;
		a[i] = {t, s};
		mx = max(mx, s);
	}
	int ans = 0;
	sort(all(a));
	reverse(all(a));
	rep(i, n) {
		if(a[i].first > mx) {
			h -= a[i].first;
			ans++;
			if(h <= 0) {
				cout << ans << endl;
				return 0;
			}
		} else break;
	}
	ans += (h+mx-1) / mx;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
    int n,m,a;
    cin>>n>>m>>a;
    if(a >= n && a <= m) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    intl a[n];
    cin(i,a);
    sort(a, a + n);
    cout << a[n-1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
// CODE by Kazhybay Askar
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define iter   set<int>::iterator
#define f      first
#define s      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define mp     make_pair
#define cont   continue
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define endl   '\n'

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

const int MAXN  = 1e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll a[MAXN],b[MAXN],d[MAXN],dist[MAXN];
vector<int>g[MAXN],v;
bool used[MAXN];
ll n,m,k,cnt,sum,ans,mx=1,mn=INF;
bool y;

void freopen(){
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
}
void dfs(int v){
    used[v]=1;
    for(auto i:g[v]){
        if(!used[i]){
            dist[i]=max(dist[i],dist[v]+1);
            d[i]--;
            if(!d[i])dfs(i);
        }
    }
}

void solve(){
	cin>>n;
    cin>>m;
    for(int i=1;i<=m;i++){
        int v,u;
        cin>>v>>u;
        g[v].pb(u);
        d[u]++;
    }
    for(int i=1;i<=n;i++){
        if(!used[i] && d[i]==0){
            dfs(i);
        }
    }
    for(int i=1;i<=n;i++){
        mx=max(mx,dist[i]);
    }
    cout<<mx;
}

int main(){
	Speed;
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	r0;
}




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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

signed main() {
  int T;
  cin >> T;
  Rep(i, T) {
    int N, D;
    cin >> N >> D;
    if ( N == 1 ) cout << D << endl;
    else {
      if ( N % 2  == 0 )
	cout << ((1 << 7)-1) * (N-1) + (((1 << 7)-1) - D) << endl;
      else {
	cout << ((1 << 7)-1) * (N-1) + D << endl;
      }
	
    }
    
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	cin>>x;
	ll ans = (x/11)*2;
	x %= 11;
	if(x ==0)
	{
		cout<<ans<<endl;
		return 0;
	}
	if(ans&1)
	{
		if(x>5) ans+= 2;
		else ans++;
	}
	else
	{
		if(x>6) ans+= 2;
		else ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N,W;
  cin >> N >> W;
  vector<vector<int>> sina(N,vector<int>(2,0));
  vector<vector<int64_t>> dp(N+1,vector<int64_t>(W+1,0));
  for (int i=0;i<N;i++){
    cin >> sina.at(i).at(0) >> sina.at(i).at(1);
  }
  for (int n=1;n<=N;n++){
    for (int w=1;w<=W;w++){
      if (w>=sina.at(n-1).at(0)){
        dp.at(n).at(w)=(int64_t)max(dp.at(n-1).at(w),dp.at(n-1).at(w-sina.at(n-1).at(0))+sina.at(n-1).at(1));
      }else{
        dp.at(n).at(w)=dp.at(n-1).at(w);
      }
    }
  }
  cout << dp.at(N).at(W) << endl;
}

Measured memory_bytes: 80256
S = list(input())
i = 0
while i <= len(S)-3:
    if S[i] == S[i+1]:
        print(i+1, i+2)
        break
    elif S[i] == S[i+2]:
        print(i+1, i+3)
        break
    i += 1
else:
    if S[i] == S[i+1]:
        print(i+1, i+2)
    else:
        print(-1, -1)

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

using namespace std;

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int flag=1;
    if(a==b){
        if(a!=5) flag=0;
        else if(c!=7) flag=0;
    }
    else if(a==c){
       if(a!=5) flag=0;
       else if(b!=7) flag=0;
    }
    else if(b==c){
       if(b!=5) flag=0;
       else if(a!=7) flag=0;
    }
    if(flag) printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int x,n,m=2e9,ans;
int main()
{
    cin>>n;
    while(n--){
        scanf("%d",&x);
        if(x%10) m=min(m,x);
        ans+=x;
    }
    if(ans%10) cout<<ans;
    else cout<<max(0,ans-m);
    return 0;
}

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

int main()
{
int N;scanf("%d",&N);
vector<int> A(N);
for(int i=0;i<N;i++)scanf("%d ",&A[i]);
int ans=1000000000;
for(int i=0;i<N;i++)
{
  int times=0;
  while(A[i]%2==0){A[i]/=2;times++;}
  ans=min(times,ans);
}
printf("%d\n",ans);
}

Measured memory_bytes: 256
import re

arg = input()

valid_year = r"[0-9][0-9]"
valid_month = r"0[1-9]|1[0-2]"

s1_is_year = re.match(valid_year, arg[:2])
s1_is_month = re.match(valid_month, arg[:2])
s2_is_year = re.match(valid_year, arg[2:])
s2_is_month = re.match(valid_month, arg[2:])

is_yymm = s1_is_year and s2_is_month
is_mmyy = s1_is_month and s2_is_year

if is_yymm and is_mmyy:
    print("AMBIGUOUS")
elif is_yymm:
    print("YYMM")
elif is_mmyy:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main() {
	int a, b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3096
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/

void build(){

}
#define N 1010101
char c[ N ];
void init(){
  scanf( "%s" , c + 1 );
}
void solve(){
  c[ 0 ] = 'x';
  int cnt = -1;
  for( int i = 1 ; c[ i ] ; i ++ )
    if( c[ i ] != c[ i - 1 ] )
      cnt ++;
  printf( "%d\n" , cnt );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;

#define DEBUG (1)

#ifdef DEBUG
#define DPRINT(...)  printf("D(L%d)%s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINT(...)
#endif

void swap(int &a, int &b);
void printAns(int ary[], int size, int count);

int main() {
	int size;
	cin >> size; cin.ignore();
	assert(size > 0);

	int ary[size];
	for (int i=0; i < size; i++)
		cin >> ary[i];

	int count = 0;
	for (int i=0; i < size-1; i++) {
		int minIdx = i;
		for (int j = i+1; j < size; j++) {
			if (ary[minIdx] > ary[j])
				minIdx = j;
		}
		if (i != minIdx) {
			swap(ary[i], ary[minIdx]);
			count++;
		}
	}

	printAns(ary, size, count);
	return 0;
}

void swap(int &a, int &b) {
	int temp = a;
	a = b;
	b = temp;
}

void printAns(int ary[], int size, int count) {
	for (int i=0; i < size; i++) {
		if (i > 0)	cout << " ";
		cout << ary[i];
	}
	cout << endl;
	cout << count << endl;
}

Measured memory_bytes: 3076
using System;

class MainClass
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = new int[n];
        int sum = 0;

        for (int i = 0; i < n;i++)
        {
            int tmp = int.Parse(Console.ReadLine());
            if(-1 == Array.IndexOf(d, tmp))
            {
                sum++;
            }
            d[i] = tmp;
        }



        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13268
n = int(input())
a = list(map(int, input().split()))
m = 10 ** 6 + 1
cnt = [0] * m
for x in a:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x, m, x):
        cnt[i] += 1
ans = 0
for x in a:
    if cnt[x] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 121600
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main() {
	fast();
	ll n;
	cin >> n;
	ll lastI;
	ll res = 0;
	for (ll i = 2; i * i <= n; ++i) {
		//cout << "pi";
		int tot = 0;
		while (n % i == 0) {
			//cout << "po";
			n /= i;
			++tot;
		}
		if (tot > 0) {
			ll lb = 1, rb = 44;
			while (lb < rb) {
				//cout << "pe";
				ll mb = (lb + rb + 1)/2;
				ll val = mb * (mb + 1) / 2;
				if (val == tot) {
					lb = mb;
					rb = mb;
				} else if (val < tot) {
					lb = mb;
				} else {
					rb = mb - 1;
				}
			}
			res += lb;
		}
		lastI = i;
	}
	if (n > 1) {
		++res;
	}
	cout << res << nl;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vi p(n, k-q);
    rep(i, q) {
        int a;
        cin >> a;
        --a;
        p[a]++;
    }
    rep(i, n) puts(p[i]>0?"Yes":"No");
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,n,c=0;
	while(1){
		c=0;
	cin>>a>>n;
	if(a==0&&n==0)break;
	for(int i=1;i<=a;i++)for(int j=i+1;j<=a;j++)for(int k=j+1;k<=a;k++)if(i+j+k==n)c++;
cout<<c<<'\n';
}return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define REP(i,n) for(int i=0;i<signed(n);i++)
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-2){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(llabs(s)>llabs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1||b==N-1)continue;
            if(llabs(t)>llabs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
vector<ll> fac, finv, inv;

ll combCalc(ll n, ll k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll comb(ll x, ll y){
    fac = finv = inv = vector<ll>(x+1);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i=2; i<=x; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
    return combCalc(x, y);
}
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;
mint calc(ll N, ll K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}


int main(){
    ll n, a, b; cin >> n >> a >> b;
    mint ans = modpow(mint(2), n)-1;
    ans -= calc(n, a)+calc(n, b);
    cout << ans << endl;
}

Measured memory_bytes: 256