akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int m,f,r,i;
	while(1)
	{
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1 || f==-1 )
		{	
			if(m==-1 && f==-1 && r==-1)
			{
				break;
			}
			else
			{
			printf("F\n");
			}
		}
		else if(m+f>=80)
		{
			printf("A\n");
		}
		else if(m+f>=65 && m+f<80)
		{
			printf("B\n");
		}
		else if(m+f>=50 && m+f<65)
		{
			printf("C\n");
		}
		else if(m+f>=30 && m+f<50)
		{
			if(r>=50)
			{
				printf("C\n");
			}
			else
			{
				printf("D\n");
			}
		}
		else
		{
			printf("F\n");
		}
	}

	return 0;
}

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

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def dijkstra(N: int, nodes: list, src: int) -> list:
    """ ダイクストラ高速化版(頂点数, 隣接リスト(0-indexed), 始点) """
    from heapq import heappush, heappop

    # 頂点[ある始点からの最短距離]
    res = [INF] * N
    # スタート位置
    que = [src]
    res[src] = 0
    # キューが空になるまで
    while len(que) != 0:
        # 距離*N + 現在のノード
        cur = heappop(que)
        # 距離とノードに分ける
        dist = cur // N
        cur %= N
        # 出発ノードcurの到着ノードでループ
        for nxt, cost in nodes[cur]:
            # 今回の経路のが短い時
            if dist + cost < res[nxt]:
                res[nxt] = dist + cost
                # 距離*N+ノード番号 の形でキューに詰める
                heappush(que, (dist+cost)*N+nxt)
    # ノードsrcからの最短距離リストを返却
    return res

N, M, s, t = MAP()
s -= 1
t -= 1
nodes1 = tuple([] for i in range(N))
nodes2 = tuple([] for i in range(N))
for i in range(M):
    u, v, a, b = MAP()
    u -= 1
    v -= 1
    nodes1[u].append((v, a))
    nodes1[v].append((u, a))
    nodes2[u].append((v, b))
    nodes2[v].append((u, b))

res1 = dijkstra(N, nodes1, s)
res2 = dijkstra(N, nodes2, t)

A = [0] * N
for i in range(N):
    # sからiまで円、iからtまでスヌークで行く
    A[i] = res1[i] + res2[i]

# 最後のが使える両替所が少ないので、後ろから累積minする
ans = list(accumulate(A[::-1], min))[::-1]
total = 10 ** 15
[print(total-a) for a in ans]


Measured memory_bytes: 82376
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    ll N, K, a; cin >> N >> K;
    const ll m = 2000000;
    vp v(m, P(m, m)); vb exist(m, false);
    for (ll i = 0; i < N; i++) {
        cin >> a;
        if(exist[a]) v[a].second++;
        else{
            v[a] = P(a, 1);
            exist[a] = true;
        }
    }
    
    sort(v.begin(), v.end(), p_comp_ss);
    ll count = count_if(exist.begin(), exist.end(), [](bool f){return f;});
    ll ret = 0;
    for (int i = 0; i < count - K; i++) {
        ret += v[i].second;
    }
    cout << ret << endstr;
    return 0;
}


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

//約数の個数を出力
ll divisor_counter(ll n){
	if(n==1) return 1L;
	ll count = 0L;
	for(ll i=1L; i*i<=n; ++i) if(n%i == 0L) count++;
	return count*2L;
}

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

	ll ans = 0;
	for(int n=1; n<=N; n+=2){
		if(divisor_counter(n) == 8){
			ans++;
		}
	}

	cout<< ans <<endl;
}


Measured memory_bytes: 256
#include<queue>
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;
typedef pair<int, int> pii;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
 
bool isRange(int nx, int ny, int w, int h){
  return (0 <= nx and nx < w and
          0 <= ny and ny < h);
}
 
void bfs(queue<vector<int> > &que, vector<vector<int> > &dist , vector<string> &grid){
  int h = dist.size(), w = dist[0].size();
  while(not que.empty()){
    int c = que.front()[0];
    int x = que.front()[1];
    int y = que.front()[2];
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if(not isRange(nx, ny, w, h))continue;
      if(c + 1 >= dist[ny][nx])continue;
      if(grid[ny][nx] == '#')continue;
      dist[ny][nx] = c + 1;
      que.push(vector<int>{c + 1, nx, ny});
    }
  }
}
 
int main(){
  int h, w;
  std::cin >> h >> w;
  vector<string> grid(h);
  pii s, g;
  set<pii> e;
  vector<vector<int> > dist_p(h, vector<int>(w, 1e9));
  vector<vector<int> > dist_e(h, vector<int>(w, 1e9));
  for (int i = 0; i < h; i++) {
    std::cin >> grid[i];
    for (int j = 0; j < w; j++) {
      if(grid[i][j] == '%')g = pii(j, i);
      if(grid[i][j] == '@')s = pii(j, i);
      if(grid[i][j] == '$')e.insert(pii(j, i));
    }
  }
  queue<vector<int> > que;
  que.push(vector<int>{0, s.first, s.second});
  dist_p[s.second][s.first] = 0;
  bfs(que, dist_p, grid);
 
  for (auto pos: e){
    dist_e[pos.second][pos.first] = 0;
    que.push(vector<int>{0, pos.first, pos.second});
  }
  bfs(que, dist_e, grid);
  
  que.push(vector<int>{0, s.first, s.second});
  vector< vector<bool> > visited(h, vector<bool>(w,false));
  visited[s.second][s.first] = true;
  while(not que.empty()){
    int c = que.front()[0];
    int x = que.front()[1];
    int y = que.front()[2];
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if(not isRange(nx, ny, w, h))continue;
      if(dist_p[ny][nx] >= dist_e[ny][nx])continue;
      if(grid[ny][nx] == '#')continue;
      if(visited[ny][nx])continue;
      visited[ny][nx] = true;
      que.push(vector<int>{c + 1, nx, ny});
    }
  }
  std::cout << ((visited[g.second][g.first])?"Yes":"No") << std::endl;
  return 0;
}

Measured memory_bytes: 6768
#include <iostream> 
#include <string> 
#include <map>
using namespace std;
 
map<string, int>mp1, mp2;
 
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    mp1[s]+=1;
  }
  int m;
  cin>>m;
  for(int i = 0; i < m; i++){
	string s ;
	cin>>s ;
	mp2[s]+=1 ;
   }
  	map<string, int> :: iterator it ;
	int mx = 0 ;
	for(it = mp1.begin(); it != mp1.end(); it++){
		mx = max(mx, mp1[it->first] - mp2[it->first]) ;
	}
	cout<<mx<<endl ;
	return 0 ;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

ans = 1
dp = [0]*3
for a in A:
    cnt = 0
    for i in range(3):
        if a == dp[i]:
            cnt += 1
    for i in range(3):
        if a == dp[i]:
            dp[i] += 1
            break
    ans = ans*cnt % MOD
print(ans)


Measured memory_bytes: 52952
def main():
    N = int(input())
    P = list(map(int, input().split()))
    min_P = float('inf')
    cnt = 0
    for i in range(N):
        if P[i] <= min_P:
            cnt += 1
        min_P = min(min_P, P[i])

    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 76624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#ifndef ONLINE_JUDGE
//#include <custom/prettyprint.hpp>
//#endif
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define pow10(n) stoll("1"+string(n,'0'))
#define dbg(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9+7; //998244353
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;
const ld PI = acos((ld)-1);
const int dx[8] = {1,0,-1,0,1,1,-1,-1}, dy[8] = {0,1,0,-1,-1,1,1,-1};
mt19937_64 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll n) { return uniform_int_distribution<ll>(0, n)(rng); }
template<class T> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {

    setIO("input");
    int a,b,c; cin >> a >> b >> c;
    int k; cin >> k;
    while(k && b <= a) {
        b <<= 1;
        k--;
    }
    while(k && c <= b) {
        c <<= 1;
        k--;
    }
    cout << (a < b && b < c ? "Yes\n" : "No\n");

}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<int> freqs(10, 0);
  int extra = 0;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int a; scanf("%d", &a);
    if (a >= 3200) { ++extra; }
    else { ++freqs[a / 400]; }
  }
  for (int i = 0; i < 10; ++i) {
    cnt += (freqs[i] > 0);
  }
  int ans_min = max(1, cnt);
  int ans_max = cnt + extra;
  printf("%d %d\n", ans_min, ans_max);
  return 0;
}


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

using namespace std;

typedef long long LL;

int N,a[100010],b[100010];
bool nop[100010];

int main()
{
    scanf("%d",&N);
    for (int i=1;i<=N;i++)
    scanf("%d",&a[i]),b[i] = a[i];
    sort(b+1,b+N+1);
    for (int i=1;i<=N;i++)a[i] = lower_bound(b+1,b+N+1,a[i]) - b;
    int ans = 0;
    for (int i=1;i<=N;i++) ans += ((a[i] % 2) != (i % 2));
    printf("%d\n",ans / 2);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<math.h>
#include<climits>
#include<set>
//#include<bits/stdc++.h>
#define debug(x) cout <<#x<<" = "<<x<<endl
#define debug2(x, y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define gg cout <<"---------------QAQ---------------"<<endl
#define fi first
#define SZ(x) (int)x.size()
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, string> pii;
typedef pair<pii, ll> Pii;
template<class T> inline void read(T &x){
    x=0; char c=getchar(); int f=1;
    while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
    while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
const int N = 2e5+10, maxn = 1e6+10;
void FAST(){ios::sync_with_stdio(false);cin.tie(nullptr); cout.tie(nullptr);}
const ll mod =  1e9+7;

int n, m, x;
ll k;
int a[N];
bool vis[N];
vector<int> ans, tmp;

void solve()
{
    ans.clear(); tmp.clear();
    scanf("%d%lld", &n, &k);
    for(int i = 1;i <= n; ++i) scanf("%d", &a[i]), vis[i] = 0;
    int cnt = 0, ret = 0, pos = 1;
    while(1)
    {
        if(cnt++ == k) {
            printf("%d\n", pos);
            return ;
        }
        ans.pb(pos);
        if(vis[pos]) break;
        vis[pos] = 1;
        pos = a[pos];
    }
    int c = 0;
    for(int i = 0; i < k; ++i) {
        c++;
        if(ans[i] == pos) break;
    }
    for(int i = c; i < SZ(ans); ++i) tmp.pb(ans[i]);
    k -= c;
    pos = k%SZ(tmp);

    printf("%d\n", tmp[pos]);
}

int main()
{
//    init();
//    int _;scanf("%d", &_); while(_--)
    solve();
    return 0;
}


Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int x, a, b;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> x >> a >> b;
  if(abs(a-x)<abs(b-x)){
    cout << "A" << endl;
  }else{
    cout << "B" << endl;
  }
}

Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int t[100100],x[100100],y[100100];
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int flag=1,ans,sum;
	    x[0]=0,y[0]=0;
		for(int i=1; i<=n; i++)
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		for(int i=0; i<=n-1; i++)
		{
			ans=sqrt((x[i+1]-x[i])*(x[i+1]-x[i]))+sqrt((y[i+1]-y[i])*(y[i+1]-y[i]));
			sum=t[i+1]-t[i];
			if(ans>sum)
			flag=0;
			else
			{
				if((sum-ans)%2!=0)
				flag=0;
			}
		}
	    if(flag==1)
	    printf("Yes\n");
	    else
	    printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1280
// ARC080-D
#include <bits/stdc++.h>
using namespace std;

int H, W, N;
int a[10010];
int B[109][109];

int main() {
   cin >> H >> W >> N;
   int idx = 0;
   for (int i = 0; i < N; i++) {
      int x;
      cin >> x;
      for (int j = 0; j < x; j++) {
         a[idx] = i+1;
         idx++;
      }
   }

   idx = 0;
   for (int i = 0; i < H; i++) {
      if (i%2==0) {
         for (int j = 0; j < W; j++) {
            B[i][j] = a[idx];
            idx++;
         }
      } else {
         for (int j = W-1; j >= 0; j--) {
            B[i][j] = a[idx];
            idx++;
         }
      }
   }

   cerr << endl;
   for (int i = 0; i < H; i++) {
      for (int j = 0; j < W-1; j++) {
         cout << B[i][j] << " ";
      }
      cout << B[i][W-1] << endl;
   }

   return 0;
}

Measured memory_bytes: 384
a, b, m = map(int, input().split())
pa = list(map(int, input().split()))
pb = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for j in range(m)]
minprice = min(pa)+min(pb)
wari=0
for i in xyc:
    wari = pa[i[0]-1]+pb[i[1]-1]-i[2]
    if wari<minprice:
        minprice = wari
print(minprice)

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

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    double S = 0 ;
    double[] A = new double[N];
    for(int i = 0;i<N;i++){
      A[i] = scan.nextDouble();
      A[i] =1/A[i];
      S+=A[i];
    }
    System.out.println(1/S);
  }
}

Measured memory_bytes: 23252
class Unionfind
  attr_accessor(:par, :size)

  def initialize(n)
    @par = Array.new(n+1)
    (n+1).times do |i|
      @par[i] = i
    end
    @size = Array.new(n+1,1)
  end

  def root(x)
    while @par[x] != x
      x = @par[@par[x]]
      @par[x] = @par[@par[x]]
    end
    x
  end

  def unite(x,y)
    rx = root(x)
    ry = root(y)
    if rx != ry
      @size[ry] += size(rx)
      @par[rx] = ry
    end
  end

  def same(x,y)
    return root(x)==root(y)
  end

  def size(x)
    if @par[x] == x
      @size[x]
    else
      size(root(par[x]))
    end
  end

end

n,m = gets.chomp.split(" ").map(&:to_i)
a,b = m.times.map{gets.split.map(&:to_i)}.transpose
cnt = n * (n-1) / 2
ans = [cnt]
tree = Unionfind.new(n)
(m-1).downto(1) do |i|
  size_a = tree.size(a[i])
  size_b = tree.size(b[i])
  if !tree.same(a[i],b[i])
    tree.unite(a[i],b[i])
    cnt -= size_a * size_b
  end
  ans << cnt
end
ans.reverse!
puts ans

Measured memory_bytes: 24892
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, k, h, ans = 0;
    cin >> n >> k;
    while (n--) {
        cin >> h;
        if (h >= k)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    a=int(readline())
    #ss=readline().rstrip()
    #yn(1)
    print(a+a**2+a**3)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16076
#include <bits/stdc++.h>
#include <set> 
#include <iterator> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a) for(ll i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)


int main()
{
  
    fastio();
    int n,k;
    cin>>n>>k;
    int a[n];
    cn(a,n);
    int dp[k+1]={0};
    sort(a,a+n);
    for(int i=0;i<a[0];i++)
    {
        dp[i]=2;
    }
    for(int i=a[0];i<=k;i++)
    {
        int f=2;
        for(int j=0;j<n;j++)
        {
            if(i-a[j]>=0)
            {
                if(dp[i-a[j]]==2)
                    f=1;
            }
        }
        dp[i]=f;
    }
    string s = "First";
    if(dp[k]==2)
        s="Second";
    cout<<s<<endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define mod 1e9+7
using namespace std;
vector<int>v[100010];
int DP[100010];
int dp(int cur)
{
    if(DP[cur]!=-1) return DP[cur];
    int ans=0;
    for(int i:v[cur])
    {
        ans=max(ans, dp(i));
    }
    ans++;
    return DP[cur]=ans;
}
int main()
{
    memset(DP, -1, sizeof(DP));
    int n, m;
    cin>>n>>m;
    int x, y;
    for(int i=0; i<m; i++)
    {
        scanf("%d%d", &x, &y);
        v[x].pb(y);
    }
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        ans=max(ans, dp(i));
    }
    cout<<ans-1<<endl;
    return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dl double long
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rrep(i, m, n) for(ll i = (ll)(m); i > (ll)(n); --i)
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;

int main(void){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if(a >= k){
        cout << k << endl;
        return 0;
    }else if(a + b >= k){
        cout << a << endl;
        return 0;
    }else{
        cout << (a - (k-a-b)) << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

constexpr int INF = 1e8;
constexpr int N_MAX = 100;
constexpr int M_MAX = 500;
bool visited[N_MAX] = {}; 
int n, m;

struct Edge {
    int to_;
    int cost_;
    Edge(int to, int cost) : to_(to), cost_(cost) {}
};

auto clear(vector<vector<Edge>> &g) -> void {
    for (int i = 0; i < N_MAX; ++i) {
        visited[i] = false;
    }

    for(auto& e : g) {
        g.clear();
    }
}

auto prim(vector<vector<Edge>> &g) -> int {
    auto comp = [](auto lhs, auto rhs){return lhs.first > rhs.first;};
    priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(comp)> que(comp);
    int ans = 0;
    que.push(make_pair(0, 0));
    while (!que.empty()) {
        auto p = que.top();
        que.pop();
        if (visited[p.second]) continue;
        visited[p.second] = true;
        auto edges = g[p.second];
        ans += p.first;
        for(const auto &e : edges) {
            if (!visited[e.to_]) {
                que.push(make_pair(e.cost_, e.to_));
            }
        }
    }
    return ans;
}

auto main(int argc, char const *argv[]) -> int {
    while (cin>>n>>m, n || m) {
        vector<vector<Edge>> g(n);
        clear(g);
        for (int i = 0; i < m; ++i) {
            int a, b, cost;
            cin>>a>>b>>cost;
            g[a].push_back(Edge(b, cost));
            g[b].push_back(Edge(a, cost));
        }
        cout<<prim(g)<<endl;
    }
    return 0;
}

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

typedef long long ijt;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define rep(i,n) for(int i = 0;i < n;i++)

int N,Q;
int main(void){
   cin >> N >> Q;
   set<int> P;
   vector<pair<int,pair<int,int>>> E;
   for(int i = 0;i < N;i++){
      int s,t,x;scanf("%d %d %d",&s,&t,&x);
      E.pb(mp(s - x,mp(-1,x)));
      E.pb(mp(t - x - 1,mp(1,x)));
   }
   for(int i = 0;i < Q;i++){
      int d;scanf("%d",&d);
      E.pb(mp(d,mp(0,0)));
   }
   
   sort(all(E));
 
   for(int i = 0;i < E.size();i++){
      auto e = E[i];
      int command = e.second.first;
      int posi = e.second.second;
      if(command == -1){
         P.insert(posi);
      }else if(command == 1){
         P.erase(posi);
      }else{
         int ans = *P.begin();
         if(!P.empty())printf("%d\n",ans);
         else printf("-1\n");
      }
   }
   return 0;
}

Measured memory_bytes: 17768
#include <stdio.h>

int main(void) {
  int x, y;
  while (1) {
    scanf(" %d %d", &x, &y);
    if (x == 0 && y == 0)
      return 0;
    if (x > y)
      printf("%d %d\n", y, x);
    else
      printf("%d %d\n", x, y);
  }
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s,t;
    ll n;cin >>n;
    cin >>s>>t;
    string ans="";
    for (int i = 0; i < n; ++i) {
        ans+=s[i];
        ans+=t[i];
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]g){int a[]=new int[8],i,j,h,b;for(Scanner S=new Scanner(System.in);S.hasNext();System.out.println(h+" "+b)){for(h=b=i=0;i<8;)a[i++]=S.nextInt();for(i=0;i<4;i++)for(j=4;j<8;j++)if(i==j-4){if(a[i]==a[j])h++;}else{if(a[i]==a[j])b++;}}}}


Measured memory_bytes: 25992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

string str;
int i,n;
int main()
{
	cin>>str;
	n=str.length();
	if(n<4)
	{
		cout<<"No"<<endl;
		return 0;
	}
	if(str[0]=='Y'&&str[1]=='A'&&str[2]=='K'&&str[3]=='I')
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
 return 0;
}

Measured memory_bytes: 256
#ABC128_C
N,M=map(int,input().split())

#ks=[list(map(int,input().split())) for _ in range(M)]
k=[]
s=[]
for i in range(M):
    inp=list(map(int,input().split()))
    k.append(inp[0])
    s.append(inp[1:])

p=list(map(int,input().split()))

fil=1
A=0
for ans in range(2**N):#ONになっている電球の組み合わせをbit全探索
    for i in range(M):#各電球ごと
        sw_on_cnt=0
        for j in range(k[i]):#各電球の指定のスイッチごと k[i]はi番目の電球がswにつながっている数
            if ans>>(s[i][j]-1)&fil==1:#優先順位は-,>>,& sw_numで指定されたswがONなら
                sw_on_cnt+=1
        if sw_on_cnt%2==p[i]:
            pass
        else:
            break
    else:
        A+=1
print(A)

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int main() {
	vector< string > keitai;

	keitai.push_back(".,!? "); keitai.push_back("abc"); keitai.push_back("def"); keitai.push_back("ghi"); keitai.push_back("jkl");
	keitai.push_back("mno"); keitai.push_back("pqrs"); keitai.push_back("tuv"); keitai.push_back("wxyz");

	vector< int > count(keitai.size(), 0);

	int n;
	cin >> n;

	vector< string > s;
	for(int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		s.push_back(tmp);
	}

	for(int i = 0; i < n; i++) {
		string ans;

		for(int j = 0; j < s[i].size(); j++) {
			if(s[i][j] == '0') {
				fill(count.begin(), count.end(), 0);
				continue;
			}

			if(j == 0) {
				fill(count.begin(), count.end(), 0);
				ans.push_back(' ');
			} else if(s[i][j - 1] == '0' && s[i][j] != '0') {
				fill(count.begin(), count.end(), 0);
				ans.push_back(' ');
			}

			ans[ans.size() - 1] = keitai[s[i][j] - '0' - 1][count[s[i][j] - '0' - 1] % keitai[s[i][j] - '0' - 1].size()];
			count[s[i][j] - '0' - 1]++;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1296
#include<iostream>
#include<vector>
#include<iostream>
using namespace std;
int main(){
	int n,m,k,l,s=0;
	vector<int> t,p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>m;
		s+=m;
		t.push_back(m); 
	}
	cin>>m;
	for(int i=0;i<m;i++){
		cin>>k>>l;
		p.push_back(s-t[k-1]+l);
	}
	for(int i=0;i<m;i++){
		cout<<p[i]<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	
	string s;
	cin >> s;

	int cnt=0;
	int len = s.size();
  //cout<<len<<endl;

	for (int i = 0; i < len / 2; i++) {

		//cout << s[i] << s[len-1-i] << endl;

		if (s[i] != s[len-1 - i]) {
			cnt++;

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

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int First = 1000;
int w,h,n;
int ans = 0;
int d[1001][1001];
typedef struct p{
	int x, y;
}P;
string mapp[1001];
P nezumi[11];


//幅優先探索を行う
void bfs(){
	for(int i=1 ; i <= n ; i++ ){
		P sp = nezumi[i-1];
		int sx = nezumi[i-1].x;
		int sy = nezumi[i-1].y;
		int gx = nezumi[i].x;
		int gy = nezumi[i].y;

		//二次元配列の初期化をする
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				d[y][x] = First;
			}
		}
		
		queue<P> q;
		q.push( sp );
		d[sy][sx] = 0;
		while( !q.empty() ){
			P now = q.front();
			q.pop();
			int x = now.x;
			int y = now.y;

			if( x == gx && y == gy ){
				ans += d[gy][gx];

				/*動作確認
				cout << "\n";
				for(int y=0 ; y < h ; y++ ){
					for(int x=0 ; x < w ; x++ ){
						if (d[y][x]==First){cout << "X";}
							else{cout << d[y][x];}
					}
					cout << "\n";
				}*/
				break;
			}

			//redandblackと同じように探索
			for(int i=0 ; i < 4 ; i++ ){
				int newx = x + dx[i];
				int newy = y + dy[i];
				if( newx < 0 || newy < 0 || newx >= w || newy >= h ) continue;
				if( mapp[newy][newx] != 'X' ){
					P next;
					next.x = newx;
					next.y = newy;
					if( d[newy][newx] == First ){
						d[newy][newx] = d[y][x] + 1;
						q.push( next );
					}
				}
			}
		}
	}
}

int main(){
	//標準入力
	cin >> h >> w >> n;
	for(int y=0 ; y < h ; y++ ){
		cin >> mapp[y];
	}
	
	//スタートと数字の確認
	for(int y=0 ; y < h ; y++ ){
		for(int x=0 ; x < w ; x++ ){
			char c = mapp[y][x];

			//アスキー使っていい感じにしてみる
			if( c >= '1' && c <= '9' ){
				nezumi[ c - '0' ].x = x;
				nezumi[ c - '0' ].y = y;
			}
			if(c == 'S'){
				nezumi[0].x = x;
				nezumi[0].y = y;
			}
		}
	}
	bfs();
	cout << ans << endl;
}

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

int main(){
  long long int n;
  cin >> n;
  vector<long long int> a(n), b(n+1), ans(n);
  rep(i,n,0) cin >> a[i];
  b[0] = 0;
  rep(i,n+1,1) b[i] = a[i-1] - b[i-1];
  ans[0] = b[n]/2;
  rep(i,n,1) ans[i] = a[i-1] - ans[i-1];
  rep(i,n,0) cout << 2*ans[i] << " ";
  cout << endl;
}

Measured memory_bytes: 3712
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
ll ans;
char s[11];
int n;
void dfs(int p, ll t, ll x) {
	if (p == n + 1)	return ans += t + x, void();
	dfs(p + 1, t + x, s[p] - '0');
	dfs(p + 1, t, x * 10 + s[p] - '0');
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	dfs(2, 0, s[1] - '0');
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int A;
	int B;
	scanf("%d",&A);
	scanf("%d",&B);

	if(A==1&&B==2){
		printf("%d\n",A+B);
	}
	else if(A==2&&B==1){
		printf("%d\n",A+B);	
	}
	else if(A==3&&B==1){
		printf("%d\n",A-B);
	}
	else if(A==2&&B==3){
		printf("%d\n",B-A);
	}
	else if(A==3&&B==2){
		printf("%d\n",A-B);
	}
	else if(A==1&&B==3){
		printf("%d\n",B-A);
	}

	
	return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n,m,par[N],sz[N],col[N];
struct node{
	int a;
	node(int x = 0){
		a = x;
	}
	bool operator<(const node &x)const{
		return col[a] <= col[x.a];
	}
};
set<node>st[N];
struct node1{
	int a;
	node1(int x = 0){
		a = x;
	}
	bool operator<(const node1 &x)const{
		if(sz[a] != sz[x.a])return sz[a] < sz[x.a];
		return col[a] > col[x.a];
	}
};
int get(int u){return par[u] == u ? u : par[u] = get(par[u]);}
void merge(int x,int y){
	if(x == y)return;
	if(st[x].size() < st[y].size())swap(x,y);
	sz[x]+=sz[y];
	par[y] = x;
	for(auto i : st[y])st[x].insert(i);
	st[y].clear();
}
int main(){
	//freopen("readin.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for(int i = 0;i < n;i++)scanf("%d",col + i),par[i] = i,sz[i] = 1,st[i].insert(i);
	for(int i = 0,a,b;i < m;i++){
		scanf("%d%d",&a,&b);
		merge(get(a),get(b));
	}
	priority_queue<node1>q;
	for(int i = 0;i < n;i++)if(i == par[i])q.push(node1(i));
	long long ans = 0;
	while(q.size() > 1){
		int x = q.top().a;
		q.pop();
		int y = q.top().a;
		q.pop();
		if(st[x].empty() || st[y].empty()){
			if(st[x].size())q.push(x);
			if(st[y].size())q.push(y);
			continue;
		}
		ans+=col[st[x].begin()->a] + col[st[y].begin()->a];
		st[x].erase(st[x].begin());
		st[y].erase(st[y].begin());
		merge(get(x),get(y));
		q.push(get(x));
	}
	int count = 0;
	for(int i = 0;i < n;i++)count+=i == par[i];
	if(count > 1)return puts("Impossible"),0;
	printf("%lld\n",ans);
}

Measured memory_bytes: 11392
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------


int col[9];
int inp;
int ans;
int mn;
int mx;
int n;
int main(){
    cin>>n;
    REP(i,n){
        cin>>inp;
        if(inp<400)col[0]++;
        else if(inp<800)col[1]++;
        else if(inp<1200)col[2]++;
        else if(inp<1600)col[3]++;
        else if(inp<2000)col[4]++;
        else if(inp<2400)col[5]++;
        else if(inp<2800)col[6]++;
        else if(inp<3200)col[7]++;
        else if(3200<=inp)col[8]++;
    }
    REP(i,8){
        if(col[i])ans++;
    }

    if(!col[8]){
        mn=ans;
        mx=ans;
    }else if(col[8]){
        mn=ans;
        mx=ans+col[8];
        if(ans==0)mn=1;
        //if(mx>8)mx=8;
    }
    cout<<mn<<" "<<mx<<endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;


int main() {
	int n; cin >> n;
	vector<double> x(n), y(n);
	rep(i, n)cin >> x[i]; rep(i, n)cin >> y[i];

	double a1 = 0., a2 = 0., a3 = 0., a4 = 0.;

	//a1
	rep(i, n)a1 += abs(x[i] - y[i]);

	//a2
	rep(i, n) a2 += abs(x[i] - y[i]) * abs(x[i] - y[i]);
	a2 = sqrt(a2);

	//a3
	rep(i, n)a3 += abs(x[i] - y[i])*abs(x[i] - y[i])*abs(x[i] - y[i]);
	a3 = cbrt(a3);

	//a4
	rep(i, n)a4 = max(a4, abs(x[i] - y[i]));

	printf("%.20f\n%.20f\n%.20f\n%.20f\n", a1, a2, a3, a4);
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int mn = 100000000;
  int k= 0;
  int num;
  for(int i = 0;i<s.size()-t.size()+1;i++){
    num = 0;
    for(int j = 0;j<t.size();j++){
      if(s[i+j] != t[j]){
        num++;
      }
    }
    mn = min(mn,num);
  }
  cout << mn;
}

Measured memory_bytes: 3572
#include <stdio.h>
int main(void){
    int A, B;
    scanf("%d %d", &A, &B);
    if (A > B) {
        printf("%d", A * 2 - 1);
    }
    else if (A == B) {
        printf("%d", A + B);
    }
    else {
        printf("%d", B * 2 - 1);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <map>
using namespace std;
int main(){
    map<char, int> m;
    string s; cin >> s;
    for(char c : s) {
        m[c]++;
    }
    for(auto i : m) {
        if(i.second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
//The Doc

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> a(n);
    for (int i = 0; i <n ; ++i) {
        cin>>a[i];
    }
    ll x=a[0];
    for (int i = 1; i <n ; ++i) {
        x=gcd(a[i],x);
    }
    //cout<<x<<"\n";
   if(x!=1){
        cout<<"not coprime"<<"\n";
    }
   else{
        vector<ll> minPrime(1e6 + 1,0);
        for (int i = 2; i * i <= 1e6; ++i) {
            if (minPrime[i] == 0) {
                for (int j = i * i; j <= 1e6; j += i) {
                    if (minPrime[j] == 0) {
                        minPrime[j] = i;
                    }
                }
            }
        }
        for (int i = 2; i <= 1e6; ++i) {
            if (minPrime[i] == 0) {
                minPrime[i] = i;
            }
        }
        vector<ll> ct(1e6+1,0);
        for (int i = 0; i <n ; ++i) {
            set<ll> sett;
            while(a[i]!=1){
                if(minPrime[a[i]]!=1)
                sett.insert(minPrime[a[i]]);
                a[i] /= minPrime[a[i]];
            }
            set<ll> ::iterator itr;
            for (itr = sett.begin(); itr != sett.end(); ++itr)
            {
                ll kkk=*itr;
               // cout<<kkk<<" ";
                ct[kkk]++;
            }
            sett.clear();
        }
        //cout<<ct[2]<<" "<<ct[3]<<"\n";
        sort(ct.begin(),ct.end());
        //cout<<ct[n]<<"\n";
        if(ct[1e6]<=1){
            cout<<"pairwise coprime"<<"\n";
        }
        else{
            cout<<"setwise coprime"<<"\n";
        }
    }
    return 0;
}


Measured memory_bytes: 26612
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 200050;

int head[N], to[N], nex[N], tot, sg[N], n;
void addedge(int u, int v){
	tot ++; to[tot] = v, nex[tot] = head[u], head[u] = tot;
	tot ++; to[tot] = u, nex[tot] = head[v], head[v] = tot;
}
void dfs(int x, int fa){
	for(int i = head[x]; i; i = nex[i]){
		if(to[i] != fa){
			dfs(to[i], x);
			sg[x] ^= sg[to[i]] + 1;
		}
	}
}
inline void gi(int &x){
	x = 0; char c = getchar();
	while(c < '0' || c > '9')c = getchar();
	while(c >= '0' && c <= '9'){
		x = x * 10 + c - '0';
		c = getchar();
	}
}

int main()
{
	int i, j, k;
	for(gi(n), i = 1; i < n; i ++)
		gi(j), gi(k), addedge(j, k);
	dfs(1, 0); puts(sg[1] ? "Alice" : "Bob");
	
	return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      if(s.at(i)=='L'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    else{
        if(s.at(i)=='R'){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int dp[(1<<16)];
typedef double D;
typedef complex<D> P;
typedef pair<P, P> L;
typedef vector<P> VP;
const D EPS = 1e-9; 
#define X real()
#define Y imag()
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;
  if (cross(b,c) < -EPS) return -1;
  if (dot(b,c)   < -EPS) return +2;
  if (norm(b) < norm(c)) return -2; 
  return 0; 
}
P proj(P a1, P a2, P p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

bool isecSP(P a1, P a2, P b) {
  return !ccw(a1, a2, b);
}
D distSP(P a1, P a2, P p) {
  P r = proj(a1, a2, p);
  if (isecSP(a1, a2, r)) return abs(r-p);
  return min(abs(a1-p), abs(a2-p));
}
int n,ans;
double sy[20],sx[20],gx[20],gy[20],r[20];
int main(){
  cin>>n;
  r(i,n)cin>>r[i]>>sx[i]>>sy[i]>>gx[i]>>gy[i];
  dp[0]=1;
  for(int i=0;i<(1<<n);i++){
    if(dp[i]){
      int sum=0;
      r(j,n)if((1<<j)&i)sum++;
      ans=max(sum,ans);
      for(int j=0;j<n;j++){
	if(((1<<j)&i)==0){
	  int f=0;
	  for(int k=0;k<n;k++)if(j!=k){
	    if((1<<k)&i){
	      if(distSP(P(sx[j],sy[j]),P(gx[j],gy[j]),P(gx[k],gy[k]))>r[j]+r[k])f++;
	    }
	    else{
	       if(distSP(P(sx[j],sy[j]),P(gx[j],gy[j]),P(sx[k],sy[k]))>r[j]+r[k])f++;
	    }
	  }
	  if(f==n-1)dp[i|(1<<j)]=1;
	}
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3540
#include <stdio.h>
#include <limits.h>

int main(void){
  
  int NumOfJewel;
  int ValueOfJewel[50];
  int CostOfJewel[50];
  int i, tmp = 0;
  int Otoku_Num;
  
  scanf("%d", &NumOfJewel);
  
  if(NumOfJewel <= 0 || NumOfJewel > 20)
    return 0;
  
  for(i = 0; i < NumOfJewel; i++) {
	scanf("%d", &ValueOfJewel[i]);
  }
  
  for(i = 0; i < NumOfJewel; i++) {
	scanf("%d", &CostOfJewel[i]);
  }
  
  // 価値＞コストを加算
  for(i = 0; i < NumOfJewel; i++) {
    if(ValueOfJewel[i] > CostOfJewel[i])
      tmp += ValueOfJewel[i] - CostOfJewel[i];
  }
  
  printf("%d", tmp);
  
  return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
int main() 
{
    ll n,i,sum=0,j,k;
    cin>>n;
    for(i=1;i<=n;i++)
    {
       for(j=1;j<=n;j++)
       {
           for(k=1;k<=n;k++)
           {
               sum+=gcd(i,gcd(j,k));
           }
       }
    }
    cout<<sum;
}

        

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

int main (){
long long a,b,k,ansa,ansb;
 
cin >> a >> b >> k; 

if (k > a){
    ansa = 0;
    k -= a;
    ansb = b-k;
}else
{
    ansa = a-k;
    ansb = b;
}
if(ansb < 0)
    ansb = 0;

cout << ansa <<  " " << ansb << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
int main(){
  ll N; cin >> N;
  ll ans = (1LL<<50);
  for(ll i=1; (i*i) <= N+10; ++i){
    
    if( N%i ==0 ){
      if(((N/i)+i-2) < ans) ans = N/i+i-2;
    }
    //cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

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

sorted_X = sorted(X)

left_med = sorted_X[N//2 -1]
right_mid = sorted_X[N//2]

for i in range(N):
    if X[i] <= left_med:
        print(right_mid)
    else:
        print(left_med)

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x = a+b,y = a+c,z = b+c;
    cout << min({x,y,z}) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=3005,Mo=1e9+7;

void inc(int &x,int y) {
	x+=y;
	x-=(x>=Mo)?Mo:0; 
}

int n,m,f[N][N];

int Dp(int n,int m) {
	fo(i,0,m) fo(j,0,n) f[i][j]=0;
	fo(i,0,n) f[0][i]=1;
	fo(i,0,m-1)
		fo(j,0,n)
			if (f[i][j]) {	
				if (j>0) inc(f[i+1][j-1],f[i][j]);
				if (j>0) inc(f[i+1][j],f[i][j]);
				if (j<n) inc(f[i+1][j],f[i][j]);
				if (j<n) inc(f[i+1][j+1],f[i][j]); 	
			}
	int ans=0;
	fo(i,0,n) inc(ans,f[m][i]);
	return ans;
}

int main() {
	scanf("%d%d",&n,&m);
	printf("%d\n",(Dp(n,m)-Dp(n-1,m)+Mo)%Mo);
	return 0;
}

Measured memory_bytes: 35456
/*
      author : nishi5451
      created: 12.08.2020 14:34:19
*/

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


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

Measured memory_bytes: 3604
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

pair<ll, ll> dfs(int cur, int parent, vector<bool> &visited, const vector<vi> &g) {
  if (visited[cur])
    return {0LL, 0LL};
  visited[cur] = true;
  pair<ll, ll> ans = {1LL, 0LL};
  if (cur < 1e5)
    ans.second++;
  for (const auto e : g[cur]) {
    if (e == parent)
      continue;
    auto tmp = dfs(e, cur, visited, g);
    ans.first += tmp.first;
    ans.second += tmp.second;
  }
  return ans;
}

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

  int n;
  cin >> n;
  vector<vector<int>> g(2e5);
  REP(i, n) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(1e5 + y);
    g[1e5 + y].push_back(x);
  }

  vector<bool> visited(2e5, false);

  ll ans = 0;

  REP(i, 1e5) {
    auto tmp = dfs(i, -1, visited, g);
    if (tmp.first > 1) {
      ans += tmp.second * (tmp.first - tmp.second);
    }
  }
  ans -= n;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12928
#include <iostream>

using namespace std;

using ll = long long;

ll solve(ll n, ll a, ll b) {
  if (a > b) {
    return 0;
  }

  if (b > a && n <= 1) {
    return 0;
  }

  if (b == a) {
    return 1;
  }

  return (b*(n-1)+a) - (b+a*(n-1)) + 1;
}

int main() {
  ll n, a, b; cin >> n >> a >> b;
  
  cout << solve(n, a, b) << endl;
  
  return 0;
}


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

using namespace std;

int main(){
    string a,b,c;
    cin>>a>>b>>c;
    if(a[(int)a.length()-1] == b[0] && b[(int)b.length()-1] == c[0]) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


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

using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

bool f(int x){
  int keta = 0;
  while(x){
    keta++;
    x /= 10;
  }
  return keta%2==1;
}

int main(){
  int n,count = 0;
  cin >> n;
  rep(i,n){
    if(f(i))count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256