akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nof(T) [](T a){return a;}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, r;
	scanf("%d%d", &n, &r);
	if (n < 10)r += 100 * (10 - n);
	printf("%d\n", r);

	Please AC;
}


Measured memory_bytes: 256
<?php

//文字列の入力
fscanf(STDIN,"%3s",$s);
fscanf(STDIN,"%3s",$t);


//文字列から一文字ずつ取り出す
//Sの文字列
$a = substr($s,0,1);
$b = substr($s,1,1);
$c = substr($s,2,1);

//Tの文字列
$aa = substr($t,0,1);
$bb = substr($t,1,1);
$cc = substr($t,2,1);

//照合
if ($a == $aa){
    $e = 1;
}
if ($b == $bb){
    $f = 1;
}
if($c == $cc) {
    $g = 1;
}

echo $e + $f + $g;



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

int main() {

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

  sort (M.begin(),M.end());
  int C;C=0;
    for (int i=0;i<N-1;i++){
    if (M.at(i) == M.at(i+1)){
      C++;}
    }

  cout << N - C << endl;
}


Measured memory_bytes: 256
//Code by ASIM FOIZE AIMON
//CSE'19;CUET
//avoid copy paste//Hit the friend button
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(n) for (int i = 0; i < n; i++)
#define fo(i, x, n) for (int i = x; i < n; i++)
#define fb(i, x, n) for (int i = n - 1; i <= 0; i--)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
typedef unsigned long long ull;
typedef vector<long long> vi;
#define ull unsigned long long
#define msi map<string, long long>
#define mii map<long long, long long>
const int MX = 2e5 + 5;
const int INF = 1e18;
#define pb push_back
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define all(x) x.begin(), x.end()
int a[11] = {0};
int check(int n)
{
    while (n > 0)
    {
        int m = n % 10;
        if (a[m])
        {
            return 0;
        }
        n /= 10;
    }
    return 1;
}
int32_t main()
{
    int n, k, x;
    cin >> n >> k;
    f(k)
    {
        cin >> x;
        a[x]++;
    }
    int y = n;
    while (1)
    {
        if (check(y))
        {
            break;
        }
        y++;
    }
    cout << y << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int count=0;
    for(int i=1;i<=n;i++)
    {
        int ip;
        cin>>ip;
        if(ip!=i)
        {
            count++;
        }
    }
    if(count<=2)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 100000000000000000
#define int long long
typedef pair<int, int> P;
int d[100010];
vector<P> G[100010];
int N, M;
int dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P>> que;
    rep(i, N) d[i] = INF2;
    d[s] = 0;
    que.push({d[s], s});
    while(que.size()) {
        P p = que.top(); que.pop();
        int cost = p.first;
        int u = p.second;
        if(d[u] < cost) continue;
        for(auto e: G[u]) {
            int to = e.first;
            int add = e.second;
            if(d[to] > cost + add) {
                d[to] = cost + add;
                que.push({d[to], to});
            }
        }
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int s, t, c;
        cin >> s >> t >> c;
        s--; t--;
        G[s].push_back({t, c});
        G[t].push_back({s, c});
    }
    rep(i, N - 1) G[i + 1].push_back({i, 0});
    dijkstra(0);
    if(d[N - 1] >= INF2) {
        cout << -1 << endl;
        return 0;
    }
    cout << d[N - 1] << endl;
    //rep(i, N) cout << i << " " << d[i] << endl;

    return 0;
}


Measured memory_bytes: 12792
#include<iostream>

using namespace std;

int main(void){
  char C; // small alphabet
  string alp = "abcdefghijklmnopqrstuvwxyz";
  cin >> C;
  int index=0;

  for(int i=0; i<24; i++){
	//cout << C << alp[i] << endl;
	if(C == alp[i]){
	  break;
	}
	index++;
  }

  cout << alp[index+1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;

const int N = (int)1e5+5;

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

    ll n,k;
    cin>>n>>k;
    ll ans = n;
    if(n>k) {
        ll p = n-n/k*k;
        ll lo=0, hi = n/k, mi;
        while(lo<hi) {
            mi = 1+(lo+hi)/2;
            if(n-mi*k >= k) lo = mi;
            else hi = mi-1;
        }
        p = n-k*lo;
        ans = p-k;
        n = p-k;
    }
    ans = min(ans,(ll)abs(k-n));
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define print(n) std::cout << n << std::endl
#define FOR(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
    string n;
    cin >> n;
    print("ABC" + n);
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void) 
{
    int d, t, s;
    int calculate;

    scanf("%d %d %d", &d, &t, &s);
    calculate = t * s;

    if (d <= calculate) {
        printf("Yes");
    }
    else {
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
long long ans=0,a,b,c,n;
string s,t;
int main(){
  cin >> a >> b >> c >> n;
  int d=max({a,b,c});
  for(int i=0;i<n;i++){
    d*=2;
  }
  ans+=a+b+c+d-max({a,b,c});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter
import bisect
ii = lambda: int(input())
iia = lambda: list(map(int,input().split()))
isa = lambda: list(input().split())
def gcd(a,b):
	if(b==0):
		return a
	return gcd(b,a%b)

n = ii()
a = iia()
x = 1
c = 0
for i in a:
	if(x==i):
		x+=1
	else:
		c+=1
if(c==n):
	c=-1
print(c)

Measured memory_bytes: 26780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define ll long long int
#define vr vector
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define loop(i,n) for(i=0;i<n;i++)
#define inp !cin.eof()
#define sec itr->second
#define fir itr->first

ll power(ll x,ll y,ll p)
{
    ll res = 1;

    while (y > 0)
    {

        if (y & 1)
            res = (res*x)%p;


        y = y>>1;
        x = ((x%p)*(x%p))%p;
    }
    return res%p;
}





int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     // iterating a loop until input is providing====!cin.eof()

    //ll t; cin>>t;
     //scanf("%lld",&t);
     //while(t--)
        {

         ll n,m,i,x,y,p=0,z,j,k,flag=1,mi=mod,ans=0,sum=0;

         string s;
         cin>>s;
         s='S'+s;
         s.push_back('S');
         ll ma=0;
         for(i=0;i<s.size();i++)
         {
             if(s[i]=='R')
                ans++;
             else
             {
                ma=max(ma,ans);
                ans=0;
             }
         }

         cout<<ma;

         cout<<endl;
         }
    return 0;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 2e6+5;
void solve(){
    int n;
    cin>>n;
    int a[4]={};
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        if(s[0]=='A')a[0]++;
        if(s[0]=='W')a[1]++;
        if(s[0]=='T')a[2]++;
        if(s[0]=='R')a[3]++;
    }
    cout<<"AC x "<<a[0]<<endl;
    cout<<"WA x "<<a[1]<<endl;
    cout<<"TLE x "<<a[2]<<endl;
    cout<<"RE x "<<a[3]<<endl;

}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
  //  cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

#define mid ((l + r) >> 1)

int n, q, t[2][800800], lz[2][800800];
ll ans;

void build(int node = 1, int l = 1, int r = n){
	if(l == r){
		t[0][node] = t[1][node] = n;
		return;
	}
	build(node*2, l, mid), build(node*2+1, mid+1, r);
}

void lazy_update(int node, int l, int r){
	for(int i=0;i<2;i++){
		t[i][node] = min(t[i][node], lz[i][node]);
		if(l != r) lz[i][node*2] = min(lz[i][node*2], lz[i][node]), lz[i][node*2+1] = min(lz[i][node*2+1], lz[i][node]);
		lz[i][node] = 1e9;
	}
}

int find(int fl, int id, int node = 1, int l = 1, int r = n){
	lazy_update(node, l, r);
	if(id < l || r < id) return 0;
	if(l == r) return t[fl][node];
	return find(fl, id, node*2, l, mid) + find(fl, id, node*2+1, mid+1, r);
}

void update(int fl, int nl, int nr, int x, int node = 1, int l = 1, int r = n){
	lazy_update(node, l, r);
	if(nr < l || r < nl) return;
	if(nl <= l && r <= nr){
		lz[fl][node] = x;
		lazy_update(node, l, r);
		return;
	}
	update(fl, nl, nr, x, node*2, l, mid), update(fl, nl, nr, x, node*2+1, mid+1, r);
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n >> q;
	build();
	for(int i=1;i<=4*n;i++) lz[0][i] = lz[1][i] = 1e9;

	while(q--){
		int a, b; cin >> a >> b; a--;

		int k = find(a, b);
		update(!a, 1, k-1, b);
		ans += k - 2;
	}

	cout << 1ll * (n - 2) * (n - 2) - ans;
}

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

int main()
{
  int n;
  cin >> n;
  unordered_set<int> prime_set;
  unordered_map<int, int> master_gcd;
  bool is_pairwise_coprime = true;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    unordered_map<int, int> prime;
    for (int i = 2; i*i <= x; i++) {
      while (x % i == 0) {
        x /= i;
        prime[i]++;
      }
    }
    if (x != 1) {
      prime[x]++;
    }

    if (is_pairwise_coprime) {
      for (const auto& p : prime) {
        if (prime_set.find(p.first) != prime_set.end()) {
          is_pairwise_coprime = false;
          break;
        }
        prime_set.insert(p.first);
      }
    }

    if (i == 0) {
      swap(master_gcd, prime);
      continue;
    }
    unordered_map<int, int> new_gcd;
    for (const auto& p : prime) {
      auto it = master_gcd.find(p.first);
      if (it == master_gcd.end()) {
        continue;
      }
      new_gcd[p.first] = min(p.second, it->second);
    }
    swap(master_gcd, new_gcd);
  }
  if (is_pairwise_coprime) {
    cout << "pairwise coprime\n";
  } else if (master_gcd.empty()) {
    cout << "setwise coprime\n";
  } else {
    cout << "not coprime\n";
  }
  return 0;
}


Measured memory_bytes: 6696
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <utility>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> pii;
ll mod = 1e9+7;
ll f(ll n){
    ll res = 1;
    for(ll i = 1; i <= n; i++){
        res *= i;
        res %= mod;
    }
    return res;
}
int main(){
    ll n,m;
    cin >> n >> m;
    if(abs(n-m)>=2){
        cout << 0 << endl;
        return 0;
    }
    if(abs(n-m)==1){
        cout << f(n) * f(m) %mod << endl;
    }else{
        cout << 2 * f(n) * f(m) % mod << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#define N 600
int a[2][2],i,j,m,n,o,p,x,y;bool b[N][N],c[N][N];
int main()
{
	scanf("%d%d%d",&n,&o,&p),m=n<<1;
	while(~o&1)o>>=1,x++;
	while(~p&1)p>>=1,y++;
	if(x&y&1)for(i=0,x=1<<(x>>1),y=1<<(y>>1);i<m;i++)for(j=0;j<m;j++)a[b[i][j]=i&x][c[i][j]=i&y]++;
	else if(x&1)for(i=0,x=1<<(x>>1),y=1<<(y>>1);i<m;i++)for(j=0;j<m;j++)a[b[i][j]=i&x][c[i][j]=i+j&y]++;
	else if(y&1)for(i=0,x=1<<(x>>1),y=1<<(y>>1);i<m;i++)for(j=0;j<m;j++)a[b[i][j]=i+j&x][c[i][j]=i&y]++;
	else for(i=0,x=1<<(x>>1),y=1<<(y>>1);i<m;i++)for(j=0;j<m;j++)a[b[i][j]=i+j&x][c[i][j]=i+j&y]++;
	if(a[0][0]>=n*n)x=y=0;
	else if(a[0][1]>=n*n)x=0,y=1;
	else if(a[1][0]>=n*n)x=1,y=0;
	else x=y=1;
	for(i=0,n*=n;i<m&&n;i++)for(j=0;j<m&&n;j++)if(b[i][j]==x&&c[i][j]==y)n--,printf("%d %d\n",i,j);
	return 0;
}

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

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



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

    int N, K;
    cin >> N >> K;

    cout << bool(N % K);
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < k; i++){
        char pre ='x';
        for (int j = i; j < n; j += k){
            char c = t[j];
            if(c==pre){
                pre = 'x';
                continue;
            }
            if(c=='r'){
                ans += p;
            }
            if (c == 's'){
                ans += r;
            }
            if (c == 'p'){
                ans += s;
            }
            pre = c;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
	int N;
	long K, ans = 0;
	cin >> N >> K;
	vector<int> A(N);
	for (int& i : A) cin >> i;
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) {
				ans += K;
				ans %= 1000000007;
			}
		}
	}
	for (vector<int>::iterator i = A.begin(); i != A.end(); i++) {
		long a = count_if(A.begin(), A.end(), [&i](int& a) { return *i > a; });
		a *= (K - 1) * K / 2 % 1000000007;
		a %= 1000000007;
		ans += a;
		ans %= 1000000007;
	}
	cout << ans;
}

Measured memory_bytes: 256
def merge_sort(A):
    if len(A) <= 1:
        return A, 0
    mid = len(A) // 2
    left, lcount = merge_sort(A[:mid])
    right, rcount = merge_sort(A[mid:])
    merged, count = merge(left, right)
    return merged, lcount + rcount + count

def merge(left, right):
    lpos = 0
    rpos = 0
    lcount = 0
    rcount = 0
    merged = []
    while lpos < len(left) and rpos < len(right):
        if left[lpos] <= right[rpos]:
            merged.append(left[lpos])
            lpos += 1
            lcount += 1
        else:
            merged.append(right[rpos])
            rpos += 1
            rcount += 1
    
    if left[lpos:]:
        merged.extend(left[lpos:])
        lcount += len(left[lpos:])
    if right[rpos:]:
        merged.extend(right[rpos:])
        rcount += len(right[rpos:])
        
    return merged, lcount + rcount

if __name__ == '__main__':
    n = int(raw_input())
    A = map(int, raw_input().split())
    
    sorted, count = merge_sort(A)
    print ' '.join(str(x) for x in sorted)
    print count

Measured memory_bytes: 66116
/*
 * WelcomeToAtCoder.cpp
 *
 *  Created on: 2020/02/19
 *      Author: black
 */
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int S, W;
	cin >> S >> W;

	if (W >= S){
		cout << "unsafe" << endl;
	}
	else{
		cout << "safe" << endl;
	}


	return 0;
}


Measured memory_bytes: 3104
/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define			endl			"\n"


using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        swap(a,b);
    if(a%b==0 || b==0)
        return b;
    else
        return gcd(b,a%b);
}



ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a,b);
}



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}


ll X_or(ll for1, ll for2, ll value)
{
	ll arr[7];
	arr[3] = for1^for2;
	//cout<<(for1^for2)<<endl;
	arr[4] = arr[3]^for2;
	arr[5] = arr[4]^arr[3];
	cout<<arr[3]<<" "<<arr[4]<<" "<<arr[5]<<" ..... \n";
	if(value%3==0)
	{
		//cout<<arr[]
		return arr[3];
	}
	else
	{
		ll ret = ((value%3)==1)?arr[4] : arr[5];
		return ret;
	}
}


ll X_nor(ll for1, ll for2, ll value)
{
	ll arr[7];
	arr[3] = ~(for1^for2);
	//cout<<~(for1^for2)<<endl;
	if(arr[3]<0)
		arr[3]*=(-1);
	arr[4] = ~(arr[3]^for2);
	if(arr[4]<0)
		arr[4]*=(-1);
	arr[5] = ~(arr[3]^arr[4]);
	if(arr[5]<0)
		arr[5]*=(-1);
	cout<<arr[3]<<" "<<arr[4]<<" "<<arr[5]<<" ..... \n";
	if(value%3==0)
	{
		return arr[3];
	}
	else
	{
		ll ret = (value%3==1)? arr[4] : arr[5];
		return ret;
	}
}





bool Visit[9999990];
int cnt[9999990];





int main()
{
	int n;
	cin>>n;
	rep(i,n)
	{
		int k;
		cin>>k;
		cnt[k]++;
	}
	int Co = 0;
	rep(i,9999990)
	{
		if(Visit[i] || cnt[i]==0)
		continue;
		if(cnt[i]==1 && !Visit[i])
			Co++;
		for(int j=i;j<9999990;j+=i)
			Visit[j] = true;		
	}
	cout<<Co<<endl;
	return 0;
}


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

const int INF = 1e9 + 5;
int main()
{
    int t ;
    cin>>t;
    vector<int> heights(t);
    for(int& i:heights)
    {
        cin>>i;
    }
    vector<int> dp(t,INF);
    dp[0] = 0;
    for(int i=0;i<heights.size();i++)
    {
        for(int j:{i+1,i+2}){
            if(j<t)
            {
                dp[j] = min(dp[j],dp[i]+abs(heights[i]-heights[j]));
            }
        }
    }
    cout<<dp[t-1];
    return 0;
}

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

signed main() {
  string s; cin >> s;
  vector<int> v(30, 0);
  for(int i = 0; i < s.size(); i++) {
    v.at(s.at(i)-'a')++;
  }
  bool flag = true;
  for(int i = 0; i < v.size(); i++) {
    if(v.at(i)%2 != 0) flag = false;
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=10**10
for i in range(n-k+1):
  if k==1:
    ans=min(ans,abs(arr[i]))
  else:
    if arr[i]*arr[i+k-1]>=0:
      ans=min(ans,max(abs(arr[i]),abs(arr[i+k-1])))
    else:
      ans=min(ans,min(2*abs(arr[i])+arr[i+k-1],abs(arr[i])+2*arr[i+k-1]))
print(ans)

Measured memory_bytes: 14252
import java.io.*;
import java.util.*;

public class Main {
    static int[] enter;
    static int visited;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        String[] tmp = br.readLine().split(" ");
        int n = Integer.parseInt(tmp[0]);
        int m = Integer.parseInt(tmp[1]);
        Node[] ary = new Node[n];
        for( int i = 0; i < n; i++ ) ary[i] = new Node(i);
        while(m-->0) {
            tmp = br.readLine().split(" ");
            int u = Integer.parseInt(tmp[0])-1;
            int v = Integer.parseInt(tmp[1])-1;
            ary[u].adj.add(ary[v]);
            ary[v].adj.add(ary[u]);
        }
        enter = new int[n];
        Arrays.fill(enter,-1);
        visited = 1;
        Queue<Node> q = new LinkedList<>();
        q.add(ary[0]);
        enter[0] = 0;
        while(!q.isEmpty()) {
            Node curr = q.remove();
            for( Node node : curr.adj ) {
                if( enter[node.i] == -1 ) {
                    q.add(node);
                    enter[node.i] = curr.i+1;
                    visited++;
                }
            }
        }
        if( visited == n ) {
            pw.println("Yes");
            for( int i = 1; i < n; i++ ) {
                pw.println(enter[i]);
            }
        } else {
            pw.println("No");
        }
        pw.close();
    }
    static class Node {
        int i;
        ArrayList<Node> adj = new ArrayList<>();
        public Node(int i) {
            this.i = i;
        }
    }
}

Measured memory_bytes: 70396
#include <stdio.h>

int main(){
  char line[100];
  int W, H, x, y, r;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d %d %d %d %d", &W, &H, &x, &y, &r);
  if((x+r<=W)&&(x-r>=0)&&(y+r<=H)&&(y-r>=0))
	printf("Yes\n");
  else
	printf("No\n");
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	
	if (a <= 0 && b >= 0){
		cout << "Zero" << endl;
	}
	else if (b < 0 && (b - a + 1) % 2 == 1) {
		cout << "Negative" << endl;
	} else {
		cout << "Positive" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
class UnionFind
    def initialize(n)
        @parent = [*0...n]
        @rank = Array.new(n, 0)
    end
    def findSet(x)
        @parent[x] = findSet(@parent[x]) if x != @parent[x]
        @parent[x]
    end
    def same(x, y)
        findSet(x) == findSet(y)
    end
    def link(x, y)
        if @rank[x] > @rank[y] then
            @parent[y] = x
        else
            @parent[x] = y
            @rank[y] += 1 if @rank[x] == @rank[y]
        end
    end
    def unite(x, y)
        link(findSet(x), findSet(y))
    end
    def get_parent(idx)
        return findSet(idx)
    end
end

n, m = gets.chomp.split.map(&:to_i)
uf = UnionFind.new(n)
m.times do
    a, b = gets.chomp.split.map(&:to_i)
    uf.unite(a-1, b-1)
end

h = Hash.new(0)

n.times do |i|
    tmp = uf.get_parent(i)
    h[tmp] += 1
end

puts h.size-1

Measured memory_bytes: 21200
s = list(input())
t = list(input())
s.sort() # list.sort()で昇順にソート
t.sort()
t.reverse() # ソートした文字列を逆順に並び替え
s = ''.join(s)
t = ''.join(t)
if s < t:
    print('Yes')
else:
    print('No')

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

using namespace std;
int main()
{
    int a,b,c,d,n,m,i;
    cin>>a>>b>>c>>d;
    while(d>0 && b>0)
    {
       if(a<=0 && c>0){
        cout<<"No"<<endl;
       break;
       }
       else if(a>=0 && c<=0)
       {
           cout<<"Yes"<<endl;
           break;
       }
       a-=d;
       c-=b;



    }

   return 0;
}


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

using namespace std;

#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

ll n;

vector<vi> e;
vi p;
vi level;
vi deepest;

ll dfs(ll v,ll l,ll lev){
    p[v] = l;
    level[v] = lev;
    ll depth = 0;
    trav(u,e[v]){
        if(l!=u)
            depth = max(depth,dfs(u,v,lev+1));
    }
    return deepest[v] = depth+1;
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll u,v;
    cin>>n>>u>>v;
    --u; --v;
    e.resize(n);
    p.resize(n);
    level.resize(n);
    deepest.resize(n);

    rep(i,0,n-1){
        ll a,b;
        cin>>a>>b;
        --a;--b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    dfs(v,v,0);

    //if(level[u]==1&&deepest[u]==1) {
    //    cout<<0<<endl;
    //    return 0;
    //}

    if(level[u]%2==0){
        ll up = level[u]/2-1;
        rep(i,0,up) {
            u = p[u];
        }
        cout<<up + max(1ll,deepest[u])<<endl;
    } else {
        ll up = level[u]/2;
        rep(i,0,up) {
            u = p[u];
        }
        cout<<up + max(0ll,deepest[u]-1)<<endl;
    }
}


Measured memory_bytes: 16000
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


k = I()
now = 0
for i in range(k):
    now = (now * 10 + 7) % k
    if now == 0:
        print(i + 1)
        exit()
print(-1)


Measured memory_bytes: 76804
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}
long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H;
long long int ans;
long long int pas[100001];


int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W >> N >> M;
	long long int num[1000][1000] = {};
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			num[i][j] = 1;
		}
	}
	for (int i = 0; i < H; i += N) {
		for (int j = 0; j <= W; j+=M) {
			num[i][j] += 250000;
		}
	}
	for (int i = N - 1; i < H; i += N) {
		for (int j = M - 1; j < W; j += M) {
			num[i][j] = -(N*M + 250000);
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++)ans += num[i][j];
	}
	if (ans < 0) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j)cout << " ";
			cout << num[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 9856
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


N = int(input())
H = list(map(int, input().split()))

max_h = 0

count = 0
for h in H:
    if h >= max_h:
        count += 1
    max_h = max(max_h, h)

print(count)


Measured memory_bytes: 9156
import re
input()
S=raw_input()
K=input()
a=[]
for i in range(len(S)):
  k=map(lambda x:x.start(),re.finditer(S[K-1],S))
  if i in k:
      a.append(S[i])
  else:
      a.append("*")
print(''.join(a))


Measured memory_bytes: 2568
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{


    ll i,j,k,a,b,c,n,t,m;
    vector<ll> v,s,su;
    string st,et;
    cin>>n;
    v.clear();
    for(i=1; i<=n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    for(i=1; i<=n; i++)
    {
        cin>>a;
        s.push_back(a);
    }
    b = 0;
    for(i=0;i<n;i++){
            b = b+v[i];
            a = 0;
        for(j=i;j<n;j++){
            a = a+s[j];
        }
         su.push_back(a+b);
    }
    sort(su.begin(),su.end(),greater<int>());
    cout<<su[0]<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

const ll INF = mod * 328ll;
struct Dinic {
    struct edge {
        ll t, c, r;
        edge(ll _t, ll _c, ll _r) : t(_t), c(_c), r(_r) {}
    };
    vector<ll> l, nxt;
    vector<vector<edge>> e;
    Dinic(ll n) : e(n + 1) {}
    void add_edge(ll u, ll v, ll w) {//directed
        e[u].push_back(edge(v, w, (int)e[v].size()));
        e[v].push_back(edge(u, 0, (int)e[u].size() - 1));
    }
    edge& rev(const edge& E) {
        return e[E.t][E.r];
    }
    bool bfs(ll s, ll t) {
        l.assign(e.size(), INF);
        l[s] = 1;
        queue<ll> Q;
        for (Q.push(s); !Q.empty(); Q.pop()) {
            s = Q.front();
            for (const edge& E : e[s])
                if (E.c > 0 && l[E.t] > l[s] + 1) {
                    l[E.t] = l[s] + 1; Q.push(E.t);
                }
        }
        return l[t] < INF;
    }
    ll dfs(ll s, ll t, ll num = INF) {
        if (s == t || num == 0) return num;
        ll ans = 0;
        for (ll& i = nxt[s]; num && i < e[s].size(); i += num > 0) {
            edge& E = e[s][i];
            if (E.c > 0 && l[s] + 1 == l[E.t]) {
                ll tmp = dfs(E.t, t, min(num, E.c));
                rev(E).c += tmp, ans += tmp;
                E.c -= tmp, num -= tmp;
            }
        }
        return ans > 0 ? ans : l[s] = 0;
    }
    ll operator()(ll s, ll t) {
        ll ans = 0;
        for (; bfs(s, t); ans += dfs(s, t)) nxt.assign(e.size(), 0);
        return ans;
    }
};

int main() {
    ios::sync_with_stdio(false);
    int n, a[102] = {};
    ll z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    Dinic D(n + 2);
    for (int i = 1; i <= n; i++) {
        if (a[i] > 0) D.add_edge(0, i, a[i]), z += a[i];
        else D.add_edge(i, n + 1, -a[i]);
        for (int j = i + i; j <= n; j += i) D.add_edge(j, i, mod * 328ll);
    }
    cout << z - D(0, n + 1) << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	vector<lli> a(n),b(n);
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> b[i];
	int ans = 0;
	lli rem = 0;
	vector<lli> c(n,0);
	for(int i=0; i<n; i++){
		if(a[i] >= b[i]){
			c[i] = a[i] -b[i];
		}else{
			ans++;
			rem += b[i] -a[i];
		}
	}
	sort(c.begin(), c.end(), greater<lli>());
	for(int i=0; i<n; i++){
		if(rem <= 0) break;
		ans++;
		rem -= c[i];
	}
	if(rem <= 0){
		cout << ans << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

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

int main(){
	long long n;
	cin>>n;
	long long arr[5];
	for(int i=0; i<5; i++) cin>>arr[i];
	long long bottle_neck = *min_element(arr,arr+5);
	for(int i=0; i<5; i++){
		if(bottle_neck == arr[i]){
			long long ret = 4+n/arr[i];
			if(n%arr[i]) ret++;
			cout<<ret;
			return 0;
		}
	}
}

Measured memory_bytes: 3628
S = input()
Q = int(input())

queries = []
for i in range(Q):
    query = input()
    queries.append(query)

from collections import deque
slist = deque(list(S))
even = True
for query in queries:
    if query == "1":
        even = not even
    else:
        t, f, c = query.split()
        if f == '1':
            if even:
                slist.appendleft(c)
            else:
                slist.append(c)
        else:
            if even:
                slist.append(c)
            else:
                slist.appendleft(c)
if not even:
    slist.reverse()

print(''.join(slist))


Measured memory_bytes: 21224
#include<stdio.h>
int main(void)
{
  int i,j;
  int ymd[100][3], n, y3=590, date;

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

  for(i=0;i<n;i++) {
    date = 0;
    date += ((ymd[i][0]-1)/3)*y3;
    switch(ymd[i][0]%3){
    case 2:
      date += 195;
      for(j=0;j<ymd[i][1]-1;j++) {
	j%2 ? (date += 19):(date += 20);
      }
      date += ymd[i][2];
      break;
      
    case 1:
      for(j=0;j<ymd[i][1]-1;j++) {
	j%2 ? (date += 19):(date += 20);
      }
      date += ymd[i][2];
      break;
      
    case 0:
      date += 390;
      for(j=0;j<ymd[i][1]-1;j++) {
	date += 20;
      }
      date += ymd[i][2];
      break;
    }
    printf("%d\n", 196471 - date);
  }

  return 0;
}
      

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

//配列に数字を入れていく。
void InputNumber(int n, int pt[5]){
  for(int i = 0; i < 5; i++){
    pt[i] = n % 10;
    n /= 10;
  }
}

int main(void){
  int cnt = 0;
  int A, B;
  int pt[5];
  cin >> A >> B;
  for(int i = A; i <= B; i++){
    InputNumber(i, pt);
    if(pt[0] == pt[4] && pt[1] == pt[3]){cnt++;}
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;
#define pii pair<int,int>

int n,a[maxn],b[maxn];
int sum[maxn];
pii sx[maxn<<1];
int tx;

ll ans;

inline void init()
{
	n=read();
	REP(i,1,n)a[i]=read(),b[i]=read();
	REP(i,1,n)sx[++tx]=mkr(a[i],i),sx[++tx]=mkr(b[i],i+n);
	sort(sx+1,sx+tx+1); 
	REP(i,1,n)
	{
		ans+=sx[i].fi;
		int id=sx[i].se;
		if(id<=n)sum[id]|=1;
		else sum[id-n]|=2;
	}
}

inline int ID(int x){ return x>n?x-n:x;}

inline void doing()
{
	int Sum=0;
	REP(i,1,n)if(sum[i]==3)printf("%lld\n",ans),exit(0);
	REP(i,1,n)Sum+=sum[i];
	if(Sum==n || Sum==2*n)printf("%lld\n",ans),exit(0);
	int t;

	ll ANS=1ll<<60;

	t=ID(sx[n+1].se);
	//sum[t=ID(sx[n+1].se)]|=3;
	//ans+=sx[n+1].fi;
	int newSum=Sum-sum[t]+(3-sum[t]);
	if(ID(sx[n].se)!=t || (newSum==n || newSum==2*n))chkmin(ANS,ans+sx[n+1].fi-sx[n].fi);
	else {
		chkmin(ANS,ans+sx[n+1].fi-sx[n-1].fi);
		chkmin(ANS,ans+sx[n+2].fi-sx[n].fi);
	}
	printf("%lld\n",ANS);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  ll a,b,k;
  cin >> k >> a >> b;
  bool ok = false;
  FOR(i,a,b+1) if((i%k)==0)ok = true;
  if(ok){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }



}


Measured memory_bytes: 3596
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cout<<setprecision(16);
    cin>>n;
    double sum=0;
    rep(i,n){
        double a;
        cin>>a;
        sum+=(1.0/a);
        
    }
    cout<<1.0/sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int i,n,a[1000]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n-1;i>=0;i--){
		if(i==0){
			printf("%d",a[0]);
		}else{
		
		printf("%d ",a[i]);
	}}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2700
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int ary[31];
	int w, n, a, b;
	for(int i=0; i < 31; i++){
		ary[i] = i;
	}
	cin >> w;
	cin >> n;
	for(int i=0; i < n; i++){
		scanf("%d,%d", &a, &b);

		swap(ary[a], ary[b]);
	}
	for(int i=1; i <= w; i++){
		cout << ary[i] << endl;
	}

}

Measured memory_bytes: 1236
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        mut arr: [i32; n],
    }
    arr.dedup();
    let n = arr.len();
    if n == 1 {
        println!("1");
        return;
    }
    let mut skip = false;
    let mut state = arr[0].cmp(&arr[1]);
    let mut ans = 1;
    for i in 0..n - 1 {
        let rel = arr[i].cmp(&arr[i + 1]);
        if skip {
            state = rel;
            skip = false;
        }
        else if state != rel {
            ans += 1;
            skip = true;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3340
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstdlib>
using namespace std;


int n;
int a[55];
vector<pair<int,int>> v;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }

    int mx = -1;
    int idx;
    for(int i=1;i<=n;i++){
        if (abs(a[i]) > mx){
            idx = i;
            mx = abs(a[i]);
        }
    }
    for(int i=1;i<=n;i++){
        if(i!=idx){
            v.emplace_back(idx,i);
        }
    }
    if(a[idx] > 0){
        for(int i=2;i<=n;i++){
            v.emplace_back(i-1,i);
        }
    }
    else {
        for(int i=n-1;i>=1;i--){
            v.emplace_back(i+1,i);
        }

    }

    printf("%d\n", int(v.size()));
    for(auto p : v){
        printf("%d %d\n", p.first, p.second);
    }
}


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

Measured memory_bytes: 35684
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    w, h, n = map(int, readline().split())

    x_max = w
    x_min = 0
    y_max = h
    y_min = 0

    for _ in range(n):
        x, y, a = map(int, readline().split())
        if a == 1:
            x_min = max(x_min, x)
        elif a == 2:
            x_max = min(x_max, x)
        elif a == 3:
            y_min = max(y_min, y)
        else:
            y_max = min(y_max, y)

    print(max(0, (x_max - x_min)) * max(0, (y_max - y_min)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62164
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string A,B,C;
  cin >> A >> B >> C;

  int x = A.size(),y=B.size(),z=C.size();
  int flag = 0;
  int a = 0,b = 0,c = 0;
  while((flag==0&&a<x)||(flag==1&&b<y)||(flag==2&&c<z)){
    if(flag==0){
      if(A.at(a)=='a'){
        flag = 0;
      }else if(A.at(a)=='b'){
        flag = 1;
      }else if(A.at(a)=='c'){
        flag = 2;
      }
      a++;
    }else if(flag==1){
      if(B.at(b)=='a'){
        flag = 0;
      }else if(B.at(b)=='b'){
        flag = 1;
      }else if(B.at(b)=='c'){
        flag = 2;
      }
      b++;
    }else if(flag==2){
      if(C.at(c)=='a'){
        flag = 0;
      }else if(C.at(c)=='b'){
        flag = 1;
      }else if(C.at(c)=='c'){
        flag = 2;
      }
      c++;
    }
  }

  if(flag==0){
    cout << "A" << endl;
  }else if(flag==1){
    cout << "B" << endl;
  }else{
    cout << "C" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int n; cin >> n;
    for (int i = 1; i < 10; i++) if (n % i == 0 && n / i < 10) {
      cout << "Yes\n"; return 0;   
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	long long N, ans;
	cin >> N;
	ans = N - 1;
	for (long long i = 1; i <= sqrt(N); i++){
		if (N%i == 0){
			ans = min(ans, (N / i) + i - 2);
		}
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

const int N = 100009;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;

int main() {
	int n, m;
	cin >> n >> m;
	vector<bool> A(N, true);
	rep(i, n) {
		int a;
		cin >> a;
		A[a] = false;
	}

	long long dp[N];
	rep(i, N) dp[i] = 0;
	dp[0] = 1;
	rep(i, n + 1) {
		if (A[i + 1])
			dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
		if (A[i + 2])
			dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
	}

	//rep(i, n+1) cout << dp[i] << endl;
	//cout << endl;
	cout << dp[n] << endl;
}

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

int main(){
  int a, b;
  cin >> a >> b;

  string num;
  num = to_string(a) + to_string(b);

  if (sqrt(stoi(num)) == floor(sqrt(stoi(num)))){
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3756
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int n,d;

int main()
{
    cin>>n>>d;

    int c=(2*d+1);
    if (n%c==0)
        cout<<n/c<<endl;
    else
        cout<<(n/c)+1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int r, c, sr, sc, er, ec;
	cin >> r >> c >> sr >> sc >> er >> ec;
	sr--, er--, sc--, ec--;
	char mat[r][c];

	for (int i = 0; i < r; i++)
		for (int j = 0; j < c; j++)
			cin >> mat[i][j];

	deque<pair<int, int>> q;
	q.push_front({sr, sc});
	vector<vector<int>> dist(r, vector<int>(c, INT_MAX));
	dist[sr][sc] = 0;
	int d[4][2] = {{ -1, 0}, {1, 0}, { 0, 1}, {0, -1}};
	while (!q.empty()) {
		pair<int, int> front = q.front();
		q.pop_front();
		for (int i = 0; i < 4; i++) {
			int nx = front.first + d[i][0], ny = front.second + d[i][1];
			if (nx < 0 || ny < 0 || nx >= r || ny >= c || mat[nx][ny] == '#')
				continue;
			if (dist[nx][ny] > dist[front.first][front.second]) {
				dist[nx][ny] = dist[front.first][front.second];
				q.push_front({nx, ny});
			}
		}
		for (int i = front.first - 2; i <= front.first + 2; i++) {
			for (int j = front.second - 2; j <= front.second + 2; j++) {
				if (i < 0 || j < 0 || i >= r || j >= c || mat[i][j] == '#')
					continue;
				if (dist[i][j] > dist[front.first][front.second] + 1) {
					dist[i][j] = dist[front.first][front.second] + 1;
					q.push_back({i, j});
				}
			}
		}
	}
	cout << (dist[er][ec] >= INT_MAX ? -1 : dist[er][ec]);
	return 0;
}



Measured memory_bytes: 12544