akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],b[N],ans=0;
map<int,int> cnt;
int main() {
    n=gi();
    for(int i=1;i<=n;i++) a[i]=gi(),++cnt[a[i]];
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++) {
        b[i]=1;
        while(b[i]<=a[i]) b[i]<<=1;
        b[i]-=a[i];
    }
    for(int i=n;i;i--) {
        if(cnt[a[i]]) {
            --cnt[a[i]];
            if(cnt[b[i]]) {
                --cnt[b[i]],++ans;
            }
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 20608
#include <iostream>

using namespace std;

int main() {
    int N = 0;
    cin >> N;
    
    if ((N - 7) % 10 == 0) 
    {
        cout << "Yes";
    }
    else if ((N / 10 - 7) % 10 == 0) 
    {
        cout << "Yes";
    }
    else if((N / 100 - 7) % 10 == 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }


    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
int N, Q;

//FenwickTree
vector<int> FenTree;

void init(void) {
  FenTree.resize(N+1);
  rep(i, N+1) FenTree[i] = 0;
}

void add(int i, int x) {
  for(; i <= N; i += (i & -i))
    FenTree[i] += x;
}

int sum(int i) {
  int ret = 0;
  for(; i > 0; i -= (i & -i))
    ret += FenTree[i];
  return ret;
}

int query(int l, int r) {
  return sum(r) - sum(l-1);
}

int main(void) {
  ios::sync_with_stdio(false);
  cin >> N >> Q;
  vector<int> C(N);
  rep(i, N) cin >> C[i];
  vector<vector<pair<int, int>>> LR(N+1);
  rep(i, Q) {
    int L, R;
    cin >> L >> R;
    LR[R].emplace_back(L, i);
  }

  init();
  vector<int> answer(Q);
  vector<int> pos(N+1, 0);
  for(int i = 1; i <= N; ++i) {
    if(pos[C[i-1]] > 0) {
      add(pos[C[i-1]], -1);
    }
    add(i, +1);
    pos[C[i-1]] = i;
    rep(j, (int)LR[i].size()) {
      answer[LR[i][j].second] = query(LR[i][j].first, i);
    }
  }
  rep(i, Q) cout << answer[i] << endl;
  return 0;
}


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


#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for (int i = 0; i < v.size(); ++i) cout << v[i] << c;

typedef long long ll;
using namespace std;

int main()
{
     ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
     int n,i,k,l,c=0,d,p,nl,np;
    int a[51],b;
   cin>>n;
   vector<int> v(n);

   REP(i,n)
   {
    cin>>v[i];

   }
   REP(i,n)
   {
       if(v[i]!=i+1)c++;

   }

   if(c==2 || c==0)cout<<"YES";
   else cout<<"NO";





}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int cnt[100100];

template <typename T>
T expt(T a, T n, T mod = std::numeric_limits<T>::max()){
    T res = 1;
    while(n){
        if(n & 1){res = res * a % mod;}
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    std::cin >> N;

    for(int i=0;i<N;++i){
        int a;
        std::cin >> a;

        ++cnt[a];
    }

    if(cnt[0] > 1){
        std::cout << 0 << std::endl;
        return 0;
    }

    int n = cnt[0];
    for(int i=1;i<N;++i){
        if(cnt[i] == 0 || cnt[i] == 2){
            n += cnt[i];
        }else{
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    if(n == N){
        std::cout << expt(2ll, 1ll * N / 2, 1000000000ll + 7) << std::endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  ll n, k;
  cin >> n >> k;

  ll p = 1;
  int ans = 1;
  while (p < n) {
    p *= k;
    if (p > n) break;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


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

const int mod=1e9+7;
const int maxn=1e3+10;
int vis[maxn][maxn];
queue<pair<int,int>> q;
int ans[maxn][maxn];
int dir[4][2]={{1,0},{0,1},{0,-1},{-1,0}};

int main()
{
    int n,m;
    cin>>n>>m;
    vector<string>gra(maxn);
    for(int i=0;i<n;++i)
     cin>>gra[i];
    q.push({0,0});
    vis[0][0]=1;
    ans[0][0]=1;
    while(!q.empty())
    {
        pair<int,int> f=q.front();
        q.pop();
        for (int i=0;i<2;++i)
        {
            int x=f.first+dir[i][0];
			int y=f.second+dir[i][1];
            if(x>=0&&x<n&&y>=0&&y<m&&gra[x][y]=='.')
            {
                ans[x][y]=(ans[f.first][f.second]+ans[x][y])%mod;
                if(!vis[x][y])
                {
                    vis[x][y]=1;
                    q.push({x,y});
                }
            }
        }
    }
    cout<<ans[n-1][m-1]<<endl;
    return 0;
}

Measured memory_bytes: 13404
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N; cin >> N;
  vector<char> ans;
  while(N != 0) {
    ll a = N%26;
    N /= 26;
    if(a == 0) {
      ans.push_back('z');
      --N;
    }
    else ans.push_back(96+a);
  }
  for(ll i=ans.size()-1; i >= 0; --i) cout << ans[i];
  cout << endl;
}


Measured memory_bytes: 3624
import java.io.*;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            System.out.println(x*x*x);

        }catch(IOException e){
            System.out.println(e);
        }catch(NumberFormatException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24468
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		int []b = new int [n];
		
		for(int i = 0 ;i < n;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		
		for(int i = 0 ;i < n;i++) {
			b[i] = Integer.parseInt(sc.next());
		}
		
		int aid = 0;
		int bid = 0;
		
		int N = 1;
		
		for(int i = 1 ;i <= n ;i++) {
			N *= i;
		}
		
		int A =solve(n,N,a);
		int B =solve(n,N,b);
		
		int ans = Math.abs(A - B);
		
		System.out.println(ans);
		
		}
	static int solve(int n , int N , int []a) {
		
		int min = 0;
		List <Integer> list = new ArrayList<Integer>();
		
		for(int i = 0; i < n ; i++) {
		int cnt = 0;
		for(int j = 1 ;j <= n; j++) {
			if(!list.contains(j)) {
				cnt++;
				if(a[i] == j) {
					list.add(j);
					break;
				}
			}
		}
			min += N/(n-i) * (cnt-1); 
			N = N / (n-i);
	}
		
		return min;
	}
	}


Measured memory_bytes: 25044
def main():
    H, W = map(int, input().split())
    matrix = [list(input()) for _ in range(H)]
    for r in matrix:
        r.insert(0, ".")
        r.append(".")
    matrix.insert(0, ["."] * (W + 2))
    matrix.append(["."] * (W + 2))

    ans = "Yes"
    for r in range(1, H + 1):
        for c in range(1, W + 1):
            if matrix[r][c] == ".":
                continue
            if matrix[r-1][c] == "." and matrix[r+1][c] == "." and matrix[r][c-1] == "." and matrix[r][c+1] == ".":
                ans = "No"
                break
        if ans == "No":
            break
    print(ans)

if __name__ == '__main__':
    main()

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
#define SpaceNewLine(a) Rep(i,a.size())cout<<a[i]<<(i==a.size()-1?'\n':' ')
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {
    // setup {{{ 1
    cin.tie(0);
    ios::sync_with_stdio(false);
    // }}}

    int N,D;
    Scd2(N,D);

    printf ("%d\n", (N+D*2)/(D*2+1) );

    return 0;
}



Measured memory_bytes: 256
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif



void solve(){
	int n , k ;
	cin >> n >> k ;
	int ans = 0 ;
	for(int i = k ; i <= n ; i++){
		int pre = i*(i-1)/2 ;
		int suf = n*i-pre ;
		ans += suf-pre+1 ;	
		while(ans>=MOD) ans -= MOD ;
	}
	ans++ ;
	cout << ans%MOD ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
}


Measured memory_bytes: 3616
n = gets.to_i
as = gets.split.map(&:to_i)

ans = 0
(0..n-1).each do |i|
  minj = i
  (i..n-1).each do |j|
    if as[j] < as[minj]
      minj = j
    end
  end
  next if minj == i
  tmp = as[i]
  as[i] = as[minj]
  as[minj] = tmp
  ans += 1
end

puts as.join(" ")
puts ans



Measured memory_bytes: 8860
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,M,Q = inpl()
kukan = []

for i in range(M):#加算
	l,r = inpl()
	kukan.append([r,-1,l])


for i in range(Q):#クエリ
	p,q = inpl()
	kukan.append([q,i,p])

kukan.sort()

bit = [0]*(N+1)
ans = [0]*Q

def BIT_add(a,w):
	global bit
	x = a
	while x <= N:
		bit[x] += w
		x += x & -x

def BIT_sum(a):
	global bit
	tmp = 0
	x = a
	while x > 0:
		tmp += bit[x]
		x -= x & -x
	return tmp

for t,flag,s in kukan:
	if flag == -1: #加算
		BIT_add(s,1)
	else:#クエリ
		ans[flag] = BIT_sum(t)-BIT_sum(s-1)

for a in ans:
	print(a)


Measured memory_bytes: 53736
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n;
double a[111];

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

	double avg = 0.0;
	for (int i = 0;i < n;i++) avg += a[i];
	avg = avg / ((double)n);

	double dmin = 99999.9999;
	for (int i = 0;i < n;i++) {
		dmin = std::min(dmin, abs(avg - a[i]));
	}

	for (int i = 0;i < n;i++) {
		if (abs(avg - a[i]) == dmin) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


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

int main() {
  int N, A;
  int tmp;

  cin >> N >> A;

  tmp = N % 500;
  
  if (tmp <= A) {
    cout << "Yes" << endl;
  }
  else {
	    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let t: u32 = read();
    let mut m: u32 = 1001;
    for _ in 0..n {
        let c: u32 = read();
        let v: u32 = read();
        if t >= v {
            m = min(c, m);
        }
    }
    if m == 1001 {
        println!("TLE");
    } else {
        println!("{}", m);
    }
}


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

int main() {
  int A1,A2,A3,N;
  string res;
  
  cin >> A1;
  cin >> A2;
  cin >> A3;

  N = A1+A2+A3;

  if(N >= 22) res = "bust";
  else res = "win";

  cout << res << endl;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

const int MAX=1e6+1;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));

    //エラトステネスのふるい
    vb dp(MAX,false);
    rep(i,n){
        if(i!=0 && a[i]==a[i-1]){
            dp[a[i]]=true;
            continue;
        }
        for(int j=a[i]*2; j<MAX; j+=a[i]){
            dp[j]=true;
        }
    }
    int res=0;
    rep(i,n){
        if(dp[a[i]]==false) res++;
    }
    cout<<res<<endl;


}

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

using namespace std;
	
const int maxn = 1e5 + 20;
int ar[maxn];

int main()
{
	long long a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(2*a<b)
		b=2*a;
	if(2*b < c)
		c=2*b;
	if(2*c < d)
		d=2*c;
	
	long long ans=0;	
	ans+=(e/2)*d;
	ans+=(e%2)*c;
	
	cout << ans;
}		

 



Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000

int main() {
	static char s[N + 1];
	int n, i, tcd;

	scanf("%s", s);
	n = strlen(s);
	tcd = 0;
	for (i = 0; i < n; i++)
		if (s[i] == 'p')
			tcd++;
	printf("%d\n", n / 2 - tcd);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

long long n;
double x[50000], y[50000];

double ds(double x1, double y1, double x2, double y2)
{
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

signed main()
{
    srand(time(NULL));
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    double s = 0, cnt = 0;
    vector<int> p;
    for (int i = 0; i < n; i++) p.push_back(i);
    while (1)
    {
        for (int i = 0; i + 1 < n; i++)
        {
            s += ds(x[p[i]], y[p[i]], x[p[i + 1]], y[p[i + 1]]);
        }
        cnt++;
        if (!next_permutation(all(p)))
        {
            printf("%.9f", s / cnt);
            return 0;
        }
    }
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

const int MAX = 310000; //テーブルの数
const int MOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];
// finv ->階乗割り算
// fac ->階乗掛け算

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll Pow(ll  x, ll n){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return Pow((x * x )  % MOD, n / 2);
  else
    return (x * Pow(x, n - 1)) % MOD;
}


int main(){
    COMinit();
    ll n, m, k; cin >> n >> m >> k;
    ll ans = 0;
    REP(i, 0, k+1){
        ans = (ans + (m%MOD) *((COM(n-1, i) % MOD) * Pow(m-1, n-1-i) % MOD )% MOD) %MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 10844
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main() {
  int N,a;
  int ans = 1;
  cin >> N >> a;
  int tmp = 0;
  int pos = 0;
  rep(i, N) {
    cin >> tmp;
    pos += tmp;
    if (pos <= a) {
      ans++;
    }
  }
  cout << ans;
  
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
sort(all(list));
sort(all(list), greater<int>());
//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    map<string,int>mp;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"]<<endl;
    return 0;
}


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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int sum=0;

    if(a>=k){
        sum=k;
    }else if(a+b>=k){
        sum=a;
    }else{
        sum=2*a+b-k;
    }

    cout<<sum<<endl;
}

Measured memory_bytes: 3632
#coding: euc-jp
class Main
  def self.main
    n = read
    min = 10 ** 15
    5.times do
      a = read
      min = a if a < min
    end
    puts 4 + n / min + (n % min == 0 ? 0 : 1)
  end

  def self.read
    gets.chomp.to_i
  end
end

Main.main


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int n, ans;
vector<pair<int, int> > evi[16];
vector<int> kind(16);

int search(int i){
	int coun = 0;
	for (int j = 0; j < n; j++){
		if (i & (1<<j)){
			coun++;
			for (int k = 0; k < evi[j+1].size(); k++){
				if (evi[j+1][k].second != kind[evi[j+1][k].first]) return 0;
			}
		}
	}
	return coun;
}


int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		int a;
		cin >> a;
		for (int j = 0; j < a; j++){
			int x, y;
			cin >> x >> y;
			evi[i].push_back(make_pair(x, y));
		}
	}
	for (int i = 0; i < (1<<n); i++){
		for (int i = 0; i < 16; i++) kind[i] = 0;
		for (int j = 0; j < n; j++){
			if (i & (1<<j)){
				kind[j+1] = 1;
			}
		}
		ans = max(ans, search(i));
	}
	cout << ans << endl;
	return 0;
}




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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    int ans;
    if(n%2){
        int l = a[n/2];
        int r = b[n/2];
        ans = r-l+1;
    }
    else{
        int l = a[n/2]+a[n/2-1];
        int r = b[n/2]+b[n/2-1];
        ans = r-l+1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll n,item,temp,ans=0;
    vector<ll>A;
    vector<ll>B;
    vector<ll>C;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>item;
        item--;
        A.push_back(item);
    }
    for(int i=0;i<n;i++)
    {
        cin>>item;
        B.push_back(item);
    }
    for(int i=0;i<n-1;i++)
    {
        cin>>item;
        C.push_back(item);
    }
    for(int i=0;i<n;i++)
    {
        ans+=B[A[i]];
        if(i==0)
            continue;
        if(A[i-1]<n-1 && A[i-1]+1==A[i])
        {
          ans+=C[A[i-1]];
        }

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


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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    ll X;
    cin >> X;
    cout << ((X / 500) * 1000) + ((X % 500) / 5) * 5 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
const ll mod=1e9+7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll s=0;
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0) s+=i;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  ULL H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }
  ULL seki = H * W;
  cout << (seki + 1) / 2 << endl;

  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int ac, wa, tle, re;
	ac = wa = tle = re = 0;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		if(s == "AC") ++ac;
		else if(s == "WA") ++wa;
		else if(s == "TLE") ++tle;
		else ++re;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}

Measured memory_bytes: 3628
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        h:  i64,
        w: i64
    }
    if h % 3  == 0 {
        println!("0");
    } else if w % 3 == 0 {
        println!("0");
    } else {
        let mut  mi = std::i64::MAX;
        if h > w {
            let tmp = if h % 3 == 0 {0} else {1};
            mi = std::cmp::min(mi, (tmp % 3) * w);
        } else {
            let tmp = if w % 3 == 0 {0} else {1};
            mi = std::cmp::min(mi, (tmp % 3) * h);
        }
        for i  in 1..h {
            let v = vec![(h - i) * (w / 2), i * w, (h-i) * ((w + 2 - 1) / 2)];
            mi = std::cmp::min(mi,
                v.iter().max().unwrap() - v.iter().min().unwrap());
        }
        for i  in 1..w {
            let v = vec![(w - i) * (h / 2), i * h, (w - i) * ((h + 2 - 1) / 2)];
            mi = std::cmp::min(mi,
                v.iter().max().unwrap() - v.iter().min().unwrap());
        }
        println!("{}", mi);
    }
}

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

const int INF=1e9+5;
const int N=100+5;
const int mod=1e9+7;

int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	// freopen("input.txt","r",stdin);
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int& x:a) cin>>x;
	vector<bool> dp(k+1);
	for(int stone=0;stone<=k;++stone){
		for(int x:a){
			if(stone>=x&&!dp[stone-x]){
				dp[stone]=1;
			}
		}
	}
	cout<<(dp[k]?"First":"Second");
	return 0;
}
		


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

using namespace std;
typedef long long ll;

ll N,Q;


//与えられた要素数より大きくすること 配列範囲
const ll INT_INF = 1LL << 31;
//INF定義
const ll MAX_N = 1LL << 20;
ll n; //要素数が与えられた時、それ以上の最小の２＾k数が欲しい
ll dat[2*MAX_N - 1]; //RMQのサイズは２*MAX_N（ビットと混同しないように）

void init(ll a){
  n = 1;  while( n < a){ n *= 2;}
  for(ll i = 0; i < 2*n - 1 ; i++){
    dat[i] = INT_INF - 1;} // infで初期化,範囲外参照でREしやすいので注意
}
void update(ll k, ll a){
  k += n - 1;
  dat[k] = a;
  while( k > 0){
    k = ( k - 1)/ 2;
    dat[k] = min( dat[ 2* k + 1] , dat[2*k + 2]);}
}

//[a,b)での最小値を求める
// l , r　は　k番目のノードが[l,r)に対応していることを意味
ll query(ll a, ll b, ll k , ll l, ll r){
  if( r <= a || b <= l){ return INT_INF;}
  else if( a <= l && r <= b){ return dat[k];}
  else{
    ll vl = query(a,b,2*k + 1, l, ( l + r) / 2);
    ll vr = query(a, b, 2* k + 2, ( l + r) / 2, r);
  
  return min( vl, vr);}
}
//initで初期化忘れないこと　0-index か 1-index問題によって注意(0-に合わせる）


int main(){
 cin >> N >> Q;
  init(N);
  
  for(ll i = 0; i < Q; i++){
    ll com,x,y; cin >> com >> x >> y;
    if( com == 0){ update(x,y);}
    else{ cout << query(x,y+1,0,0,n) << endl;}
    
  }
  return 0;}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
// #define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
using namespace std;
using namespace __gnu_pbds;

// typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
 
 ll mod=1e9 +7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
 
vector<bool>  prime(90000002,true);
void Sieve() 
{ 
   
    for (int p=2; p*p<=90000001; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=90000001; i += p) 
                prime[i] = false; 
        } 
    } 
}

const ll M=3000006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // compute();
    // Sieve();
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        ll n,x,t;
        cin>>n>>x>>t;
        ll ans=(n/x)*t;
        if(n%x!=0) ans+=t;
        cout<<ans;

    }

    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

int a[4];
map<int,int>mp;

void input(){
	for(int i=0;i<4;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	return;
}

void solve(){
	if(mp[1]&&mp[9]&&mp[7]&&mp[4]){
		cout<<"YES"<<endl;
	}
	else cout<<"NO"<<endl;
	return;
}

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

Measured memory_bytes: 764
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
 
using namespace std;
int MOD = 1000000007;
char m[101][101];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int ans = 0;
int h,w;
void bfs(int sx,int sy,int gx,int gy){
    int used[101][101];
    rep(i,h) rep(j,w) used[i][j] = INF;
    queue<pair<int,int>> que;
    que.push(MP(sx,sy));
    used[sx][sy] = 0;
    while(que.size()){
        pair<int,int> p = que.front();
        que.pop();
        int x = p.fi;
        int y = p.se;
        if(x == gx && y == gy){
            ans = used[x][y];
            return;
        }
        rep(i,4){
            if(x+dx[i] >= 0 && y+dy[i] >= 0 && x+dx[i] <= h-1 && y+dy[i] <= w-1){
                if(m[x+dx[i]][y+dy[i]] != '#' && used[x+dx[i]][y+dy[i]] == INF){
                    used[x+dx[i]][y+dy[i]] = used[x][y] + 1;
                    que.push(MP(x+dx[i],y+dy[i]));
                }
            }
        }
    }
    ans = INF;
    return;
}

signed main(){
    
    cin >> h >> w;
    int bl = 0;
    int wh = 0;
    rep(i,h){
        rep(j,w){
            cin >> m[i][j]; 
            if(m[i][j] == '.')wh++;
            else bl++;
        }
    }
    bfs(0,0,h-1,w-1);
    if(ans == INF)cout << -1 << endl;
    else cout << wh-ans-1 << endl;
    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://abc088.contest.atcoder.jp/tasks/abc088_d
// rm -r -f test;oj dl http://yahoo-procon2017-qual.contest.atcoder.jp/tasks/yahoo_procon2017_qual_c

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

using namespace std;

typedef long long int ll;
typedef long double ld;

int main()
{
	int n;
	cin >> n;
	ll sum = 0;
	unordered_map <ll,ll> mp1;
	for(int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		sum += x;
		mp1[x]++;
	}
	int q;
	cin >> q;
	while(q--)
	{
		ll b, c;
		cin >> b >> c;
		sum += (c - b) * mp1[b];
		mp1[c] += mp1[b];
		mp1[b] = 0;
		cout << sum << "\n";
	}
}

Measured memory_bytes: 7028
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

vector<bool> isprime(100004,true);
void furui(){
    isprime[0]=false;
    isprime[1]=false;
    for(int i=0; i*i<=100003; ++i){ // 0からmaxまで全て調べる
        if(isprime[i]){ // iが素数ならば
            for(int j=2; j*i<=100003; ++j){ //i+1からmaxまで全て調べる
                    isprime[i*j] = false; // 素数ではない
            }
        }
    }

}


int main(){
    ll ans,x;
    cin>>x;

    furui();

    while(isprime[x]==false){
        x++;
    }

    cout <<x<<endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ip = pair<int,int>;
using iv =   vector<int>;
using vp =    vector<ip>;
const int N = 1e5+1;
int m, n; vp g[N]; iv parity, x, s; bool visited[N];
inline void read_bombs() {
	vp bomb(n); iv b(n+1,0);
	for (int i = 0; i < n; ++i)
		cin >> bomb[i].first >> bomb[i].second;
	sort(bomb.begin(),bomb.end());
	for (int i = 0; i < n; ++i)
		x.push_back(bomb[i].first), b[i] = bomb[i].second;
	x.push_back(INT_MAX), parity.push_back(b[0]);
	for (int i = 0, j = 1; i < n; i = j++)
		parity.push_back(b[j] != b[i]); }
inline int lb(int d) { return lower_bound(x.cbegin(),x.cend(),d)-x.cbegin(); }
inline void read_cord(int i) {
	int l, r;
	cin >> l >> r, l = lb(l), r = lb(r+1),
	g[l].emplace_back(i,r), g[r].emplace_back(i,l); }
int dfs(int u, int p = -1) {
	visited[u] = true;
	for (auto e: g[u])
		if (e.second != p and not visited[e.second] and dfs(e.second,u))
			s.push_back(e.first), parity[u] ^= 1;
	return parity[u]; }
inline void write_ans() {
	cout << s.size() << "\n", sort(s.begin(), s.end());
	for (auto cord: s)
		cout << cord <<  ' '; }
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cin >> n >> m, read_bombs();
	for (int i = 1; i <= m; ++i)
		read_cord(i);
	for (int i = 0; i <= n; ++i)
		if (not visited[i] and dfs(i))
			cout << -1, exit(0);
	write_ans(); }

Measured memory_bytes: 16096
//   ┏━━┓┏━━┓┏┓┏┓┏┳━┳┓┏━━┓┏━┳┓┏━━┓     ┏┳┓┏┳┓┏━┳━┓┏━━┓┏━┓
//   ┃┏┓┃┃━━┫┃┗┛┃┃┃┃┃┃┃┏┓┃┃┃┃┃┗┃┃┛     ┃┏┛┃┃┃┃┃┃┃┃┃┏┓┃┃╋┃
//   ┃┣┫┃┣━━┃┃┏┓┃┃┃┃┃┃┃┣┫┃┃┃┃┃┏┃┃┓     ┃┗┓┃┃┃┃┃┃┃┃┃┣┫┃┃┓┫
//   ┗┛┗┛┗━━┛┗┛┗┛┗━┻━┛┗┛┗┛┗┻━┛┗━━┛     ┗┻┛┗━┛┗┻━┻┛┗┛┗┛┗┻┛
#include "bits/stdc++.h" 
using namespace std; 
#define mod 1e9 + 7 
#define FOR(a, c) for (int(a) = 0; (a) < (c); (a)++) 
#define FORL(a, b, c) for (int(a) = (b); (a) < (c); (a)++) 
#define FORR(a, b, c) for (int(a) = (b); (a) > (c); (a)--) 
typedef long long int ll; 
typedef vector<int> vi; 
typedef pair<int, int> pi; 
#define PB push_back 
#define POB pop_back 
#define MP make_pair 
int main() 
{ 
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string n;
  cin>>n;
  ll an=0;
  for(int i=0; i<n.size(); i++){
    an+=(n[i]-'0');
  }
  if(an%9==0){
    cout<< "Yes";
  }
  else{
    cout<<"No";
  }
}
// By Ashwani Kumar, Indian Institute Of Technology(IIT), Guwahati.
//   ╔══╗╔══╗╔══╗     ╔══╗╔╦╗╔╦═╦╗╔══╗╔╗╔╗╔══╗╔══╗╔══╗
//   ╚║║╝╚║║╝╚╗╔╝     ║╔═╣║║║║║║║║║╔╗║║╚╝║║╔╗║╚╗╔╝╚║║╝
//   ╔║║╗╔║║╗─║║─     ║╚╗║║║║║║║║║║╠╣║║╔╗║║╠╣║─║║─╔║║╗
//   ╚══╝╚══╝─╚╝─     ╚══╝╚═╝╚═╩═╝╚╝╚╝╚╝╚╝╚╝╚╝─╚╝─╚══╝

Measured memory_bytes: 3780
def f(a):
    for x in ['b','w']:
        if a[0::4].count(x)==3 or a[2:7:2].count(x)==3:return x
        for i in range(3):
            if a[i*3:i*3+3].count(x)==3 or a[i::3].count(x)==3:return x
    return 'NA'

while 1:
    a=input()
    if a=='0':break
    print(f(a+input()+input()))

Measured memory_bytes: 7436
N = int(input())
A = list(map(int,input().split()))
answer = 0
flag = 0
while flag == 0 :
    counter = 0
    for i in range(N) :
        if A[i] % 2 != 0 :
            flag += 1
        else :
            A[i] = A[i]//2
            counter += 1
        if counter == N :
            answer += 1
print(answer)


Measured memory_bytes: 3060
$xs = {}

$xs["a"] = gets.chomp
$xs["b"] = gets.chomp
$xs["c"] = gets.chomp

def pull_card(s)
    if $xs[s].size > 0
        atama = $xs[s][0]
        $xs[s].slice!(0)
        return atama
    else
        puts s.upcase
        return 0
    end

end

turn = pull_card("a")

loop do
    turn = pull_card(turn)

    break if turn == 0
end

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

int main(){
    int N,b,minB=1000000000;
    long long a,sum=0;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> a >> b;
        sum+=a;
        if(a>b && minB>b)
        minB=b;
    }
    if(minB==1000000000)
    cout << 0 << endl;
    else
    cout << sum-minB << endl;
    return 0;
}

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

int gcd(int x, int y) {
	int r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int K;
	long long sum = 0;
	cin >> K;
	for (int ii = 1; ii <= K; ii++) {
		for (int jj = 1; jj <= K; jj++) {
			for (int kk = 1; kk <= K; kk++) {
				sum += gcd(gcd(ii, jj), kk);
			}
		}
	}
	cout << sum << endl;
}


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

int main(){
  int n; cin >> n;
  int v[n],c[n];
  for(int i=0;i<n;i++){cin >> v[i];}
  for(int i=0;i<n;i++){cin >> c[i];}
  int rieki=0;
  for(int i=0;i<n;i++){
    int sa = v[i] - c[i];
    if(sa>0){
      rieki += sa;
    }
  }
  cout << rieki << endl;
  
}

Measured memory_bytes: 256
//gcc listsirkuler.c map.c player.c mesinkata.c mesinkar.c matriks.c pcolor.c point.c stackpoint.c queue.c unit.c main.c -o main
#include <bits/stdc++.h>
#define Semangat using
#define World namespace
#define Final std;
#define WF {ios_base::sync_with_stdio(0);cin.tie(0);}
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long

const int MOD = 1e9+7;
const int MAXN = 1e5+3;
Semangat World Final

int n,m,ax,by;
string s[55],t;

int main(){
	cin>>n;
	cout<<48-n<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
    if (n == 1) {
        return false;
    } else {
        for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
            if (n%i == 0) return false;
        }
    }
    return true;
}

int main() {
    ll n;
    cin >> n;
    ll tmp = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if (prime(a)) tmp++;
    }
    cout << tmp << endl;
}


Measured memory_bytes: 3472
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			while (true) {
				String input = br.readLine();
				String[] cut = input.split(" ");
				int a = Integer.parseInt(cut[0]);
				String op = cut[1];
				int b = Integer.parseInt(cut[2]);
				if (op.equals("?"))
					break;
				switch (op) {
				case "+":
					System.out.println(a + b);
					break;
				case "-":
					System.out.println(a - b);
					break;
				case "*":
					System.out.println(a * b);
					break;
				case "/":
					System.out.println(a / b);
					break;
				}

			}
			br.close();
		} catch (Exception e) {
			System.exit(-1);
		}

	}
}

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

int main() {

	int x , y, z;
	x = y = z = 0;
	char next = 'a';

	string A, B, C;

	cin >> A >> B >> C;

	while (true)
	{
		if (next == 'a')
		{
			if (x == A.length())
			{
				cout << 'A' << endl;
				break;
			}
			next = A[x];
			x++;

		}
		else if (next == 'b')
		{
			if (y == B.length())
			{
				cout << 'B' << endl;
				break;
			}
			next = B[y];
			y++;

		}

		else if (next == 'c')
		{
			if (z == C.length())
			{
				cout << 'C' << endl;
				break;
			}
			next = C[z];
			z++;

		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>

using namespace std;

int main(){

	int t,sum,s,e,n;

	while(true){
		scanf("%d",&t);
		if(t == 0)break;

		scanf("%d",&n);

		sum = 0;

		for(int i = 0; i < n; i++){
			scanf("%d %d",&s,&e);
			sum += e-s;
		}

		if(sum >= t){
			printf("OK\n");
		}else{
			printf("%d\n",t-sum);
		}

	}


    return 0;
}


Measured memory_bytes: 2744
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin>>n;
  vector<ll> c(5,0);
  rep(i,n){
    string s; cin>>s;
    if(s[0]=='M')
    c[0]++;
    else if(s[0]=='A')
    c[1]++;
    else if(s[0]=='R')
    c[2]++;
    else if(s[0]=='C')
    c[3]++;
    else if(s[0]=='H')
    c[4]++;
  }
  ll sum=0;
  rep(i,3){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        sum+=c[i]*c[j]*c[k];
      }
    }
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256