akhauriyash/Code-Regression huggingface dataset:
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
fn main() {
    let n = get!(i32);

    println!("{}", if n%2 == 1 {n*2} else {n});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    string s,t;
    cin>>s>>t;
    ll ans=0;
    rep(0,i,(ll)s.size())if(s[i]!=t[i])++ans;
    cout<<ans;
}


Measured memory_bytes: 3916
#include<iostream>
#include<cmath>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int Dice(int n[6],string str){
  int east;
  int west;
  int sou;
  int nor;
  int g;
  g = 1;
  int t = 0;
  sou = 2;
  east = 3;
  west = 4;
  nor = 5;

  for(int i = 0;i < str.length(); i++){
    if(str[i] == 'E'){
      east = g;
      g = west;
      west = 7-east;
    }else if(str[i] == 'W'){
      west = g;
      g = east;
      east = 7-west;
    }else if(str[i] == 'N'){
      nor = g;
      g = sou;
      sou = 7-nor;
    }else{
      sou = g;
      g = nor;
      nor = 7-sou;
    }
  //cout << g << endl;
  //cout << nor << " " << sou <<" " << east <<" " << west << endl;
  }
  return n[g-1];
}

int main(void){
  int k[6];
  for(int i = 0;i < 6;i++){
    cin >> k[i];
  }
  string s;
  cin >> s;
  cout << Dice(k,s) << endl;
}
      

Measured memory_bytes: 3192
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define MOD 1000000007;

int main(){
  ll n,ans=0;cin>>n;
  vll p(n),basyo(n+1);
  rep(i,0,n){cin>>p[i];p[i]--;basyo[p[i]]=i;}
  set<ll> s;
  for(int i=n-1;i>=0;i--){
    int idx=basyo[i];
    ll c=0;vll l(2,-1),r(2,n);
    s.insert(idx);
    auto it=s.find(idx);
    rep(j,0,2){
      if(it==s.begin()){break;}
      it--;
      l[j]=*it;
    }
    it=s.find(idx);
    rep(j,0,2){
      it++;
      if(it==s.end()){break;}
      r[j]=*it;
    }
    ll l1=idx-l[0],l2=l[0]-l[1],r1=r[1]-r[0],r2=r[0]-idx;
    c=l1*r1+l2*r2;
    ans+=c*(i+1);
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 6528
from collections import Counter
import copy
from itertools import combinations


def A(x):
  return 1000 - x % 1000 if x % 1000 != 0 else 0


def B(n, ss):
  keys_values = Counter(ss)
  orders = ['AC', 'WA', 'TLE', 'RE']
  for order in orders:
    if order in keys_values:
      print("{} x {}".format(order, keys_values[order]))
    else:
      print("{} x {}".format(order, 0))


def _get_num_black(c_list, r_list, h, w, g):
  num_black = 0
  for i in range(h):
    if i in r_list:
      continue
    for j in range(w):
      if j in c_list:
        continue
      num_black += (1 if g[i][j] == '#' else 0)
  return num_black


def C(h, w, k, g):
  num_choice = 0
  for i in range(k + 1):
    for j in range(k - i + 1):
      for c_list in list(combinations(range(w), j)):
        for r_list in list(combinations(range(h), i)):
          if _get_num_black(c_list, r_list, h, w, g) == k:
            num_choice += 1
  return num_choice


def C2(H, W, K, g):
  """All copied."""
  c = []
  for i in range(H):
    c.append([])
    for j in range(W):
      c[i].append(g[i][j])

  ans = 0
  for h in range(H + 1):
    for w in range(W + 1):
      for h2 in combinations(list(range(H)), h):
        for w2 in combinations(list(range(W)), w):
          paint = copy.deepcopy(c)
          for h3 in h2:
            for i in range(W):
              paint[h3][i] = "r"
          for i in range(H):
            for w3 in w2:
              paint[i][w3] = "r"
          count_black = 0
          for i in range(H):
            count_black += paint[i].count("#")
            #print(count_black,paint[i])
          if count_black == K:
            ans += 1

  return ans


def C3(h, w, k, g):
  """
  - Change the calculation of count_black.
  - Change the name of variables.
  - Change the expression of combinations.
  """
  num_choice = 0
  for i in range(h + 1):
    for j in range(w + 1):
      for c_list in list(combinations(range(w), j)):
        for r_list in list(combinations(range(h), i)):
          if _get_num_black(c_list, r_list, h, w, g) == k:
            num_choice += 1
  return num_choice


def main():
  h, w, k = map(int, input().split())
  g = []
  for i in range(h):
    g.append(input())
  print(C3(h, w, k, g))


if __name__ == '__main__':
  main()


Measured memory_bytes: 9628
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll K, A, B;
    scanf("%lld", &K);
    scanf("%lld %lld", &A, &B);

    if (((A / K) + ((A % K == 0) ? 0 : 1)) * K <= B)
        printf("OK");
    else
        printf("NG");
}


Measured memory_bytes: 3752
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	var A int
	homework := 0
	for i := 0; i < M; i++ {
		fmt.Scan(&A)
		homework += A
	}
	res := N - homework
	if res < 0 {
		res = -1
	}

	fmt.Println(res)

}


Measured memory_bytes: 2404
#include<iostream>
#include<string>
using namespace std;
bool isAlpha(char ch){
  return ('a'<=ch&&ch<='z');
}
string change(string str){
  for(int i=0;i<(int)str.size();i++){
    if(isAlpha(str[i])){
      if(str[i]=='z')str[i]='a';
      else str[i]++;
    }
  }
  return str;
}
string st(string str,int x,int y){
  string res="";
  for(int i=x;i<x+y;i++)res.push_back(str[i]);
  return res;
}
int main(){
  string str;
  string a ="abcdefghi";
  int flg;
  while(getline(cin,str)){
    flg=0;
    for(int i=0;i<26;i++){
      str=change(str);
      for(int j=0;j+3<=(int)str.size();j++)
	if(st(str,j,3)=="the")flg=1;
      if(flg)break;
      for(int j=0;j+4<=(int)str.size();j++)
	if(st(str,j,4)=="this")flg=1;
      if(flg)break;
      for(int j=0;j+4<=(int)str.size();j++)
	if(st(str,j,4)=="that")flg=1;
      if(flg)break;
    }
    cout<<str<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); cout << fixed;
 
const int N = 1e5+5;
int a[N];
 
int32_t main()
{
	int x = 0;
	for(int i = 0; i < 3; i++)
	{
		int y;
		cin >> y;
		x += y;
	}
	if(x >= 22)
	{
		cout <<"bust";
	}
	else
	{
		cout <<"win";
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort()
sumcost = 0
k = 0
t = 0
while M-k>0:
    buy = min(M-k, A[t][1])
    sumcost += A[t][0]*buy
    k += buy
    t += 1


print(sumcost)

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

int main() {
	string S; cin >> S;
	int i; string T;
	for(i=S.size()/2-1; i>0; --i){
	    T=S.substr(0, i);
	    T += T;
	    if(T==S.substr(0, i*2)) break;
	}
	cout << 2*i << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a, b, c, d;
int main() {
	while (cin >> a >> b >> c) {
		d = a * 10000 + b * 100 + c;
		if (d < 18680908) {
			cout << "pre-meiji" << endl;
		}
		else if (d < 19120730) {
			cout << "meiji " << a - 1867 << ' ' << b << ' ' << c << endl;
		}
		else if (d < 19261225) {
			cout << "taisho " << a - 1911 << ' ' << b << ' ' << c << endl;
		}
		else if (d < 19890108) {
			cout << "showa " << a - 1925 << ' ' << b << ' ' << c << endl;
		}
		else {
			cout << "heisei " << a - 1988 << ' ' << b << ' ' << c << endl;
		}
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 8000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

using namespace std;


int ans,ans2;
int n,m;

signed main(){

	int a,b,c;
    cin>>a>>b>>c;
    cout<<std::max((int)0,c-(a-b))<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld double
#define ff first
#define ss second
int main(){
	string si; cin>>si;
	vector<int>alp(26,-1);
	int s=-1;
	for(int i=0;i<(int)si.length();++i){
		char ch=si[i];
		if(alp[ch-'a']>-1 and alp[ch-'a']>=i-2){
			cout<<alp[ch-'a']+1<<" "<<i+1<<"\n";
			s=0;
			break;
		}
		alp[ch-'a']=i;
	}
	if(s==-1) cout<<"-1"<<" "<<"-1\n";
	return 0;
}


Measured memory_bytes: 3728
n = int(input())
#a, b = map(int, input().split())
l = list(map(int, input().split()))
#s = input()
ans = 1

if 0 in l:
    print (0)
    exit()

for i in range(n):
    ans = ans * l[i]
    if (ans > 10**18):
        ans = -1
        break

print (ans)


Measured memory_bytes: 21672
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	cin>>n;
	cout<<800*n - (n/15)*200<<endl;

}

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


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


ok_list = []
ng_list = []

for i in num:
    if i % 2 == 1:
        ok_list.append(i)

    elif i % 3 == 0 or i % 5 == 0:
        ok_list.append(i)

    else:
        ng_list.append(i)

if not ng_list:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 9140
#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;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  cout << (s[0]==s[2] ? "Yes" : "No") << endl;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

bool isprime(int x){
	for(int i=2; i*i<=x; i++){
		if (x%i == 0) return false;
	}
	return true;
}
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	int x;
	cin >> x;
	while(!isprime(x)) x++;
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//時間が同じなので，早い順に載せるのが最適解

int main(void){
	ll n,c,k,t[100010],s=0,ans=1;
	cin>>n>>c>>k;
	rep(i,n)cin>>t[i];
	sort(t,t+n);
	rep(i,n){
		if(t[i]>t[s]+k || i-s+1>c){
			ans++;
			s=i;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
'use strict';

function main(stdin) {
  const input = stdin.split(' ').map(v => parseInt(v, 10));
  const W = input[0];
  const H = input[1];
  const x = input[2];
  const y = input[3];

  let center = 0;

  if (x * 2 === W && y * 2 === H) center = 1;
  
  console.log(W * H / 2, center);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  int x, y;
  cin >> x >> y;
  int ans = x * 2;
  for (int i = 0; i <= x; i++) {
    if (ans + 2 * i == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3616
// ITP1_5_A
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  // 初期値
  int H, W;
  bool finished = false;
  
  //Main loop
  while(!finished){
    cin >> H >> W;
    if (H == 0 && W == 0){
      finished = true;
      break;
    }
    for (int i = 0; i < H; i++){
      // cout << "i=" << i;
      for (int j = 0; j < W; j++){
        // cout << ", j=" << j << endl;
        if (i == 0 || i == H -1|| j == 0 || j == W -1){
          cout << "#";
        } else {
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}


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

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);

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

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

    int sum{0};
    for(int i{0}; i<N-1; ++i){
        sum += a[i+1] - a[i];
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500000
#define SENTINEL 2000000000
int L[MAX/2+2], R[MAX/2+2];
int cnt;
void merge(int A[],int n,int left,int mid,int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int i,j,k;
    for(i = 0;i<n1;i++) L[i] = A[left +i];
    for(i = 0;i<n2;i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    i = j = 0;
    for(k = left;k < right;k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i++];
        }
        else{
            A[k] =R[j++]; 
        }
    }
    
}

void mergeSort(int A[],int n,int left,int right){
    if((left + 1) < right){
        int mid = (left + right) / 2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}
int main(void){
    int A[MAX],n,i;
    cnt = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    mergeSort(A,n,0,n);
    for(i=0;i<n;i++){
        if(i>=1) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",cnt);
    return 0;
}



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

int main() 
{
      int n;
      cin>>n;
      double arr[n+1];
      arr[0]=0.0;
      for(int i=1; i<=n;i++)
      cin>>arr[i];
       
       double dp[n+1][n+1];
       dp[0][0]=1.0;//0 heads lane ki probability whith 0 coins
       
       for(int i=1; i<=n;i++)// number of coins
       {
         for(int j=0; j<=n; j++)// no. of heads
         {
            if(j==0)
            dp[i][j]=dp[i-1][j]*(1-arr[i]);
            else
            dp[i][j]=dp[i-1][j]*(1-arr[i])+dp[i-1][j-1]*arr[i];
         }
       }
       
       double ans=0.0;
       for(int i=(n+1)/2; i<=n; i++)
            ans+=dp[n][i]; //n coins with probability of getting i coins
            
        cout<<setprecision(10)<<ans<<endl;    
        return 0;
}

Measured memory_bytes: 74072
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

using P = pair<int, int>;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

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

  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int g = gcd(a[0], a[1]);
  for (int i = 2; i < n; i++) {
    g = gcd(g, a[i]);
  }

  if (g != 1) {
    puts("not coprime");
    return 0;
  }

  set<int> f;

  sort(a.rbegin(), a.rend());
  Sieve sieve(1000000);

  rep(i, n) {
    auto fac = sieve.factor(a[i]);
    for (auto p : fac) {
      if (f.count(p.first) > 0) {
        puts("setwise coprime");
        return 0;
      } else {
        f.insert(p.first);
      }
    }
  }

  puts("pairwise coprime");

  return 0;
}


Measured memory_bytes: 11688
line = gets.split(' ').map(&:to_i)
n = line[0]
m = line[1]
l = Array.new(m)
r = Array.new(m)
m.times do |i|
  #puts "#{i}回目"
  input = gets.split(' ').map(&:to_i)
  l[i] = input[0]
  r[i] = input[1]
end

hairetu = [*(l[0]..r[0])]
#puts hairetu[1]
=begin
for i in 1..m-1
  t = 0
  k = hairetu.size
  k.times do |u|
    if hairetu[t] >= l[i] && hairetu[t] <= r[i] then
        t+=1
    else
       hairetu.delete_at(t)
    end
  end
end
puts hairetu.size
=end

if l.max <= r.min then
  u = r.min - l.max + 1
else
  u = 0
end

puts u


Measured memory_bytes: 4988
// 15:44-15:53, 2WA
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    int X = 0;
    while((int)(X * 1.08) != N){
        if (X == N){
            cout << ":(" << endl;
            return 0;
        }
        X++;
    }

    cout << X << endl;

    return 0;
}

Measured memory_bytes: 3564
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	count := make(map[int]int, M)
	var K, A int
	for i := 0; i < N; i++ {
		fmt.Scan(&K)
		for j := 0; j < K; j++ {
			fmt.Scan(&A)
			count[A] ++
		}
	}

	var ans int
	for _, v := range count {
		if v == N {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n,x,t=get_ints()
a1=n//x
if(n%x==0):
    print(a1*t)
else:
    print((a1+1)*t)


Measured memory_bytes: 61860
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#define mod 1000000007
using namespace std; 

int main(){
	string s;
	cin >> s;
	int n=s.size();
	for (int i=0;i<n/2;i++){
		if (s[i]!=s[n-i-1]){
			cout << "No" << "\n";
			return 0;
		}
	}
	for (int i=0;i<(n-1)/2/2;i++){
		if (s[i]!=s[(n-1)/2-i-1]){
			cout << "No" << "\n";
			return 0;
		}
	}
	int y=(n+3)/2-1;
	int q=0;
	for (int i=y;i<y+((n-y)/2);i++){
		if (s[i]!=s[n-q-1]){
			cout << "No" << "\n";
			return 0;
		}
		q++;
	}
	cout << "Yes"  <<"\n";
}


Measured memory_bytes: 256
object Main extends App {
  val n =  scala.io.StdIn.readInt()
  val s = scala.io.StdIn.readLine()
  if (n % 2 == 0) {
    val splitLength = n / 2
    val before = s dropRight splitLength
    val after = s drop splitLength
    if (before == after) {
      println("Yes")
    } else {
      println("No")
    }
  } else {
    println("No")
  }
}

Measured memory_bytes: 25412
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    ans = 10 ** 5
    ans = min(ans, abs(a - b) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(b - c))
    ans = min(ans, abs(a - c) + abs(a - b))
    print(ans)
    return

#B
def B():
    s, t = S(), S()
    f = 0
    for i in range(len(s)):
        f = f or s[i:] + s[:i] == t
    print(["No","Yes"][f])
    return

#C
def C():
    return

# D
# 解説AC
# 貪欲かよ
# 言われればその通りでbi昇順でソートしていれば
# 直前で取り除いたものに関してはその橋より左側
# の街について絶対に橋が途切れているからね
# fuck!!! 
def D():
    n, m = LI()
    d = defaultdict(int)
    for _ in range(m):
        a, b = LI_()
        d[a] = max(d[a], n-b)
    mi = 0
    ans = 0
    for i in range(n-1):
        mi = max(mi, d[i])
        if i == n - mi - 1:
            mi = 0
            ans += 1
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 55900
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<time.h>
#include<cmath>
#include<functional>
#include<cassert>
#define rep(a,b) for(int a=0;a<b;++a)
#define REP(a,b,c,d) for(int a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
    int N;cin>>N;
    vector<int> p(N);
    rep(i,N)cin>>p[i];
    sort(p.rbegin(),p.rend());
    ll ans=0;
    for(int i=1;i<N;++i){
        ans+=p[i];
    }
    cout<<ans+p[0]/2<<endl;
}

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

void solve(){
  string s; cin >> s;
  int n = s.size();
  reverse(s.begin(), s.end());
  int ten = 1, sum = 0;
  vector<int> cnt(2019, 0);
  long long ans = 0;
  for(int i = 0; i < n; i++){
    cnt[sum]++;
    sum += (s[i] - '0') * ten;
    sum %= 2019;
    ans += cnt[sum];
    ten = (ten * 10) % 2019;
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

#define N 100005

bool d[N+1];
bool dd[N+1];
ll ddd[N+1];

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

int main() {
    REP(i, N) {
        if (isPrime(i)) {
            d[i] = true;
        } else {
            d[i] = false;
        }
        dd[i] = d[i];
    }
    for (int i = 3; i <= N; i += 2) {
        if (d[i]) {
            ll a = (i + 1) / 2;
            if (d[a]) {
                dd[i] = true;
            } else {
                dd[i] = false;
            }
        }
    }
    for (int i = 1; i <= N; i += 2) {
        if (dd[i]) {
            cnt++;
        }
        ddd[i] = cnt;
    }
    cin >> n;
    REP(i, n) {
        ll a, b;
        cin >> a >> b;
        /*cout << ddd[a] << " " << ddd[b] << endl;
        if (a == b) {
            cout << ddd[a] << endl;
        } else {
            ans = ddd[b] - ddd[a] + 1;
            cout << ans << endl;
        }*/

        if (dd[a]) {
            ans = ddd[b] - ddd[a] + 1;
        } else {
            ans = ddd[b] - ddd[a];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1664
/*
 * @Author: Kaizyn
 * @Date: 2020-04-04 20:48:15
 * @LastEditTime: 2020-04-04 20:50:51
 */
#include <bits/stdc++.h>

// #define DEBUG

using namespace std;

const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
const double PI = acos(-1);
typedef pair<int, int> pii;

long long n, k;

inline void solve()
{
    cin >> n >> k;
    n %= k;
    cout << min(n, k-n) << endl;
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int testcase = 1;
    // cin >> testcase;
    for (int i = 1; i <= testcase; ++i) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,deg[101010],q[101010],head,tail,d[101010];
vector<int>e[101010];
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		e[a].push_back(b);
		deg[b]++;
	}
	for(int i=0;i<n;i++)
	{
		if(!deg[i])
		{
			q[++tail]=i;
		}
	}
	int ans=0;
	while(head<tail)
	{
		int x=q[++head];
		ans=max(ans,d[x]);
		for(int i=0;i<e[x].size();i++)
		{
			int y=e[x][i];
			deg[y]--;
			d[y]=max(d[y],d[x]+1);
			if(!deg[y])
			{
				q[++tail]=y;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6912
N,K = map(int,input().split())
tmp=[]
for i in range(N):
    a_i,b_i=map(int,input().split())
    tmp.append([a_i,b_i])

tmp.sort(key=lambda x:x[0])
for t in tmp:
    K -= t[1]
    if K<=0:
        print(t[0])
        break

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

int main(){
    int n;
    scanf("%d",&n);
    int x[n],y[n];
    double sum=0;
    for(int i=0;i<n;i++) scanf("%d %d",&x[i],&y[i]);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    
    sum=(sum*(n-1)*2)/(n*(n-1));
    printf("%lf\n",sum);
}

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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int mm1 = h1*60 + m1;
    int mm2 = h2*60 + m2;
    if(mm2<mm1) mm2+=24*60;
    int d = mm2 - mm1;
    cout << max(0LL, d - k) << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int A[110000], B[110000];

signed main() {
    cin >> N;
    rep(i, N + 1) { cin >> A[i]; }
    rep(i, N) { cin >> B[i]; }
    int ans = 0;
    rep(i, N) {
        int k = min(A[i], B[i]);
        ans += k, B[i] -= k;
        k = min(A[i + 1], B[i]);
        ans += k, A[i + 1] -= k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
N,ma,mb=map(int,(input().split()))
a,b,c=[0]*N,[0]*N,[0]*N
for i in range(N):
    a[i],b[i],c[i]=map(int,input().split())

MA=sum(a)
MB=sum(b)
dp=[[[float("inf") for i in range(MB+1)] for j in range(MA+1)] for k in range(N+1)]
dp[0][0][0]=0
for i in range(N):
    for j in range(MA):
        for k in range(MB):
            if dp[i][j][k]==float("inf"):
                continue
            dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k])
            dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i])

ans=float("inf")
for i in range(1,MA+1):
    for j in range(1,MB+1):
        if i*mb==j*ma:
            ans=min(ans,dp[N][i][j])

if ans==float("inf"):
    print(-1)
else:
    print(ans)

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

ll N, L[205];

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

    cin >> N;

    for(ll i = 0; i < 2 * N; i++) cin >> L[i];

    sort(L, L + 2 * N);

    ll ans = 0;
    for(ll i = 0; i < 2 * N; i += 2) {
        ans += L[i];
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(string s){
    int n = s.size();
    rep(i,n)s[i]='x';
    cout<<s<<endl;
}

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


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cstring>
#include <iostream>
#include <algorithm>

#define fi first
#define se second
#define pb push_back
#define MP std::make_pair
#define PII std::pair<int, int>
#define all(x) (x).begin(), (x).end()
#define CL(a, b) memset(a, b, sizeof a)
#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)
#define per(i, r, l) for (int i = (r); i >= (l); -- i)
#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

typedef long long ll;

const int MAXN = 3e5 + 7;

int n;
ll a[MAXN], b[MAXN], k;

struct Node {
	int p;
	ll w;
	
	bool operator < (const Node& other) const {
		return w == other.w ? p > other.p : w > other.w;
	}
} s[MAXN];

bool check(ll mid) {
	ll use = 0;
	rep(i, 1, n) {
		if (s[i].w <= mid) return 1;
		if (s[i].w > mid) {
			int p = s[i].p;
			ll num = (a[p] * b[p] - mid + b[p] - 1ll) / b[p];
			if (num > a[p]) return 0;
			use += num;
			if (use > k) return 0;
		}
	}
	return 1;
}

int main() {
	scanf("%d %lld", &n, &k);
	rep(i, 1, n) scanf("%lld", a + i);
	rep(i, 1, n) scanf("%lld", b + i);
	std::sort(a + 1, a + n + 1);
	std::sort(b + 1, b + n + 1); std::reverse(b + 1, b + n + 1);
	rep(i, 1, n) s[i] = (Node){i, a[i] * b[i]};
	std::sort(s + 1, s + n + 1);
	ll l = 0, r = s[1].w, mid, ans = LLONG_MAX;
	while (l <= r) {
		mid = (l + r) / 2;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

vector<int> div(int n){
	
	vector<int> div;

	for (int i=1; i*i <= n; i++){
		if (!(n%i)){
			div.push_back(i);
			div.push_back(n/i);
		}
	}

	sort(div.begin(), div.end());
	return div;
}

int main(){

	int ia, ib, k, gcd = 1, cont = 0, x = 0, flag = 1;
	scanf("%d %d %d", &ia, &ib, &k);

	vector<int> a, b, c;
	a = div(ia);
	b = div(ib);

	for (auto i : a){
		for (auto j : b){
			
			if (i == j){
				for (auto k : c) if (k==i) flag = 0;
				if (flag) c.push_back(i);
			}
			flag = 1;
		}
	}
		
	printf("\n%d\n", c[c.size()-k]);
	return 0;
}


Measured memory_bytes: 3768
input = [int(i) for i in input().split()]

N = input[0]
Y = input[1]

ans = False
total = 0

for i in range(0,N+1):
    for j in range(0,(N+1-i)):
        total = 10000 * i + 5000 * j + (N-i-j) * 1000
        if Y == total:
            print(i,j,(N-i-j))
            ans = True
            break
    else:
        continue
    break
if ans == False:

    print(-1,-1,-1)

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

int main(){
    double a; cin >> a;
    a *= 6.28318530717958623200;

    cout << fixed << setprecision(10) << a << endl;
    
}

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

using namespace std;

int main() {
    int K;
    string S;

    cin >> K >> S;

    string ans = "";

    if (K >= S.size()) {
        ans = S;
    } else {
        for(int i = 0; i < K; i++) {
            ans += S[i];
        }
        ans += "...";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
import bisect
n = int(input())
a = list(map(int, input().split( )))
s_a = []
sm = 0
for i in range(n):
    sm+= a[i]
    s_a.append(sm)
    
al = s_a[-1]
half = al//2

i = bisect.bisect_left(s_a,half)
ans1 = s_a[i-1]
ans2 = s_a[i]
#print(s_a)
#print(al,ans1,ans2)
print(min(al-2*ans1,2*ans2-al))

Measured memory_bytes: 99920
// https://atcoder.jp/contests/abc126/tasks/abc126_f

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int M_MAX = 17;
const int K_MAX = 1e9;

int M, K;

void solve() {
  if (K >> M) {
    puts("-1");
    return;
  }

  if (M == 1) {
    if (K == 0) {
      puts("0 0 1 1");
    } else {
      puts("-1");
    }
    return;
  }

  REP(i, 1 << M) if (i != K) printf("%d ", i);
  printf("%d ", K);
  for (int i = (1 << M) - 1; i >=0; i --) if (i != K) printf("%d ", i);
  printf("%d\n", K);
}

void input() {
  scanf("%d%d", &M, &K);
}

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


Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

double a,b,x;
double xx;

int main(){
	scanf("%lf%lf%lf",&a,&b,&x);
	if((a*a*b/2)<x){//体积大于一班 
		xx=(a*a*b-x)*2/(a*a);
		printf("%.10lf",atan(xx/a)*180/acos(-1.0));
	} 
	else if(a*a*b/2==x) printf("45.0000000000");
	else{
		xx=(2*x)/(a*b);
		printf("%.10lf",atan(b/xx)*180/acos(-1.0));
	} 
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long h = Long.parseLong(sc.next());
        Long[] a = new Long[n];
        Long[] b = new Long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(sc.next());
            b[i] = Long.parseLong(sc.next());
        }
        sc.close();

        // 主処理
        long maxA = Arrays.stream(a).mapToLong(i -> i).max().orElse(0);
        List<Long> list = Arrays.asList(b).stream().filter(i -> maxA <= i).collect(Collectors.toList());
        long sum = list.stream().mapToLong(i -> i).sum();
        int result = 0;
        if (h < sum) {
            PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder());
            pq.addAll(list);
            while (0 < h) {
                h -= pq.poll();
                result++;
            }
        } else {
            h -= sum;
            result += list.size() + Math.ceil((double) h / maxA);
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 66332
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)

#define pi 3.14159265358979323846
typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int mp[200020];
int dp[200020];


int main()
{
	long double plu = (20. * pi / 4.) - 20.;
	long double mai = (20. * pi / 2.) - 20.;
	
	REP(i,200020)dp[i] = 1000000000;
	
	ll sx,sy,gx,gy;cin >> sx >> sy >> gx >> gy;
	if(sx > gx)
	{
		swap(sx,gx);swap(sy,gy);
	}
	ll kake = 1;
	if(sy > gy)
	{
		kake = -1;
		sy *= -1;gy *= -1;
	}
	int n;cin >> n;
	
	vector<pair<ll,ll> > x;
	vector<pair<ll,ll> > y;
	
	REP(i,n)
	{
		ll a,b;cin >> a >> b;b*=kake;
		if(a >= sx && a <= gx && b >= sy && b <= gy)
		{
			x.PB(MP(a,i));y.PB(MP(b,i));
		}
	}
	
	sort(ALL(x));
	sort(ALL(y));
	
	REP(i,x.size())
	{
		mp[x[i].SE] = i;
	}
	
	REP(i,x.size())
	{
		ll tmp = mp[y[i].SE];
		*lower_bound(dp,dp+n,tmp) = tmp;
	}
	
	ll ans = lower_bound(dp,dp+n,1000000000) - dp;
	ll ret = 0;
	if(ans-1 == min(abs(gx-sx),abs(gy-sy)))
	{
		ret++;ans--;ans = max(0LL,ans);
	}
	
	long double dist = (long double)(100.*(abs(gx-sx)+abs(gy-sy))) + ans*plu + ret*mai;
	//cout << ans << ' ' << ret << endl;
	cout << Decimal << dist << endl;
	
	
	return 0;
}

Measured memory_bytes: 11360
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main(){
  std::string S;
  std::cin >> S;
  if (S=="ARC") std::cout << "ABC" << std::endl;
  if (S=="ABC") std::cout << "ARC" << std::endl;
  return 0;
}


Measured memory_bytes: 3056
#include<stdio.h>
int main(void){
   int n, i, L, M, N, m, sum, key_mon;
   scanf("%d", &L);
   while ( L ) {
      sum = 0;
      m = 0;
      key_mon = 0;
      for ( i = 0; i < 12; i++ ) {
         scanf("%d %d", &M, &N);
         sum += ( M - N );
         if ( sum >= L && key_mon == 0 ) key_mon = m + 1;
         m++;
      }
      if ( key_mon != 0 ) printf("%d\n", key_mon);
      else printf("NA\n");
      scanf("%d", &L);
   }
   return 0;
}

Measured memory_bytes: 1684
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll n, ans = 0;

bool check(ll v)
{
	vector<bool> ok(10);
	while (v)
	{
		ok[v % 10] = 1;
		v /= 10;
	}

	return ok[7] && ok[5] && ok[3];
}

void dfs(ll v)
{
	if (v > n) return;
	if (check(v)) ++ans;
	dfs(v * 10 + 3);
	dfs(v * 10 + 5);
	dfs(v * 10 + 7);
}

int main()
{
	cin >> n;
	dfs(0);
	cout << ans << endl;
}

Measured memory_bytes: 256