akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

const int N = 16, INF = 1e18;

int dp[N][1 << N];

int ask(vector <int> & x, vector <int> &p, int mask, int n, int good) {
    int ans = 0;
    loop(i, n)
        if (mask & (1 << i))
            ans += abs(good - x[i]) * p[i];
    return ans;
}

int ternary_search(vector <int> &x, vector <int> &p, int mask, int n) {
    int l = -10000, r = 10000;
    while (r - l > 1) {
        int m1 = l + (r - l + 1) / 3, m2 = r - (r - l + 1) / 3;
        if (ask(x, p, mask, n, m1) > ask(x, p, mask, n, m2))
            l = m1;
        else
            r = m2;
    }
    return min(ask(x, p, mask, n, l), ask(x, p, mask, n, r));
}

void solve() {
    for (int i = 2; i < N; ++i)
        loop(j, (1 << N))
            dp[i][j] = INF;
    int n; cin >> n;
    vector <int> x(n), y(n), p(n);
    loop(i, n)
        cin >> x[i] >> y[i] >> p[i];
    loop(mask, (1 << n)) {
        loop(i, n)
            if (mask & (1 << i))
                dp[0][mask] += min(abs(x[i]), abs(y[i])) * p[i];
        dp[1][mask] = min(ternary_search(x, p, mask, n), ternary_search(y, p, mask, n));
    }
    loop1(k, n)
        loop(mask, (1 << n))
            for (int sub = mask; sub; sub = (sub - 1) & mask)
                loop(i, (k + 3) / 2)
                    dp[k][mask] = min(dp[k][mask], dp[i][sub] + dp[k - i][mask ^ sub]);
    loop(i, n + 1)
        cout << dp[i][(1 << n) - 1] << "\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<pair<int64_t,int>> p(n);
  for(int i=0;i<n;++i){
    cin>>p[i].first;
    p[i].second=i;
  }
  sort(p.begin(),p.end(),greater<pair<int64_t,int>>());

  //上から左にl個、右にr個振り分けた時の最大値f[l][r];
  vector<vector<int64_t>> f(n+1,vector<int64_t>(n+1,0));
  for(int l=0;l<=n;++l){
    for(int r=0;l+r<=n;++r){
      if(l==0 && r==0) continue;
      else{
      int64_t a=p[l+r-1].first;
      int m=p[l+r-1].second;
      if(l==0) f[0][r]=f[0][r-1]+a*abs(n-r-m);
      else if(r==0) f[l][0]=f[l-1][0]+a*abs(l-1-m);
      else f[l][r]=max(f[l-1][r]+a*abs(l-1-m),f[l][r-1]+a*abs(n-r-m));
      }
    }
  }


  int64_t ans=0;
  for(int i=0;i<=n;++i){
    if(ans<f[i][n-i]) ans=f[i][n-i];
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 34588
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	int minx=INF;
	int miny=INF;
	int maxx=-INF;
	int maxy=-INF;
	rep(i,n){
		int a,b;
		cin >> a>>b;
		maxx=max(maxx,a-b);
		minx=min(minx,a-b);
		maxy=max(maxy,a+b);
		miny=min(miny,a+b);
	}
	print(max(maxx-minx,maxy-miny));
}

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

using namespace std;

void Main() {
    long long N, T;
    cin >> N >> T;
    long long ans = 0LL;
    long long prevt;
    cin >> prevt;
    for (long long i = 1; i < N; ++i) {
        long long t;
        cin >> t;
        if (T <= t - prevt) {
            ans += T;
        }
        else {
            ans += t - prevt;
        }
        prevt = t;
    }
    ans += T;
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main(){
    int a, b;

    cin >> a >> b;

    if (a == b){
        cout << "Draw" << endl;
    } else if (a == 1) {
        cout << "Alice" << endl;
    } else if (b == 1) {
        cout << "Bob" << endl;
    } else if (a > b){
        cout << "Alice" << endl;
    } else if (a < b){
        cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll X;

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

  ll cnt = 0, p = 100;

  while( p < X )
  {
    p = p*1.01;
    ++cnt;
  }

  std::cout << cnt << std::endl;

  return 0;
}

Measured memory_bytes: 3192
import java.util.*;
public class Main{
    public static void Koch(Point start, Point end, int level){
        if(level == 0){
            System.out.println(end.x + " " + end.y);
        }
        else{
                Point p1 = new Point((end.x-start.x)/3 + start.x,(end.y-start.y)/3 + start.y);
                Point p3 = new Point(2*(end.x - start.x)/3 + start.x, 2*(end.y-start.y)/3 + start.y);
                Point p2 = new Point((p1.x+p3.x)/2 - Math.sqrt(3)*(p3.y-p1.y)/2, Math.sqrt(3)*(p3.x-p1.x)/2+(p1.y+p3.y)/2);
                Koch(start,p1,level-1);
                Koch(p1,p2,level-1);
                Koch(p2,p3,level-1);
                Koch(p3,end,level-1);
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Point p1 = new Point(0,0);
        Point p2 = new Point(100,0);
        System.out.println(0 + " " + 0);
        Koch(p1,p2,n);
    }
}
class Point{
    double x;
    double y;
    Point(double x, double y){
        this.x = x;
        this.y = y;
    }
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

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

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

char s[MAXN];

void solve(){
	int cntg = 0, cntp = 0, ans = 0, n;
	scanf("%s", &s[0]);
	n = strlen(s);
	REP(i, 0, n){
		if (s[i] == 'g'){
			if (cntp < cntg){
				cntp++;
				ans++;
			} else {
				cntg++;
			}
		} else {
			if (cntp < cntg){
				cntp++;
			} else {
				cntg++;
				ans--;
			}
		}
	}
	cout << ans << endl;
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

void solv()
{
	long long int S; scanf("%lld", &S);
	long long int x, y;
	y = S / 1000000000 + 1;
	x = 1000000000 - S % 1000000000;
	if (1000000001 == y){
		printf("0 0 1000000000 0 0 1000000000");
		return;
	}

	printf("0 0 1000000000 1 %d %d", x, y);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using itn = int;
using ld = long double;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()


int main(){
  int n;
  cin >>n;
  vec<string> s(n);
  vec<int> p(n);
  REP(i,n) cin >>s[i] >>p[i];

  vec<int> ans(n);

  vec<int> memo(n,1);
  REP(i,n){
    for(int j=0;j<i;j++){
      if(s[i] > s[j]){
        ++memo[i];
      }else if(s[i] == s[j]){
        if(p[i] < p[j]) ++memo[i];
      }
    }
    for(int j=i+1;j<n;j++){
      if(s[i] > s[j]){
        ++memo[i];
      }else if(s[i] == s[j]){
        if(p[i] < p[j]) ++memo[i];
      }
    }
  }

  REP(i,n) ans[memo[i]-1] = i+1;

  REP(i,n) cout <<ans[i] <<endl;
}


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

int main(){
    ll res = 0;
    string s;
    ll n, i, j, tem, tem2;
    cin >> s;
    n = s.length();
    for(i=0; i<(1<<(n-1)); i++){
        tem = i;
        tem2 = s[0] - '0';
        for(j=1; j<n; j++){
            if(tem & 1 == 1){
                tem2 *= 10;
                tem2 += s[j] - '0';
            }else{
                res += tem2;
                tem2 = s[j]-'0';
            }
            tem >>= 1;
        }
        res += tem2;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a;
 
    while(cin >> a){
        if(a % 39 == 0){
            cout << "3C39" << endl;
        }
        else{
            if(a % 39 < 10){
                cout << "3C0" << a % 39 << endl;
            }
            else{
                cout << "3C" << a % 39 << endl;
            }
        }
    }
}


Measured memory_bytes: 2984
s = gets
for i in 1..2 do
	for j in 1..2 do
		for k in 1..2 do
			ans = s[0].to_i
			str = s[0]
			if i == 1 then
				ans += s[1].to_i
				str += "+" + s[1]
			else
				ans -= s[1].to_i
				str += "-" + s[1]
			end
			if j == 1 then
				ans += s[2].to_i
				str += "+" + s[2]
			else
				ans -= s[2].to_i
				str += "-" + s[2]
			end
			if k == 1 then
				ans += s[3].to_i
				str += "+" + s[3]
			else
				ans -= s[3].to_i
				str += "-" + s[3]
			end
			#puts ans
			#puts str
			if ans == 7 then
				puts str + "=7"
				exit
			end
		end
	end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
bool ispal(string s){
    int l=s.size();
    for (int i = 0; i < l/2; ++i) {
        if(s[i]==s[l-i-1]) continue;
        else return false;
    }
    return true;
}
int main(){
    string s;
    cin>>s;
    int l=s.size();
    bool k=true;
    if(!ispal(s)) k=false;
    else if(!ispal(s.substr(0,(l-1)/2))) k=false;
    else if(!ispal(s.substr((l+3)/2-1,l-1))) k=false;
    if(k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define For(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define sz(x) ((int)(x).size())
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef long long ll;

const int N = 1e5+10;

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

  string s,t; cin>>s>>t;
  int ns = s.length(), nt = t.length();
  vector<vi> dp(ns+1, vi(nt+1, 0));
  rep(i,ns) rep(j,nt) {
    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
    if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
  }
  int x = ns, y = nt;
  string ans = "";
  while(x && y) {
    if(dp[x][y]==dp[x-1][y]) {
      x--;
    } else if(dp[x][y]==dp[x][y-1]) {
      y--;
    } else {
      ans+=s[x-1];
      x--; y--;
    }
  }
  reverse(all(ans));
  cout<<ans<<endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch LazyFaith | diff LazyFaith.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address LazyFaith.cpp && ./a.out

/*
 
 3/11/2019
 
 14:54-
 
 */

const int MAX_N=1e6+1;
LL P[2][MAX_N];
int N[2];

void solve(LL x) {
  vector<LL> ps[2];
  REP(c,2) {
    int i=lower_bound(P[c],P[c]+N[c],x)-P[c];
    ps[c].push_back(P[c][i]);
    if(i>0) ps[c].push_back(P[c][i-1]);
  }
  LL res=1e17;
  REP(o,2) {
    REP(mask,4) {
      LL cost=0;
      LL p=x;
      REP(i,2) {
        int j=(mask>>i)&1;
        LL pp=ps[i][min(j,SZ(ps[i])-1)];
        cost+=abs(pp-p),p=pp;
      }
      SMIN(res,cost);
    }
    swap(ps[0],ps[1]);
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  int Q;
  cin>>N[0]>>N[1]>>Q;
  REP(c,2)REP(i,N[c]) cin>>P[c][i];
  REP(c,2)P[c][N[c]++]=1e16;
  REP(_,Q) {
    LL x; cin>>x;
    solve(x);
  }
  
  return 0;
}


Measured memory_bytes: 6272
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int ans=c-a+b;
    if(ans<0) ans=0;
  cout<<ans<<endl;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll n,ans = 0;
    cin >> n;

    REP(i,1,n)ans += i;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m,n,a[105],cnt=0,sum=0;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int ff=ceil(sum/(4.0*m));
	for(int i=1;i<=n;i++){
		if(a[i]>=ff) cnt++;
	}
	if(cnt>=m) cout<<"Yes";
	else cout<<"No";
	return 0;
} 

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

int main(){
    int n; cin >> n; 
    long long x; cin >> x;
    vector<long long> dist(n);
    for(int i = 0; i < n; i++){
        cin >> dist.at(i);
    }
    long long ans = abs(dist.at(0) - x);
    for(int i = 0; i < n; i++){
        ans = __gcd(ans, abs(x - dist.at(i)));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <map>
using namespace std;
 

int main() {
  int N,M;
  cin >> N >> M;
  vector<pair<long, long>> pairs(N);
  int B[N];
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    cin >> B[i];
    pairs[i] = make_pair(A[i], B[i]);
  }
  sort(pairs.begin(), pairs.end());
  long long ans =0; 
  for(int i=0;i<N;i++){
    if(M<=pairs[i].second){
      ans+=M*pairs[i].first;
      break;
    }else{
      ans += pairs[i].first*pairs[i].second;
      M -= pairs[i].second;
    }   
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {


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

		int N = sc.nextInt();
		int Y = sc.nextInt();

		int x = 0;
		int y = 0;
		int z = 0;


		for (x = 0; x <= N; x++){

			for ( y = 0; y <= N - x; y++){

				z = N - x - y;

				if (z > N - x - y || z < 0){
					continue;
				} else if (Y == 10000* x + 5000 * y + 1000 * z){

					System.out.println(x + " " + y + " " + z);
					return;
				}

			}

		}

		System.out.println("-1 -1 -1");

	}

}


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


int main() {
    int n,m;
    cin >> n >> m;
    vector<int> l(m),r(m);
    rep(i,m){
        cin >> l.at(i) >> r.at(i);
    }
    int L=0,R=n;
    rep(i,m){
        if(L<l.at(i)) L=l.at(i);
        if(R>r.at(i)) R=r.at(i);
    }
    int ans=R-L+1;
    if(ans>0) cout << ans;
    else cout << 0;
    cout << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

int next(int n){
  if (n%10 == 0)
    return n;
  else
    return n + (10-n%10);
}

int main(int argc, const char * argv[]) {
  vector<int> v(5);
  for (int i=0; i<5; i++) {
    cin >> v[i];
  }
  
  sort(v.begin(), v.end());
  int ans = INF;
  do {
    int now = 0;
    for(int i=0; i<v.size()-1; i++){
      now = next(v[i]+now);
    }
    now += v.back();
    ans = min(ans, now);
  } while( next_permutation(v.begin(), v.end()) );
  
  cout << ans << endl;
  return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	ll N=in();
	if(!N){
		out(0);
		return 0;
	}
	string S;
	while(N!=1LL){
		if(N<0){
			if(abs(N)%2LL){
				N = (N-1LL)/(-2LL);
				S.push_back('1');
			}
			else{
				N = (N)/(-2LL);
				S.push_back('0');
			}
		}
		else{
			if(abs(N)%2LL){
				S.push_back('1');
			}
			else S.push_back('0');
			N /=(-2LL);
		}
	}
	S.push_back('1');
	reverse(ALL(S));
	out(S);
	return 0;
}


Measured memory_bytes: 256
import functools
import fractions

n, k = map(int, input().split())
a = list(map(int, input().split()))
m = max(a)

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(fractions.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


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

#define int     long long int
#define pii     pair<int, int>
#define vi      vector<int>
#define vii     vector<pair<int, int>>
#define pb      push_back
#define all(a)  (a).begin(),(a).end()
#define f       first
#define s       second
#define endl    '\n'
#define mod     1000000007    		

void solve()
{
	int a, b ;
	cin >> a >> b ;
	cout << a * b << endl ;
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int a[105];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int count=0;
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            a[i]=0;
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 256
require 'set'
S = gets.chomp
s = Set.new
S.each_char { |c|
	s.add c
}
s.sort
if s == Set["E","N","S","W"] \
	|| s == Set["E","W"] \
	|| s == Set["N","S"]
	puts "Yes"
else
	puts "No"
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(),p.end());
    int ans=0;
    rep(i,k) ans+=p[i];
    cout << ans << endl;
}


Measured memory_bytes: 3672
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],ans=0,lft=0;

int main()
{
	cin>>n;
	rep(i,n) scanf("%I64d",&a[i]);
	rep(i,n)
	{
		LL th=min(lft,a[i]);
		a[i]-=th;
		ans+=th;
		ans+=a[i]/2;
		a[i]%=2;
		lft=a[i];
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <set>
#include <utility>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, d, x;
llint p[15][15];
llint dp[15][100005];

int main(void)
{
	cin >> n >> d >> x;
	for(int i = 1; i <= d; i++){
		for(int j = 1; j <= n; j++){
			cin >> p[i][j];
		}
	}
	
	for(int i = 1; i < d; i++){
		for(int j = 0; j <= n; j++){
			for(int k = 100000; k >= 0; k--){
				dp[j][k] = -inf;
			}
		}
		dp[0][x] = 0;
		for(int j = 0; j < n; j++){
			for(int k = 100000; k >= 0; k--){
				dp[j+1][k] = max(dp[j+1][k], dp[j][k]);
				if(k-p[i][j+1] >= 0) dp[j][k-p[i][j+1]] = max(dp[j][k-p[i][j+1]], dp[j][k] + p[i+1][j+1]);
			}
		}
		for(int k = 0; k <= 100000; k++) x = max(x, k+dp[n][k]);
		/*for(int j = 0; j <= n; j++){
			for(int k = 0; k <= 20; k++){
				cout << dp[j][k] << " ";
			}
			cout << endl;
		}
		cout << x << endl;*/
	}
	cout << x << endl;
	
	return 0;
}


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

#define ubuntu ios_base::sync_with_stdio, cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()

const long long MXN = 3e6 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef long double ldub;
typedef unsigned long long ullong;

using namespace std;

string s;

int main(){
    ubuntu;
    ///freopen("in.in", "r", stdin);
    ///freopen("out.out", "w", stdout);
    cin >> s;
    for(int i = 0;i <= 3;i ++){
        if(i == 0){
            s[i] = '2';
        }if(i == 1){
            s[i] = '0';
        }if(i == 2){
            s[i] = '1';
        }if(i == 3){
            s[i] = '8';
        }
    }cout << s;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int maxn=55555;

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

int n,p[maxn+10],prime[maxn+10],cnt,ans[maxn+10],tot;

int getprime()
{
  for(int i=2; i<=maxn; ++i)
    {
      if(!p[i])
        {
          prime[++cnt]=i;
          if(i%5==1)
            {
              ans[++tot]=i;
            }
        }
      for(int j=1; (j<=cnt)&&(i*prime[j]<=maxn); ++j)
        {
          p[i*prime[j]]=1;
          if(!(i%prime[j]))
            {
              break;
            }
        }
    }
  return 0;
}

int main()
{
  getprime();
  n=read();
  for(int i=1; i<n; ++i)
    {
      printf("%d ",ans[i]);
    }
  printf("%d\n",ans[n]);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200010
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int a[N];

signed main()
{
    
    speed
    int k,n;cin>>k>>n;
    rep(i,1,n)cin>>a[i];
    int ans=k-a[1];
    rep(i,2,n){
        ans=min(ans,k-(a[i]-a[i-1]));
    }
    ans=min(a[n]-a[1],ans);
    cout<<ans<<endl;





    
    


    return 0;
}


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

int main(){
  int N;
  cin >> N;
  long long M = 1000000007;
  long long a = 1;
  long long b = 1;
  long long c = 1;
  for(int i = 0; i < N; i++){
    a = (a*10)%M;
    b = (b*9)%M;
    c = (c*8)%M;
  }
  long long sum = a;
  sum = (sum-b)%M;
  if(sum < 0) sum += M;
  sum = (sum-b)%M;
  if(sum < 0) sum += M;
  sum = (sum+c)%M;
  cout << sum << endl;
}

Measured memory_bytes: 3632
// AOJ 2191: A Book Shop With a Frequent Greetings
// 2017.12.10

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define QSIZE 2000000
#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

typedef struct { int t, n; } QUE;
QUE que[QSIZE+2];
int qsize;

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

int max;
void enq(int n, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].t = t, que[i].n = n;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}

int xp[1001], yp[1001];
int rel[1001][1001];
int len[1001];
int prev[1001];

char buf[30], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	p++;
	return n;
}

int main()
{
	int cno, n, X, Y, x0, y0, i, j, t, ans;

	fgets(p=buf, 10, stdin), cno = getint();
	while (cno--) {
		fgets(p=buf, 30, stdin);
		n = getint(), X = getint(), Y = getint();
		fgets(p=buf, 30, stdin);
		x0 = getint(), y0 = getint();
		for (i = 0; i < n; i++) {
			fgets(p=buf, 30, stdin);
			xp[i] = getint(), yp[i] = getint();
		}

		ans = 0, qsize = 0;
		memset(prev, 0x81, sizeof(prev));
		memset(len, 0, sizeof(len));
		for (i = 0; i < n; i++) {
			if (hypot(xp[i]-x0, yp[i]-y0) <= 10) enq(i, 0);
			for (j = i+1; j < n; j++) {
				if (hypot(xp[i]-xp[j], yp[i]-yp[j]) <= 50)
					rel[i][len[i]++] = j, rel[j][len[j]++] = i;
			}
		}

		while (qsize) {
			i = que[0].n, t = que[0].t, deq();
			if (t > n*X) { ans = -1; break; }
			if (prev[i] < t-Y) {
				t += X;
				prev[i] = t;
				if (t > ans) ans = t;
				for (j = 0; j < len[i]; j++) enq(rel[i][j], t);
			}
		}
		if (ans < 0) puts("You're always welcome!");
		else printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 13444
#include<stdio.h>
int main(void)
{
	int t[4][14];
	int n, i, j, sum;
	char m, mark;
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 14; j++)
		{
			t[i][j] = 0;
		}
	}
	scanf("%d", &sum);
	for (i = 0; i < sum; i++)
	{
		scanf("%c", &mark);
		scanf("%c %d", &m, &n);
		if (m == 'S')
		{
			t[0][n] = 1;
		}
		else if (m == 'H')
		{
			t[1][n] = 1;
		}
		else if (m == 'C')
		{
			t[2][n] = 1;
		}
		else if (m == 'D')
		{
			t[3][n] = 1;
		}
	}
	for (j = 1; j < 14; j++)
	{
		if (t[0][j] != 1)
		{
			printf("S %d\n", j);
		}
	}

	for (j = 1; j < 14; j++)
	{
		if (t[1][j] != 1)
		{
			printf("H %d\n", j);
		}
	}

	for (j = 1; j < 14; j++)
	{
		if (t[2][j] != 1)
		{
			printf("C %d\n", j);
		}
	}

	for (j = 1; j < 14; j++)
	{
		if (t[3][j] != 1)
		{
			printf("D %d\n", j);
		}
	}
	return 0;
}


Measured memory_bytes: 2052
package main

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

var (
	uft      []int
	children map[int]int64
)

func find(x int) int {
	if uft[x] == x {
		return x
	}

	uft[x] = find(uft[x])
	return uft[x]
}

func union(a, b int) {
	uft[a] = uft[b]
	children[b] += children[a]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, m)
	bs := make([]int, m)
	for i := 0; i < m; i++ {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}

	uft = make([]int, n+1)
	children = make(map[int]int64)
	for i := range uft {
		uft[i] = i
		children[i]++
	}

	ans := make([]int64, m)
	ans[m-1] = int64(n * (n - 1) / 2)
	for i := m - 1; i >= 1; i-- {
		ar := find(as[i])
		br := find(bs[i])

		if ar != br {
			ans[i-1] = ans[i] - children[ar]*children[br]
			union(ar, br)
			continue
		}
		ans[i-1] = ans[i]
	}

	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 10880
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(ll i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(ll i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	ll t;
	cin>>t;
	cout<<t*t<<endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;



/* Name of the class has to be "Main" only if the class is public. */



public class Main
{
     
     
     static int mod(int a, int m) 
{ 
    return (a%m + m) % m; 
}
   
    
public static void main (String[] args) throws java.lang.Exception
{Scanner scn = new Scanner(System.in) ;

String s  = scn.nextLine() ;
String t  = scn.nextLine() ; int count  = 0 ;

for(int i = 0 ; i <  s.length() ; i++ )
{
    if(s.charAt(i) != t.charAt(i) )count++ ;
    
    
    
}

System.out.println(count) ;
              
}
}




              
             

Measured memory_bytes: 42212
nv, ne = map(int, input().split(' '))
in_degs = [0] * nv
q = []
outs = {}
o = []

for _ in range(ne):
    s, t = map(int, input().split(' '))

    if s in outs: outs[s].append(t)
    else: outs[s] = [t]

    in_degs[t] += 1

for i in range(nv):
    if in_degs[i] == 0: q.append(i)

while q:
    v = q.pop(0)
    o.append(v)

    if v in outs:
        for out in outs[v]:
            in_degs[out] -= 1
            if in_degs[out] == 0: q.append(out)

[print(v) for v in o]

Measured memory_bytes: 11360
import java.util.*;
import java.io.*;

public class Main {
 
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    int N = in.readInt(); 
	    int cnt[] = new int[1001];
	    int MOD = 1000000007;
	    for (int i = 2; i <= N; i++) {
			int num = i;
			for (int p = 2; p*p <= num; p++) {
				int pow = 0;
				while (num%p == 0) {
					pow++;
					num /= p;
				}
				cnt[p] += pow;
			}
			if (num > 1)
				cnt[num] += 1;
		}
		long ans = 1;
		for (int i = 0; i <= 1000; i++)
			ans = ((cnt[i]+1)*ans)%MOD;
		System.out.println(ans);
		
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 22228
#include <cstdio>
	#include <string>
	#include <cstring>
	#include <iostream>
	#include <algorithm>
	
	using namespace std;
	
	const int maxn = 1e5 + 10;
	
	struct node {
		int t,x,y;
	}dot[maxn];
	
	bool cmp(node a,node b) {
		return a.x != b.x ? a.y < b.y : a.x < b.x;
	}
	
	int u[maxn],v[maxn];
	
	int n;
	
	int main(void) {
		scanf("%d",&n);
		for(int i = 1; i <= n; i ++) {
			scanf("%d%d%d",&dot[i].t,&dot[i].x,&dot[i].y);
		} 
		bool flag = true;
		for(int i = 1; i <= n; i ++) {
			if(abs(dot[i].x - dot[i -1].x ) + abs(dot[i].y - dot[i - 1].y ) > dot[i].t - dot[i - 1].t) {
				flag = false;
				break;
			}
			if((abs(dot[i].x - dot[i -1].x ) + abs(dot[i].y - dot[i - 1].y ) ) != (dot[i].t - dot[i - 1].t ) && i != n) {
				flag = false;
				break;
			}
		
		}
		if(flag) puts("Yes");
		else puts("No");
		return 0;
	} 

Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_N = 100;
int N, K;
int X[MAX_N];
int main(){
scanf("%d", &N);
scanf("%d", &K);
for(int i = 0; i < N; ++i){
scanf("%d", X + i);
}
int ans = 0;
for(int i = 0; i < N; ++i){
int tmp = min(X[i], K - X[i]);
ans += tmp;
}
printf("%d\n", ans * 2);
return 0;
}

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

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

signed main()
{
    int N; cin >> N;
    vector<int> V(N); rep(i, N) cin >> V[i];
    vector<int> C(N); rep(i, N) cin >> C[i];
    
    int ans = 0;
    rep(i, N)
        if (V[i] > C[i]) ans += (V[i] - C[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define maxLL 1000000000000000000

int main(void)
{
	int x;
	long long int A[100000];
	long long int y = 1;
	scanf("%d", &x);
	for (int i = 0; i < x; i++)
	{
		scanf("%lld", &A[i]);
		if (A[i] == 0)
		{
			printf("0");
			return 0;
		}
	}
	for (int i = 0; i < x; i++)
	{
		if (A[i] > maxLL / y)
		{
			printf("-1");
			return 0;
		}
		y = y * A[i];

	}
	if (y > maxLL)
	{
		puts("-1");
	}
	else
	{
		printf("%lld", y);
	}
	return 0;
}

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

using namespace std;

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	
	vector<int> x = {a, b, c, d, e};
	sort(x.begin(), x.end());

	if (x.back() - x.front() <= k) {
		cout << "Yay!";
	} else {
		cout << ":(";
	}
}


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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define eb emplace_back
#define pb push_back
#define lli long long int
#define modn 998244353
#define NL '\n'

using namespace std;

typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< bool > vb;
typedef vector< string > vs;
typedef vector< lli > vli;
typedef vector< vector< char > > vvc;
typedef vector< vector< int > > vvi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef pair< lli, int> pli;
typedef pair< lli, lli> pll;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	#ifdef LOCAL_TEST
		clock_t z = clock();
    	ifstream h("in");
	    ofstream g("out");
	#else
	    #define h cin
	    #define g cout
	#endif // LOCAL_TEST

	int hr, a;
	h >> hr >> a;
	g << (hr + a - 1) / a;

	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << fixed << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif // LOCAL_TEST
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d;
    cin >> d;
    vector<int> c(26);
    for(int i=0; i<26; i++) cin >> c[i];
    vector<vector<int>> G(d,vector<int> (26));
    for(int i=0; i<d; i++){
        for(int j=0; j<26; j++){
            cin >> G[i][j];
        }
    }
    vector<int> t(d);
    for(int i=0; i<d; i++){
        t[i] = rand() % 26;
    }
    ll sum = 0;
    for(int k=0; k<10000; k++){
        vector<P> pre(100);
        for(int i=0; i<100; i++){
            int a = rand() % d;
            int b = rand() % 26;
            pre[i].first = a;
            pre[i].second = t[a];
            t[a] = b;
        }
        vector<ll> now(26,0);
        vector<int> last(26,0);
        for(int i=0; i<d; i++){
            last[t[i]] = i+1;
            now[t[i]] += G[i][t[i]];
            for(int j=0; j<26; j++){
                now[t[i]] -= c[j] * (i+1 - last[j]);
            }
        }
        ll s = 0;
        for(int j=0; j<26; j++){
            s += now[j];
        }
        if(s > sum){
            sum = s;
        }else{
            for(int i=0; i<100; i++){
                t[pre[i].first] = pre[i].second;
            }
        }
    }
    for(int i=0; i<d; i++){
        cout << t[i]+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <complex>
#include <iomanip>
#include <random>

using namespace std;

typedef long long ll;
#define int long long

int M = (int)1e9 + 7;
#define msum(a, b) ((a) + (b) >= M ? (a) + (b) - M : (a) + (b))
#define msub(a, b) ((a) - (b) < 0 ? (a) - (b) + M : (a) - (b))
#define mmult(a, b) (((a) * (b)) % M)

typedef long double ld;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vlll;
typedef vector<double> vd;
typedef vector<vd> vdd;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpi;
#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)(a).size())
#define watch(x) cout << (#x) << " = " << (x) << endl;

const double PI = 2 * acos(0.0);
const int oo = 1e18 + 100;
const string DIGITS = "0123456789", alph = "abcdefghijklmnopqrstuvwxyz", ALPH = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

//THE END OF TEMPLATE////////////////////////////////////////////////////////////////////////////////

#define N 3100



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

	int n, w;
	cin >> n >> w;
	vi a(n + 1), b(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];

	vvi dp(n + 1, vi(w + 1));

	dp[0][0] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			dp[i][j] = dp[i - 1][j];
			if (j - a[i] >= 0)
				inmax(dp[i][j], dp[i - 1][j - a[i]] + b[i]);
		}
	}

	int mx = 0;
	for (int i = 0; i <= w; i++)
		inmax(mx, dp[n][i]);

	
	cout << mx;




}

//m1.codeforces.com, m2.codeforces.com или m3.codeforces.com

Measured memory_bytes: 80256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::string S;
std::set<char> mp;
std::set<char> L[300010], R[30010];
std::set<std::string> ans;

int main()
{
  std::cin >> N >> S;

  rep( i, N )
  {
    L[i] = mp;

    mp.emplace( S[i] );
  }

  mp.clear();

  repd( i, N )
  {
    R[i] = mp;

    mp.emplace( S[i] );
  }

  rep( i, N )
  {
    for( auto l : L[i] ) for( auto r : R[i] )
    {
      std::string t;
      t += l;
      t += S[i];
      t += r;

      ans.emplace( t );
    }   
  }

  std::cout << ans.size() << std::endl;

  return 0;
}

Measured memory_bytes: 36224