akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>

#include <map>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <random>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}


int main() {
	ll N; cin >> N;
	V<ll> A(N), pow2(31, 1); REP(i, N) cin >> A[i];
	map<ll, int> mp; REP(i, N) mp[A[i]]++;
	FOR(i, 1, 31) pow2[i] = pow2[i - 1] * 2;

	sort(ALL(A),greater<ll>());
	ll ans = 0;
	REP(i, N) {
		if (mp[A[i]] == 0) continue;
		FOR(j, 1, 31) {
			if (pow2[j] - A[i] <= 0) continue;
			if (mp[pow2[j] - A[i]] == 0) continue;
			if (A[i] != pow2[j] - A[i]) {
				mp[A[i]]--;
				mp[pow2[j] - A[i]]--;
				ans++;
			}
			if (A[i] == pow2[j] - A[i] && mp[A[i]] >= 2){
				mp[A[i]]--;
				mp[pow2[j] - A[i]]--;
				ans++;
			}
			break;
		}
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 40192
#include <bits/stdc++.h>
using namespace std;
namespace LCY{
	#define double long double
	const double EPS=1e-10;
	inline int dcmp(double x){if(fabs(x)<EPS)return 0;return (x<0)?-1:1;}
	struct Point{double x,y;Point(double _x=0,double _y=0){x=_x;y=_y;}};
	struct Vector{double x,y;Vector(double _x=0,double _y=0){x=_x;y=_y;}};
	
	Vector operator - (Point a,Point b){return Vector(a.x-b.x,a.y-b.y);}
	Vector operator * (Vector a,double d){return Vector(a.x*d,a.y*d);}
	Point operator + (Point a,Vector b){return Point(a.x+b.x,a.y+b.y);}
	
	inline double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
	inline double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
	inline double norm(Vector a){return dot(a,a);}
	
	struct Line{
		Point p1,p2;
		Line(Point _p1=Point(0,0),Point _p2=Point(0,0)){p1=_p1;p2=_p2;}
	};
	inline bool is_parallel(Line l1,Line l2){return dcmp(cross(l2.p2-l2.p1,l1.p2-l1.p1))==0;}
	inline bool is_vertical(Line l1,Line l2){return dcmp(dot(l2.p2-l2.p1,l1.p2-l1.p1))==0;}
	
	Point project(Line l,Point p){
		Vector base=l.p2-l.p1;
		double r=dot(p-l.p1,base)/norm(base);
		return l.p1+base*r;
	}
	Point reflect(Line l,Point p){
		Point q=project(l,p);
		Vector v=p-q;v.x=-v.x;v.y=-v.y;
		return q+v;
	}
	int ccw(Vector v1,Vector v2){
		if(dcmp(cross(v1,v2))>0)return 1;//COUNTER_CLOCKWISE
		else if(dcmp(cross(v1,v2))<0)return 2;//CLOCKWISE
		else{
			if(dcmp(dot(v1,v2))<0)return 3;//ONLINE_BACK
			else{
				if(dcmp(norm(v1)-norm(v2))<0)return 4;//ONLINE_FRONT
				else return 5;//ON_SEGMENT
			}
		}
	}
	inline bool is_inter(Line l1,Line l2){
		bool flag=1;
		int t1=ccw(l1.p2-l1.p1,l2.p1-l1.p1),t2=ccw(l1.p2-l1.p1,l2.p2-l1.p1);
		if(t1==5 || t2==5) return true;
		else if(t1==t2)return false;
		else if(t1>=3 && t2<=2) return false;
		else if(t1<=2 && t2>=3) return false;
		swap(l1,l2);
		t1=ccw(l1.p2-l1.p1,l2.p1-l1.p1),t2=ccw(l1.p2-l1.p1,l2.p2-l1.p1);
		if(t1==5 || t2==5) return true;
		else if(t1==t2)return false;
		else if(t1>=3 && t2<=2) return false;
		else if(t1<=2 && t2>=3) return false;
		return true;
	}
	inline Point line_intersection(Line l1,Line l2){
		if(is_parallel(l1,l2)) return Point(233,233);
		Vector u=l1.p1-l2.p1,v=l1.p2-l1.p1,w=l2.p2-l2.p1;
		double t=cross(w,u)/cross(v,w);
		return l1.p1+v*t;
	}
	inline Point segment_intersection(Line l1,Line l2){
		if(!is_inter(l1,l2)) return Point(233,233);
		return line_intersection(l1,l2);
	}
}
using namespace LCY;
int main(){
	int n;cin>>n;while(n--){
		Point p1,p2,p3,p4;
		cin>>p1.x>>p1.y>>p2.x>>p2.y>>p3.x>>p3.y>>p4.x>>p4.y;
		Point res=segment_intersection(Line(p1,p2),Line(p3,p4));
		cout<<setiosflags(ios::fixed)<<setprecision(10)<<res.x<<" "<<res.y<<endl;
	}
	return 0;
}


Measured memory_bytes: 3304
#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.at(i);
  }
  sort(A.begin(),A.end());
  string answer = "YES";
  for(int i=0; i<N-1; i++) {
    if(A.at(i)==A.at(i+1)) {
      answer = "NO";
      break;
    }
  }
  cout << answer << endl;
}
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[114514],ran[114514],ans[114514],cnt[114514];
ll root(ll x) {
	return par[x]==x?x:par[x]=root(par[x]);
}
bool same(ll x, ll y) {
	return root(x)==root(y);
}
void unite(ll x, ll y) {
	x=root(x);
	y=root(y);
	if(x==y)return;
	if(ran[x]<ran[y]) {
		par[x]=y;
	}
	else{
		par[y]=x;
		if(ran[x]==ran[y])ran[x]++;
	}
}
int main() {
  ll n,m,a[114514],b[114514];
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>a[i]>>b[i];
  for(int i=0;i<n;i++)par[i]=i,cnt[i]=1;
  ans[m-1]=n*(n-1)/2;
  for(int i=m-2;i>=0;i--){
    if(same(a[i+1],b[i+1]))ans[i]=ans[i+1];
    else{
      ans[i]=ans[i+1]-cnt[root(a[i+1])]*cnt[root(b[i+1])];
      cnt[root(a[i+1])]+=cnt[root(b[i+1])];
			cnt[root(b[i+1])]=cnt[root(a[i+1])];
      unite(a[i+1],b[i+1]);
    }
  }
  for(int i=0;i<m;i++)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 6016
#include<iostream>
#include<map>
#include<string>

int main(){
    int n;
    std::cin >> n;
    std::map<std::string, int> mp;
    for(int i = 0; i < n; i++){
        std::string S;
        std::cin >> S;
        mp[S]++;
    }
    int m;
    std::cin >> m;
    for(int i = 0; i < m; i++){
        std::string T;
        std::cin >> T;
        mp[T]--;
    }

    int maxVal = 0;
    for(auto iter : mp){
        maxVal = std::max(maxVal, iter.second);
    }
    std::cout << maxVal << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=0LL;
	cin >>n;
	V a(n+1), b(n);
	rep(i,n+1){
		cin>>a[i];
	}
	rep(i,n){
		cin>>b[i];
		if(a[i] >b[i]){
			ans+=b[i];
			a[i]-=b[i];
		}else{
			ans+=a[i];
			b[i]-=a[i];
			a[i]=0LL;
			ans+=min(a[i+1],b[i]);
			a[i+1]=max(0LL,a[i+1]-b[i]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
def edpcB(n, k, hs):
    dp = [0]
    for i in range(1, n):
        h = hs[i]
        dp.append(dp[i-1]+abs(h-hs[i-1]))
        for j in range(max(0, i-k), i-1):
            d = dp[j] + abs(h-hs[j])
            if dp[i] > d:
                dp[i] = d
    print(dp[-1])
n, k = tuple(map(int, input().split(' ')))
hs = list(map(int, input().split(' ')))
edpcB(n, k, hs)

Measured memory_bytes: 13980
a=int(input())
b=input().split()
 
l=[int(i) for i in b]
 
cnt=[0 for i in range(a)]
 
for i in range(a):
    while l[i]%2==0:
        cnt[i]+=1
        l[i]=l[i]/2
        if l[i]%2==1:
            break
 
print(min(cnt))

Measured memory_bytes: 3060
#include <cstdio>
#include <map>
#include <queue>
using namespace std;
typedef pair<int, int> P;
int dx1[6]={0,1,-1,1,0,1};
int dy[6]={-1,-1,0,0,1,1};
int dx2[6]={-1,0,-1,1,-1,0};
int field[105][105];
int main() {
	int w,h; scanf("%d%d",&w,&h);
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			scanf("%d",&field[i][j]);
		}
	}
	int res=0;
	queue<P> nst;
	nst.push(P(0,0));
	while (!nst.empty()) {
		P p=nst.front(); nst.pop();
		int x=p.first, y=p.second;
		if (field[x][y]!=0) continue;
		field[x][y]=2;
		if (x%2) {
			for (int i=0; i<6; i++) {
				int nx=x+dy[i], ny=y+dx1[i];
				if (nx>=0&&nx<=h+1&&ny>=0&&ny<=w+1) {
					if (field[nx][ny]==1) {
						res++;
					} else if (field[nx][ny]==0) {
						nst.push(P(nx,ny));
					}
				}
			}
		} else {
			for (int i=0; i<6; i++) {
				int nx=x+dy[i], ny=y+dx2[i];
				if (nx>=0&&nx<=h+1&&ny>=0&&ny<=w+1) {
					if (field[nx][ny]==1) {
						res++;
					} else if (field[nx][ny]==0) {
						nst.push(P(nx,ny));
					}
				}
			}
		}
	}
	printf("%d\n",res);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n;
ll fac[110000],ans,res=1;


ll power(ll x,ll k){
  ll ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}

int main(){
  cin>>n;
  FOR(i,1,n+1){
    fac[i]=(fac[i-1]+power(i,M-2))%M;
  }

  FOR(i,1,n+1){
    int x;
    cin>>x;
    ans=(ans+x*(fac[i]+fac[n-i+1]-1+M)%M)%M;
    res=res*i%M;
  }

  cout<<(ans*res)%M<<endl;
}


Measured memory_bytes: 1024
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val n = readInteger()
    val aList = readIntegerList().sorted()
    val aMax = aList.max()!!
    val tmp = BooleanArray(aMax + 1)
    for (a in aList) {
        tmp[a] = true
    }
    for ((i, a) in aList.withIndex()) {
        if (tmp[a] == false) {
            continue
        }
        if (i + 1 < aList.size && aList[i] == aList[i + 1]) {
            tmp[a] = false
        }

        var i = 2
        while (a * i <= aMax) {
            tmp[a * i] = false
            i++
        }
    }
    println(tmp.count { it })
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 66992
#include <iostream>
#include <stdio.h>
#include <bitset>
#define maxr 12
#define maxc 10010
using namespace std;

bitset<maxc> a[maxr];
int r, c, ans;

void dfs(int k) {
    if (k == -1) {
        int tot = 0;
        for (int i = 0; i < c; i++) {
            int totr = 0;
            for (int j = 0; j < r; j++)
                if (a[j][i]) totr++;
            tot += max(totr, r - totr);
        }
        ans = max(ans, tot);
        return;
    }
    dfs(k - 1);
    a[k].flip();
    dfs(k - 1);
}

int main() {
    while (scanf("%d %d", &r, &c) == 2 && r && c) {
        for (int i = 0; i < r; i++)
            for (int j = 0; j < c; j++) {
                int tmp; scanf("%d", &tmp);
                a[i][j] = bool(tmp);
            }
        ans = 0;
        dfs(r - 1);
        printf("%d\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  bool check = false;
  for(int i = 1; i <=9; i++)
  {
    if((n/i) < 10 && (n%i) == 0)
    check = true;
  }
  if(check == true) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
//#define int long long
const int P = 998244353; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(ll &a, ll b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}
namespace FastIO {
    const int SIZE=1<<16; char buf[SIZE], obuf[SIZE], str[64]; int bi=SIZE, bn=SIZE, opt;
    int read(char *s) {
        while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
        int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
    }
    bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n)return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
    void write(int x) {
        if(!x) obuf[opt++] = '0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
        if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}
    }
    void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf, 1, opt, stdout); opt=0;}}
    void Fflush() { if (opt) fwrite(obuf, 1, opt, stdout); opt=0;}
}
const int MAXN = 1e6 + 5;
int n, d[MAXN];
void init(int n) {
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j * i <= n; j++) {
			d[i * j]++;
		}
	}
}
signed main()
{
	#ifndef ONLINE_JUDGE
		file("pro");
	#endif
	cin >> n; init(1000000);
	ll res = 0;
	For(i, 1, n) {
		res += d[n - i];
	}
	cout << res <<endl;
    return FastIO::Fflush(), 0;
}
/*

*/



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

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x;
    cin >> x;
    long long int count = 0;
    if(x >= 500)
    {
        count += (x/500) * 1000;
        x %= 500;
    }
    if(x >= 5)
    {
        count += (x/5) * 5;
    }
    cout << count;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    int t;
//    cin>>t;
    int x=1;
//    while(t--) {
     int n;
     cin>>n;
     int a[n-1];
     fo(i,n-1){
         cin>>a[i];
     }
     int arr[200001] = {0};
     for(int o:a){
         arr[o]++;
     }
     for(int i=1;i<=n;i++){
         cout<<arr[i]<<endl;
     }

       x++;
//    }
    return 0;
}

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

using namespace std;

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

#define F first
#define S second

const int MAXN = 2e3 + 10;
const int INF = 1e9 + 1;

int n, k, q, a[MAXN], ans = 2e9;

int get(int mn){
	int lo = mn-1, hi = INF;
	while (hi-lo>1){
		int mid = hi+lo>>1, cnt = 0;
	
		for (int l = 0; l < n;){
			if (a[l] < mn){
				l++;
				continue;
			}

			int r = l;
			while (r < n && a[r] >= mn) r++;
			if (r - l >= k){
				int c = 0, c2 = 0;
				for (; l < r; l++)
					if (a[l] <= mid)
						c++;
					else
						c2++;

				c -= max(0, (k-1 - c2));
				cnt += c;
			}
			l = r;
		}
		if (cnt >= q)
			hi = mid;
		else
			lo = mid;
	}
	return hi == INF? INF: hi-mn;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k >> q;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++)
		ans = min(ans, get(a[i]));
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll INF = 1000000000;
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vvl dat = VV(n, 2, 0, ll);
  re(i, n) {
    scanf("%lld %lld", &dat[i][0], &dat[i][1]);
    dat[i][0] = INF - dat[i][0];
  }
  sort(all(dat), [](vll a, vll b){return a[0]-a[1]>b[0]-b[1];});

  vvl dp = VV(n+1, n+1, -INF*INF, ll);
  dp[0][0] = INF;

  for(int i=1;i<=n;i++){
    dp[i][0] = INF;
    for(int j=1;j<=i;j++){
      if(dp[i-1][j-1]<dat[i-1][0]) dp[i][j] = dp[i-1][j];
      else dp[i][j] = max(dp[i-1][j], dp[i-1][j-1]-dat[i-1][1]);
    }
  }
  ll ans = 0;
  for(int i=0;i<=n;i++) if(dp[n][i]!=-INF*INF) ans = i;
  std::cout << ans << '\n';
  return 0;
}


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

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];

int main(void){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, T;
  cin >> N >> T;
  vint(t, N);

  int tot = 0;
  REP(i, N-1){
    if(t[i+1]-t[i] >= T) tot += T;
    else tot += t[i+1]-t[i];
  }
  cout << tot + T << endl;

  return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=input().split()

m=int(input())
b=input().split()

a=[int(i) for i in a]
b=[int(i) for i in b]

a.sort()
b.sort()
cnt=0

for j in range(m):
  if b[j] in a:
    cnt+=1
print(cnt)




Measured memory_bytes: 6336
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const X = Number(input[0][0]);
  const A = Number(input[1][0]);
  const B = Number(input[2][0]);

  return (X - A) % B;
};

console.log(main(read()));


Measured memory_bytes: 29592
#n,d=map(int,input().split())
#xy = [list(map(int,input().split())) for i in range(n)]
n=int(input())
c=list(input())
left=0
right=0
aru=0
for i in range(n):
  if c[i]=="R":
    aru+=1
dab=n-aru

left=0
right=aru
hantei=1000000000
for i in range(n):
  if c[i]=="R":
    right-=1
  else:
    left+=1
  if max(left,right)<hantei:
    hantei= max(left,right)
ans1=hantei
print(min(ans1,aru,dab))



Measured memory_bytes: 10752
#include <stdio.h>
#include <string.h>

int main(void)
{
    int i;
    int te[6];
    int freq[4];
    
    while (1){
        scanf("%d", &te[1]);
        if (te[1] == 0){
            break;
        }
        
        for (i = 2; i <= 5; i++){
            scanf("%d", &te[i]);
        }
        
        memset(freq, 0, sizeof(freq));
        
        for (i = 1; i <= 5; i++){
            freq[te[i]]++;
        }
        
        if (freq[1] * freq[2] * freq[3] != 0){
            printf("3\n3\n3\n3\n3\n");
            continue;
        }
        if (freq[1] + freq[2] == 0 || freq[2] + freq[3] == 0 || freq[3] + freq[1] == 0){
            printf("3\n3\n3\n3\n3\n");
            continue;
        }
        
        if (freq[1] == 0){
            for (i = 1; i <= 5; i++){
                if (te[i] == 2){
                    printf("1\n");
                }
                else {
                    printf("2\n");
                }
            }
        }
        else if (freq[2] == 0){
            for (i = 1; i <= 5; i++){
                if (te[i] == 1){
                    printf("2\n");
                }
                else {
                    printf("1\n");
                }
            }
        }
        else if (freq[3] == 0){
            for (i = 1; i <= 5; i++){
                if (te[i] == 1){
                    printf("1\n");
                }
                else {
                    printf("2\n");
                }
            }
        }
    }
    return (0);
}

    

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

typedef long long ll;

int main()
{
    int n,i,j;
    cin >> n;
    vector<int> x(n);
    for(i = 0;i < n;++i){
        cin >> x.at(i);
    }
    int min_sum = 1e9;
    for(i = 1;i <= 100;++i){
        int sum = 0;
        for(j = 0;j < n;++j){
            sum += (x.at(j)- i)*(x.at(j)- i);
        }
        if(min_sum > sum){
            min_sum = sum;
        }
    }
    cout << min_sum << endl;
    return 0;
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int change=0, ans;
    for (int i=0; i<n; i++){ if (s[i] == 'E') change += 1;}
    if (s[0] == 'E') ans = change-1;
    else ans = change;
    for (int leader=1; leader < n; leader++){
        if (s[leader-1] == 'E') change += -1;
        else change += 1;
        if (s[leader] == 'E') ans = min(ans, change-1);
        else ans = min(ans, change);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3900
main = getLine >>= putStrLn . solve . map read . words

solve :: [Int] -> String
solve (a:b:_)
  | (a + 11) `mod` 13 < (b + 11) `mod` 13 = "Bob"
  | (a + 11) `mod` 13 > (b + 11) `mod` 13 = "Alice"
  | otherwise = "Draw"
 

Measured memory_bytes: 508
h,n=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(n)]

A_max=max(AB)[0]
DP=[0]+[float("inf")]*(h+A_max)
for i in range(h):
    if DP[i]==float("inf"):continue
    for a,b in AB:
        t=DP[i]+b
        if t<DP[i+a]:
            DP[i+a]=t
print(min(DP[h:]))

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


def dfs(s,cnt):
    global ans
    if cnt > 10:
        ans = False
        return
    for t in lines[s]:
        dfs(t,cnt+1)


N = inp()
for _ in range(N):
    H,W = inpl()
    MAP = [['.']*(W+2)] + [['.']+list(input())+['.'] for y in range(H)] + [['.']*(W+2)]

    als = set([])
    almm = [[INF,0,INF,0] for _ in range(30)]
    for y in range(1,H+1):
        for x in range(1,W+1):
            tmp = MAP[y][x]
            if tmp != '.':
                tmp = ord(tmp) - ord('A')
                als.add(tmp)
                almm[tmp][0] = min(almm[tmp][0],x)
                almm[tmp][1] = max(almm[tmp][1],x)
                almm[tmp][2] = min(almm[tmp][2],y)
                almm[tmp][3] = max(almm[tmp][3],y)

    ans = True
    lines = defaultdict(set)
    for a in als:
        xl,xr,yl,yr = almm[a]
        alpha = chr(a+ord('A'))
        for x in range(xl,xr+1):
            for y in range(yl,yr+1):
                if MAP[y][x] == '.':
                    ans = False
                    break
                elif MAP[y][x] != alpha:
                    lines[a].add(ord(MAP[y][x])-ord('A'))

    for a in als:
        dfs(a,0)


    if not ans:
        print('SUSPICIOUS')
    else:
        print('SAFE')



Measured memory_bytes: 7220
#include <iostream>

using namespace std;

main(int argc, char const *argv[])
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if(b-a == c-b){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int x,N; cin >> x >> N;
    vector<bool> A(102,1);
    rep(i,N) {
        int a; cin >> a;
        A[a] = 0;
    }
    int ans = -1;
    int val = 1e9;
    rep(i,102) {
        if (A[i]) {
            if (chmin(val,abs(i-x))) ans = i;
        }
    }

    cout << ans << ln;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int N;
int a[100000];
int main()
{
	//freopen("J.txt","r",stdin);
	while(~scanf("%d",&N))
	{
		long long chang=0,kuan=0;
		for(int i=0; i<N; i++)
			cin>>a[i];
		sort(a,a+N);
		int k=N-1;
		while(1)
		{
			if(k<=0)
			{
				cout<<0<<endl;
				break;
			}
			if(a[k]==a[k-1])
			{
				if(chang>0)
				{
					kuan=a[k];
					long long ans;
					ans=chang*kuan;//此处为什么不会进行自动类型装换？ 
					printf("%lld\n",ans);
					break;
				}
				else
				{
					chang=a[k];
					k-=2;
				}
			}
			else
				k--;
		}
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int ans=min(a+b,min(b+c,c+a));
  cout<<ans;
  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);

		String s = sc.next();
		StringBuilder sb = new StringBuilder();

		for(int i=0; i<s.length(); i++) {
			if(i%2==0) {
				sb.append(s.charAt(i));
			}
		}
		System.out.println(sb);

	}

}


Measured memory_bytes: 27736
n = int(input())
A = list(map(int, input().split()))
mod=int(1e9+7)

memo={i:0 for i in range(n)}
for a in A:
  memo[a]=memo.get(a,0)+1

answer=1
if n%2:
  if memo[0]!=1:
    print(0)
    exit()
  for i in range(1, (n+1)//2):
    if memo[2*i]!=2:
      print(0)
      exit()
    else:
      answer = 2*answer %mod
elif not n%2:
  for i in range(n//2):
    if memo[2*i+1]!=2:
      print(0)
      exit()
    else:
      answer = 2*answer %mod
      
print(answer)
      
    

    
  

Measured memory_bytes: 20704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(); int B = sc.nextInt();
		String string = sc.next();
		for(int i=0;i<A;i++) 
			if('0' > string.charAt(i)  || '9' < string.charAt(i)) 
				{
					System.out.println("No"); 
					System.exit(0);
				}
		
		if(string.charAt(A)  != '-') 
			{
				System.out.println("No");
				System.exit(0);
			}
		
		for(int i=A+1;i<A+B;i++) 
			if('0' > string.charAt(i)  || '9' < string.charAt(i)) 
				{
					System.out.println("No"); 
					System.exit(0);
				}
		System.out.println("Yes");
	}

}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main()
{
    int n, a[100001], b[100001], p = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        p = p + (b[i] - a[i] + 1);
    }
    cout << p;
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll T, N, A, B, C, D;
ll i, j, k;
void mnin(ll& a,ll b){
    if(a>b)
        a = b;
}
int main(){
    scanf("%lld", &T);
    while(T--){
        scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
        priority_queue<pll> pq;
        pq.push({0, N});
        ll ans = 1e18;
        set<ll> st;
        i = 2e18;
        while(pq.top().second){
            pll qa = pq.top();
            pq.pop();
            ll a = qa.second;
            ll b = qa.first;
            if(st.count(a))
                continue;
            st.insert(a);

            //printf("%lld,%lld\n", b, a);
            i = a;
            pq.push({b - A - (a % 2) * D, a / 2});
            pq.push({b - A - (2 - a % 2) * D, a / 2 + 1});
            pq.push({b - B - (a % 3) * D, a / 3});
            pq.push({b - B - (3 - a % 3) * D, a / 3 + 1});
            pq.push({b - C - (a % 5) * D, a / 5});
            pq.push({b - C - (5 - a % 5) * D, a / 5 + 1});
            if (-b+1.0*a*D<2e18&&-b + a * D < ans)
            {
                ans = -b + a * D;
            }
        }
        ans = min(ans, -pq.top().first);
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4556
use text_io::*;
use std::process::exit;
use im_rc::HashMap;
use std::cmp::*;

fn main() {
    let n:usize = read!();
    let aa:String = read!();
    let bb:String = read!();
    let a:Vec<char> = aa.chars().collect();
    let b:Vec<char> = bb.chars().collect();
    let mut c:Vec<char> = Vec::new();
    for i in 0..n {
        c.push(a[i]);
        c.push(b[i]);
    }
    let d:String = c.iter().collect();
    println!("{}",d);
}

Measured memory_bytes: 2104
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

dis = max(abs(b-a),abs(c-a),abs(d-a),abs(e-a),abs(c-b),abs(d-b),abs(e-b),abs(d-c),abs(e-c),abs(e-d))
if dis <= k :
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
int main(){
	int a,b,sum;
	scanf("%d%d",&a,&b);
	sum=0;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10&&i/1000%10==i/10%10) sum++;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <string>
#define SIZE 105

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll C[SIZE][SIZE];

void init()
{
	for(int i=0;i<SIZE;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++) C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
}
int main()
{
	init();
	int n;
	int p;
	scanf("%d %d",&n,&p);
	int a=0,b=0;
	for(int i=0;i<n;i++)
	{
		int c;
		scanf("%d",&c);
		if(c%2==0) a++;
		else b++;
	}
	ll ret=0;
	for(int i=0;i<=b;i++)
	{
		if(i%2==p)
		{
			ret+=C[b][i];
		}
	}
	for(int i=0;i<a;i++) ret=ret*2LL;
	printf("%lld\n",ret);
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 2e5 + 5;
int n, m, k, ans;
int cnt[N];
int a[N];
int idx;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> m;
        ++cnt[m];
    }
    for (int i = 1; i <= n; ++i) {
        if (cnt[i] != 0) {
            a[idx++] = cnt[i];
        }
    }
    sort(a, a + idx);
    for (int i = 0; i < idx - k; ++i) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5104
s = gets.chomp.split("")
n = s.size
ans = Array.new(n, 0)
count = 0
n.times do |i|
    if s[i] == "R"
        count += 1
    else
        ans[i] += count / 2
        ans[i-1] += count - count/2
        count = 0
    end
end
count = 0
(n-1).downto(0) do |i|
    if s[i] == "L"
        count += 1
    else
        ans[i] += count / 2
        ans[i+1] += count - count/2
        count = 0
    end
end

puts ans.join(" ")

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())

//Dijkstra (no minus cost path)
const int MAX_V = 50;
const ll INF = 1LL << 50;
typedef struct{
  int to;
  ll cost;
  ll time;
} Edge;
typedef pair<ll,pair<int,ll>> P; //first:dis second:num

ll d[MAX_V][2501];
vector<Edge> G[MAX_V];

void dijkstra(int m) {
  rep(i,MAX_V) {
    rep(j,2501) {
      d[i][j] = INF;
    }
  }
  m = min(m, 2500);
  d[0][m] = 0;

  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P(0, make_pair(0,m)));
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    ll f = p.second.first, s = p.second.second;
    if (d[f][s] < p.first)
      continue;
    for (auto &e: G[f]) {
      if (s<e.cost)
        continue;
      ll c = min(s-e.cost,(ll)2500);
      if (d[e.to][c] > d[f][s]+e.time) {
        d[e.to][c] = d[f][s]+e.time;
        que.push(P(d[e.to][c], make_pair(e.to, c)));
      }
    }
  }
}


int main() {
  int N, M, S;
  cin >> N >> M >> S;
  int u,v; ll a,b;
  rep(i,M) {
    cin >> u >> v >> a >> b;
    u--; v--;
    G[u].push_back({v,a,b});
    G[v].push_back({u,a,b});
  }
  rep(i,N) {
    cin >> a >> b;
    G[i].push_back({i,-a,b});
  }
  dijkstra(S);
  rep1(i,N-1) {
    ll ans = INF;
    rep(j,2501) {
      ans = min(ans, d[i][j]);
    }
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 7336
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

#define int long long
#define double long double

typedef pair<int, int> P;
typedef tuple<int, int, int> T;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e17 + 9;

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

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

	vector<vector<int>> road(n), line(n);


	rep(i, k) {
		int p, q;
		cin >> p >> q; 
		p--; q--;
		road[p].push_back(q);
		road[q].push_back(p);
	}
	rep(i, l) {
		int r, s;
		cin >> r >> s;
		r--; s--;
		line[r].push_back(s);
		line[s].push_back(r);
	}

	vector<int> num_road(n, -1);
	
	function<void(int, int)> dfs_road = [&](int m, int nm) {
		if (num_road[m] != -1)return;
		num_road[m] = nm;
		each(to, road[m]) {
			dfs_road(to, nm);
		}
	};

	vector<int> num_line(n, -1);

	function<void(int, int)> dfs_line = [&](int m, int nm) {
		if (num_line[m] != -1)return;
		num_line[m] = nm;
		each(to, line[m]) {
			dfs_line(to, nm);
		}
	};

	rep(i, n) {
		dfs_road(i, i);
	}
	rep(i, n) {
		dfs_line(i, i);
	}

	map<P, int> mp;
	rep(i, n) {
		mp[P(num_road[i], num_line[i])]++;
	}

	rep(i, n) {
		cout << mp[P(num_road[i], num_line[i])];
		if (i == n - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}

	return 0; 
}

Measured memory_bytes: 30336
N,M=map(int,input().split())
s,e=set(),set()
for _ in range(M):
	a,b=map(int,input().split())
	if a == 1:
		s.add(b)
	if b == 1:
		s.add(a)
	if a == N:
		e.add(b)
	if b == N:
		e.add(a)
print("POSSIBLE" if len(s&e) > 0 else "IMPOSSIBLE")


Measured memory_bytes: 19024
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, W, w[111] = {0}, v[111], w0, sp = 0;

  std::cin >> N >> W >> w0 >> v[0];
  
  for (int i = 1; i < N; i ++) {
    std::cin >> w[i] >> v[i];

    w[i] -= w0;
  }

  for (int t = 0; t <= N; t ++) {
    if (t * w0 > W)
      break;

    int r = W - t * w0;

    int dp[2][333][111];

    auto curr = dp[0], next = dp[1];

    memset(curr, -1, sizeof(dp[0]));

    curr[0][0] = 0;

    for (int i = 0; i < N; i ++) {
      memset(next, -1, sizeof(dp[0]));
      
      for (int j = 0; j < 333; j ++) {
        for (int k = 0; k <= t; k ++) {
          if (curr[j][k] < 0)
            continue;

          next[j][k] = std::max(curr[j][k], next[j][k]);
          
          if (j + w[i] <= r && k < t)
            next[j + w[i]][k + 1] = std::max(curr[j][k] + v[i], next[j + w[i]][k + 1]);
        }
      }
      
      std::swap(curr, next);
    }

    for (int j = 0; j < 333; j ++)
      for (int k = 0; k <= t; k ++)
        if (curr[j][k] > sp)
          sp = curr[j][k];
  }

  std::cout << sp << std::endl;

  return 0;
}


Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		VI A(N+1),B(N);
		REP(i, N+1) cin>>A[i];
		REP(i, N) cin>>B[i];
		ll ans = 0;
		REP(i, N) {
			ll L = min(A[i], B[i]);
			ll R = min(A[i+1], B[i]-L);
			A[i]-=L;
			A[i+1]-=R;
			ans+=L+R;
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 3e5 + 5;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll mx[mxN], mx1[mxN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int h, w, m;
	cin >> h >> w >> m;
	vi a(m), b(m);
	rep(i, m) cin >> a[i] >> b[i], mx[a[i]]++, mx1[b[i]]++;
	//basically
	//it is either max(mx) + max(mx1)
	//or that - 1
	ll a1 = 0LL, b1 = 0LL;
	ll bg = 0LL, bg1 = 0LL;
	rep(i, mxN) bg = max(bg, mx[i]);
	rep(i, mxN) if(mx[i] == bg) a1++;
	rep(i, mxN) bg1 = max(bg1, mx1[i]);
	rep(i, mxN) if(mx1[i] == bg1) b1++;
	ll num = a1 * b1, tot = 0LL;
	rep(i, m){
		if(mx[a[i]] == bg && mx1[b[i]] == bg1) tot++;
	}
	if(num != tot) cout << bg + bg1 << endl;
	else cout << bg + bg1 - 1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

count = 0

for i in range(N):
  D1, D2 = input().split(" ")
  
  if D1 == D2:
    count += 1
  else:
    count = 0
    
  if count >= 3:
    print("Yes")
    break

if count < 3:
	print("No")

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

using namespace std;

// container utility
#define ALL(x) (x).begin(), (x).end()

// rep
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define rep(i,n) REP(i,0,n)

string func(int x) {
  string ret;
  while(x > 0) {
    ret += char(x % 2 + '0');
    x /= 2;
  }
  
  reverse(ALL(ret));
  return ret;
}

int main() {

  double in;
  
  while(cin >> in && in > 0.0) {
    string int_part = func(int(in));
    in *= 16;// in <<= 4; (integer type only)
    if(ceil(in) != in) {
      cout << "NA" << endl;
    }
    else {
      rep(i, 8-int_part.size()) cout << 0;
      cout << int_part << '.';
      string decimal_part = func(int(in));
      cout << decimal_part.substr(decimal_part.size()-4) << endl;
    }
  }
  
  return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

void rec(int d, ll val, vector<ll> &all)
{
  all.push_back(val);

  if (d == 10)
    return;

  for (int j = -1; j <= 1; j++)
  {
    int add = (val % 10) + j;
    if (add >= 0 && add <= 9)
      rec(d + 1, val * 10 + add, all);
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int K;
  cin >> K;
  vector<ll> all;
  for (int v = 1; v < 10; v++)
    rec(1, v, all);
  sort(all.begin(), all.end());
  cout << all[K - 1] << endl;
  return 0;
}

// 全列挙した後にK番目を取る．サンプル3を見ると最大のKに対する答えが3234566667であることがわかる．つまり，最大でも10桁のlunlun数を列挙すればよさそう．(d桁のlunlun数は大体3^dくらいになりそう．)まず最初に1～9を列挙しておいてそこから次々と新しい数値を付け加えて行くイメージ　DFSでたどれる．


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main(){

  map<string, int> dict;
    int max=-1;
    int n,N; cin >> N;n=N;
    vector<string> strings; 
    for (string x; n--; dict[x]++) { 
        cin >> x;
        if(dict[x]+1>max)max=dict[x]+1;  
    }
    int count=0;
    for (auto i = dict.begin(); i != dict.end() ; ++i ){
        if(i->second==max){
            strings.push_back(i->first);
            count++;
        }
    }

    sort(strings.begin(),strings.end());
    for(int i=0;i<count;i++)cout<<strings[i]<<endl;


}

Measured memory_bytes: 26868
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>

bool debug=true;
/*
   Write In New Computer
    By XiaoGeNintendo
	     gwq2017
	Type:
*/

map<ll,ll> mp;
int n;
int a[200005];
 
int main(int argc,char* argv[]){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	mp[0]=1;
	ll sm=0,ans=0;
	for(int i=0;i<n;i++){
		sm+=a[i];
		ans+=mp[sm];
		mp[sm]++;
	}
	
	cout<<ans;
	return 0;
}


Measured memory_bytes: 13568