akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
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 INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll p = 1000000007;

// 処理内容
int main() {
    
    ll n; cin >> n;

    vector<ll> r;
    RANGE(x0, 2, n) {
        ll x = x0;
        while (x % 2 == 0) {
            r.push_back(2);
            x /= 2;
        }
        for (ll f = 3; f * f <= x0; f += 2) {
            while (x % f == 0) {
                r.push_back(f);
                x /= f;
            }
        }
        if (x > 1) r.push_back(x);
    }
    sort(ALL_OF(r));
    vector<ll> fn;

    if (r.empty()) {
        cout << "1" << endl;
    } else {
        for (ll i = 0, j = 0, rn = r.size(); i < rn; i++) {
            if (r[i] != r[j]) {
                fn.push_back(i - j);
                j = i;
            }
            if (i == rn - 1) {
                fn.push_back(i - j + 1);
            }
        }
        ll ans = 1;
        REP(i, fn.size()) {
            ans *= fn[i] + 1;
            ans %= p;
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>
#define NIL -1
#define MAX 100005
using namespace std;

struct Node {
    int parent, left, right, depth, sibling, degree, height;
};
Node T[MAX];
void print(int u)
{
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << T[u].sibling << ", ";
    cout << "degree = " << T[u].degree << ", ";
    cout << "depth = " << T[u].depth << ", ";
    cout << "height = " << T[u].height << ", ";
    if (T[u].parent == NIL)
    {
        cout << "root";
    }
    else if (T[u].left == NIL && T[u].right == NIL)
    {
        cout << "leaf";
    }
    else
    {
        cout << "internal node";
    }
    cout << "\n";
}
void calcDepth(Node *node)
{
    if(node->parent == NIL){
        node->depth = 0;
    } else {
        node->depth = T[node->parent].depth + 1;
    }
    if (node->left != NIL)
        calcDepth(&T[node->left]);
    if (node->right != NIL)
        calcDepth(&T[node->right]);
}

int calcHeight(Node *node) {
    if(node->left != NIL && node->right != NIL) {
        node->height = max(calcHeight(&T[node->left]) + 1, calcHeight(&T[node->right]) + 1);
    } else if(node->left != NIL) {
        node->height = calcHeight(&T[node->left]) + 1;
    } else if(node->right != NIL) {
        node->height = calcHeight(&T[node->right]) + 1;
    } else {
        node->height = 0;
    }
    return node->height;
}

int main() {
    int n, root;
    cin >> n;
    for(int i=0; i<n; i++){
        T[i].degree = 0;
        T[i].sibling = -1;
        T[i].parent = NIL;
    }
    for(int i=0; i<n; i++) {
        int t;
        cin >> t;
        cin >> T[t].left >> T[t].right;
        if(T[t].left != NIL) {
            T[T[t].left].parent = t;
            T[t].degree++;
        }
        if (T[t].right != NIL) {
            T[T[t].right].parent = t;
            T[t].degree++;
        }
        if(T[t].degree == 2) {
            T[T[t].left].sibling = T[t].right;
            T[T[t].right].sibling = T[t].left;
        } else {
            if(T[t].left != NIL)
                T[T[t].left].sibling = -1;
            if (T[t].right != NIL)
                T[T[t].right].sibling = -1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        if(T[i].parent == NIL) root = i;
    }

    calcDepth(&T[root]);
    calcHeight(&T[root]);
    for (int i = 0; i < n; i++) {
        print(i);
    }
}



Measured memory_bytes: 3112
import java.util.*;

/**
 * Created by thompson on 08/09/2018.
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        List<String> list = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            list.add(sc.next());
        }

        Set<String> set = new HashSet<>();
        boolean result = true;
        set.add(list.get(0));

        for (int i = 1; i < list.size(); i++) {
            String last = list.get(i - 1);
            String current = list.get(i);

            if (set.contains(current)) {
                result = false;
                break;
            }

            if (current.charAt(0) != last.charAt(last.length() - 1)){
                result = false;
                break;
            }

            set.add(current);
        }

        if (result)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 22740
s = input()
len_s = len(s)
cnt_b = s.count('B')
diff_list = [i for i in range(len_s - cnt_b, len_s)][::-1]
b_idx = []

for idx, el in enumerate(s):
    if el == 'B':
        b_idx.append(idx)
    else:
        pass

total = 0
for pos, idx in zip(diff_list, b_idx):
    total += pos - idx
print(total)


Measured memory_bytes: 24508
//36
#include<iostream>
#include<string>

using namespace std;

int main(){
  for(int n,q;cin>>n>>q,n|q;){
    string en[1000];
    int ey[1000],wy[1000];
    for(int i=0;i<n;i++){
      cin>>en[i]>>ey[i]>>wy[i];
    }
    while(q--){
      string s;
      int y=-1;
      int q;
      cin>>q;
      for(int i=0;i<n;i++){
	if(q<=wy[i]&&wy[i]-ey[i]+1<=q){
	  s=en[i];
	  y=ey[i]-(wy[i]-q);
	}
      }
      if(y==-1){
	cout<<"Unknown"<<endl;
      }else{
	cout<<s<<' '<<y<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs              v.size()
#define sot(v)        sort(v.begin(),v.end())
#define rev(v)        reverse(v.begin(),v.end())
#define ii                pair<int,int>
#define ll                long long
#define ull              unsigned long long
#define pb              push_back
#define mpp          make_pair
#define Okay         0
#define pi               3.14159

static ll int inf = 1e9;
const int cont = 10e5+10;
using namespace std;


void solve(){
    vector<int>v(3);
    for(int i=0; i<3;i++)cin>>v[i];
    sot(v);
    if(v[0] == 5  && v[1] == 5 && v[2] == 7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

int main(){

solve();

	return Okay;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int W,H;
  cin>>W>>H;
  VL P(W),Q(H);
  rep(i,W) cin>>P[i];
  rep(i,H) cin>>Q[i];
  vector<PLL> R(0);
  rep(i,W) R.pb(mp(P[i],0));
  rep(i,H) R.pb(mp(Q[i],1));
  sort(all(R));
  ll ans=0;
  rep(i,R.size()){
    if(R[i].second==0){
      ans+=(H+1)*R[i].first;
      W--;
    }else{
      ans+=(W+1)*R[i].first;
      H--;
    }
  }
  cout<<ans<<endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  int sum = 0; 
  int x;
  for (int i = 0; i < M; i++) {
    cin >> x;
    sum += x;
  }

if(N >= sum){
    cout  << N - sum << endl;
  }
else if(N < sum){
    cout  << "-1" << endl;
  } 

}


Measured memory_bytes: 3636
use proconio::input;
use std::collections::VecDeque;

fn main() {
    input! {
        n: usize
    }

    let ans = {
        let mut ans: usize = 1;
        let mut que = VecDeque::new();
        for i in 1..=9 {
            que.push_front(i);
        } 
        let mut count = 1;
        while let Some(k) = que.pop_back() {
            if count == n+1 {
                break;
            }
            ans = k;
            match k%10 {
                0 => {
                    que.push_front(10*k);
                    que.push_front(10*k+1);
                }
                9=> {
                    que.push_front(10*k+8);
                    que.push_front(10*k+9);
                }
                l => {
                    que.push_front(10*k+l-1);
                    que.push_front(10*k+l);
                    que.push_front(10*k+l+1);
                }
            }
            count += 1;
        }
        ans
    };

    println!("{}",ans)
}

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

string s;

int main(){
  cin >> s;
  int p = s.size();
  int cnt;
  for (int i=1; i<p-1 ; i++) cnt++;
  cout << s[0] << cnt << s[p-1] <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
	int i, N, M, a, b;
	static int s1[200000], sn[200000];
	scanf("%d %d", &N, &M);

	for ( i = 0; i < M; i++ ){
		scanf("%d %d", &a, &b);
		if ( a == 1 ){
			s1[b-1] = 1;
		} else if ( b == 1 ){
			s1[a-1] = 1;
		} else if ( a == N ){
			sn[b-1] = 1;
		} else if ( b == N ){
			sn[a-1] = 1;
		}
	}

	for ( i = 0; i < N; i++ ){
		if ( s1[i] == 1 && sn[i] == 1 ){
			printf("POSSIBLE\n");
			return 0;
		}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}


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

int main(){
  ll n; cin >> n;
  string s; cin >> s;
  ll rnum = 0, gnum = 0, bnum = 0;
  for(char x : s){
    if (x == 'R') ++rnum;
    if (x == 'G') ++gnum;
    if (x == 'B') ++bnum;
  }
  ll res = rnum * gnum * bnum;
  for(ll i=1; i<=(n-1)/2; ++i){
    for(ll j=0; j+2*i<n; ++j){
      if(s[j] != s[j+i] && s[j+i] != s[j+2*i] && s[j+2*i] != s[j]) --res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,i,max=0;
    string s;
    cin>>s;
    n=s.length();
    if(n==1)
    cout<<0;
    else
    {
    	string s1,s2;
    	for(i=0;i<n;i++)
    	{
    		if(i%2==0)
    		s1.push_back('0');
    		else
    		s1.push_back('1');
		}
		for(i=0;i<n;i++)
    	{
    		if(i%2==0)
    		s2.push_back('1');
    		else
    		s2.push_back('0');
		}
		int x,y;
		x=0;y=0;
		for(i=0;i<n;i++)
		{
			if(s[i]!=s1[i])
			x++;
			if(s[i]!=s2[i])
			y++;
		}
		cout<<min(x,y);
		
	}
    

}

Measured memory_bytes: 720
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n, a;
	cin >> n >> a;
	cout << n*n - a << endl;
}

Measured memory_bytes: 256
function main (arg) {
	arg = arg.trim().split('\n');
  	var n = Number(arg.shift()),
        s = arg, cnt = 0, out = [];
	//文字列を昇順にする為の配列処理
	s = s.map(str => str.split(''));
    for (var i = 0; i < n; i++) {
      var str = s[i].sort().join('');
      //console.log(i+1+'週目', '【'+str+'】', '配列に'+out[str])
        if(out[str]) {
            cnt += out[str];
            out[str]++;
        } else {
            out[str] = 1;
        }
    }
  console.log(cnt)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 77288
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    for (int i = 0; i < n; ++i)
        cin >> x[i];

    ll ans = 0;
    for (int i = 0; i < n - 1; ++i)
    {
        ll d = x[i + 1] - x[i];
        if (a * d > b)
            ans += b;
        else
            ans += a * d;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const double PI=3.14;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    double r;
    cin >> r;

    cout << fixed << setprecision(3) << r * 2 * PI << endl;

    return 0;
}

Measured memory_bytes: 3820
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define alli(a, n, k) (a + k), (a + n + k)
#define FP(i, a, b, k) for (__typeof(a) i = a; i < b; i += k)
#define FS(i, a, b, k) for (__typeof(a) i = a; i > b; i -= k)
#define IT(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template <class T>
inline T gcd(T x, T y)
{
	if (!y)
		return x;
	return gcd(y, x % y);
}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int k;
	cin>>k;
	priority_queue<ll,vector<ll>,greater<ll>> pq;
	for(int i=1;i<=9;++i)
	pq.push(i);

	int sz=0;
	ll u;
	while(sz<k)
	{
		u=pq.top();
		pq.pop();

		int ll1=u%10;
		if(ll1-1>=0)
		{
			pq.push(stoll(to_string(u)+to_string(ll1-1)));
		}
		if(ll1+1<=9)
		{
			pq.push(stoll(to_string(u) + to_string(ll1 + 1)));
		}
		
			pq.push(stoll(to_string(u)+to_string(ll1)));
		sz++;
	}
	cout<<u<<endl;
	return 0;
}

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

vector<int> Fri[100001],Blo[100001];
int cnts[100001];

int main(){
  int n,m,k,a,b;
  cin>>n>>m>>k;
  rep(i,m){
    cin>>a>>b;
    a--,b--;
    Fri[a].push_back(b);
    Fri[b].push_back(a);
  }
  rep(i,k){
    cin>>a>>b;
    a--,b--;
    Blo[a].push_back(b);
    Blo[b].push_back(a);
  }

  int area[100001]={},rel=1;
  rep(i,n){
    if(area[i]!=0)continue;
    area[i]=rel;
    queue<int> que;
    rep(j,Fri[i].size()){
      if(area[Fri[i][j]]==0)que.push(Fri[i][j]);
     // cout<<Fri[i][j]<<endl;
    }
    while(!que.empty()){
      int q=que.front();que.pop();
      if(area[q]!=0)continue;
      area[q]=rel;
      rep(j,Fri[q].size()){
        if(area[Fri[q][j]]==0)que.push(Fri[q][j]);
      }
    }
    rel++;
  }
  
  int friInArea[100001],bloInArea[100001];

  rep(i,n+1){
    cnts[i]=0;
    friInArea[i]=0;
    bloInArea[i]=0;
    //cout<<area[i]<<endl;
  }

  rep(i,n+1){
    if(area[i]!=0)cnts[area[i]]++;
  }
  
  rep(i,n){
    rep(j,Fri[i].size()){
      if(area[Fri[i][j]]==area[i])friInArea[i]++;
    }

    rep(j,Blo[i].size()){
      if(area[Blo[i][j]]==area[i])bloInArea[i]++;
    }
  }

 
  rep(i,n){
    //cout<<Fri[i].size()<<" "<<Blo[i].size()<<endl;
    rep(j,Fri[i].size()){
      //cout<<Fri[i][j]<<" ";
    }
    //cout<<endl;
    cout<<cnts[area[i]]-friInArea[i]-bloInArea[i]-1;
    if(i!=n-1)cout<<" ";
  }//*/
  cout<<endl;
}

Measured memory_bytes: 13816
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static Scanner scan;

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

        int n = scan.nextInt();
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            list.add(scan.nextInt());
        }
        Collections.reverse(list);
        for (int i = 0; i < list.size(); i++) {
            if (i < list.size() - 1) {
                System.out.print(list.get(i).toString() + " ");
            } else {
                System.out.println(list.get(i).toString());
            }
        }
    }
}

Measured memory_bytes: 19116
#include<cstdio>
#include<algorithm>
#include<cstring>
const int MAXN = 100000;
const int MAXK = 1000;
int x[MAXN + 5], y[MAXN + 5], c[MAXN + 5];
int y1[10 * MAXK + 5];
int main() 
{
	int N,K,Max=0,cnt = 0;
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++) 
	{
		char ch;
		scanf("%d%d %c",&x[i],&y[i],&ch);
		x[i]= x[i] % (2*K);
		y[i]= y[i] % (2*K);
		if(ch=='W' ) c[i] = 1;
		else c[i]=0;
	}
	for(int i=0;i<=K;i++) {
		cnt = 0;
		memset(y1,0,sizeof(y1));
		for(int j=1;j<=N;j++) {
			bool p = ( i <= x[j] && x[j] < i+K );
			bool q = ( 0 <= y[j] && y[j] < K );
			if( p ^ q == c[j] )
			{
				cnt++;
				y1[y[j]] ++;
			}
			else 
			{
				y1[y[j]] --;
			}
		}
		for(int j=0;j<=K;j++) 
		{
			Max=std::max(Max,std::max(cnt,N-cnt));
			if( j != K )
				cnt = cnt - y1[j] - y1[K+j];
		}
	}
	printf("%d\n",Max);
}


Measured memory_bytes: 1408
import copy

N,M = list(map(int,input().rstrip().split()))
sides = []
for i in range(M):
    ab = list(map(int,input().rstrip().split()))
    sides.append(ab)
    ba = [ab[1],ab[0]]
    sides.append(ba)

explored = [False for i in range(N+1)]
explored[0] = True
explored[1] = True

def explore(currentposition,flg):
    count = 0
    if all(flg):
        return 1
    for p in sides:
        if p[0] == currentposition and flg[p[1]]==False:
            tmp_flg = copy.deepcopy(flg)
            tmp_flg[p[1]] = True
            count += explore(p[1],tmp_flg)
    return count

print(explore(1,explored))

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

int check(char character, int index, int init){
    char targ = '0';
    if(index % 2 != 0){
        if(init == 0) targ = '1'; 
    }else{
        if(init == 1) targ = '1';
    }

    if(character != targ) return 1; //different
    return 0; //correct
}

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

    int res1 = 0, res2 = 0;
    for(int i=0;i<S.length();i++){
        res1 += check(S[i],i,0);
        res2 += check(S[i],i,1);
        //cout << res1 << res2 << endl;
    }

    cout << min(res1, res2) << endl;
}

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

int main() {
  int n;
  while (cin >> n) {
    if (n == 0) break;
    int number[n];
    bool useN[4000];
    long long int total[4000];
    for (int i = 0; i < n; i++) number[i] = 0;
    for (int i = 0; i < 4000; i++) {
      useN[i] = false;
      total[i] = 0;
    }
    
    for (int i = 0; i < n; i++) {
      int a;
      long long int b,c;
      cin >> a >> b >> c;
      number[i] = a;
      if (!useN[a-1]) useN[a-1] = true;
      total[a-1] += b*c;
    }
    
    bool NA = true;
    for (int i = 0; i < n; i++) {
      if ( useN[number[i]-1] && total[number[i]-1] >= 1000000) {
	cout << number[i] << endl;
	useN[number[i]-1] = false;
	NA = false;
      }
    }
    if (NA) cout << "NA" << endl;
  }
  return 0;
}



Measured memory_bytes: 3136
import numpy as np
import time
import random

def calc(d, q):
    select_rand = select.copy()
    select_rand[d] = q
    last = [0] * 26
    satisfied_rand = 0
    for i in range(1, D+1):
        t = select_rand[i-1]
        satisfied_rand += s[i-1][t-1]
        last[t-1] = i
        for j in range(26):
            satisfied_rand -= c[j] * (i-last[j])
    return (satisfied_rand, select_rand)

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

c = np.array(c)

last = [0] * 26
select = []
satisfied = 0
for i in range(1, D+1):
    last_d = [c[j]*(i-last[j]) for j in range(26)]
    last_d_sum = sum(last_d)
    #選択肢A 満足度の高いものから選ぶ
    s_d = np.array(s[i-1])
    maxindexA = np.argmax(s_d)
    satis_optA = s_d[maxindexA] - last_d_sum + last_d[maxindexA]
    
    #選択肢B コストが大きいものから選ぶ
    last_d = np.array([c[j]*(i-last[j]) for j in range(26)])
    maxindexB = np.argmax(last_d)
    satis_optB = s_d[maxindexB] -last_d_sum + last_d[maxindexB]

    if satis_optA >= satis_optB:
        #Aを選択
        select.append(maxindexA+1)
        satisfied += satis_optA
        last[maxindexA] = i
    else:
        #Bを選択
        select.append(maxindexB+1)
        satisfied += satis_optB
        last[maxindexB] = i

while time.time() < 2:
    d = random.randint(0, D-1)
    q = random.randint(1, 26)
    result = calc(d, q)
    if satisfied < result[0]:
        select = result[1]

for i in range(D):
    print(select[i])





        




Measured memory_bytes: 27408
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll N, K;
  cin >> N >> K;

  ll m = N % K;

  if (abs(m - K) < m) cout << abs(m-K) << endl;
  else cout << m << endl;

  return 0;
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

int N;
vector<int> a;
vector<bool> pushed;
int INF = 1e7;

int check(int i)
{
    if (i == 2) {
        return 0;
    } else if (!pushed[i]) {
        pushed[i] = true;
        return check(a[i]) + 1;
    } else {
        return -1e7;
    }
}

int main()
{
    cin >> N;
    a.resize(N + 1);
    pushed.resize(N + 1);

    for (int i = 1; i <= N; i++) {
        cin >> a[i];
        pushed[i] = false;
    }

    cout << max(check(1), -1) << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
    int i,j,k;
    char s[200],s1[200];
    scanf("%[^\n]",s);
    j=strlen(s);
    for(i=0; i<j; i++)
        printf("%c",(toupper(s[i])));
        printf("\n");
    return 0;
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
    ll N;
    cin>>N;
    for(ll h=1; h<=3500; h++){
        for(ll n=1; n<=3500; n++){
            ll A=N*h*n;
            ll B=4*h*n-N*h-N*n;
            if(B>0&&A%B==0){
                cout<<A/B<<" "<<n<<" "<<h<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(){
    int b=0;
    string a;
    char s,l;
    cin >> a;
    for(int i=0;i<a.size()-2;i++){
        b++;
    }   
    cout << a[0];
    cout << b;
    cout << a[a.size()-1];
    cout << endl;



}

Measured memory_bytes: 256
input_line = gets.chomp.to_i
res = 0
count = 0
  s = gets.chomp.split(' ').map(&:to_i)
    while res do
      res = s.map! do |line| 
        if line.even?
          line /= 2 
        else
          break false
        end
      end
      count += 1 if res
    end
p count

Measured memory_bytes: 1788
#include<cstdio>
#include<iostream>

using namespace std;
#define INF 100000

int  road, max_t = 0, time_[100][100] = { 0 }, sum, root[100] = { 0 };

void dijkstra(int a) {

	int i,j,k=INF,used[100],minroot;
	for (i = 0; i <= max_t; i++) {
		used[i] = 0;
		root[i] = INF;
	}
	root[a] = 0;
	while (1) {
		minroot = INF;
		for (i = 0; i <= max_t; i++) {
			if (used[i] == 0&&root[i]<minroot) {
				j = i;
				minroot = root[i];
			}
			
		}
		if (k == j) {
			break;
		}
		else {
			k = j;
		}
		used[j] = 1;
		for (i = 0; i <= max_t; i++) {
			if (root[i] > root[j] + time_[j][i]) {
				root[i] = root[j] + time_[j][i];
			}

		}
	}
	sum = 0;
	for (i = 0; i <= max_t; i++)sum += root[i];

	return ;
}






int main() {
	while (1) {
		cin >> road;
		if (road == 0) return 0;
		int i, j, a=0, b=0, c=0, save_a[450] = { 0 }, save_b[450] = { 0 }, save_c[450] = { 0 }, min_sum = INF, ans_town=0;
		max_t = 0;
		for (i = 1; i <= road; i++) {
			cin >> a >> b >> c;
			if (max_t < a) max_t = a;
			if (max_t < b) max_t = b;
			save_a[i] = a;
			save_b[i] = b;
			save_c[i] = c;
		}
		for (i = 0; i <= max_t; i++) {
			for (j = 0; j <= max_t; j++) {
				time_[i][j] = INF;
			}
			time_[i][i] = 0;
		}
		for (i = 1; i <= road; i++) {
			time_[save_a[i]][save_b[i]] = save_c[i];
			time_[save_b[i]][save_a[i]] = save_c[i];
		}
		for (i = 0; i <= max_t; i++) {
			dijkstra(i);
			if (sum < min_sum) {
				ans_town = i;
				min_sum = sum;
			}
		}
		cout << ans_town << " " << min_sum << endl;

	}
}

Measured memory_bytes: 1168
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	//出力
	if (a*b%2 == 1) {
        console.log("Odd");
    }
    if (a*b%2 == 0) {
        console.log("Even");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int n,m,k;
int fn(int p,int q){
  int i;
  int sm=0;
  if(p==n){
    sm=max(q-k,1);
  }else{
    for(i=1;i<m+1;i++)
      sm+=fn(p+1,q+i);
  }
  return sm;
}
int main(){
  while(cin>>n>>m>>k&&n+m+k)
    printf("%.8lf\n",fn(0,0)/pow(m,n));
  return 0;
}

Measured memory_bytes: 924
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;


bool a[105];

int main()
{
    faster

    int x,n,z;
    cin>>x>>n;


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

    if(a[x]==false)
    {
        cout<<x<<endl;
        return 0;
    }

    int i=x-1,j=x+1;

    while(i>=0 && j<=101)
    {
        if(a[i]==false)
        {
            cout<<i<<endl;
            return 0;
        }

        if(a[j]==false)
        {
            cout<<j<<endl;
            return 0;
        }
        i--,j++;
    }


    while(i>=0)
    {
        if(a[i]==false)
        {
            cout<<i<<endl;
            return 0;
        }


        i--;
    }
    while(j<=101)
    {

        if(a[j]==false)
        {
            cout<<j<<endl;
            return 0;
        }
        j++;
    }






    return 0;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<>());

  if (s < t){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	static InputStream is = System.in;
	static String INPUT = "";

	public static void main(String[] args) throws Exception
	{
		int n = ni();
		int M = 1000001;
		int W = (M>>>6)+1;
		long[] f1 = new long[W];
		long[] f2 = new long[W];
		long[] ex = new long[W];
		for(int i = 0;i < n;i++){
			int v = ni();
			if(f1[v>>>6]<<~v>=0){
				f1[v>>>6] |= 1L<<v;
				if(ex[v>>>6]<<~v>=0){
					for(int j = v*2;j < M;j+=v){
						ex[j>>>6] |= 1L<<j;
					}
				}
			}else{
				f2[v>>>6] |= 1L<<v;
			}
		}
		int ans = 0;
		for(int i = 0;i < W;i++){
			ans += Long.bitCount((f1[i]^f2[i])&~ex[i]);
		}
		System.out.println(ans);
	}
	
	private static byte[] inbuf = new byte[1024];
	static int lenbuf = 0, ptrbuf = 0;
	
	private static int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
//	private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }
	private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private static double nd() { return Double.parseDouble(ns()); }
	private static char nc() { return (char)skip(); }
	
	private static String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private static char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private static char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private static int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private static int ni()
	{
		int num = 0, b;
//		boolean minus = false;
//		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
//		if(b == '-'){
//			minus = true;
//			b = readByte();
//		}
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9')));
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return num;
//				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 34208
from bisect import bisect
n = int(input())
a = list(map(int, input().split()))

a.sort()

i = bisect(a, (a[-1]+1) // 2)

if a[i] - a[-1] / 2 < a[-1] / 2 - a[i-1]:
    print(a[-1], a[i])
else:
    print(a[-1], a[i-1])

Measured memory_bytes: 85032
import java.util.*;

public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] jun = new int[n];
	for (int i=1; i<=n; i++) {
	    jun[sc.nextInt() - 1] = i;
	}
	for (int i=0; i<n; i++) {
	    System.out.print(jun[i] + " ");
	}		 
    }
}


Measured memory_bytes: 60640
#include<iostream>
using namespace std;
int a[100000];
int main(){
	int n,m;
	cin>>n>>m;
	int ans=0;
	for(int i=0;i<m;i++)
	{
		cin>>a[i];
		ans+=a[i];
	}
	if(ans>n)
	{
		cout<<-1;
	}
	else
	{
		cout<<n-ans;
	}
    return 0;
}


Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
#define MAXN 200000
#define LL long long
#define MOD 1000000007
int n,k,a,b;
int F;LL ans;
vector<int> G[MAXN+5];
void dfs(int x,int fa,int dep){
	if(F)return ;
	int L=k-min(dep,2);
	if(L+1<G[x].size()){F=1;return ;}
	for(int i=0;i<G[x].size();i++){
		int nxt=G[x][i];
		if(nxt==fa)continue;
		dfs(nxt,x,dep+1);
		ans=(ans*(LL)L)%MOD;
		L--;
	}
}
int main()
{
	scanf("%d%d",&n,&k);
	ans=k;
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if(G[1].size()>k){printf("0");return 0;}
	dfs(1,0,1);
	if(!F)printf("%lld",ans);
	else printf("0");
}

Measured memory_bytes: 13952
""" AtCoder """

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    min_len = 1000000000
    for j in range(M):
        tmp = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if min_len > tmp:
            ans = j+1
            min_len = tmp
    print(ans)


Measured memory_bytes: 3064
a,b,n=map(int,input().split())

nb=n//b

#xmax=0
if n<b:
    xmax=a*n//b
else:
    xmax=0
#    for xb in range(nb):
#        xv=(a*xb*b+a*(b-1))//b-a*xb
#        xmax=max(xmax,xv)
    xb=nb-1
    xv=(a*xb*b+a*(b-1))//b-a*xb
    xmax=max(xmax,xv)
    xb=nb
    xv=(a*xb*b+a*n%b)//b-a*xb
    xmax=max(xmax,xv)

print(xmax)    


Measured memory_bytes: 61888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio {
  int it, len;
  char s[LEN + 5];
  fastio() {
    it = len = 0;
  }
  char get() {
    if(it < len) return s[it++];
    it = 0, len = fread(s, 1, LEN, stdin);
    return len ? s[it++] : EOF;
  }
  bool notend() {
    char c;
    for (c = get();c == ' ' || c == '\n';c = get());
    if (it) it--;
    return c != EOF;
  }
  void put(char c) {
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush() {
    fwrite(s, 1, it, stdout);
  }
}buff, bufo;
inline int getint() {
  char c; int res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if(c == '-') sig = -1;
  for (;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll() {
  char c; ll res = 0, sig = 1;
  for (c = buff.get(); c < '0' || c > '9'; c = buff.get()) if (c == '-') sig = -1;
  for (; c >= '0' && c <= '9'; c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x, char suf) {
  if (!x) bufo.put('0');
  else {
    if (x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while (x) {
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for (; k; k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char() {
  char c;
  for (c = buff.get(); c == ' ' || c == '\n'; c = buff.get());
  return c;
}
#define maxn 200005
#define maxAns 31
#define a first
#define b second
#define mp make_pair
typedef pair<ll, ll> P;
const ll inf = 0x3f3f3f3f;
int n;
P st[maxn];
ll T, f[maxn][maxAns];
bool cmp(P x, P y) {
  if (!x.a && !y.a) return x.b > y.b;
  return y.a * (x.b + 1) < x.a * (y.b + 1);
}
vector <ll> bs;
int main() {
  n = getint(), T = getll();
  for (int i = 1; i <= n; i++) st[i].a = getll(), st[i].b = getll();
  sort(st + 1, st + n + 1, cmp);
  
//  cout << "ok" << endl;

//  ll tot = 0;
//  for (int i = 1; i <= 30; i++) {
//    tot++;
//    tot += tot;
//    if (tot > (ll)1e8) cout << i << ": " << tot << endl;
//  }
  int j = n;
  while (j && !st[j].a) {
    bs.push_back(st[j].b);
    j--;
  }
  if (!bs.empty()) {
    bs[0]++;
    for (int i = 1; i < (int)bs.size(); i++) bs[i] += bs[i - 1] + 1;
  }
  for (int i = 1; i <= 28; i++) f[0][i] = inf;
  for (int i = 1; i <= j; i++) {
    for (int j = 1; j <= 28; j++) {
      f[i][j] = min(f[i - 1][j],
                f[i - 1][j - 1] + 1 + st[i].a * (f[i - 1][j - 1] + 1) + st[i].b);
    }
  }
  int ans = 0;
  for (int i = 0; i <= 28; i++) {
    if (f[j][i] > T) break;
    int res = i;
    if (!bs.empty()) {
      res += upper_bound(bs.begin(), bs.end(), T - f[j][i]) - bs.begin();
    }
    ans = max(ans, res);
  }
  putll(ans, '\n');
  bufo.flush();
  return 0;
}


Measured memory_bytes: 51968
#include <bits/stdc++.h>
#define MD 1000000007
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
ll dp[100100][2];
vvi tr;
int n;
ll ds(int n, int p, int s) {
	if(dp[n][s] != -1) {return dp[n][s];}
	ll re = 1;
	for(int i=0;i<tr[n].size();i++) {
		if(tr[n][i] == p) {continue;}
		re *= ds(tr[n][i],n,1-s);
		re %= MD;
	}
	if(s) {
		re += ds(n,p,0);
	}
	return dp[n][s] = re%MD;
}
int main() {
	scanf("%d ",&n);
	memset(dp,-1,sizeof(dp));
	tr.assign(n,vi());
	for(int i=0;i<n-1;i++) {
		int a,b;
		scanf("%d %d ",&a,&b);a--;b--;
		//tr[min(a,b)].push_back(max(a,b));
		tr[a].push_back(b);
		tr[b].push_back(a);
	}
	printf("%lld\n",ds(0,-1,1));
}


Measured memory_bytes: 14208
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  if (a == 1)
  {
    if (b == 2) cout << 3;
    if (b == 3) cout << 2;
  }
  if (a == 2)
  {
    if (b == 1) cout << 3;
    if (b == 3) cout << 1;
  }
  if (a == 3)
  {
    if (b == 1) cout << 2;
    if (b == 2) cout << 1;
  }
}


Measured memory_bytes: 3552
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, a[SIZE], pos[SIZE];

  scanf("%d", &n);
  
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    a[i]--;
    pos[a[i]] = i;
  }

  int ans = n-1;

  int count = 1;
  for(int i=1;i<n;i++){
    if (pos[i-1] < pos[i]) count++;
    else count = 1;

    ans = min(ans, n-count);
  }

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



Measured memory_bytes: 1792
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    over = []
    for a in A:
        if a >= K:
            over.append(a)

    if len(over) == 0:
        print("IMPOSSIBLE")
        exit(0)
    if min(over) == K:
        print("POSSIBLE")
        exit(0)

    while True:
        min_A = min(A)
        B = []
        for a in A:
            r = a % min_A
            if r != 0:
                B.append(r)
        if len(B) == 0:
            print("IMPOSSIBLE")
            exit(0)
        else:
            min_B = min(B)
            for oa in over:
                if (oa - K) % min_B == 0:
                    print("POSSIBLE")
                    exit(0)
            A = A + B


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

using namespace std;

int n;
string s[200000];
set<string> ss;

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> s[i];
		ss.insert(s[i]);
	}
	cout << ss.size() << endl;
}

Measured memory_bytes: 25428
#ALDS1_2-A Bubble Sort
def bubbleSort(A,N):
    c=0
    flag=1
    while flag:
        flag=0
        j=N-1
        while j>0:
            if(int(A[j])<int(A[j-1])):
                c+=1
                A[j],A[j-1]=A[j-1],A[j]
                flag=1
            j-=1
    return c

N=int(input())
A=input().split()
c=bubbleSort(A,N)
S=""
for i in range(N-1):
    S+=A[i]+" "
S+=str(A[-1])
print(S)
print(c)

Measured memory_bytes: 7728
//	Author : amnptl 
//	   Godbless
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define NeedForSpeed() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD (1000000007); // 1e9+7
int main()
{
	NeedForSpeed();
	int n,m; cin>>n>>m;
	(n==m)?cout<<"Yes":cout<<"No";		
	return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	int ans = MOD;
	for (int i = 0; i <= 100; i++) {
		int sum = 0;
		for (auto j : v) {
			sum += (i - j)*(i - j);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

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

#define LOG(x) // cerr << #x << " = " << x << endl

int main() {
  while(true) {
    int N, W; cin >> N >> W;
    if(N == 0 && W == 0) break;
    map<int, int> occ;
    for(int i = 0; i < N; ++i) {
      int v; cin >> v;
      occ[v /  W]++;
    }
    int maxOcc = 0;
    int numBars = 0;
    for(auto&& iter : occ) {
      maxOcc = max(maxOcc, iter.second);
      numBars = max(numBars, iter.first + 1);
    }
    LOG(maxOcc);
    LOG(numBars);
    double ans = 0.01;
    for(auto&& iter : occ) {
      ans += (1.0 - (1.0 * iter.first / (numBars - 1))) * (1.0 * iter.second / maxOcc);
    }
    cout.setf(ios::fixed);
    cout.precision(6);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;


int main(void){
    int t;
    cin >> t;
    while(t-- > 0){
        vint a(3);
        rep(i, 3) cin >> a[i];
        sort(a.begin(), a.end());
        if(a[2]*a[2] == a[1]*a[1] + a[0]*a[0])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;

int main(void){

	string s, t, u;
	unsigned int a, b;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if(u == s)
		a = a - 1;

	else if(u == t)
		b = b - 1;

	cout << a << " " << b << endl;

return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution() {
  int n, m;
  cin >> n >> m;
  int a[n], b[m];
  rep(i, 0, n, 1) cin >> a[i];
  rep(i, 0, m, 1) cin >> b[i];
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));

  for (int i = 0; i < n; i++) {
    if (a[i] == b[0]) dp[i][0] = 1;
  }

  for (int i = 0; i < m; i++) {
    if (a[0] == b[i]) dp[0][i] = 1;
  }

  for (int i = 0; i < n; i++) dp[i + 1][0] += dp[i][0];
  for (int i = 0; i < m; i++) dp[0][i + 1] += dp[0][i];

  for (int i = 1; i < n; i++) {
    for (int j = 1; j < m; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];
      if (a[i] == b[j]) dp[i][j] += dp[i - 1][j - 1] + 1;
      dp[i][j] = mod(dp[i][j]);
    }
  }
  cout << mod(dp[n - 1][m - 1] + 1) << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 34484
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;


int main(){
  int N;
  cin >> N;
  bool ok = false;
  REP(i, N/4  +1){
    if((N - i * 4 )% 7 == 0)ok = true;
  }
  if(ok) printf("Yes\n");
  else printf("No\n");

}


Measured memory_bytes: 888