akhauriyash/Code-Regression huggingface dataset:
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;
double PI = acos(-1);
int main()
{
    int r;
    scanf("%d", &r);
    printf("%.10f\n", 2 * PI * r);
    return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
  
using namespace std;
  
int N;
  
int solve(string &s,string &t){
    queue<string> Q;
    map<string,int> dist;
    Q.push(s);
    dist[s] = 0;
    while(!Q.empty()){
	string v = Q.front(); Q.pop();
	if(v == t) return dist[v];
	int i;
	for(i = 0 ; i < N ; i++){
	    if(v[i] != t[i]) break;
	}
	string next = v;
	int diff = (t[i]-v[i]+10)%10;
	for(int j = i ; j < N ; j++){
	    next[j] = ((next[j]-'0' + diff) % 10) + '0';
	    if(dist.find(next) == dist.end()){
		dist[next] = dist[v] + 1;
		Q.push(next);
	    }
	}
    }
}
  
int main(){
    string s,t;
    while(cin >> N, N){
	cin >> s >> t;
	cout << solve(s,t) << endl;
    }
    return 0;
}

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

using namespace std;

void No() {
    cout << "No\n";
    exit(0);
}

int main() {
	ios_base::sync_with_stdio(0);
	int n, m, q;
    cin >> n >> m >> q;
    vector<int> qs(q, 0);
    for (int i = 0; i < q; ++i) {
        cin >> qs[i];
        qs[i]--;
    }

    reverse(qs.begin(), qs.end());
    vector<int> used(m, 0), seq;
    for (int i = 0; i < q; ++i)
        if (!used[qs[i]]) {
            seq.push_back(qs[i]);
            used[qs[i]] = 1;
        }

    for (int i = 0; i < m; ++i)
        if (!used[i])
            seq.push_back(i);
    vector<int> myNum(m, -1);
    for (int i = 0; i < m; ++i) {
        myNum[seq[i]] = i;
    //    cerr << seq[i] << ' ';
    }
    //cerr << "\n";

    int ind = m-1;
    while (ind > 0 && seq[ind] > seq[ind-1])
        --ind;
    vector<int> kol(m+1, 0);
    kol[0] = n;
    bool weCan = false;
    for (int i = 0; i < q; ++i) {
        int v = qs[i];
        int pos = myNum[v] + 1;
        if (pos > ind) {
            if (!weCan && kol[pos-1] == kol[pos])
                No();
            weCan = true;
            kol[pos] += 1;
        }
        else {
            kol[pos] = min(kol[pos-1], kol[pos] + 1);
        }
    }

    //cerr << ind << ' ' << kol[ind] << "\n";
    if (kol[ind] < n)
        No();
    cout << "Yes\n"; 
	return 0;
}

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

using int64 = long long;

int main() {
  int64 n, a;
  cin >> n >> a;
  vector<int64> xs(n);
  for (int64& x : xs)
    cin >> x;

  static constexpr int64 kBase = 2510;
  vector<int64> more(kBase, 0);
  vector<int64> less(kBase, 0);
  more[0] = 1;
  less[0] = 1;
  int64 even = 0;
  for (int64 x : xs) {
    if (x < a) {
      int64 d = a - x;
      for (int64 i = less.size() - d - 1; i >= 0; --i) {
        less[i + d] += less[i];
      }
    } else if (x > a) {
      int64 d = x - a;
      for (int64 i = more.size() - d - 1; i >= 0; --i) {
        more[i + d] += more[i];
      }
    } else {
      ++even;
    }
  }

  int64 ret = 0;
  for (int64 i = 1; i < kBase; ++i) {
    ret += more[i] * less[i];
  }
  ret <<= even;
  ret += (1LL << even) - 1;
  cout << ret << "\n";

  return 0;
}


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

int ctoi(char c){
  return c - '0';
}

int main(){
  string S;
  cin >> S;
  int ans = 10000;
  for(int i = 0; i < S.size()-2; i++){
    int a = ctoi(S[i])*100 + ctoi(S[i+1])*10 + ctoi(S[i+2]);
    int b = abs(753 - a);
    ans = min(ans, b);
  }
  cout << ans << endl;
  return 0;
}


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

int main(void){
    long N = 0;
    long A = 0;
    long B = 0;
    long count = 0;
    long itr_n = 0;

    cin >> N >> A >> B;

    //A+Bで割った余りが1～A以内なら、青いボールとしてカウント
    //Nになるまで繰り返す:繰り返す回数はN/(A+B)
    itr_n = N/(A+B);
    
    //繰り返す回数分×A個の青ボールは確定
    count = itr_n * A;

    //最後の残り分
    if( (N - itr_n*(A+B)) >= A)
    {
        //青ボール全部
        count = count + A;
    }
    else
    {
        //オーバー分
        count = count + (N - itr_n*(A+B));
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			if (a != 1 && b != 1) {
				System.out.println(1);
			} else if (a != 2 && b != 2) {
				System.out.println(2);
			} else {
				System.out.println(3);
			}
		}
	}
}


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

int main() {
  int k;
  cin >> k;
  
  int x = 7 % k;
  
  int i = 1;
  
  for(int i = 1 ; i <= k ; ++i){
    if(x==0){
      cout << i << endl;
      return 0;
    }
    
    x = (x*10+7)%k;
  }
  
  cout << -1 << endl;
  
  return 0;
  
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W, D;
int A[333][333];
int px[111111], py[111111];
int a[111111];

int main() {
   cin >> H >> W >> D;
   rep (i, H) {
      rep (j, W) {
         int A;
         cin >> A;
         px[A] = j, py[A] = i;
      }
   }

   for (int i = D+1; i <= H*W; i++) {
      a[i] = a[i-D] + abs(px[i] - px[i-D]) + abs(py[i] - py[i-D]);
   }

   int Q;
   cin >> Q;
   while (Q--) {
      int l, r;
      cin >> l >> r;
      cout << a[r] - a[l] << endl;
   }

   return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <queue>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;
typedef unsigned long long int ll;
#define INFI LLONG_MAX
int main(){
	ll t=1;
	//cin>>t; 

	while(t--){
ll h;
cin>>h;
ll n=log2(h);
ll ans=1;
for(int i=0;i<n;i++)
ans=ans*2+1;
cout<<ans;
}
	
}







   
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    for(int i = 1; i <= 10000; i++){
        double ans1 = i * 0.08;
        double ans2 = i * 0.1;
        int ans3 = ans1;
        int ans4 = ans2;
        if(ans3 == A && ans4 == B){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

int main() {
    int n, k;
    string s, ans;

    cin >> n >> k;
    cin >> s;

    ans = s;
    f(i, n) {
        if(i == (k - 1)) {
            ans.at(i) = s.at(i) + 32;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;

void solve() {
	int a, b; cin >> a >> b;
	cout << a * b << '\n';
}

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


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

namespace B___Resale
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            var N = int.Parse(read);

            var values = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var costs = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            int benefit = 0;

            for(int i = 0 ; i < N ; i++)
            {
                if(values[i] > costs[i])
                {
                    benefit += values[i] - costs[i];
                }
            }
            Console.WriteLine(benefit);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;


ll euclid(ll a, ll b, ll &x, ll &y){
    if(b) {
        ll d = euclid(b, a%b, y, x);
        y -= a/b * x;
        return d;
    }
    else {
        x = 1, y = 0;
        return a;
    }
}

ll crt_(ll a, ll m, ll b, ll n){
    ll x,y;
    euclid(m,n,x,y);
    ll ret = a * (y+m) % m * n + b * (x+n) % n * m;
    if(ret >= m*n) ret -= m*n;
    return ret;
}
ll crt(ll a, ll m, ll b, ll n){
    ll d = __gcd(m,n);
    if(((b-=a) %= n) < 0) b += n;
    if(b%d) return -1;
    return d * crt_(0,m/d,b/d,n/d) + a;
}

ll phi(ll n){
    ll res = 1;
    for(ll a = 2; a*a <= n; ++a){
        if(n % a == 0){
            n/=a;
            ll p = 1;
            while(n % a == 0) n/=a, p*=a;
            res *= p*(a-1);
        }
    }
    if(n>1) res *= n-1;
    return res;
}

ll modpow(ll x, ll n, ll m){
    ll res = 1;
    while(n){
        if(n&1) res = (res*x) % m;
        x = (x*x) % m;
        n/=2;
    }
    return res;
}

ll f(ll a, ll m){
    ll n = phi(m);
    ll d = __gcd(n,m);
    //cerr<<" "<<a<<" "<<m<<" "<<n<<" "<<d<<endl;
    if(d == 1) return crt(1,n, a,m);
    ll y = f(a,d);
    ll ay = modpow(a,y,m);
    //cerr<<" "<<a<<" "<<m<<" "<<n<<" "<<d<<" "<<y<<" "<<ay<<endl;
    return crt(y,n, ay,m);
}

void solve(){
    ll a,m;
    cin>>a>>m;
    ll t = f(a,m);
    if(t == 0) {
        t = phi(m)*m/__gcd(phi(m),m);
        cerr<<"tada"<<endl;
    }
    //cout<<modpow(a,t,m)<<" "<<(t%m)<<endl;
    cout<<t<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int q;
    cin>>q;
    rep(_,0,q) solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String a = "";
		Main r = new Main();
		while(sc.hasNext()){
			a = sc.nextLine();
			int x=a.length()-1;
			int sum = 0;
			char ch='I';
			ch = a.charAt(a.length()-1);
			sum += r.get(ch);
			for(int i=a.length()-2;i>=0;i--){
				if(r.get(ch)<=r.get(a.charAt(i))){
					ch = a.charAt(i);
					sum+=r.get(ch);
				}
				else
					sum-=r.get(a.charAt(i));
			}
			System.out.println(sum);
			sum = 0;
		}
	}
	
	public int get(char ch){
		int x = 0;
		if(ch=='I')
			x = 1;
		else if(ch=='V')
			x = 5;
		else if(ch=='X')
			x = 10;
		else if(ch=='L')
			x = 50;
		else if(ch=='C')
			x = 100;
		else if(ch=='D')
			x = 500;
		else if(ch=='M')
			x = 1000;
		return x;
	}
}

Measured memory_bytes: 11000
N = int(input())

prime = [2]
for i in range(3, 55556):
    flag = 1
    for j in prime:
        if i % j == 0:
            flag = 0
            break
    if flag == 1:
        prime.append(i)

ans = []
for i in prime:
    if i % 5 == 1:
        ans.append(i)
print(" ".join(map(str, ans[:N])))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int MAX = 1e6;

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

int main()
{
	vector<bool> prime(MAX + 1, true); prime[0] = prime[1] = false;
	for (int i = 2; i * i <= MAX; i++) {
		if (prime[i]) {
			for (int j = i * 2; j <= MAX; j += i) {
				prime[j] = false;
			}
		}
	}
	int m, n;
	while (cin >> m >> n, m | n) {
		vector<P> pos(m + 1);
		map<P, int> mp;
		P tmp(0, 0);
		for (int i = 1, j = 1, d = 0, k = 1, c = 0; i <= m; i++) {
			pos[i] = tmp;
			mp[tmp] = i;
			tmp.first += dx[d];
			tmp.second += dy[d];
			if (k == j) {
				k = 1;
				j = c ? j + 1 : j;
				c = 1 - c;
				d = d == 3 ? 0 : d + 1;
			}
			else {
				k++;
			}
		}
		map<P, int> val; val[pos[n]] = prime[n];
		set<P> q; q.insert(pos[n]);
		for (; !q.empty(); ) {
			auto t = q; q.clear();
			for (auto v : t) {
				for (int x = -1; x <= 1; x++) {
					P to(v.first + x, v.second - 1);
					int num = mp[to];
					if (num) {
						q.insert(to);
						val[to] = max(val[to], val[v] + (prime[num] ? 1 : 0));
					}
				}
			}
		}
		int ma = 0, id = 0;
		for (auto p : val) {
			if (!prime[mp[p.first]]) continue;
			if (p.second > ma) {
				ma = p.second;
				id = mp[p.first];
			}
			else if (p.second == ma && mp[p.first] > id) {
				id = mp[p.first];
			}
		}
		cout << ma << ' ' << (ma ? id : 0) << endl;
	}
	return 0;
}

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

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

	bool ans = false;

	for (int i = 0; i <= N / 4; i++){
		for (int j = 0; j <= N / 7; j++){
			if ((i * 4 + j * 7) == N){
				ans = true;
				break;
			}
		}
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {

        int N;
        int[] Ai;
        Set<Integer> searched = new HashSet<>();
        Queue<Integer> queue = new LinkedList<>();
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Ai = new int[N];
            for (int i = 0; i < N; i++) {
                Ai[i] = sc.nextInt();
            }
        }
        queue.add(0);
        searched.add(0);

        while (!queue.isEmpty()) {
            Integer i = queue.poll();
            if (i == 1) {
                System.out.println(searched.size() - 1);
                return;
            }
            Integer t = Ai[i] - 1;
            if (!searched.contains(t)) {
                queue.add(t);
                searched.add(t);
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 56348
class Node
    attr_accessor :parent, :left, :right

    def initialize(parent, left, right)
        @parent = parent
        @left   = left
        @right  = right
    end
end

def sibling(key, nodes)
    p = nodes[key].parent
    if p != -1
        if nodes[p].left == key
            nodes[p].right
        else
            nodes[p].left
        end
    else
        -1
    end
end

def degree(key, nodes)
    if nodes[key].left != -1 && nodes[key].right != -1
        2
    elsif nodes[key].left != -1 || nodes[key].right != -1
        1
    else
        0
    end
end

def depth(key, nodes)
    depth = 0
    i = key
    while nodes[i].parent != -1
        depth += 1
        i = nodes[i].parent
    end
    depth
end

def height(key, nodes)
    left_h = right_h = 0
    if nodes[key].left != -1
        left_h = 1 + height(nodes[key].left, nodes)
    end

    if nodes[key].right != -1
        right_h = 1 + height(nodes[key].right, nodes)
    end
    left_h > right_h ? left_h : right_h
end

def kind(key, nodes)
    if nodes[key].parent == -1
        "root"
    elsif nodes[key].left == -1 && nodes[key].right == -1
        "leaf"
    else
        "internal node"
    end
end

nodes = {}
n = gets.chomp.to_i
n.times{
    k, l, r = gets.chomp.split.map(&:to_i)
    if nodes[k] != nil
        nodes[k].left = l
        nodes[k].right = r
    else
        nodes[k] = Node.new(-1, l, r)
    end

    #-- left格納
    if l != -1 && nodes[l] != nil
        nodes[l].parent = k
    elsif l != -1
        nodes[l] = Node.new(k, -1 , -1)
    end

    #-- right格納
    if r != -1 && nodes[r] != nil
        nodes[r].parent = k
    elsif r != -1
        nodes[r] = Node.new(k, -1, -1)
    end
}

[*0...n].each do |i|
    print "node #{i}: parent = #{nodes[i].parent}"
    print ", sibling = #{sibling(i, nodes)}"
    print ", degree = #{degree(i, nodes)}"
    print ", depth = #{depth(i, nodes)}"
    print ", height = #{height(i, nodes)}"
    puts  ", #{kind(i, nodes)}"
end


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


int main(void) {
  int N, M;
  ll K;
  cin >> N >> M >> K;
  vector<ll> A(N);
  vector<ll> B(M);
  rep(i, N) {
    cin >> A[i];
  }
  rep(i, M) {
    cin >> B[i];
  }
  int ans = 0;

  ll time = 0;
  rep(i, M) {
    time += B[i];
  }

  int j = M;
  for (int i = 0; i < N + 1; ++i) {
    while (j > 0 && time > K) {
      j--;
      time -= B[j];
    }
    if (time > K) break;
    ans = max(ans, i + j);
    if (i == N)  break;
    time += A[i];
  }


  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int arr[200010][2];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  int a, b;
  fi(0, m) {
    cin >> a >> b;
    if(min(a, b) == 1) {
      arr[max(a, b)][0] = 1;
    }
    else if(max(a, b) == n) {
      arr[min(a, b)][1] = 1;
    }
  }
  fi(2, n) {
    if(arr[i][0] && arr[i][1]) {
      cout << "POSSIBLE\n";
      return 0;
    }
  }
  cout << "IMPOSSIBLE\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int m,int n) {//2のn乗
	if (n == 0)return 0;
	llint x = Tow(m,n / 2);
	x *= x;
	if (n % 2 == 1)x *= m;
	return x;
}
ll max(ll a, ll b) {
	if (a < b)return b;
	else return a;
}

int main() {
	int c[3][3];
	rep(i, 0, 3)rep(j, 0, 3)cin >> c[i][j];
	int A[2];
	int B[2];
	rep(i, 0, 2) {
		A[i] = c[i + 1][0] - c[i][0];
		B[i] = c[0][i + 1] - c[0][i];
	}
	bool a = true;
	if (c[1][1] != A[0] + B[0] + c[0][0])a = false;
	if (c[2][2] != c[1][1] + A[1] + B[1])a = false;
	if (c[1][1] + A[1] != c[2][1] || c[1][1] + B[1] != c[1][2])a = false;
	Yes(a)

	return 0;
}

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n, m; cin >> n >> m;
    Graph G(n, vector<int>());

    REP(i, m) {
        int a, b; cin >> a >> b;
        a--, b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }

    VI np;
    REP(i, n) np.push_back(i);

    sort(np.begin(), np.end());

    int ans = 0;

    do {
        bool flag = true;
        if (np.at(0) != 0) continue;
        REP(i, n-1) {
            int from = np.at(i);
            int to = np.at(i + 1);
            if (find(G.at(from).begin(), G.at(from).end(), to) == G.at(from).end()){
                flag = false;
                break;
            }
        }
        if (flag) ans++;

    }while(next_permutation(np.begin(), np.end()));

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int N, M;

    std::cin >> N >> M;

    vector<int> v = fetch_vec<int>(N);

    double sum = accumulate(v.begin(), v.end(), 0.0);

    int valid = 0;
    for (int i = 0; i < N; ++i) {
        if (static_cast<double>(v[i]) >= sum / (4.0 * M))
            ++valid;
    }

    if (valid >= M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

int main()
{
//    std::cout << solve() << std::endl;
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <string>
    using namespace std;
     
    int main() {
     
    string S;
    cin >> S;
    int a_index = -1,  z_index = -1, S_length = S.length(), max_length = 0;
     
    for (int i = 0; i < S_length; i++) {
     
    if ( S[i] == 'A' && a_index == -1) a_index = i;
    if ( S[S_length - i - 1] == 'Z' && z_index == -1 ) z_index = S_length - i - 1;
     
    if ( a_index != -1 && z_index != -1) break;
    }
     cout << z_index - a_index + 1;
     
    return 0;
    }

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>

using namespace std;
const long int MAX_N = 200;
const long int MAX_A = 1000000000;

int main(int argc, char const *argv[]) {
  long int A[MAX_N];
  long int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];

  int count = 0;

  while (true) {
    int numodd = 0;
    for (int i = 0; i < n; i++) {
      if (A[i]%2 == 1) numodd++;
    }
    if (numodd == 0) {
      for (int i = 0; i < n; i++) A[i] /= 2;
      count++;
    }
    else break;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd

N, K, *X = map(int, open(0).read().split())

d = reduce(gcd, X)
for i in range(N):
    if X[i] < K:
        continue
        
    if (X[i] - K) % d == 0:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 95524
#include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int> ans;

void bfs(vector<int> *edges,int s,int n,int x[],int total)
{
    bool v[n]={0};
    queue<int>q; q.push(s); v[s]=1; x[s]=0;
    while(!q.empty())
    {
        int z=q.front(); q.pop(); int y=1;
        for(int i=0; i<edges[z].size(); i++)
        {
            if(!v[edges[z][i]])
            {
                v[edges[z][i]]=1;
                q.push(edges[z][i]);
                if(x[z]==y) y++;
                x[edges[z][i]]=ans[make_pair(z,edges[z][i])]=ans[make_pair(edges[z][i],z)]=y;
                y++;
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;
    vector<int> edges[n]; int x[n]={0},total=0;
    pair<int,int> v[n-1];
    for(int i=0; i<n-1; i++)
    {
        int a,b;
        cin>>a>>b; a--; b--;
        x[a]++; x[b]++; total=max(total,max(x[a],x[b]));
        edges[a].push_back(b);
        edges[b].push_back(a);
        v[i].first=a; v[i].second=b;
    }
    int color[n]={0};
    bfs(edges,0,n,color,total);
    cout<<total<<endl;
    for(int i=0; i<n-1; i++)
        cout<<ans[v[i]]<<endl;
    return 0;
}


Measured memory_bytes: 20224
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	string S;
    cin >> S;
    string ans = "Yes";
    rep(i,S.size()){
        if(i%2 == 0){
            if(S[i] != 'h') ans = "No";
        }else{
            if(S[i] != 'i') ans = "No";
        }
    }
    if(S.size()%2==1)ans = "No";
    cout << ans << endl;
    return 0;
}


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

typedef long long int          ll;
typedef set<int>               si;
typedef pair<int,int>          pii;
typedef pair<ll,ll>            pll;
typedef vector<int>            vi;
typedef vector<ll>             vll;
typedef vector<vll>            vvl;
typedef map<int,int>           mi;
typedef map<ll,ll>             mll; 

/*.................................................................................................................................*/

#define mod                    1000000007
#define nl                     "\n";
#define ff                     first 
#define ss                     second
#define mp                     make_pair
#define pb                     push_back
#define sz(a)                  (int)a.size()
#define fi(a,b)                for(ll i=a;i<b;i++)
#define fj(a,b)                for(ll j=a;j<b;j++)
#define fri(a,b)               for(ll i=a;i>=b;i--)
#define frj(a,b)               for(ll j=a;j>=b;j--)
#define all(v)                 (v).begin(),(v).end()
#define mem(v,a)               memset((v),a,sizeof(v))
#define show(v)                for(auto i:v)cout<<i<<" ";cout<<nl; 
#define fast                   ios_base::sync_with_stdio(false);cin.tie(NULL);

/*.................................................................................................................................*/

inline ll add(ll a, ll b)      {a += b ;return a >= mod ? a - mod : a ;}
inline ll sub(ll a, ll b)      {a -= b ;return a < 0 ? a + mod : a ;}
inline ll mul(ll a, ll b)      {return (ll)a * b % mod ;}
inline ll power(ll a,ll n)     {ll res=1;while(n){if(n&1){res=mul(res,a);} n>>=1,a=mul(a,a);}return res;}
inline ll sum(ll n)            {ll sum=n;if(sum%2==0){sum=sum>>1;sum*=(n+1);}else sum*=((n+1)/2);return sum;}

/*.....................................................CODE_STARTS.................................................................*/
int prime[1000005];
void solve(){
	int n;cin>>n;
	if(n%1000==0)cout<<0;
	else
	cout<<1000-(n%1000);
}
int main(){
    fast
    int t=1;
    //cin>>t;
    while(t--){
       solve();if(t!=0)cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,k;
  cin >> n >> k;
  
  cout << max(0LL,n-k+1) << endl;

  return 0;
}

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

using namespace std;

int main(void){

	string roman;
	string fig("IVXLCDM");
	int ure[]={1,5,10,50,100,500,1000};
	int sum;
	while(cin>>roman){
		sum=0;
		for(int i=1;i<roman.length();i++){
			if(ure[fig.find(roman[i])]>ure[fig.find(roman[i-1])]) sum+=-1*ure[fig.find(roman[i-1])];
			else sum+=ure[fig.find(roman[i-1])];
		}
		sum+=ure[fig.find(roman[roman.length()-1])];
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 1188
program main
implicit none
integer :: i, j, c
integer :: a, b, k

read(*,*) a, b, k

j = k/2
do i = 1, j
   if( mod(a,2) == 1 ) then
      a = a-1
    end if
    c = a/2
    a = a-c
    b = b+c
    if( mod(b,2) == 1 ) then
       b = b-1
    end if
    c = b/2
    a = a+c
    b = b-c
end do
if( mod(k,2) == 1 ) then
   if( mod(a,2) == 1 ) then
      a = a-1
    end if
    c = a/2
    a = a-c
    b = b+c
end if
write(*,'(i0,a1,i0)') a,' ',b
end program main


Measured memory_bytes: 256
from sys import stdin

def bubble_sort(A, N):
    flg = 1
    count = 0
    while flg:
        flg = 0
        for i in range(N-1,0,-1):
            if A[i] < A[i-1]:
                A[i], A[i-1] = A[i-1], A[i]
                flg = 1
                count += 1
    return count
                
    
def main():
    read = stdin.readline
    N = int(read())
    data = list(map(int, read().split(" ")))
    count = bubble_sort(data, N)
    for i in range(N-1):
        print(data[i], end = " ")
    print(data[N-1])
    print(count)
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 5608
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b || b <= c && c <= a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    int n;
    SCD(n);
    vector<double> dp(n + 1);//probability that there was i heads so far
    dp[0] = 1;
    for (int i = 0; i < n; i++) {
    	double head;
    	SCLF(head);
    	for (int j = i + 1; j >= 0; j--) { 
    		dp[j] = ((j == 0)? 0 : 1.0 *dp[j - 1] * head) + 1.0 * dp[j] * (1 - head); 
    	}
    }
    double ans = 0;
    for (int i = 0; i <= n; i++) {
        int tail = n - i;
        if (i > tail) {
            ans += dp[i];        
        }
    } 
    printf("%.10lf\n", ans);
    return 0;
}



Measured memory_bytes: 256
//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip> 
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , b[N] , d[N] , p[N] , ans = 1 , g = 0;
int gcd(int x,int y){
    if(x>y) swap(x,y);
    if(x==0) return y;
    return gcd(y%x , x);
}
int main(){
fcin;
  cin >> n;
  vector<int> a(n);
  vector<int> c(N);
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
    g=gcd(a[i],g);
    c[a[i]]++;
  }
 
  bool pairwise = true;
  for (int i = 2; i < N; i++) {
    int cnt = 0;
    for (int j = i; j < N; j += i) {
      cnt += c[j];
    }
    if (cnt > 1) pairwise = false;
  }
    if(pairwise) {
        cout << "pairwise coprime\n";
        return 0;
    }
    else if(g==1) {
        cout << "setwise coprime\n";
        return 0;
    }
    cout << "not coprime\n";


}

Measured memory_bytes: 18756
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> xs(N);
  vector<ll> ys(N);
  for (auto i = 0; i < N; i++) {
    cin >> xs[i];
    ys[i] = xs[i];
  }
  sort(xs.begin(), xs.end());

  ll half = xs.size() / 2;
  for (auto i = 0; i < N; i++) {
    ll res;
    if (ys[i] >= xs[half]) res = xs[half - 1];
    else res = xs[half];
    cout << res << endl;
  }

  return 0;
}


Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a > b) {
            System.out.println("a > b");
        } else if (a < b) {
            System.out.println("a < b");
        } else if (a == b) {
            System.out.println("a == b");
        }
    }
}



Measured memory_bytes: 26404
#include <iostream>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;

  rep(i, 0, n) cout << s[i] << t[i];
  cout << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n; cin >> n;
  int res = 1;
  for(int i = 1;i*i <= n;++i) {
    res = i*i;
  }
  cout << res << "\n";
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	const ll MOD = 1e9 + 7;
	int N;
	cin >> N;
	string s;
	cin >> s;

	map<char, ll> mp;
	for (int i = 0; i < N; ++i) {
		mp[s[i]] += 1;
	}

	ll res = 1;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		res = (res * (it->second + 1)) % MOD;
	}

	cout << (res - 1 + MOD) % MOD << endl;

	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    vector<int> S(N, -1);
    rep(i, N) {
        int left = -1;
        int right = N;
        while (right - left > 1) {
            int mid = (right + left) / 2;
            if (S[mid] < A[i]) right = mid;
            else left = mid;
        }
        S[right] = A[i];
    }
    rep(i, N) {
        if (S[i] == -1) {
            cout << i << endl;
            return 0;
        }
    }
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> l(n);
  vector<int> r(n);
  for(int i=0;i<n;i++)
    cin>>l.at(i)>>r.at(i);
  int c=0;
  for(int x=1;x<=100000;x++){
    for(int i=0;i<n;i++){
      if(l.at(i)<=x&&x<=r.at(i)){
        c++;
        break;
      }
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
import sys
from collections import defaultdict
input = sys.stdin.readline
N= int(input())
AB = [list(map(int,input().split())) for i in range(N)]

def gcd(a,b):
    while a:
        b,a = a, b%a
    return b

ans = 0

PAB = []
for a,b in AB:
    d = gcd(a,b)
    if d == 0:
        PAB.append((0,0))
        continue
    PAB.append((a//d,b//d)) # a//d >= 0
    
dic1 = defaultdict(int)
dic4 = defaultdict(int)

yaxis = 0
xaxis = 0
origin = 0
vs = []
for a,b in PAB:
    if a == 0 and b == 0:
        origin += 1
        continue
    if a == 0:
        yaxis += 1
        continue
    if b == 0:
        xaxis += 1
        continue
    if b > 0:
        dic1[(a,b)] += 1
        vs.append((a,b))
    else:
        dic4[(-b,a)] += 1
        vs.append((-b,a))

vs = list(set(vs))

ans = 1
for v in vs:
    n1 = dic1[v]
    n4 = dic4[v]
    ans *= (pow(2,n1,MOD) + pow(2,n4,MOD) - 1)
    ans %= MOD

ans *= (pow(2,xaxis,MOD)+pow(2,yaxis,MOD)-1)
ans -= 1 # no fish
ans += origin
print(ans % MOD)





Measured memory_bytes: 202908
k = int(input())
a, b = (int(x) for x in input().split())
i = 0
for i in range(k+1):
  if (a+i)%k == 0:
    print('OK')
    break
  elif a+i == b:
    print('NG')
    break
  elif i == k:
    print('NG')

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

using namespace std;

void MakeData(int, int, bool, vector<int>, vector<int>&);
void NextData(vector<int>, vector<int>&);

int main(){
  int i, n;
  vector<int> coin, data;

  for(i=1; i<=17; ++i) coin.push_back(i*i);

  while(1){
    cin >> n;
    if(n == 0) break;
    MakeData(n, n, true, coin, data);

    for(i=1; data[0]!=1; ++i) NextData(coin, data);
    cout << i << endl;
    data.clear();
  }
  return 0;
}

void MakeData(int n, int m, bool is_upper,
	      vector<int> coin, vector<int>& data){
  vector<int>::iterator i;
  if(is_upper) i = upper_bound(coin.begin(), coin.end(), m);
  else i = lower_bound(coin.begin(), coin.end(), m);
  --i;
  while(1){
    if(n >= *i){
      data.push_back(*i);
      n -= *i;
      if(n == 0) return;
    }else{
      --i;
    }
  }
}

void NextData(vector<int> coin, vector<int>& data){
  int n, sum;
  vector<int>::iterator i, j;
  i = find(data.begin(), data.end(), 1);
  n = *(i-1);
  if(i == data.end()){
    data.pop_back();
    MakeData(n, n, false, coin, data);
  }else{
    for(j=i-1, sum=0; j!=data.end(); ++j) sum += *j;
    data.erase(i-1, data.end());
    MakeData(sum, n, false, coin, data);
  }
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<string.h>
#define N 510
#define NN N*N

int n;
int x[N];
int ans[NN];
int queue[NN];
int qfront, qback;

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d", x+i);
  memset(ans, -1, sizeof(ans));
  for(int i = 0; i < n; i++) ans[x[i]-1] = i+1+1000;
  int now = 0;
  for(int i = 0; i < n*n; i++) {
    if(ans[i] != -1) {
      int u = ans[i]-1000;
      int cnt = 1;
      while(cnt < u) {
        if(ans[now] != -1) now++;
        else {ans[now++] = u; cnt++;}
      }
      if(now > i) {
        printf("No\n");
        return 0;
      }
    }
  }
  for(int i = 0; i < n*n; i++) {
    if(ans[i] == -1) {
      if(qfront == qback) {
        printf("No\n");
        return 0;
      }
      ans[i] = queue[qfront++];
    }
    if(ans[i] > 1000) {
      ans[i] -= 1000;
      for(int j = 0; j < n-ans[i]; j++) queue[qback++] = ans[i];
    }
  }

  printf("Yes\n");
  for(int i = 0; i < n*n; i++) {
    if(i) printf(" ");
    printf("%d", ans[i]);
  }
  printf("\n");
}

Measured memory_bytes: 3620
n = gets.to_i

digit = n.to_s.length

a = digit.odd? ? (10 ** ((digit - 1))..n).size : 0

b = 0

(digit - 1).downto(0) do |i|
  b += 10 ** (i - 1) * 9 if i.odd?
end

puts a + b

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int hand[6] = {};
	while (~scanf("%d", &hand[0])){
		for (int i = 1; i < 5; i++){
			scanf(",%d", &hand[i]);
		}

		int cnt = 0, flag = true, card[13] = {}, max = 4;
		sort(hand, hand + 5);
		/*for (int i = 0; i < 5; i++){
			printf("%d ", hand[i]);
		}
		puts("");*/
		for (int i = 0; i < 4; i++){
			for (int j = i + 1; j < 5; j++){
				if (hand[i] == hand[j]){
					cnt++;
				}
			}
		}
		//printf("%d\n", cnt);
		int i = 0;
		if (hand[i] == 1 && hand[i + 1] == 10){
			//printf("!!!!!!!\n");
			i = 1;
			max = 5;
			hand[5] = 14;
		}
		for (; i < max; i++){
			if (hand[i] + 1 != hand[i + 1]){
				flag = false;
			}
		}
		if (cnt == 6){
			printf("four card\n");
		}
		else if (cnt == 4){
			printf("full house\n");
		}
		else if (flag){
			printf("straight\n");
		}
		else if (cnt == 3){
			printf("three card\n");
		}
		else if (cnt == 2){
			printf("two pair\n");
		}
		else if (cnt == 1){
			printf("one pair\n");
		}
		else{
			printf("null\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1184