akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define N 100005
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

bool check(int mid){

  return false;
}

ll serch(ll ok,ll ng) {
	while (abs(ok-ng) > 1) {
		ll mid = (ok + ng) / 2;
		if (check(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}

int main(){
  cout<<fixed<<setprecision(20);
  cin.tie(0);ios::sync_with_stdio(false);
  int k,s;
  cin>>k>>s;
  k++;
  ll ans=0;
  rep(i,k){
    rep(j,k){
      if(s-i-j>=0&&i+j+k-1>=s){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

const M: usize = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();

    let mut xs = vec![0 as i64; n];
    for i in 0..n {
        xs[i] = sc.cin();
    }
    xs.sort();

    let mut a = 0;
    let mut b = 0;

    let mut i = 0;
    while i < n - 1 {
        if xs[i] == xs[i + 1] {
            a = b;
            b = xs[i];
            i += 2;
        } else {
            i += 1;
        }
    }

    trace!((a, b));
    println!("{}", a * b);

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}


Measured memory_bytes: 11768
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main(void){
	char s[1001]={0};
	int sum=0;
	while(1){
		cin >>s;
		if(strcmp(&s[0], "0")==0){
			break;
		}
		for(int i=0; s[i]!='\0'; i++){
			sum+=(int)(s[i]-'0');
		}
		cout <<sum <<endl;
		sum=0;
	}
    return 0;
}

Measured memory_bytes: 1140
#include<iostream>
#include<cstdio>
#define endl '\n'
using namespace std;
int main()
{
    int n,A,B;
    char s[100001];
    int cnt[100001] = {0};
    cin>>n>>A>>B>>s;
    int t = A+B;
    int total = 0,b = 0;
    for(int i = 0; i<n; i++)
    {
        if(s[i]=='c')continue;
        else{
            if(s[i]=='a' && total<t)
                {total++;cnt[i] = 1;}
            else if( s[i]=='b' && total<t)
                if(b<B) total++,b++,cnt[i]=1;
        }
    }
    for(int i = 0; i<n; i++){
        if(cnt[i]==0)puts("No");
        else if(cnt[i])puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 1656
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000+5;
const ll mod = 1e9+7;

int main(){
    int n;
    string s;
    cin>> s;
    map<string,int>M;
    // SUN, MON, TUE, WED, THU, FRI, or SAT
    M["SUN"] = 7;
    M["MON"] = 6;
    M["TUE"] = 5;
    M["WED"] = 4;
    M["THU"] = 3;
    M["FRI"] = 2;
    M["SAT"] = 1;
    cout << M[s] << endl;
    return 0;
}


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

int main(){
  int n,h;
  for(;cin>>n>>h,n;)
    {
      long long int sum=n*n*n;
      long long int cnt=0;
      map<pair<pair<int,int>, int> ,bool> hash;
      for(int i=0;i<h;i++)
	{
	  string c;
	  int a,b;
	  cin>>c>>a>>b;
	  a--;
	  b--;
	  if(c=="xy")
	      for(int i=0;i<n;i++)
		{
		  if(!hash[make_pair(make_pair(a,b),i)])
		    {
		      hash[make_pair(make_pair(a,b),i)]=true;
		      cnt++;
		    }
		}
	  else if(c=="xz")
	      for(int i=0;i<n;i++)
		{
		  if(!hash[make_pair(make_pair(a,i),b)])
		    {
		      hash[make_pair(make_pair(a,i),b)]=true;
		      cnt++;
		    }
		}
	  else if(c=="yz")
	      for(int i=0;i<n;i++)
		{
		  if(!hash[make_pair(make_pair(i,a),b)])
		    {
		      hash[make_pair(make_pair(i,a),b)]=true;
		      cnt++;
		    }
		}
	}
       cout<<sum-cnt<<endl;
    }

}

Measured memory_bytes: 4332
import heapq
import sys

N = int(input())
a = [[] for i in range(N)]
for i in range(N - 1):
	u, v, w = map(int, input().split())
	a[u - 1].append((v - 1, w))
	a[v - 1].append((u - 1, w))
b = [(0, 0)]
c = [False] * N
d = [sys.maxsize] * N
d[0] = 0
while len(b) != 0:
	e = heapq.heappop(b)
	c[e[1]] = True
	for i in a[e[1]]:
		if c[i[0]]:
			continue
		if d[e[1]] + i[1] < d[i[0]]:
			d[i[0]] = d[e[1]] + i[1]
			heapq.heappush(b, (d[i[0]], i[0]))
for i in d:
	print(i % 2)

Measured memory_bytes: 43676
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

int main()
{
    int k, x;
    cin >> k >> x;

    for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) {
        cout << i << " ";
    }
    return 0;
}


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

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int __sv;scanf("%d", &(__sv));vec.PB(__sv);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 1000000000000000007LL

int k, a, b;
bool res;

int main ()
{
  R1(k);
  R2(a, b);
  res = false;
  FOR(i, a, b + 1) if (i % k); else res = true;
  printf("%s\n", res ? "OK" : "NG");
  return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

int dp[100010];
int main() {
	
	int n;
	cin >> n;
	int *h = new int[n+1];
	for (int i = 1; i < n+1; i++) {
		cin >> h[i];
	}
	h[0] = INT_MAX;
	for (int i = 2; i <= n; i++) {
		dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
		int temp = dp[i - 2] + abs(h[i] - h[i - 2]);
		if (temp < dp[i])dp[i] = temp;
	}
	cout << dp[n];



	return 0;
}


Measured memory_bytes: 1024
N, x = map(int, input().split())
a = list(map(int, input().split()))

y = min(a[0], x)
ans = a[0]-y
for i in range(1, N):
    z = a[i]
    w = max(y+z-x, 0)
    y = z-w
    ans += w

print(ans)

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

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

	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x)ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main(){
    int n;cin >> n;
    vector<int> a(n);
    map<int,int> ma;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ma[a[i]]++;
    }
    sort(ALL(a));
    a.erase(unique(ALL(a)),a.end());
    bool f=true;
    if(a.size()==1){
        if(a[0]!=0){
            f=false;
        }
    }
    else if(a.size()==2){
        if(2*ma[0]!=ma[a[1]]){
            f=false;
        }
    }
    else if(a.size()==3){
        if((a[0]^a[1]^a[2])!=0) f=false;
        if(ma[a[0]]!=ma[a[1]]||ma[a[0]]!=ma[a[2]]) f=false;
    }
    else{
        f=false;
    }
    cout << (f?"Yes":"No") << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum=0;
  int nu[N];
  for(int i=0;i<N;i++){
    cin >> nu[i];
    for(int j=0;j<i;j++){
      if(nu[i]==nu[j]){
        sum-=1;
        break;
      }
    }
    sum++;
  }
  cout << sum;
}


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

using namespace std;

typedef long long ll;

int main(){
    //俺は逃げない
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if (V <= W) {
        cout << "NO" << endl;
        return 0;
    }

    ll dis = abs(A - B);
    if (dis <= (V - W) * T) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func main(){
	var N int
	fmt.Scan(&N)
	d := make([] int, N)
	for i := range d {
		fmt.Scan(&d[i])
	}

	num := map[int]int{} 
	for i := range d{
		num[d[i]]++
	}
	fmt.Println(len(num))
}

Measured memory_bytes: 512
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
mod = 10**9 + 7
if n % 2 == 0:
    for i in a:
        if i % 2 == 0:
            print(0)
            exit()
    for i in c.values():
        if i != 2:
            print(0)
            exit()
    print(pow(2,n//2,mod))
if n % 2 == 1:
    for i in a:
        if i % 2 == 1:
            print(0)
            exit()
    if c[0]  == 1:
        c[0] = 2
    else:
        print(0)
        exit()
    for i in c.values():
        if i != 2:
            print(0)
            exit()
    print(pow(2,n//2,mod))


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

int main(){
  int n;cin>>n;
  map<int,int> m;
  
  for(int i=2;i<=n;i++){
    int a;cin>>a;
    m[a]++;
  }
  
  for(int i=1;i<=n;i++)cout<<m[i]<<endl;
}


Measured memory_bytes: 12940
#include<bits/stdc++.h>
using namespace std;
int a;
int main()
{
	cin>>a;
	int y=a/100;
	int m=a%100;
	if(y>0&&y<13)
	{
		if(m>0&&m<13) cout<<"AMBIGUOUS\n";
		else cout<<"MMYY"<<endl;
	}
	else
	{
		if(m>0&&m<13) cout<<"YYMM\n";
		else cout<<"NA"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
    long long sum;
  if(n>=k){  
  sum=accumulate(h.begin(),h.begin()+n-k,0LL);
  }
  else sum=0;
      cout<<sum<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;

#define X first
#define Y second
#define INF (INT_MAX/3-10)
typedef long double ld;


/*
input data
*/

int x,y,w,h;
vector<pair<int,int> > cats;

void init(){
  cats.clear();
}

bool input(){
  cin>>x>>y>>w>>h;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    cats.push_back(make_pair(a,b));
  }
}


/*
dp テ」ツ?ィテ」ツ??
*/

bool inside(pair<int,int> cat){
  if(!(cat.X<x||x+w<cat.X) && !(cat.Y<y||y+h<cat.Y)){
    return 1;
  }else {
    return 0;
  }
}

int solve(){
  int res=0;
  for(int i=0;i<cats.size();i++){
    if(inside(cats[i])){
      res++;
    }
  }
  return res;
}


int main(){
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    init(),input();
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1196
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

dists = list()
dists.append(a[0] - a[-1] + k)
for i in range(1, n):
    dists.append(abs(a[i] - a[(i - 1)]))
print(k - max(dists))


Measured memory_bytes: 32304
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  while (cin >> n) {
    if (n == 0) return 0;
    vector<int> dp(1 << n, 1 << 30);
    vector<vector<int>> in(n, vector<int>(n + 1));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= n; j++) {
        cin >> in[i][j];
      }
    }
    dp[0] = 0;
    for (int u = 0; u < (1 << n); u++) {
      for (int i = 0; i < n; i++) {
        if (u & (1 << i)) continue;
        dp[u | (1 << i)] = min(dp[u | (1 << i)], dp[u] + in[i][0]);
        for (int j = 0; j < n; j++) {
          if (u & (1 << j)) dp[u | (1 << i)] = min(dp[u | (1 << i)], dp[u] + in[i][j + 1]);
        }
      }
    }
    cout << dp[(1 << n) - 1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 3412
n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]
for i in range(1000):
    i = str(i)
    if len(i) != n:
        continue
    for [x, y] in lst:
        if i[x-1] != str(y):
            break
    else: 
        print(i)
        exit()

print(-1)
    


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

#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

void dump(vector<string> f, int x = -1, int y = -1) {
    REP(i, f.size()) {
        REP(j, f[i].size()) {
            if ( i == y && j == x )
                cout << "#";
            else
                cout << f[i][j];
        }
        cout << endl;
    }
}

/*
0:上
1:右
2:下
3:左
*/
int mx[] = {0, 1, 0, -1},
    my[] = {-1, 0, 1, 0};

vector< vector<int> > closed;

void go(vector<string> &f, int x, int y) {
    // dump(f, x, y);
    // cout << endl;

    while( f[y][x] != '.' ) {
        if ( closed[y][x] ) {
            cout << "LOOP" << endl;
            return;
        }
        closed[y][x] = 1;

        int mv = -1;

        switch(f[y][x]) {
            case '^':
                mv = 0;
                break;
            case '>':
                mv = 1;
                break;
            case 'v':
                mv = 2;
                break;
            case '<':
                mv = 3;
                break;
        }
        if ( mv != -1 ) {
            x += mx[mv];
            y += my[mv];
        }
        // dump(f, x, y); cout << endl;
    }
    cout << x << " " << y << endl;
}

int main() {
    int w, h;

    while( cin >> h >> w, w || h ) {
        vector<string> f(h);
        closed = vector< vector<int> >(h, vector<int>(w, 0));

        REP(i, h) {
            REP(j, w) {
                closed[i][j] = 0;
            }
        }

        REP(i, h) {
            cin >> f[i];
        }

        go(f, 0, 0);
    }

    return 0;
}

Measured memory_bytes: 1324
#include <cstdio>
using namespace std;

int main(){
	unsigned q, s;
	for(scanf("%u", &q); q--; ){
		scanf("%x", &s);
		int x = (s & 0x7fffffffu) >> 7;
		int y = (s & 0x7fu) * 78125;
		int d = 7;
		while(d > 1 && y % 10 == 0){
			y /= 10;
			--d;
		}
		
		if(s >> 31) putchar('-');
		printf("%d.%0*d\n", x, d, y);
	}
}

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

template <typename T>
class FenwickTree {
	const ll n;
	unordered_map<ll, T> data;
public:
	FenwickTree(ll n_, int pmax = 1e7) : n(n_), data(pmax) {}
	T find(ll p) {
		T res = 0;
		while (p >= 0) {
			res += data[p];
			p = (p & (p + 1)) - 1;
		}
		return res;
	}
	void add(ll p, T val) {
		while (p < n) {
			data[p] += val;
			p |= p + 1;
		}
	}
};

template <typename T>
class RARS {
	const ll n;
	FenwickTree<T> bit0, bit1;
public:
	RARS(ll n_) : n(n_), bit0(n), bit1(n) {}
	T find(ll p) {
		return bit1.find(p) * (p + 1) + bit0.find(p);
	}
	T find(ll l, ll r) {
		return find(r) - find(l - 1);
	}
	void add(ll l, ll r, T val) {
		bit0.add(l, -val * l);
		bit1.add(l, val);
		bit0.add(r + 1, val * (r + 1));
		bit1.add(r + 1, -val);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	RARS<ll> rars(n);
	for (int i = 0, type, s, t, x; i < q; i++) {
		cin >> type >> s >> t; s--; t--;
		if (type) {
			printf("%lld\n", rars.find(s, t));
		}
		else {
			cin >> x;
			rars.add(s, t, x);
		}
	}
	return 0;
}



Measured memory_bytes: 170536
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
using namespace std;
 
int main(){
  int n;
  string s;
  int t[10],hoge;
 
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    t[i] = 0;
    for(int j=0;j<n;j++){
      if(s[j] == 'o')t[i]++;
    }
  }
 
  int tmp = -1;
  for(int i=0;i<n;i++){
    if(t[i] == n-1)tmp = i;
  }
 
  bool f = false;
  if(tmp<0)f = true;
 
  srand((unsigned int)time(NULL));
  for(int i=0;i<1000;i++){
    if(f){
      do{
	tmp = rand()%n;
      }while(!t[tmp]);
    }
    printf("%d\n",tmp+1); fflush(stdout);
    scanf("%d", &hoge);
  }
}

Measured memory_bytes: 0
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var input = Reads();
            var n = input[0];
            var m = input[1];
            var first = new bool[n+1];
            var second = new bool[n+1];
            for (int i = 0; i < m; i++)
            {
                input = Reads();
                if (input[0] == 1) first[input[1]] = true;
                if (input[1] == n) second[input[0]] = true;
            }
            bool f = false;
            for (int i = 1; i <= n; i++)
            {
                if (first[i] && second[i]) f = true;
            }


            Console.WriteLine(f ? "POSSIBLE" : "IMPOSSIBLE");





            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 17628
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main(void) {
	
	int n;
	cin >>n;
	
	int l[n*2],i;
	for (i=0 ; i<n*2 ; i++) {
		cin >>l[i];
	}
	
	sort(l,l+n*2);
	int ans=0;
	for (i=0 ; i<n*2 ; i+=2) {
		ans+=l[i];
	}
	
	cout <<ans <<endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)

	aa := make([]int, n)
	max := make([]int, n)
	stones := make(Stones, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
		stones[i].a = aa[i]
		stones[i].i = i
		if i == 0 {
			continue
		}
		max[i] = max[i-1]
		if max[i] < aa[i-1] {
			max[i] = aa[i-1]
		}
	}
	sort.Sort(stones)
	sum := make([]int64, n+1)
	ss := make([]int64, n)
	for i := 0; i < n; i++ {
		sum[i+1] = int64(stones[i].a) + sum[i]
		ss[stones[i].i] = sum[i+1] - int64(stones[i].a)*int64(i+1)
	}

	ans := make([]int64, n)
	prev := -1
	var red int64
	for i := 0; i < n; i++ {
		if max[stones[i].i] >= aa[stones[i].i] {
			continue
		}
		if prev != -1 {
			ans[prev] = ss[stones[i].i] - red
			red += ans[prev]
		}
		prev = stones[i].i
	}

	ans[0] = sum[n] - red
	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, ans[i])
	}

	writer.Flush()
}

type Stone struct {
	a int
	i int
}

type Stones []Stone

func (a Stones) Len() int      { return len(a) }
func (a Stones) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a Stones) Less(i, j int) bool {
	return a[i].a > a[j].a
}


Measured memory_bytes: 8704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TPBC2019
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (x[0] < x[2] && x[2] < x[1] || x[0] > x[2] && x[2] > x[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    cout<<(min(b,d) - max(a,c) > 0 ? min(b,d) - max(a,c) : 0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(w,e) for(int w=0;w<e;w++)
int main(){
	int a,b,_a[100],_b[100],d,y,z;
	TOP:while(cin>>a>>b,a+b){
		y=z=0;r(i,a)cin>>_a[i],y+=_a[i];r(i,b)cin>>_b[i],z+=_b[i];
		if((d=y-z)%2!=0){cout<<"-1"<<endl;goto TOP;}d/=2;
		r(p,100)r(i,a)if(_a[i]==p)r(j,b)if(_b[j]==p-d){cout<<_a[i]<<" "<<_b[j]<<endl;goto TOP; }
		cout<<"-1"<<endl;
	}
}

Measured memory_bytes: 2980
#include<iostream>
#include<vector>
using namespace std;vector<vector<int> >a(11,vector<int>(330));void r(int n,int u,int s,int d){a[n][s]++;for(int i=10;i-->0;)if(!(u>>i&1))r(n+1,u^1<<i,s+d*i,d+1);}main(){r(0,0,0,1);for(int n,s;cin>>n>>s;)cout<<a[n][s]<<"\n";}

Measured memory_bytes: 0
fun main(args: Array<String>) {
    val (A, B) = readLine()!!.split(" ").map(String::toLong)
    val po = LongArray(42)
    po[0] = 1L
    for (i in 1 until 42) {
        po[i] = 2 * po[i-1]
    }
    var ans = 0L
    for (i in 0 until 41) {
        var le = 0L
        if (A > 0) {
            if (((A-1) and po[i]) != 0L) {
                le += (A-1) % po[i] + 1
            }
            le += ((A-1) / po[i+1]) * po[i]
        }
        var ri = 0L
        if((B and po[i]) != 0L) {
            ri += B % po[i] + 1
        }
        ri += (B / po[i+1]) * po[i]
        ans += ((ri - le) % 2) * po[i]
    }
    println(ans)
}

Measured memory_bytes: 38000
#include <iostream>
#include <cmath>

double cos_60 = std::cos(M_PI / 3);
double sin_60 = std::sin(M_PI / 3);

void koch_curve(int n, double start_x, double start_y, double end_x, double end_y) {
    //std::cout << start_x << " " << start_y << std::endl;
    if (n == 0) {
        return;
    }
    
    double grad_x = (end_x - start_x) / 3.0, grad_y = (end_y - start_y) / 3.0;
    double x_x = grad_x + start_x, x_y = grad_y + start_y;
    double u_x = x_x + grad_x * cos_60 - grad_y * sin_60,
        u_y = x_y + grad_x * sin_60 + grad_y * cos_60;
    double t_x = x_x + grad_x, t_y = x_y + grad_y;

    koch_curve(n - 1, start_x, start_y, x_x, x_y);
    std::cout << x_x << " " << x_y << std::endl;
    koch_curve(n - 1, x_x, x_y, u_x, u_y);
    std::cout << u_x << " " << u_y << std::endl;
    koch_curve(n - 1, u_x, u_y, t_x, t_y);
    std::cout << t_x << " " << t_y << std::endl;
    koch_curve(n - 1, t_x, t_y, end_x, end_y);
}


int main() {
    int n;
    std::cin >> n;

    std::cout << "0.0 0.0" << std::endl;
    koch_curve(n, 0.0, 0.0, 100.0, 0.0);
    std::cout << "100.0 0.0" << std::endl;
}



Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  ll n,k,s;
  cin>>n>>k>>s;
  ///////
  vector<ll> ans(n,s+1);
  rep(i,k){
    ans[i]=s;
    
  }
  if(s==1e9){
     
    ans.assign(n,1);
    rep(i,k){
     ans[i]=s; 
    }
      
    
    
    
    
    

  }
  rep(i,n){
   cout<<ans[i]<<" "; 
  }
}

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

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  int ans = 1;
  REP(i,n){
    if(ans==a[i]) ans++;
  }

  if(ans==1) cout << -1 << endl;
  else cout << n-(ans-1) << endl;
 
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int n, k;
    cin >> n >> k;
    cout << ( ( n%k == 0 ) ? 0 : 1 ) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int ans = 0;
        for (int i = 1; i <= n; i += 2) {
            int count = 0;
            for (int j = 1; j <= i; j += 2) {
                if (i % j == 0) {
                    count++;
                }
            }
            if (count == 8) {
                ans++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cmath>
#define INF 100000000
using namespace std;

int main(){
	int d[20][20];
	int n,m,s,g,v,p;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) d[i][j] = INF;
		d[i][i] = 0;
	}
	for(int i = 0;i < m;i++){
		int a,b,c,e;
		scanf("%d,%d,%d,%d",&a,&b,&c,&e);
		d[a - 1][b - 1] = c;
		d[b - 1][a - 1] = e;
	}
	for(int k = 0;k < n;k++){
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++) d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
		}
	}
	scanf("%d,%d,%d,%d",&s,&g,&v,&p);
	cout << v - p - (d[s - 1][g - 1] + d[g - 1][s - 1]) << endl;
	return 0;
}

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

P AB[100005];

int main()
{
	ll N,M;
	cin >> N >> M;
	int a,b;
	for (int i = 0; i < N; ++i)
	{
		cin >> a >> b;
		AB[i].first = a;
		AB[i].second = b;
	}
	//cout << "a" << endl;
	sort(AB,AB+N);
	//cout << "b" << endl;

	ll temp = M; //残り本数
	ll cnt = 0;
	ll ans = 0;
	while(1)
	{
		if (temp <= AB[cnt].second)
		{
			ans += AB[cnt].first * temp;
			cout << ans << endl;
			return 0;
		}
		else
		{
			temp -= AB[cnt].second;
			ans += AB[cnt].first * AB[cnt].second;
			cnt++;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N;
ll M;
ll P[1024];

int main(){
  while(scanf("%d%lld",&N,&M) && N+M){
    ll res = 0;
    rep(i,N) scanf("%lld", P+i);
    P[N] = 0;
    vector<ll>PP;
    rep(i,N+1) rep(j,N+1) PP.push_back(P[i]+P[j]);
    sort(PP.begin(), PP.end());
    PP.erase(unique(PP.begin(), PP.end()), PP.end());
    for(int i=0;i<PP.size();i++){
      if(PP[i] > M) continue;
      ll x = M-PP[i];
      ll last = *(--upper_bound(PP.begin(), PP.end(), x));
      if(PP[i]+last <= M) res =  max(res, PP[i]+last);
    }
    
    printf("%lld\n", res);
  }
  return 0;
}

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

int main() {
	int i, j, n, k;
	int h[100005];

	cin >> n >> k;
	for(i=0; i<n; i++) cin >> h[i];
	for(i=0; i<n; i++) {
		if(h[i] >= k) j++;
	}
	cout << j << endl;
	return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline

N,M,K=map(int,input().split())
mod=10**9+7

def Combi2(a,b):#aは大きいが、bは小さいとき
    if b>a:
        return 0
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)*pow(min(b,a-b)-i,mod-2,mod)%mod

    return ANS%mod

SUM_N=SUM_M=0
for i in range(N):
    SUM_N+=i*(N-i)

for i in range(M):
    SUM_M+=i*(M-i)

#print((SUM_N*(M**2)+SUM_M*(N**2))/Combi2(N*M,2)*Combi2(N*M,K)*K*(K-1)//2%mod)
print((SUM_N*(M**2)+SUM_M*(N**2))*pow(Combi2(N*M,2),mod-2,mod)*Combi2(N*M,K)*K*(K-1)*pow(2,mod-2,mod)%mod)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int abs(int x){
  if(x <=0) {
    return -x;
  }
  else {
    return x;
  }
 
}
int main(){
  int N,L;
  cin >>N>>L;
  vector<int> aji(N);
  for(int i=0;i<N;i++){
    aji.at(i) =L+i;
  }
  int total =0;
  for(int i=0;i<N;i++){
    total =total + aji.at(i);
  }
  int min =10000;
  for(int i =0;i<N;i++){
    if( abs(aji.at(i)) <= abs(min) ){
      min =aji.at(i);
    }
  }
  cout << total-min <<endl;
}


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

using namespace std;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a + b - mod * (a + b >= mod);
}

int mul(int a, int b) {
  return int(1ll * a * b % mod);
}

int pwr(int a, int x) {
  if (x == 0) {
    return 1;
  }
  return mul(pwr(mul(a, a), x >> 1), (x & 1 ? a : 1));
}

int dvd(int a, int b) {
  return mul(a, pwr(b, mod - 2));
}

int sub(int a, int b) {
  return a - b + mod * (a < b);
}

void inc(int& a, int b) {
  a = add(a, b);
}

void dec(int& a, int b) {
  a = sub(a, b);
}

const int N = 1e5 + 10, D = 110;
int dp[N][D][2];

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

  string s;
  int d;
  cin >> s >> d;
  for (char& c : s) {
    c -= '0';
  }
  int n = s.size();
  dp[0][0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      for (int k = 0; k < 2; ++k) {
        int r = (k ? 9 : s[i]);
        for (int t = 0; t <= r; ++t) {
          int nk = (t < s[i] ? 1 : k);
          inc(dp[i + 1][(j + t) % d][nk], dp[i][j][k]);
        }
      }
    }
  }
  cout << sub(add(dp[n][0][0], dp[n][0][1]), 1);

  return 0;
}

Measured memory_bytes: 10496
<?php
//$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
list($A,$V) = array_map('intval',explode(" ",trim(fgets(STDIN))));
list($B,$W) = array_map('intval',explode(" ",trim(fgets(STDIN))));
$T = (int)trim(fgets(STDIN));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$p = abs($B - $A);
$d = $V - $W;

if ($T * $d >= $p) {
  printf("YES\n");
}
else {
  printf("NO\n");
}


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

class Dice {
public:
    int face[6];

    Dice(int face1, int face2, int face3, int face4, int  face5, int face6) {
        face[0] = face1;
        face[1] = face2;
        face[2] = face3;
        face[3] = face4;
        face[4] = face5;
        face[5] = face6;
    }

    void move(char c) {
        if (c == 'N') {
            moveFace(1, 2, 6, 5);
        } else if (c == 'S') {
            moveFace(1, 5, 6, 2);
        } else if (c == 'W') {
            moveFace(1, 3, 6, 4);
        } else if (c == 'E') {
            moveFace(1, 4, 6, 3);
        }
    }

    void moveFace(int i1, int i2, int i3, int i4) {
        int tmp = face[i1 - 1];
        face[i1 - 1] = face[i2 - 1];
        face[i2 - 1] = face[i3 - 1];
        face[i3 - 1] = face[i4 - 1];
        face[i4 - 1] = tmp;
    }

    bool isSameDice(Dice d) {
        for (int i = 0; i < 4; i++) {
            move('N');
            for (int j = 0; j < 4; j++) {
                move('W');
                for (int k = 0; k < 4; k++) {
                    move('N');
                    bool isSame = true;
                    for (int l = 0; l < 6; l++) {
                        if (face[l] != d.face[l]) isSame = false;
                    }

                    if (isSame) return true;
                }
            }
        }

        return false;
    }
};

int main() {
    int face1, face2, face3, face4, face5, face6;
    cin >> face1 >> face2 >> face3 >> face4 >> face5 >> face6;
    Dice d1(face1, face2, face3, face4, face5, face6);
    cin >> face1 >> face2 >> face3 >> face4 >> face5 >> face6;
    Dice d2(face1, face2, face3, face4, face5, face6);

    cout << (d1.isSameDice(d2) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1160
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 998244353;

int n,m,b[li],a[li],k,flag,t;
int cev=1;
string s;
vector<int> v;

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

inline int mul(int x,int y){
	return (x%mod)*(y%mod)%mod;
}

inline int fp(int x,int y){
	if(y==0)return 1;
	if(y==1)return x;
	t=fp(x,y/2);
	t=mul(t,t);
	if(y%2==1)t=mul(t,x);
	return t;
}

main(void){
	//~ cout
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
		b[a[i]]++;
	}
	int say=1,mx=0;
	if(b[0]!=1 || a[1]!=0){printf("0\n");return 0;}
	for(int i=1;i<=n+2;i++){
		if(b[i]!=0 && b[i-1]==0){printf("0\n");return 0;}
		cev=mul(cev,fp(say,b[i]));
		say=b[i];
		//~ cout<<fp(0,0)<<endl;
		//~ cout<<cev<<endl;
	}
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    double a, b;
    cin >> a >> b;
    double h, m;
    cin >> h >> m;
    cout << setprecision(14);
    double r = (h / 12 + m / 12 / 60) * 360;
    double t = m / 60 * 360;
    double rad = max(r, t) - min(r, t);
    rad *= 3.141592653589 / 180;
    double c2 = a*a + b*b - 2*a*b*cos(rad);
    cout << sqrt(c2) << endl;
    
}

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

int main(){
	string s;
	cin >> s;
	if(s[0] == s[s.size() - 1]){
		if(s.size() % 2 == 0) cout << "First" << endl;
		else cout << "Second" << endl;
	}else{
		if(s.size() % 2 == 0) cout << "Second" << endl;
		else cout << "First" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
            int r = Integer.parseInt(sc.next());
            double pi = Math.PI;

            System.out.println(2 * (double)r * pi);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N;
  ll T;
  cin >> N >> T;
  vector<ll> a(N), b(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
    b[i] += a[i] + 1;
    a[i] += 1;
  }
  vector<P> ls;
  vector<ll> add;
  for (int i = 0; i < N; i++) {
    if (a[i] == 1)
      add.push_back(b[i]);
    else
      ls.emplace_back(a[i], b[i]);
  }
  sort(all(add));
  for (int i = 1; i < add.size(); i++) add[i] += add[i - 1];
  sort(all(ls), [](const P &a, const P &b) {
    return (1 - a.first) * b.second < (1 - b.first) * a.second;
  });
  dmp(add);
  dmp(ls);
  int M = ls.size();
  vector<vector<ll>> dp = vect(M + 1, vect(40, LLINF));
  dp[0][0] = 0ll;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 40; j++) {
      if (dp[i][j] == LLINF) continue;
      chmin(dp[i + 1][j], dp[i][j]);
      if (dp[i][j] < T / ls[i].first + 5)
        chmin(dp[i + 1][j + 1], ls[i].first * dp[i][j] + ls[i].second);
    }
  }
  int ans = 0;
  for (int i = 0; i < 40; i++) {
    if (dp[M][i] > T) continue;
    chmax(ans, i + (int)(upper_bound(all(add), T - dp[M][i]) - add.begin()));
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 77292
#include<stdio.h>

int main(void) {
    int W, H, x, y, r;
    
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    if(W >= x + r && x - r >= 0) {
        if(H >= y + r && y - r >= 0) {
            printf("Yes\n");
        }
        else {
            printf("No\n");
        }
    }
    else {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
ll N, M, V, P;
bool check(vector<ll> A, ll index) {
    if (index < P) {
        return true;
    } else {
        if (V - 1 <= P - 1) {
            if (A[index] + M >= A[P - 1]) {
                return true;
            } else {
                return false;
            }
        } else {
            if ((V - 1) - (P - 1) <= (N - 1) - index) {
                if (A[index] + M >= A[P - 1]) {
                    // cout << " 1" << endl;
                    return true;
                } else {
                    // cout << " 2" << endl;
                    return false;
                }
            } else {
                ll left = (V - 1) - (P - 1) - ((N - 1) - index);
                ll under = A[index] + M;
                ll sum = 0;
                bool flag = true;
                FOR(j, P - 1, index) {
                    if (under - A[j] >= 0) {
                        sum += under - A[j];
                    } else {
                        flag = false;
                    }
                }
                // printf(" left:%d, under:%d, sum:%lld\n", left, under, sum);
                if (flag && (sum >= left * M)) {
                    // cout << " 3" << endl;
                    return true;
                } else {
                    // cout << " 4" << endl;
                    return false;
                }
            }
        }
    }
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    REP(i, N) { cin >> A.at(i); }
    sort(ALL(A), greater<ll>());
    // REP(i, N) { cout << A[i] << " "; }
    // cout << endl;
    ll l = 0;
    ll r = N;

    while (r - l > 1) {
        ll mid = (r + l) / 2;
        // printf("l:%d, mid:%d, r:%d\n", l, mid, r);
        if (check(A, mid)) { // [l,mid)
            l = mid;
        } else {
            r = mid;
        }
    }
    /*
        REP(i, N) {
            printf("i:%d\n", i);
            bool tmp = check(A, i);
            printf(" check:%d\n", tmp);
        }
    */
    cout << l + 1 << endl;

    return 0;
}


Measured memory_bytes: 1792
#Aの上からi冊、Bの上からj冊をとりi+jを条件を満たしながら最大化したい
#累積和と二分探索の練習問題
#値を固定するという概念。iが決まればjが決まる
from bisect import bisect_left
from itertools import accumulate
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]+list(accumulate(a))
B=[0]+list(accumulate(b))

ans=0
sup_i=bisect_left(A,k+1)
for i in range(sup_i):
  ans=max(ans,i+bisect_left(B,k-A[i]+1)-1)
 
print(ans)




Measured memory_bytes: 50692
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
    int N = 0;
    int X = 0;
    cin >> N >> X;

    vector<int> Ls;
    Ls.reserve(N);
    for(int i = 0; i < N; i++) {
        int L = 0;
        cin >> L;
        Ls.push_back(L);
    }

    int bound_count = 1;
    int Di = 0;
    for(auto L : Ls) {
        int Dnext = Di + L;
        if(X < Dnext) {
            break;
        }
        Di = Dnext;
        bound_count++;
    }
    cout << bound_count << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
			int n, x;
			while(true){
				String buf = br.readLine();
				String[] line = buf.split(" ");
				n = Integer.parseInt(line[0]);
				x = Integer.parseInt(line[1]);
				if(n == 0 && x == 0)break;
			

			int count = 0;
			for(int i= 1;i <= n-2;i++){
				for(int j = i+1; j <=n-1;j++){
					for(int k = j+1; k <=n;k++){
						if(i + j + k == x){
							count += 1;
						}
					}
				}
			}
			System.out.println(count);
			}
		}catch (Exception e){
		}
	}
}
				

Measured memory_bytes: 25360