akhauriyash/Code-Regression huggingface dataset:
use proconio::*;
use proconio::marker::*;
use std::collections::*;
use std::cmp::*;
use std::ops::Bound::*;

const F: usize = 26;

#[fastout]
fn run() {
    input! {
        d: usize,
        c: [i64; F],
        s: [[i64; F]; d],
        t: [Usize1; d],
    }
    let mut score = 0;
    let mut last = [0; 26];
    for (i, (s, &t)) in s.iter().zip(t.iter()).enumerate() {
        let i = i as i64 + 1;
        score += s[t];
        last[t] = i;
        for (c, last) in c.iter().zip(last.iter()) {
            score -= *c * (i - *last);
        }
        println!("{}", score);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 2348
from collections import Counter
n = int(input())

arr = []
for i in range(n) :
	
    arr.append(input())
    
c = Counter(arr).most_common()

max = 0

arr2 = []

for item in c :
  
  if max == 0 :
    
    max = item[1]
    
  if max == item[1] :
    
    arr2.append(item[0])
    
  else :
    
    break
    
arr2.sort()

for item in arr2 :
  
  print(item)
    
  

Measured memory_bytes: 45084
<?php
fscanf(STDIN, "%d%d%d", $A , $B, $M);

$ref = explode(" ",trim(fgets(STDIN)));
$micro = explode(" ",trim(fgets(STDIN)));

$min = min($ref) + min($micro);

while($M--){
    fscanf(STDIN, "%d%d%d", $X , $Y, $C);
    $min = min($min, $ref[$X-1] + $micro[$Y-1] - $C);

}
echo $min;

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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }




    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        int[] s = sc.intarr;
        long N = s[0];
        var A = sc.longarr;
        for(int i = 0; i < N; ++i)
        {
            A[i] -= i+1;
        }

        Array.Sort(A);
        long b1 = A[N / 2];

        long ans1 = 0;
        for(int i = 0; i < N; ++i)
        {
            ans1 += Math.Abs(A[i] - b1);
        }
        wr.wri(ans1);
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 31008
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll dp[1010][1010];
ll M = 1000000007;


int main(){
    ll H, W; cin >> H >> W;
    vector<vector<char>> map(H, vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> map[i][j];
        }
    }

    dp[0][0] = 1;
    bool m = true;
    for(int i=1; i<H; i++){
        if(map[i][0] == '#'){
            m = false;
        }
        if(m){dp[i][0] = 1;}
        else{
            dp[i][0] = 0;
        }
    }

    m = true;
    for(int i=1; i<W; i++){
        if(map[0][i] == '#'){
            m = false;
        }
        if(m){dp[0][i] = 1;}
        else{dp[0][i] = 0;}
    }

    for(int i=1; i<H; i++){
        for(int j=1; j<W; j++){
                if(map[i][j] == '.'){
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M;
                }
                else{
                    dp[i][j] = 0;
                }
            
        }
    }

    cout << (dp[H-1][W-1])%M;
}

Measured memory_bytes: 9088
// B - Counting of Trees
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
#define MOD 998244353

int main(){
	int N; cin>>N;
	vi C(N);
	int ans = 1;
	rpz(i, N){
		int d; scanf("%d",&d);
		if((i==0 && d!=0) || (i>0 && d<=0)) ans = 0;
		C[d]++;
	}
	rp(d, 2, N) rpz(i, C[d]) ans  = 1L*ans * C[d-1] % MOD;
	cout<< ans <<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update

using namespace __gnu_pbds;
using namespace std;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define minei(x) min_element(x.begin(), x.end()) - (x).begin()
#define maxei(x) max_element(x.begin(), x.end()) - (x).begin()
#define LSOne(S) (S & (-S))

#define uns(v) sort((v).begin(), (v).end()), v.erase(unique(v.begin(), v.end()), v.end())
#define acusum(x) accumulate(x.begin(), x.end(), 0)
#define acumul(x) accumulate(x.begin(), x.end(), 1, multiplies<int>());
#define bits(x) __builtin_popcount(x)
#define oo INT_MAX
#define inf 1000000000
#define MAXN 1000007
#define MOD 1000000007

const double pi = acos(-1.0);
const double eps = 1e-11;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
string colors = "RGB";
char getChar(char a, char b) {
    for (int i = 0; i < 3; i++) {
        if (a != colors[i] && b != colors[i]) return colors[i];
    }
    return 'R';
}
int main() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map<char, vector<int> > cache;
    char c;
    int n, m, indx;
    string s;
    cin >> n;
    cin >> s;

    for (int i = 0; i < n; i++)
        cache[s[i]].push_back(i);
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (s[i] == s[j]) continue;
            c = getChar(s[i], s[j]);
            m = sz(cache[c]);
            indx = lower_bound(cache[c].begin(), cache[c].end(), j + (j - i)) - cache[c].begin();
            if (indx < m && cache[c][indx] == j + (j - i)) res--;
            res += (m - (lower_bound(cache[c].begin(), cache[c].end(), j + 1) - cache[c].begin()));
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3680
import math
import sys
a, b = map(int, input().split())
x = min(a, b)
y = max(a, b)

if x == 1:
    print(1)
    sys.exit()


d = []
for i in range(1, int(math.sqrt(x))+1):
    if x % i == 0:
        d.append(i)
        d.append(int(x/i))

zero = 0
for i in range(len(d)):
    if y % d[i] != 0:
        d[i] = 0
        zero += 1

if zero != 0:
    for i in range(zero):
        d.remove(0)

if len(d) == 1:
    print(1)
    sys.exit()

    
ans = 0
for i in range(len(d)):
    flag = 1
    for j in range(2, int(math.sqrt(d[i])) +1):
        if d[i] % j == 0:
            flag = 0
            break
    
    if flag == 1:
        ans += 1

print(ans)


    










 

 


                                        




    




        


    







        



Measured memory_bytes: 3388
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7
// https://atcoder.jp/contests/caddi2018/tasks/caddi2018_a
int main() {
    ll n, p;
    cin >> n >> p;

    if (p == 1 || p == 2 || p == 3) {
        if (n == 1) {
            cout << p << endl;
            return 0;
        } else {
            cout << 1 << endl;
            return 0;
        }
    }

    ll tmp = p;
    vector<int> a(1000010, 0);
    for (ll i = 2; i * i <= p; i++)
    {
        while (tmp % i == 0) {
            a[i] += 1;
            tmp /= i;
        }
    }

    ll ans = 1;
    if (tmp != 1 && n == 1) ans = tmp;
    for (size_t i = 0; i < a.size(); i++)
    {
        if (a[i] >= n) {
            ans *= pow(i, a[i] / n);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4096
#include<iostream>
#include<set>

using namespace std;

int main(){

    
        int N;
        cin>> N;
        string U[N];
        for(int i=0; i<N; i++) cin>> U[i];
        int M;
        cin>> M;
        string T[M];
        for(int i=0; i<M; i++) cin>> T[i];

        set<string> user;
        for(int i=0; i<N; i++) user.insert(U[i]);
        int open=0;
        for(int i=0; i<M; i++){
            if(user.count(T[i])){
                if(open){
                    cout<< "Closed by "<< T[i]<< endl;
                    open=0;
                }else{
                    cout<< "Opened by "<< T[i]<< endl;
                    open=1;
                }
            }else{
                cout<< "Unknown "<< T[i]<< endl;
            }
        }

    

    return 0;
}

Measured memory_bytes: 3220
n, m = map(int, input().split())
h = [int(x) for x in input().split()]
bad = set()
for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        bad.add(b)
    elif h[a-1] == h[b-1]:
        bad.add(a)
        bad.add(b)
    elif h[a-1] < h[b-1]:
        bad.add(a)
print(n - len(bad))


Measured memory_bytes: 20112
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

const int N = 1e6 + 9;
const int INF = 1e9;
const int mod = 1e9;
const int SZ = (1 << 17) - 1;

#define eb emplace_back
#define sz(s) (int)(s.size())

#define ll long long

const int NN = 2e3;

#define int ll

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a >= c or b >= c) {
		cout << "No";
		return;
	}
	int pro = (2 * a * b) - (2 * a * c) + (a * a + b * b) - (2 * b * c) + (c * c);
	cout << ((pro > 4 * a * b) ? "Yes" : "No");
}

signed main() {
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[200001];  // 作業用配列
  if (left < right) {
    mid = (left + right)/2; // 真ん中
    merge_sort(array, left, mid);  // 左を整列
    merge_sort(array, mid+1, right);  // 右を整列
    for (i = mid; i >= left; i--) { work[i] = array[i]; } // 左半分
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; // 右半分を逆順
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}


int main(void){
    
    int n;
    scanf("%d",&n);
    
    int a[200002]={0};

    for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    }
    
    merge_sort(a, 1, n);
    
    long long int ans=0;
    
    for (int i=2; i<=n; i++) {
    ans+=a[n+1-((i+1)/2)];
    // printf("%d \n",n+1-((i+1)/2));
    }

    printf("%lld",ans);
    
    return 0;
}

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

int main()
{
    int a, n = 3, num_5 = 0, num_7 = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a == 5)
        {
            num_5++;
        }
        else if (a == 7)
        {
            num_7++;
        }
    }
    if (num_5 == 2 && num_7 == 1)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
    return 0;
}

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

int main() {
  string N;
  cin >> N;
  
  for(int i = 0; i < 3; i++) {
    if(N.at(i) == '7') {
      cout << "Yes" << endl;
      break;
    }
    else if(i == 2) {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int s = 1000000;
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> cnt(1000010);
	rep(i, n) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	bool pa = true;
	for (int i = 2; i <= s; i++) {
		int c = 0;
		for (int j = i; j <= s; j += i) {
			c += cnt[j];
		}
		if (c >= 2) pa = false;
	}
	if (pa) {
		cout << "pairwise coprime\n";
		return 0;
	}
	int g = a[0];
	rep(i, n) g = gcd(g, a[i]);
	if (g == 1) cout << "setwise coprime\n";
	else cout << "not coprime\n";
}

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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<char>> c(h,vector<char> (w));
  rep(i,h)rep(j,w) cin >> c[i][j];
  
  int ans = 0;
  rep(hbit, 1<<h) rep(wbit, 1<<w) {
    int cnt = 0;
    rep(i,h) rep(j,w) {
      if (hbit & (1<<i)) continue;
      if (wbit & (1<<j)) continue;
      if (c[i][j] == '#') cnt++;
    }
    if (cnt == k) ans++;
  }
  
  cout<< ans <<endl;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main( ){
    int i, n, x;
    cin >> n;
    for(i=1; i<=n; i++){
        x = i;
        if(i%3==0){
            cout <<" " << i;
        }else{
            while(x){
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x/=10;
            }
        }
    }
    cout << endl;
  return 0;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)
#define rofn(i,p,n); for(long long i=p;i>n;--i)
#define pb push_back
#define vi vector<ll>

void solve(){
	double n,x,t;
	cin >> n >> x >> t;
	ll ans = ceil(n/x)*t;
	cout<<ans;
	return ;
}
 
int main()
{
	fast;
	// int test;
	// cin >> test;
	// while(test--){
		solve();
	// 	cout<<"\n";
	// }
}

Measured memory_bytes: 3752
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    int H, W, d;
    cin >> H >> W >> d;

    char col_char[] = "RBGY";

    for (int y = 0; y < H; y++)
    {
        for (int x = 0; x < W; x++)
        {
            int tx = x + y + H, ty = x - y + H;
            tx /= d;
            ty /= d;
            int idx = 0;
            idx = (tx % 2 == 0) ? 0 : 2;
            idx += (ty % 2 == 0) ? 0 : 1;
            cout << col_char[idx];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define lp(i, n) for(int i = 0;i<(n);++i)
#define INF 1000000009
using namespace std;

int hsd(string c){
  int y=stoi(c.substr(0,4));
  int m=stoi(c.substr(5,2));
  int d=stoi(c.substr(8,2));
  return y*10000+m*100+d;
}

int main(){
  int n;
  cin>>n;
  vector<pair<pair<string,string>,int>> l;
  lp(i,n){
    string a,b,c;
    cin>>a>>b>>c;
    l.push_back({{a,b},hsd(c)});
  }
  int q;
  cin>>q;
  lp(i,q){
    string a,b,c,d;
    cin>>a>>b>>c>>d;
    int un,up;
    if(c=="*") un=0;
    else un=hsd(c);
    if(d=="*") up=INF;
    else up=hsd(d);
    lp(j,n){
      string title=l[j].first.first;
      bool ok=true;
      if(a!="*"){
	ok=false;
	if(title.size()<a.size()) continue;
	lp(z,title.size()-a.size()+1){
	  if(a==title.substr(z,a.size())) ok=true;
	}
      }
      if(ok==false) continue;
      title=l[j].first.second;
      if(b!="*"){
	ok=false;
	if(title.size()<b.size()) continue;
	lp(z,title.size()-b.size()+1){
	  if(b==title.substr(z,b.size())) ok=true;
	}
	if(ok==false) continue;
      }
      ok=false;
      if(un<=l[j].second&&l[j].second<=up) ok=true;
      if(ok==true)cout<<l[j].first.first<<endl;
    }
    if(i!=q-1)cout<<endl;
  }
  return 0;
}



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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(a,b,c) for(int a=(b);a<=(c);a++)
int main( void )
{
    int K,S,ans=0;
    std::cin>>K>>S;
    FOR(x,0,K)
        FOR(y,0,K)
            if(S-x-y>=0 and S-x-y<=K) ++ans;
    std::cout<<ans<<std::endl;
    return (0);
}

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> d(k);
    vector<vector<int>> a(k,vector<int>(n));
    int ans = n;
    vector<int> p(n);
    for(int i = 0; i < k; i++){
        cin >> d.at(i);
        int tmp2 = d.at(i);
        for(int j = 0; j < tmp2; j++){
            cin >> a.at(i).at(j);
            int tmp = a.at(i).at(j) - 1;
            if(p.at(tmp)==0){
                p.at(tmp) = 1;
                ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 100;

char ss[maxn];

bool cheak(int l, int r)
{
	for (int i = 0; i <= (r - l + 1) / 2; i++) {
		if (ss[l + i] != ss[r - i]) return 0;
	}
	return 1;
}

int main(void)
{
	cin >> ss + 1;
	int flag = 0;
	int len = strlen(ss + 1);
	if (cheak(1, len)) {
		if (cheak(1, (len - 1) / 2)) {
			if (cheak((len + 3) / 2, len)) flag = 1;
		}
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
def GCD(a,b):
    while (a % b) != 0:
        a,b = b, a%b
    return b

def LCM(a,b):
    return a * b / GCD(a,b)

while True:
    try:
        a,b =map(int,raw_input().split())
        print GCD(a,b),LCM(a,b)
    except:
        break

Measured memory_bytes: 4632
n,m = map(int, input().split())
lst = [[] for i in range(m)]
for i in range(m):
    pi,si = map(str, input().split())
    lst[i] = (int(pi),si)

ac = 0
wa = 0
status = [0 for i in range(n)]

for i in lst:
    if status[i[0]-1]!="AC":
        if i[1]=="AC":
            ac += 1
            wa += status[i[0]-1]
            status[i[0]-1] = "AC"
        else:
            status[i[0]-1] += 1

print(ac,wa)


Measured memory_bytes: 19696
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main() {
//    int N ,L; cin >> N >> L;
    string N; cin >> N;

//    vector<string> vs(N);
//    REP(i, N) cin >> vs.at(i);
//    string O, E; cin >> O >> E;

    if(N.at(0) == N.at(2)) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

string s, t;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0; i < 3; i++){
		cnt += s[i] == t[i];
	}
	
	cout << cnt << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
bool Prime(int x){
    for(int i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return true;
}
int main(){
    int n;
    scanf("%d",&n);
    int N[n];
    for(int i=0;i<n;i++){
        scanf(" %d",&N[i]);
    }
    int cnt;
    for(int i=0;i<n;i++){
        if(Prime(N[i])==true){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}



Measured memory_bytes: 2680
a = 0
w = 0
t = 0
r = 0
n = int(input())
for i in range(n):
    s = str(input())
    if s == 'AC':
        a = a + 1
    elif s == 'WA':
        w = w + 1
    elif s == 'TLE':
        t = t + 1
    elif s == 'RE':
        r = r + 1
print('AC x ' + str(a))
print('WA x ' + str(w))
print('TLE x ' + str(t))
print('RE x ' + str(r))


Measured memory_bytes: 69848
S = list(input())
T = list(input())

slen = len(S)

for i in range(len(T)):
    if S == T:
        print('Yes')
        exit()
    else:
        slen = len(S)
        S.insert(0,S[len(S)-1])
        S.pop(len(S)-1)
print('No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define ll long long int

int main(){
	char word1[1001];
	char subs[1001];
	scanf ("%[^\n]", word1);
	getchar();
	scanf ("%[^\n]", subs);
	getchar();
	int s1 = strlen (word1);
	int s2 = strlen (subs);
	int ns = 0, temp = 0;
	
	for (int i=0; i<=s1-s2; i++){
		ns = 0;
		for (int j=i, k=0; k < s2; j++, k++){
			if (word1[j] == subs[k]){
				ns++;
			}
		}
		if (ns > temp){
			temp = ns;
		}
	}
	printf ("%d\n", s2-temp);
return 0;
}

Measured memory_bytes: 1668
#include <iostream>

using namespace std;

int main()
{
	int n, m, x;
	int a[100] = {0};
	int ans1 = 0, ans2 = 0;
	int num;
	int i;
	
	cin >> n >> m >> x;
	
	for (i = 0; i < m; i++) {
		cin >> num;
		a[num] = 1;
	}
	
	for (int j = x + 1; j <= n; j++) {
		ans1 += a[j];
	}
	
	for (int j = x; j >= 0; j--) {
		ans2 += a[j];
	}
	
	if (ans1 > ans2) {
		cout << ans2 << endl;
	}
	else {
		cout << ans1 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VP ps;
    int x,y;
    REP(i,0,n) {
        cin >> x >> y;
        ps.pb(x,y); 
    }
    double sum = 0;
    sort(all(ps));
    do {
        REP(i,0,n-1) {
            double diff = sqrt(sqr(ps[i].first - ps[i+1].first) + sqr(ps[i].second - ps[i+1].second));
            sum += diff;
        }
    } while (next_permutation(all(ps)));
    int p = 1;
    REP(i,2,n+1) p *= i;
    sum /= p;
    printf("%.7lf\n", sum);
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
static const int64_t INF = 1000000000;


int main(){
	int N, x;
	cin >> N >> x;
	vector<int64_t> a(N);
	rep(i, N) cin >> a[i];
	
	int64_t count = 0;
	for(int i = 1; i < N; ++i){
		if(x < a[i-1]){
			count += a[i-1] - x;
			count += a[i];
			a[i] = 0;
		}
		else if(x < (a[i-1] + a[i])){
			count += a[i] + a[i-1] - x;
			a[i] -= a[i] + a[i-1] - x;
		}
	}
	cout << count << endl;
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) != t.at(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3856
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


ll N;
int main() {
	cin >> N;
	ll sn = sqrt(N);
	ll ans = 1e12;
	for(ll i  = sn; i > 0; i--){
		if (N%i == 0) {
			ans = min(ans, i + N / i - 2);
		}
	}

	cout << ans << endl;

	return 0;
}


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

#define int long long

signed main(){
    int n;

    while(cin >> n, n != 0){
        n++;
        int a[200];

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

        for(int i = 0;i < n;i++){
            int sa = INT_MAX;
            int old = -1;
            int j;
            for(j = 0;j < n;j++){
                if(j != i){
                    if(old != -1){
                        if(sa == INT_MAX){
                            sa = a[j] - a[old];
                        }else{
                            if(sa != a[j] - a[old]){
                                break;
                            }
                        }
                    }
                    old = j;
                }
            }

            if(j == n){
                cout << a[i] << endl;
                break;
            }
        }
    }
    return 0;
}




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

#define endl '\n'
#define ll  long long
#define modd(a,b) ((a+2*b)%b)
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define debug(a) cout << #a << ": " << (a) << "\n"
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout)

int main() {
	ioso;// kholo;
	ll n,m; cin >> n >> m;
	ll ans = (n*(n-1) / 2) + (m*(m-1)/2);
	cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int count = 0;
  int p;
  for (int i = 1; i <= N; i++) {
    cin >> p;
    if (p != i) count++;
  }
  if (count == 0 || count == 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

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

using namespace std;

int main(){
	int d;
	cin >> d;
	char* ans = (char*)calloc(100, sizeof(char));
	switch(d){
	case 22:
		strcpy(ans, "Christmas Eve Eve Eve");
		break;
	case 23:
		strcpy(ans, "Christmas Eve Eve");
		break;
	case 24:
		strcpy(ans, "Christmas Eve");
		break;
	case 25:
		strcpy(ans, "Christmas");
		break;
	}
	cout << ans;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll x,y;
cin >> x >> y;
ll ans = 0;
while (x <= y) {
    x *= 2;
    ans++;
}
cout << ans << endl;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//233
	string s;
	cin>>s;
	int l=0,r=s.length()-1;
	int cnt=0;
	while(l<r) {
		if(s[l]!=s[r])cnt++;
		l++,r--;
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	double d;
	while(~scanf("%lf",&d)){
		if( d<=48.00 ){
			puts("light fly");
		}else if( 48.00<d && d<=51.00 ){
			puts("fly");
		}else if( 51.00<d && d<=54.00 ){
			puts("bantam");
		}else if( 54.00<d && d<=57.00 ){
			puts("feather");
		}else if( 57.00<d && d<=60.00 ){
			puts("light");
		}else if( 60.00<d && d<=64.00 ){
			puts("light welter");
		}else if( 64.00<d && d<=69.00 ){
			puts("welter");
		}else if( 69.00<d && d<=75.00 ){
			puts("light middle");
		}else if( 75.00<d && d<=81.00 ){
			puts("middle");
		}else if( 81.00<d && d<=91.00 ){
			puts("light heavy");
		}else{
			puts("heavy");
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
// #include<string>
#define rep(i,s,n) for(int i=s;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	// getline(cin,str);
	cin >> s;
	// cout << str <<endl;
	int near = 1000;
	rep(i,0,s.size()-2){
		int p =(s.at(i)-'0')*100+ (s.at(i+1)-'0')*10 +(s.at(i+2)-'0');
		near = min(abs(753-p),near);
	}
cout << near << "\n";
}

Measured memory_bytes: 256
/*****************************************************

*****************************************************/

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 1e5+1;
const ll inf = 1e8;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pwr(x, MOD-2);
}
int ans = 1;
int c[N], n, k; ;
vector<int> adj[N];
bool vis[N];

void dfs(int v)
{
    vis[v] = 1;
    int x, cnt = 0;
    for(auto i: adj[v])
    {
        if(vis[i])
            cnt++;
    }
    x = k-cnt-1;
    for(auto i: adj[v])
    {
        if(!vis[i])
        {
            c[i] = x;
            x--;
        }
    }
    for(auto i: adj[v])
    {
        if(!vis[i])
            dfs(i);
    }
}

void solve()
{
    cin>>n>>k;

    for(int i=0;i<n-1;i++)
    {
        int x, y; cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    memset(vis, 0, sizeof(vis));
    c[0] = 0;
    c[1] = k;
    dfs(1);
    for(int i=1;i<=n;i++)
    {
        ans *= c[i];
        ans %= MOD;
    }
    cout<<ans;
}

signed main()
{
// #ifndef ONLINE_JUDGE
//     freopen("ladders_and_snakes_sample_input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    
    int t=1;
    // cin >>t;
    for(int tt=1;tt<=t;tt++){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
    return 0;
}

/*****************************


****************************/

Measured memory_bytes: 8960
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int[] leftmax=new int[N];
		int[] rightmax=new int[N];
		int[] num=new int[N];
		leftmax[0]=0;
		rightmax[N-1]=0;
		for(int i=0; i<N; i++) {
			num[i]=sc.nextInt();
		}
		for(int i=1; i<N; i++) {
			leftmax[i]=Math.max(leftmax[i-1], num[i-1]);
		}
		for(int i=N-1; i>=1; i--) {
			rightmax[i-1]=Math.max(rightmax[i], num[i]);
		}
		for(int i=0; i<N; i++) {
			System.out.println(Math.max(leftmax[i], rightmax[i]));
		}
	}
}

Measured memory_bytes: 93480
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	
	vector<string> ans(n, string(n, '.'));
	
	vector<vector<string>> s = {
		{
			".aa",
			"b..",
			"b..",
		}, {
			"abcc",
			"abdd",
			"ccab",
			"ddab",
		}, {
			"addee",
			"a.cff",
			"bbcgg",
			"efg..",
			"efg..",
		}, {
			".aaccff",
			"b..ddgg",
			"b..eehh",
			"cde....",
			"cde....",
			"fgh....",
			"fgh....",
		}
	};
	
	auto f = [&](array<int, 4> c) {
		LL p = 0;
		inc(k, 4) {
		inc(l, c[k]) {
			int m = SI(s[k]);
			inc(i, m) {
			inc(j, m) {
				ans[p + i][p + j] = s[k][i][j];
			}
			}
			p += m;
		}
		}
	};
	
	if(n == 2) { OUT(-1); exit(0); }
	
	if(n % 3 == 0) { f({ n / 3, 0, 0, 0 }); }
	ef(n ==  7) { f({ 0, 0, 0, 1 }); }
	ef(n == 11) { f({ 0, 1, 0, 1 }); }
	else {
		int a = n - 5 * (n % 4);
		assert(a >= 0 && a % 4 == 0);
		f({ 0, a / 4, n % 4, 0 });
	}
	
	RF(e, ans) { OUT(e); }
}


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

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    vector<int> y(M);
    for (int i = 0; i < M; i++) {
        cin >> y[i];
    }

    for (int i = X+1; i <= Y; i++) {
        if (*max_element(x.begin(), x.end()) < i && i <= *min_element(y.begin(), y.end())) {
            cout << "No War";
            return 0;
        }
    }
    cout << "War";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    ll d = max(A, max(B, C));
    int e = A + B + C - d;
    for (int i=0; i<K; ++i) {
        d *= 2;
    }
    cout << e + d << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N;
    cin >> N;
    double a = 0.0;
    rep1(i, N)if(i % 2)a += 1.0;
    printf("%.9f\n", a / N);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vll a(n);
  REP(i,n) cin >> a[i];

  vll ans;
  ans.push_back(a[0]);

  for(ll i = 1; i < n; i++){
    ll t = a[i];
    if(ans.back() < t) ans.push_back(t);
    else{
      ll lef = -1, rig = ans.size();
      while(rig - lef > 1){
        ll mid = (lef + rig) / 2;
        if(t <= ans[mid]) rig = mid;
        else lef = mid;
      }
      ans[rig] = t;
    }
  }

  cout << ans.size() <<endl;

  return 0;
}




Measured memory_bytes: 4644
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    Ball[] balls = new Ball[N];
    for (int i = 0; i < N; i++) balls[i] = new Ball(scanner.nextInt(), scanner.nextInt());

    Map<Pair, Integer> freq = new HashMap<>();
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i == j) continue;
        Pair p = new Pair(balls[j].x - balls[i].x, balls[j].y - balls[i].y);
        freq.put(p, freq.getOrDefault(p, 0) + 1);
      }
    }
    int max = freq.values().stream().max(Comparator.comparingInt(i -> i)).orElse(0);
    System.out.println(N - max);
  }

  private static class Pair {
    private final int p;
    private final int q;

    private Pair(int p, int q) {
      this.p = p;
      this.q = q;
    }

    @Override public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Pair pair = (Pair) o;
      return p == pair.p &&
          q == pair.q;
    }

    @Override public int hashCode() {
      return Objects.hash(p, q);
    }
  }

  private static class Ball {
    private final int x;
    private final int y;

    private Ball(int x, int y) {
      this.x = x;
      this.y = y;
    }
  }
}


Measured memory_bytes: 27220
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    int a, b, k;
    cin >> a >> b >> k;
    int i = 0;
    vector<int> vec;
    for(int i=1; i <= min(a, b); i++){
        if(a % i == 0 && b % i == 0) vec.push_back(i);
    }

    cout << vec[vec.size()-k] << endl;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, m = MAP()
num = [-1 for _ in range(n)]
for _ in range(m):
    s, c = MAP()
    s -= 1
    if num[s] == -1 or num[s] == c:
        num[s] = c
    else:
        print(-1)
        exit()
if num[0] == 0 and n > 1:
    print(-1)
    exit()
elif num[0] == -1 and n > 1:
    num[0] = 1
elif num[0] == -1 and n == 0:
    num[0] = 0
for i in range(n):
    if num[i] == -1:
        num[i] = 0
    num[i] = str(num[i])
print(''.join(num))

Measured memory_bytes: 61804
fun main(args: Array<String>) {
    abc094b()
}

fun abc094b() {
    val (n, m, x) = readLine()!!.split(" ").map { it.toInt() }
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val goLeft = aList.count { it < x }
    val goRight = aList.count { it > x }

    println(Math.min(goLeft, goRight))
}


Measured memory_bytes: 35988
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int a,b,c,d;cin>>a>>b>>c>>d;

    while(true){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            return;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            return;
        }
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int a, b;

void _main() {
    cin >> a >> b;
    int c = stoi(to_string(a) + to_string(b));
    int i = 1;
    while (i * i < c) {
        i++;
    }
    cout << (i * i == c ? "Yes" : "No") << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a,ll b){
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
int main () {
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll p,k,r;
   p=lcm(c,d);
   if(a%p==0)
   k=a/p;
   else
   k=a/p+1;
   r=b/p;
   ll modlcm=b-a+1-(r-k+1);
   p=c;
   if(a%p==0)
   k=a/p;
   else
   k=a/p+1;
   r=b/p;
   ll modc=b-a+1-(r-k+1);
   p=d;
   if(a%p==0)
   k=a/p;
   else
   k=a/p+1;
   r=b/p;
   ll modd=b-a+1-(r-k+1);
   cout<<modd+modc-modlcm;
   return 0;
}


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

using namespace std;
using P = pair<int, int>;

int main(void){
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    for (int i = 0; i < m; i++){
        cin >> p[i].first >> p[i].second;
    }
    for(int i = 0;i < 1000;i++){
        int keta = 1;
        int nx = i/10;
        vector<int> d(1, i%10);
        while(nx){
            keta++;
            d.push_back(nx%10);
            nx /= 10;
        }
        if(keta != n) continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        for(int j = 0;j < m;j++){
            if(d[p[j].first - 1] != p[j].second) ok = false;
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256