akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define SWAP(x, y) do { char z = y; y = x; x = z; } while (0)
int main(void)
{
    double x,y,x2,y2;
    cin>>x>>y>>x2>>y2;
    double r = sqrt((x-x2)*(x-x2)+(y-y2)*(y-y2));
    cout<<fixed<<setprecision(15)<<r<<endl;
}



Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    --a[i];
  }
  vector<bool> used(n);
  used[0] = true;
  int cnt = 0, now = 0;
  while (true) {
    now = a[now];
    cnt++;
    if (used[now])
      break;
    else
      used[now] = true;
    if (used[1]) {
      cout << cnt << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
using namespace std;

const int N=2010;
struct Edge{int to,next;} e[N];
int h[N],sum=0;
int deg[N],a[N],n;
bool vis[N];

void add_edge(int u,int v)
{
	e[++sum].to=v;
	e[sum].next=h[u];
	h[u]=sum;
}

void dfs(int u)
{
	vis[u]=1;
	for(int i=1;i<=n;i++)
		if(!vis[i]&&__gcd(a[u],a[i])!=1)
			dfs(i),add_edge(u,i),deg[i]++;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++)
		if(!vis[i]) dfs(i);
	memset(vis,0,sizeof(vis));
	for(int T=1;T<=n;T++)
	{
		for(int i=n;i>=0;i--)
			if(!vis[i]&&!deg[i])
			{
				printf("%d ",a[i]);
				vis[i]=1;
				for(int tmp=h[i];tmp;tmp=e[tmp].next)
					deg[e[tmp].to]--;
				break;
			}
	}
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

#define NO { cout << "No\n"; exit(0); }
#define YES { cout << "Yes\n"; exit(0); }

int main() {
  int N; cin >> N;
  vector<int64_t> a(N); cin >> a;
  vector<int64_t> b(N); cin >> b;
  int64_t acnt = 0;
  rep(i, a.size()) {
    if (a[i] < b[i]) {
      auto num = (b[i] - a[i] + 1) / 2;
      a[i] += 2LL * num;
      acnt += num;
    }
  }

  int64_t bcnt = 0;
  rep(i, b.size()) {
    if (b[i] < a[i]) {
      auto num = a[i] - b[i];
      b[i] += num;
      bcnt += num;
    }
  }

  if (acnt < bcnt) NO;
  YES;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, k;
    cin >> n >> k;

    vector<int64_t> a;
    int64_t s = 0;
    for (auto i : irange(0L, n)) {
        int64_t aa;
        cin >> aa;
        if (aa < k) {
            a.push_back(aa);
            s += aa;
        }
    }

    sort(a.rbegin(), a.rend());

    bitset<5000> bs;
    bs[0] = true;
    int64_t ans = 0;
    for (auto aa : a) {
        auto r = irange(max(k - s, 0L), k);
        bool ok = any_of(r.begin(), r.end(), [&](int64_t i) { return bs[i]; });
        if (!ok) {
            ++ans;
        }

        bs |= (bs << aa);
        s -= aa;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
#define ld long double
#define pb push_back
#define mk make_pair
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
using namespace std;

int main(){
    ll s, w;
    cin >> s >> w;
    if(w >= s)
        cout << "unsafe";
    else
        cout << "safe";
}


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

const int mod = 998244353;
int GM(int x){
    return x >= mod? x-mod : x;
}

int main()
{
    int n ,s ,ans = 0 ,dp[3001] = {0};
    scanf("%d%d",&n,&s);
    for(int a,i=0; i<n; i++){
        scanf("%d",&a);
        for(int j=s; j>=a; j--)
            dp[j] = GM(dp[j]+dp[j-a]);
        dp[a] = GM(dp[a]+i+1);
        ans = GM(ans+dp[s]);
    }
    printf("%d\n",ans);
}


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

int main(){
  int N;
  cin >> N;
  vector<int> cnt(1e6);
  long long ans = 0;
  for(int i = 0; i < N; ++i){
    int a;
    cin >> a;
    ++cnt[a];
    ans += a;
  }
  int Q;
  cin >> Q;
  while(Q--){
    long long b, c;
    cin >> b >> c;
    ans -= b*cnt[b];
    ans += c*cnt[b];
    cnt[c] += cnt[b];
    cnt[b] = 0;
    cout << ans << "\n";
  }
}


Measured memory_bytes: 7212
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int xx = sc.nextInt();
		int yy = sc.nextInt();
	
		if(xx>=yy) {
			System.out.println("War");
			sc.close();
			return;
		}
		
		int max_x=-100;
		int min_y=100;
		
		for(int i=0;i<n;i++) {
			max_x = Math.max(max_x, sc.nextInt());
		}
		for(int i=0;i<m;i++) {
			min_y = Math.min(min_y, sc.nextInt());
		}
		
		if(max_x>= min_y) {
			System.out.println("War");
			sc.close();
			return;
		}
		
		for(int z=yy;z>xx;z--) {
			if(z <= min_y && z > max_x) {
				System.out.println("No War");
				sc.close();
				return;
			}
		}

		System.out.println("War");
		
		sc.close();
	}

}				

Measured memory_bytes: 23764
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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; }

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


ll gcd(ll a,ll b){
    if(b ==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g =gcd(a,b);
    return a/g*b;
}


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;

    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c) cout<<"Yes"<<endl;
    else if(a!=b&&b==c) cout<<"Yes"<<endl;
    else if(a==c&&a!=b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        List<Integer> integers = new ArrayList<>();
        try (Scanner scanner = new Scanner(System.in)) {
            while (scanner.hasNextInt()) {
                integers.add(scanner.nextInt() + scanner.nextInt());
            }
        }
        integers.stream()
        .map(Main::toDigitNumber)
        .forEach(System.out::println);
    }

    private static long toDigitNumber(int n) {
        return Arrays.stream(String.valueOf(n).split("")).count();
    }
}

Measured memory_bytes: 32404
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 100005;
const int MM = 1000000007;

ll N, L, T;
ll X[MX*2], W[MX*2];
ll ans[MX*2];

ll norm(ll x){ return (x%L+L) % L; }
ll dist(ll x, ll y){
	if( x == y ) return L;
	return norm(y-x);
}

ll go(ll t){
	int ch = 0;
	for(int i = 0; i < N; i++){
		if( W[0] != W[i] ) ch = 1;
	}
	if( ch == 0 ) return norm(X[0] + (W[0] == 1?t : -t));

	queue<ll> Q[3];
	ll cur = X[0], dir = W[0], tm = 0;
	for(int i = 1; i <= N-1; i++){
		if( W[i] == 2 ) Q[2].push(X[i]);
	}
	for(int i = N-1; i >= 1; i--){
		if( W[i] == 1 ) Q[1].push(X[i]);
	}
	while(t > tm){
		if( dir == 1 ){
			ll p = Q[2].front(); Q[2].pop();
			ll c = norm(p - tm), dt = dist(cur, c) / 2;
			tm += dt;
			p = norm(c - dt);
			cur = norm(cur + dt);
			
			Q[1].push(p - tm);
		}
		else{
			ll p = Q[1].front(); Q[1].pop();
			ll c = norm(p + tm), dt = dist(c, cur) / 2;
			tm += dt;
			p = norm(c + dt);
			cur = norm(cur - dt);

			Q[2].push(p + tm);
		}
		dir = 3-dir;
	}
	if( dir == 2 ) cur = norm(cur-tm+t);
	if( dir == 1 ) cur = norm(cur+tm-t);
	return cur;
}

int main()
{
	scanf("%lld%lld%lld", &N, &L, &T);
	for(int i = 0; i < N; i++) scanf("%lld%lld", X+i, W+i), X[i] *= 4;
	L *= 4; T *= 4;
	T--;

	ll x = go(L);
	ll nxt = 0;
	for(int i = 0; i < N; i++) if( x == X[i] ) nxt = i;

	ll st = (ll)(N-nxt) * (T/L) % N;
	ll y = go(T%L);

	for(int i = 0; i < N; i++){
		if( W[i] == 1 ) X[i] = ((ll)X[i] + T%L) % L;
		else X[i] = ((ll)X[i] - T%L + L) % L;
	}
	sort(X, X+N); 
	for(int i = 0; i < N; i++) if( X[i] == y ) nxt = i;

	for(int i = 0; i < N; i++){
		ans[(st+i)%N] = X[(nxt+i)%N];
	}
	for(int i = 0; i < N; i++){
		if( ans[i]%4 == 1 ) ans[i] = norm(ans[i]-1);
		else ans[i] = norm(ans[i]+1);
		printf("%lld\n", ans[i] / 4);
	}
}


Measured memory_bytes: 4672
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    ll a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if (v<=w)
        cout<<"NO\n";
    else{
        ll m=abs(a-b);
        if (m/(v-w)+(m%(v-w)!=0)<=t)
            cout<<"YES\n";
        else
            cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 3692
N = int(input())
S =  {}
count_max = 0
for i in range(0, N):
  si = input()
  if si in S:
    S[si] = S[si] + 1
  else:
    S[si] = 1
  if S[si] > count_max:
    count_max = S[si]

arr = []
for k in S:
  if S[k] == count_max:
    arr.append(k)
    
arr.sort()
print(*arr, sep='\n')

Measured memory_bytes: 34012
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	int l=1,r=m+1;
	while(l<r)
	{
		printf("%d %d\n",l,r);
		l++,r--;
	}
	l=m+2,r=m+m+1;
	while(l<r)
	{
		printf("%d %d\n",l,r);
		l++,r--;
	}
	return 0;
}

Measured memory_bytes: 3872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int P = sc.nextInt();

		int ans = (A*3+P)/2;

		System.out.println(ans);

	}

}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long t[100010];
long long p;
struct P
{
    long long x,y;
}He[100010];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>t[i];
    }
    cin>>m;
    for(int i=1;i<=m;i++)
    {
        cin>>He[i].x>>He[i].y;
    }
    for(int i=1;i<=m;i++)
    {
        long long sum=0;
        for(int j=1;j<He[i].x;j++)
        {
            sum+=t[j];
        }
        sum+=He[i].y;
        for(int j=He[i].x+1;j<=n;j++)
        {
            sum+=t[j];
        }
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
<?php
$n = (int)trim(fgets(STDIN));

$station=[];
for ($i=1; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$station[$i]=[
		'next' => (int)$input[0],
		'start' => (int)$input[1],
		'interval' => (int)$input[2],
	];
}

$result = [];
for ($i=1; $i <= $n; $i++) { 
	if ($i === $n) {
		$result[] = 0;
		continue;
	}
	$cur = $station[$i];
	$time = $cur['start']+$cur['next'];
	for ($j=$i+1; $j < $n; $j++) { 
		$dest = $station[$j];
		if ($time < $dest['start']) {
			$time = $dest['start'] + $dest['next'];
		}else{
			if ($time % $dest['interval'] === 0) {
				$wait = 0;
			}else{
				$wait = $dest['interval'] - $time % $dest['interval'];
			}
			$time += $wait + $dest['next'];
		}
	}
	$result[] = $time;
}

echo implode(PHP_EOL, $result);

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
int m,n;
int a[51],b[51];
bool visit[51];
bool graph[50][50]={0};
void dfs(int pos){
    visit[pos]=true;
    for(int i=0;i<n;i++){
        if(visit[i])continue;
        if(graph[pos][i])dfs(i);
    }
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    int ans=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++)visit[j]=0;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
        dfs(0);
        bool flag=false;
        for(int j=0;j<n;j++){
            if(!visit[j]){
                flag=true;
            }
        }
        if(flag)ans++;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    map<int,int> m;
    m[a]++;
    m[b]++;
    m[c]++;
    cout << m.size() << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	long long a , b,c;
	cin>>a>>b>>c;
	long long count=0;
	long long flag=0;
	long long flag1=0;
	while(1){
	long long	temp1=a;
	long long	temp2=b;
	long long	temp3=c;
		if((temp2+temp3)%2 || (temp1+temp2)%2 ||(temp1+temp3)%2)break;
		if(temp1==temp2&&temp2==temp3&&temp1==temp3){if(temp1%2==0){flag=1;}else flag1=1;break;}
		a=(temp2+temp3)/2;
		b=(temp1+temp3)/2;
		c=(temp1+temp2)/2;
		count++;
		
	}
	if(flag==1)
	cout<<"-1";
	else if(flag1==1)cout<<"0";
	else cout<<count;
	return 0;
}

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


using namespace std;

int main() {
  int N;
  string S;
  cin >> N>> S;
  vector<int> vec(N,0);
  int sum = 0,ans = 2000000,temp;
  for(int i = 0; i < N; i++) {
    if(S.at(i) == '#') {
      sum++;
    }
    vec.at(i) = sum;
  }

  for(int i = 0; i < N + 1; i++) {
    if(i == 0) {
      temp = N - vec.at(N-1);
    }
    else{
      temp = vec.at(i-1) * 2 + N - i - vec.at(N-1);
    }

    ans = min(temp,ans);
  }

  cout << ans << endl;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=0,sum=0,kill=0;

    int n,k;
    cin >>n>>k;

    vector<ll> h(n,0);
    
    rep(i,n){
        cin>>h[i];
        sum += h[i];
    }

    sort(all(h),greater<ll>());

    rep(i,min(k,n)){
        kill += h[i];
        //db2(i,h[i]);ln;
    }

    ans = sum-kill;

    //db2(sum,kill);ln;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<ans<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

long long GCD(long long a,long long b){return b ? GCD(b,a%b): a;}

int main(){
    long long N,M;cin>>N>>M;
    vector<long long>a(N);
    long long c=1;
    for(int i=0;i<N;i++ )cin>>a[i];
    for(int i=0;i<N;i++){
     c=(c*a[i]/GCD(a[i],c));
    }
    //cout<<c<<endl;
    bool count=true;
    for(int i=0;i<N;i++){
        //cout<<a[i]<<" hi"<<endl;
        if((c/a[i])%2==0) {
            count=false; 
            //cout<<(c/2)/a[i]<<endl;
        }
    }
    if(count==false)cout<<0<<endl;
    else{
        long long cc=c/2;
        long long ans;
        if(cc>M) ans=0;
        else ans=(M-cc)/c+1;
        cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
  int H, W;
  cin >> H >> W;
  int cnt = 1;
  while (!(0 == H && 0 == W)) {
    REP(i,H) {
      REP(j,W) {
        if (0 == (i + j)) {
          cout << '#';
          continue;
        }
        else if (1 == (i + j) % 2) cout << '.';
        else cout << '#';
      }
      cout << '\n';
    }
    cout << '\n';
    cin >> H >> W;
  }
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<int>left(N,0);
  vector<int>right(N,0);
  for(int i=1;i<N;i++)left[i]=max(left[i-1],A[i-1]);
  for(int i=N-1;i>=1;i--)right[i-1]=max(right[i],A[i]);
  for(int i=0;i<N;i++)cout<<max(left[i],right[i])<<endl;
}

Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;


int main() {
    string s;
    string t;
    cin >> s >> t;
    cout << t << s;
}

Measured memory_bytes: 256
N,x = map(int,input().split())
A = list(map(int,input().split()))
answer = 0
while x > 0  :
    A = sorted(A)
    if x < A[0] :
        break
    x = x - A[0]
    answer += 1
    A.pop(0)
    if len(A) == 0 :
        if x != 0 :
            answer -= 1
        break
print(answer)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    string s;
    int x, y, z, t;
    x = y = z = t = 0;
    cin >> s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'N') x++;
        else if(s[i] == 'W') t++;
        else if(s[i] == 'S') y++;
        else z++;
    }
    if((x  && y  || (!x && !y)) && (!z && !t || (z && t))) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	string S;
	cin >> S;
	N = S.size();
	vector< int > A(N + 1);
	rep(i, N) A[i + 1] = S[i] - '0';
	if (A[1] == 0 || A[N - 1] == 0 || A[N] == 1) {
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1; i <= N / 2; i++) {
		if (A[i] != A[N - i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	int p = 1;
	int i = N - 1;
	vector< pii > ans;
	while (i >= 1) {
		while (A[i] == 0)
			i--;
		int M = N - p;
		for (int k = 0; k <= M - i; k++) {
			ans.emplace_back(p, p + k + 1);
		}
		//cout << p << " " << M << " " << i << endl;
		p = p + M - i + 1;
		i--;
	}
	rep(i, N - 1) cout << ans[i].first << " " << ans[i].second << endl;

	return 0;
}

Measured memory_bytes: 4080
#include <stdio.h>
int main(void){
    int n,k,x,cnt=0;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(x>=k) cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int k = in(), x = in();
  for (int i=x-k+1; i<x+k-1; i++) cout << i << " ";
  cout << x+k-1 << endl;
  return 0;
}


Measured memory_bytes: 256
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var K = one[1];
	var list = nextIntArray();
	var output = Math.pow(10,16);
	if(K == 1){
		myout(0);
		return;
	}
	for(var i = 0; i < (1 << N); i++){
		var sum = 0;
        var maxH = 0;
        var selected = 0;
		for(var j = 0; j < N; j++){
			if((i & (1 << j)) != 0){
                selected++;
				if(maxH >= list[j]){
                  sum += maxH - list[j] + 1;
                  maxH++;
                }
			}
            maxH = Math.max(list[j], maxH);
		}
		if(selected >= K){
			output = Math.min(output, sum);
		}
	}
	myout(output);
}


Measured memory_bytes: 33252
# https://atcoder.jp/contests/abc054/tasks/abc054_c
# なんか水パフォだけど全探索するだけ

import sys
read = sys.stdin.readline


from itertools import permutations


def read_ints():
    return list(map(int, read().split()))


N, M = read_ints()
from collections import defaultdict
graph = defaultdict(lambda: [])
for m in range(M):
    a, b = read_ints()
    graph[a].append(b)
    graph[b].append(a)


def is_ok(p):  # 順序pにしたがってグラフがつながっているか
    for now, nx in zip(p, p[1:]):
        if nx not in graph[now]:
            return 0
    return 1


ans = 0
for perm in permutations(range(2, N + 1)):
    perm = [1] + list(perm)
    ans += is_ok(perm)

print(ans)


Measured memory_bytes: 3316
/*
	The Islad Was Silent before.
	.....
	And One day again it became Silent.
*/
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ioso ios_base::sync_with_stdio(0),cin.tie(0);
#define ffe freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);cin.tie(0);

int main() {
	#ifndef ONLINE_JUDGE
	ffe
	#endif
	string a,b;
	cin >> a >> b;

	for(int i=0;i<a.length();i++) {
		if(a[i]!=b[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes\n";	
	
} 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n,m; cin>>n>>m;
    vector<int> a(m);
    rep(i,0,m) cin>>a[i];
    int sum=0;
    rep(i,0,m) sum+=a[i];
    if(n-sum<0){
        cout<<-1<<endl;
        return 0;
    }else{
        cout<<n-sum<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, m;
    cin >> n >> m;
    vector<lint> a(m);
    lint tot = 0;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
        tot += a[i];
    }
    if (tot > n)
        cout << -1 << "\n";
    else
        cout << n - tot << "\n";
    return 0;
}

Measured memory_bytes: 3692
open Batteries
open Printf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> BatString.split_on_char ' '
  |> List.map cnv

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let (n, k) = scan "%d %d" BatTuple.Tuple2.make
let ps = scan_list float_of_string

let exp n = n *. (n +. 1.0) /. 2.0 /. n

let hold_max (m, p) (x, y) =
  let n = p -. x +. y in
  (BatFloat.max m n, n)

let () =
  let sums = List.map exp ps in
  let init = BatList.fsum @@ BatList.take k sums in
  BatList.fold_left hold_max (init, init) (zip sums @@ BatList.drop k sums)
  |> BatTuple.Tuple2.first
  |> printf "%f\n"


Measured memory_bytes: 37760
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc = new FastScanner();
		int N=sc.nextInt();
		long[] L=new long[N];
		for (int i=0;i<N;++i) {
			L[i]=sc.nextLong();
		}
		int ans=0;
		Arrays.sort(L);
		for (int i=0;i<N;++i) {
			for (int j=i+1;j<N;++j) {
				for (int k=j+1;k<N;++k) {
					if (L[i]==L[j]||L[j]==L[k]) continue;
					if (L[i]+L[j]>L[k] && L[i]+L[k]>L[j] && L[j]+L[k]>L[i]) ++ans;
				}
			}
		}
		System.out.println(ans);
	}
	
	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}


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

ll mincost=INT_MAX;
void func(int idx, vector<ll> &c, vector<vector<ll>> &a, vector<ll> cost_ar, ll cost, ll n, ll m, ll x){
	if(idx==n){
		bool flag=true;
		for(auto a:cost_ar){
			if(a<x){
				flag=false;
				break;
			} 
		}
		if(flag) {
			mincost=min(mincost, cost);
			return;
		}
		return;
	}
	//Not choose
	func(idx+1, c, a, cost_ar, cost, n, m, x);
	
	//Choose
	cost+=c[idx];
	for(ll i=0;i<m;i++){
		cost_ar[i]+=a[idx][i];
	}
	func(idx+1, c, a, cost_ar, cost, n, m, x);
}

int main() {
	// your code goes here
	ll n, m, x;
	cin>>n>>m>>x;
	vector<ll> c(n);
	vector<vector<ll>> a(n,vector<ll>(m));
	for(ll i=0;i<n;i++){
		cin>>c[i];
		for(ll j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	vector<ll> cost_ar(m, 0);
	func(0, c, a, cost_ar, 0, n, m, x);
	if(mincost==INT_MAX) mincost=-1;
	cout<<mincost<<endl;
	
	return 0;
}

Measured memory_bytes: 3636
class UnionFind:
  r = None
  
  def __init__(self, n):
    self.r = list(range(n))
    
  def root(self, x):
    if(x == self.r[x]): return self.r[x]
    else: 
      self.r[x] = self.root(self.r[x])
      return self.r[x]
  
  def unite(self, x, y):
    if(self.root(x) == self.root(y)): return False
    else: self.r[self.root(x)] = self.root(y)
  
  def same(self, x, y):
    return (self.root(x) == self.root(y))
    
N, Q = list(map(int, input().split()))
UF = UnionFind(N)
for i in range(Q):
  t, u, v = list(map(int, input().split()))
  if(t == 0): UF.unite(u,v)
  else: print(int(UF.same(u,v)))

Measured memory_bytes: 88784
#include<bits/stdc++.h>
using namespace std;
const int N=1006;
int n,m,t,a[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&t),++a[t],m=max(m,t);
	for(int i=m/2+1;i<=m;++i) if(a[i]<2){printf("Impossible"); return 0;}
	if(m%2==0){if(a[m/2]!=1){printf("Impossible"); return 0;}a[m/2]=0;}
	else{if(a[m/2+1]!=2){printf("Impossible"); return 0;}}
	for(int i=1;i<=m/2;++i) if(a[i]){printf("Impossible"); return 0;}
    printf("Possible");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=5e5+10,mo=1e9+7;
int tr[N*4];
int f[N];
struct aa
{
	int x,y,id;
}a[N],b[N];
bool cmp2(aa x,aa y)
{
	return x.x<y.x;
}
bool cmp1(aa x,aa y)
{
	return x.y<y.y;
}
bool cmp3(aa x,aa y)
{
	return x.y<y.y||(x.y==y.y&&x.x<y.x);
}
void change(int rt,int l,int r,int x,int y)
{
	if (l==r)
	{
		tr[rt]=tr[rt]+y;
		if (tr[rt]>=mo) tr[rt]=tr[rt]-mo;
		return;
	}
	int mid=l+r>>1;
	if (x<=mid) change(rt<<1,l,mid,x,y);else change(rt<<1|1,mid+1,r,x,y);
	tr[rt]=tr[rt<<1]+tr[rt<<1|1];
	if (tr[rt]>=mo) tr[rt]=tr[rt]-mo;
}
int query(int rt,int l,int r,int x,int y)
{
	if (l>=x&&r<=y) return tr[rt];
	int mid=l+r>>1;
	int ret=0;
	if (x<=mid) ret=(ret+query(rt<<1,l,mid,x,y))%mo;
	if (y>mid) ret=(ret+query(rt<<1|1,mid+1,r,x,y))%mo;
	return ret;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y);
	sort(a+1,a+n+1,cmp1);
	for (int i=1;i<=n;i++) a[i].id=i;
	sort(a+1,a+n+1,cmp2);
	int gg=n+1;
	for (int i=n;i>=1;i--)
	{
		gg=min(gg,a[i].id);
		b[a[i].id].x=gg;
	}
	gg=0;
	for (int i=1;i<=n;i++)
	{
		gg=max(a[i].id,gg);
		b[a[i].id].y=gg;
	}
	sort(b+1,b+n+1,cmp3);
	int ans=0;
	for (int i=1;i<=n;i++)
	{
		if (b[i].x==1) f[i]++;
		f[i]=f[i]+query(1,1,n,max(b[i].x-1,1),b[i].y);
		if (f[i]>=mo) f[i]=f[i]-mo;
		change(1,1,n,b[i].y,f[i]);
		if (b[i].y==n) ans=ans+f[i];
		if (ans>=mo) ans=ans-mo;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//STANDARD DATA TYPES
#define ll long long
#define llu unsigned long long
#define ld long double
//ADV DATA TYPES
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
//C ++ DS
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define all(x) x.begin(),x.end()

//priority_queue < pii, vector < pii >, greater < pii > > pq;
//lower_bound(v.begin(),v.end(),20);//for any sorted container
//CONSTANTS
#define MOD 998244353
#define INF 0x3f3f3f3f
#define MAXN (int)(1e5+1)
//MOD OPERATIONS
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
inline ll addmod(ll a, ll val, ll p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline ll submod(ll a, ll val, ll p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline ll mult(ll a, ll b, ll p = MOD) {return (ll) a * b % p;}
//DEBUG
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
int main()
{
	fastio;
	int n,k;
	cin>>n>>k;
	vi a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	vector <bool> dp(MAXN);
	for(int i=0;i<=k;i++)
	{
		for(auto u:a)
		{
			if(i>=u && !dp[i-u])
			{
				dp[i]=true;
			}
		}
	}
	cout<<(dp[k]?"First":"Second")<<endl;	
}


Measured memory_bytes: 256
MOD = 1000000007

fact = [0 for i in range(100001)] # fact[i] = i! mod MOD
inv_fact = [0 for i in range(100001)] # inv_fact[i] = i!のmod MODでの逆元
 
# aのn乗をPで割った余りを求めるよ
def mod_pow(a, n, P):
	if n == 0: # aの0乗は1（それはそう）
		return 1
	if n%2 == 0: # aの4乗は（aの2乗）の2乗、みたいなノリ
		x = mod_pow(a, n/2, P)
		return (x*x)%P
	# aの5乗はa×（aの4乗）、みたいなノリ
	return (a*mod_pow(a, n-1, P))%P
 
# nCk mod MODを求める！！
def comb(n, k):
	if n < k:
		return 0
	ans = fact[n]
	ans = (ans * inv_fact[k])%MOD
	ans = (ans * inv_fact[n-k])%MOD
	return ans

def move(n):
	twonum = n // 2
	com = 0
	for i in range(twonum + 1):
		up = n - i
		com += comb(up, i)
	return com

# fact,inv_factを初期化
fact[0] = inv_fact[0] = 1
for i in range(100000):
	# (i+1)!ってi!に(i+1)をかけたものだよね
	fact[i+1] = (fact[i]*(i+1))%MOD
	# (i+1)!の逆元って、i!の逆元に(i+1)の逆元をかけたものだよね
	inv_fact[i+1] = (inv_fact[i]*mod_pow(i+1, MOD-2, MOD))%MOD

N, M = map(int, input().split())
a = []
a.append(0)
for i in range(M):
	a.append(int(input()))
a.append(N+1)

s = 1
for i in range(M+1):
	step = a[i+1] - a[i] - 1
	if step > MOD:
		step = step % MOD
	m = move(step)
	s = (s * m) % MOD
	a[i+1] += 1

print(s)


Measured memory_bytes: 61216
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int dp[100005];

int dp_madarchod_cheez_hai(int h[],int n,int k)
{
    for(int j=3;j<=n;j++)
    {
        int min=INT_MAX;
        if(j-k>=1)
        {
            for(int i=j-k;i<j;i++)
            {
                if((abs(h[j-1]-h[i-1]))+dp[i]<min)
                    min=(abs(h[j-1]-h[i-1]))+dp[i];
            }
            dp[j]=min; 
        }
        else
        {
            for(int i=1;i<j;i++)
            {
                if((abs(h[j-1]-h[i-1]))+dp[i]<min)
                    min=(abs(h[j-1]-h[i-1]))+dp[i];
            }
            dp[j]=min;
        }
    }
    return dp[n];
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    cout.tie(0);    
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    dp[1]=0;
    dp[2]=abs(h[1]-h[0]);
    cout<<dp_madarchod_cheez_hai(h,n,k);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int A, B;
  cin >> A >> B;

  cout << max(0ll, A-B*2) << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def prime_decomposition(n):
  i = 2
  table = {}
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i in table:
        table[i] += 1
      else:
        table[i] = 1
    i += 1
  if n > 1:
      if n in table:
        table[n] += 1
      else:
        table[n] = 1
  return table

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, P] = [int(input_raw[0]),int(input_raw[1])]
    table = prime_decomposition(P)
    x = 1
    for p in table:
        if table[p] >= N:
            x *= (p ** (table[p]/N))
    print x

if __name__ == '__main__':
    main()

Measured memory_bytes: 2932
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define trarr(a,n) rep(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) rep(i,0,n)rep(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e5+10;
void solve(int _t){
	ll n, x, t;
	cin >> n >> x >> t;
	ll a = n/x;
	if(n%x)a++;
	cout<<t*a<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

Measured memory_bytes: 3648
n = int(input())
list_s = list(input() for i in range(n))
m = int(input())
list_t = list(input() for i in range(m))
count =0
set_s =list(set(list_s))
for i in set_s:
  count = max(count,list_s.count(i)-list_t.count(i))
print(count)

Measured memory_bytes: 3064
def bigger(a,b):
    if a>=b:
        return a
    else:
        return b

n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)

a.sort()
ans = a[-1] - a[0]
count = 2

left = a[0]
right = a[-1]

hidari = 1
migi = n-2
for i in range(n-2):
    if bigger(abs(left-a[hidari]),abs(left-a[migi])) >= bigger(abs(right-a[hidari]),abs(right-a[migi])):
        ans += bigger(abs(left-a[hidari]),abs(left-a[migi]))
        if abs(left-a[hidari]) > abs(left-a[migi]):
            left = a[hidari]
            hidari += 1
        else:
            left = a[migi]
            migi -= 1
    else:
        ans += bigger(abs(right-a[hidari]),abs(right-a[migi]))
        if abs(right-a[hidari]) > abs(right-a[migi]):
            right = a[hidari]
            hidari += 1
        else:
            right = a[migi]
            migi -= 1
print(ans)

Measured memory_bytes: 7528