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

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;

#define all(x) x.begin(), x.end()

const int MOD = 1000000009;
const int INF = 2e9;

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
	string s;
	s += ch;
	return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
  	to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
  	to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define pb push_back
#define fi first
#define se second  

void solve() {
  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        sum += __gcd(i, __gcd(j, k));
      }
    }
  }
  cout << sum << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);	
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
} 

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

using namespace std;

const int INF=2e9+10;

int main()
{
    int n,m;

    while(cin>>n>>m)
    {
        vector<int> v(n+1),w(n+1);
        for(int i=1;i<=n;i++)
        {
            cin>>v[i]>>w[i];
        }
        vector<vector<int> > dp(n+1,vector<int>(10001));
        fill(dp[0].begin(),dp[0].end(),INF);
        dp[0][0]=0;
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<10001;j++)
            {
                dp[i][j]=dp[i-1][j];
                if(j-v[i]>=0)
                {
                    dp[i][j]=min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
                }
            }
        }
        for(int i=10000;i>=0;i--)
        {
            if(dp[n][i]<=m)
            {
                cout<<i<<endl;
                break;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 6844
<?php
$n = trim(fgets(STDIN));
$a = explode(' ',trim(fgets(STDIN)));

$max = 0;
$min = 1000000001;
for ($i = 0; $i < $n; $i++) {
    $min = $a[$i] < $min ? $a[$i] : $min;
    $max = $a[$i] > $max ? $a[$i] : $max;
}

print $max - $min;


Measured memory_bytes: 4604
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
struct Node{
    int location;
    int p,left,right;
};
 
struct Point{
    Point(){
        id = x = y = 0;
    }
 
    Point(int arg_id,int arg_x,int arg_y){
        id = arg_id;
        x = arg_x;
        y = arg_y;
    }
    bool operator < (const Point & arg)const{
        return id < arg.id;
    }
    void print(){
        printf("%d\n",id);
    }
    int id,x,y;
};
 
static const int MAX = 1000000;
static const int NIL = -1;
 
int N;
Point P[MAX];
Node T[MAX];
int number;
 
bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y; }
 
int makeKDTree(int left,int right, int depth){
 
    if(!(left < right))return NIL;
 
    int mid = (left+right)/2;
 
    int node_id = number++;
 
    if(depth%2 == 0){
        sort(P+left,P+right,lessX);
    }else{
        sort(P+left,P+right,lessY);
    }
 
    T[node_id].location = mid;
    T[node_id].left = makeKDTree(left,mid,depth+1);
    T[node_id].right = makeKDTree(mid+1,right,depth+1);
 
    return node_id;
}
 
void find(int node_id,int sx,int tx,int sy,int ty, int depth, vector<Point> &ans){
 
    int x = P[T[node_id].location].x;
    int y = P[T[node_id].location].y;
 
    if(sx <= x && x <= tx && sy <= y && y <= ty){
        ans.push_back(P[T[node_id].location]);
    }
 
    if(depth%2 == 0){
        if(T[node_id].left != NIL){
            if(sx <= x)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[node_id].right != NIL){
            if( x <= tx)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
        }
    }else{
        if(T[node_id].left != NIL){
            if(sy <= y)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[node_id].right != NIL){
            if(y <= ty)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
        }
    }
}
 
 
int main(){
 
    int x,y;
    scanf("%d",&N);
    for(int i = 0; i < N; i++){
        scanf("%d %d",&x,&y);
        P[i] = Point(i,x,y);
        T[i].left = T[i].right = T[i].p = NIL;
    }
 
    number = 0;
 
    int root = makeKDTree(0,N,0);
 
    int q;
    scanf("%d",&q);
    int sx,tx,sy,ty;
    vector<Point> ans;
    for(int i = 0; i < q; i++){
        scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        for(int j = 0; j < ans.size(); j++){
            ans[j].print();
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    int now = 1;
    rep(i,n) {
        now = min(now*2,now+k);
    }
    cout << now << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

bool is_prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

int X;

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

  for (int i = X; i <= 1000000; i++) {
    if (is_prime(i)) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <queue>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

template<class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = 1LL << 60;


signed main() {
    int n; int k; cin >> n >> k;
    vector<bool> usable(10, true);
    for (int i = 0; i < k; i++) {
        int x; cin >> x;
        usable[x] = false;
    }

    for (int i = 1; i <= 1000000; i++) {
        if (i < n) {
            continue;
        }
        string s = to_string(i);
        bool ok = true;
        for (int j = 0; j < (int)s.size(); j++) {
            if (!usable[s[j] - '0']) {
                ok = false;
            }
        }
        if (ok) {
            cout << s << endl;
            return 0;
        }
    }

    exit(1);
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  int W, a, b;
  
  scanf("%d %d %d", &W, &a, &b);
  if (a + W < b) printf("%d\n", b - a - W);
  else if ((a <= b && b <= a + W) || (a <= b + W && b + W <= a + W)) printf("%d\n", 0);
  else printf("%d\n", a - b - W);
  
  return 0;
}

Measured memory_bytes: 128
from collections import deque


def main():
    n, m = map(int, input().split())
    shuttles = [[] for _ in range(n+1)]
    for i in range(m):
        s, e = map(int, input().split())
        shuttles[s].append(e)
    d = deque(shuttles[1])
    ans = 'IMPOSSIBLE'
    while d:
        j = d.popleft()
        if n in shuttles[j]:
            ans = 'POSSIBLE'
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 34428
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	k, _ := strconv.Atoi(Scanner())
	if k > (n-1)*(n-2)/2 {
		fmt.Println(-1)
	} else {
		x := (n - 1) * (n - 2) / 2
		u, v := make([]int, 0), make([]int, 0)
		for i := 2; i <= n; i++ {
			u = append(u, 1)
			v = append(v, i)
		}
		for i := 2; i <= n; i++ {
			for j := i + 1; j <= n; j++ {
				if x == k {
					break
				} else {
					u = append(u, i)
					v = append(v, j)
					x--
				}
			}
		}
		fmt.Println(len(u))
		for i := 0; i < len(u); i++ {
			fmt.Println(u[i], v[i])
		}
	}
}


Measured memory_bytes: 1024
import math

N, D = map(int, input().split())
X = [0] * N
Y = [0] * N
c = 0

for i in range(N):
    X[i], Y[i]  = map(int, input().split())

for i in range(N):
    x = abs(X[i])
    y = abs(Y[i])
    tmp = x**2+y**2
    distance = math.ceil(math.sqrt(tmp))

    if distance <= D:
        c = c+1

print(c)


Measured memory_bytes: 24624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))

int main()
{
    double L;
    cin >> L;

    printf("%f", L * L * L / 27);
    /*ll x1;
    ll x2;
    ll y1;
    ll y2;
    cin >> x1;
    cin >> y1;
    cin >> x2;
    cin >> y2;

    ll x3 = y2 - y1 + x1;
    ll y3 = x1 - x2 + y1;
    ll x4 = y2 - y1 + x2;
    ll y4 = x1 - x2 + y2;
    

    cout << x3 << " "<< y3<< " "<<x4<<" "<< y4<< endl;*/

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    
    int n,m;
    vector<string> blue,red;
    
    cin >> n;
    rep(i,n){
        string c;
        cin >> c;
        blue.push_back(c);
    }
    
    cin >> m;
    rep(i,m){
        string c;
        cin >> c;
        red.push_back(c);
    }
    
    int ans=0;
    
    rep(i,n){
        int subans=0;
        string s = blue[i];
        rep(j,n){
            if(s==blue[j])subans++;
        }
        rep(k,m){
            if(s==red[k])subans--;
        }
        ans=max(ans,subans);
    }
    
    cout << max(0,ans)<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <functional>

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

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	ull N;
	cin >> N;
	bitset<60> bs(N);
	ull dp[61][3] = {};
	dp[0][0] = 1;

	FOR(i, 0, 60) {
		//cout << (bs >> (60 - (i + 1))) << endl;
		
		if (bs[60 - (i + 1)]) {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] = dp[i][0] + dp[i][1];
			dp[i + 1][2] = dp[i][1] * 2 + dp[i][2] * 3;
		}
		else{
			dp[i + 1][0] = dp[i][0] + dp[i][1];
			dp[i + 1][1] = dp[i][1];
			dp[i + 1][2] = dp[i][1] + dp[i][2] * 3;
		}
			dp[i + 1][0] %= MOD;
			dp[i + 1][1] %= MOD;
			dp[i + 1][2] %= MOD;
		
			//cout << dp[i + 1][0] << " " << dp[i + 1][1] << " " << dp[i + 1][2] << endl;
	}
	//cout << endl;
	cout << (dp[60][0] + dp[60][1] + dp[60][2]) % MOD << endl;
	//cin >> N;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<ll,l_l> lll;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
ll n,m,s,t;
vector<lll> path[100010];
ll d1[100100],d2[100100];
void Dijkstra1(ll s){
    rrep(i,n)d1[i]=LINF;
    priority_queue<l_l,vector<l_l>,greater<l_l>> pq;
    pq.push({0,s});
    d1[s]=0;
    while(pq.size()){
        ll nowcost=pq.top().fi;
        ll nowpos=pq.top().se;
        pq.pop();
        if(nowcost>d1[nowpos])continue;
        for(auto nxt:path[nowpos]){
            ll nxtcost=nowcost+nxt.se.fi;
            ll nxtpos=nxt.fi;
            if(chmin(d1[nxtpos],nxtcost)){
                pq.push({nxtcost,nxtpos});
            }
        }
    }
}
void Dijkstra2(ll s){
    rrep(i,n)d2[i]=LINF;
    priority_queue<l_l,vector<l_l>,greater<l_l>> pq;
    pq.push({0,s});
    d2[s]=0;
    while(pq.size()){
        ll nowcost=pq.top().fi;
        ll nowpos=pq.top().se;
        pq.pop();
        if(nowcost>d2[nowpos])continue;
        for(auto nxt:path[nowpos]){
            ll nxtcost=nowcost+nxt.se.se;
            ll nxtpos=nxt.fi;
            if(chmin(d2[nxtpos],nxtcost)){
                pq.push({nxtcost,nxtpos});
            }
        }
    }
}
int main(){
    cin>>n>>m>>s>>t;
    rep(i,m){
        ll u,v,a,b;cin>>u>>v>>a>>b;
        path[u].pb({v,{a,b}});
        swap(u,v);
        path[u].pb({v,{a,b}});
    }
    Dijkstra1(s);
    Dijkstra2(t);
    multiset<ll> ss;
    rrep(i,n){
        ss.insert(1000000000000000-d1[i]-d2[i]);
        //cout<<d1[i]<<" "<<d2[i]<<endl;
    }
    auto itr=ss.end();
    itr--;
    cout<<*itr<<endl;
    rrep(i,n-1){
        ll tmp=1000000000000000-d1[i]-d2[i];
        ss.erase(ss.find(tmp));
        auto it=ss.end();
        it--;
        cout<<*it<<endl;
    }
    return 0;
}

Measured memory_bytes: 16896
//BISMILLAHIR RAHMANIR RAHEEM
//ALLAH IS WATCHING ME
// Allah amader korona virus theke rokkha korun.Amin.

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#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> //order_of_key return number of elements less than x, find_by_order return index (pointer use kora lgbe)

using namespace std;
using namespace __gnu_pbds;

#define ull    unsigned long long
#define ll    long long
#define ios    ios::sync_with_stdio(0);cin.tie(0);
#define ses   "\n"
#define all(x) (x).begin(), (x).end()
//#define INF   ((int)2e18)
#define ii pair<ll, ll>

string digit="0123456789";
string small="abcdefghijklmnopqrstuvwxyz";
string capital="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; // 8-direction.......
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[]= {1,-1,0,0}; // 4-direction...........
int dy4[]= {0,0,1,-1};

const int N=1e6+5;
const ll M=1e18;

typedef tree< ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;

struct Edge
{
    int u, vv;
    bool operator<(Edge const& other)
    {
        return vv > other.vv;
    }
}; // eta joss jinis.krsukal er jnno and sort 1 out of 3 or more er jnno better

/////////////////////////////////////////////////////////////////////////////
bool subsequence(string s, string t,ll i , ll point){
  for(ll k = i ; k<s.size();k++){
            if(s[k]==t[point])point++;
            if(point==t.size())return 1;
  }
  if(point<t.size())return 0;
}
////////////////////////////////////////////////////////////////////////////
//main function is here.........
int main()
{
       //ios
    string s,ss,sk;
    cin>>s;
    ll ans=1;
    ss = s.substr(0,(s.size()-1)/2);
    sk=ss;
    reverse(all(sk));
    if(sk!=ss){
          ans=0;
    }
    //cout<<ss<<ses;
    ss = s.substr(((s.size()+3)/2)-1,1 + s.size()-(s.size()+3)/2);
    sk=ss;
    reverse(all(sk));
    if(sk!=ss){
          ans=0;
    }
    ss=s;
    reverse(all(ss));
    if(s!=ss){
          ans=0;
    }
    if(ans)cout<<"Yes"<<ses;
    else cout<<"No"<<ses;
}


/*



*/



//Alhamdulillah


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int q,w,e;
	cin>>q>>w>>e;
	int k=min((max(q,w)-min(q,w)),(max(q,e)-min(q,e)));
	if (k==(max(q,w)-min(q,w))){
		cout<<'A'<<endl;
	}
	else{
		cout<<'B'<<endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());
        Long A[] = new Long[N+1];
        Long B[] = new Long[N];

        for(int i=0;i<N+1;i++){
            A[i] = Long.parseLong(scan.next());
        }
        for(int i=0;i<N;i++){
            B[i] = Long.parseLong(scan.next());
        }

        long counter = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                counter += A[i];
                B[i] -= A[i];
                A[i] = 0L;                
            }else{
                counter += B[i];
                A[i] -= B[i];
                B[i] = 0L;
            }

            if(B[i] != 0L){
                if(A[i+1] <= B[i]){
                    counter += A[i+1];
                    B[i] -= A[i+1];
                    A[i+1] = 0L;                
                }else{
                    counter += B[i];
                    A[i+1] -= B[i];
                    B[i] = 0L;
                }
            }
        }
        
        System.out.println(counter);
    }
}

Measured memory_bytes: 66240
#include <stdio.h>

int main(int argc,char* argv[]){
  int is_first = 1;


  for(;;){
    int from,to,i,is_NA = 1;
    scanf("%d %d",&from,&to);
    if(from == 0 && to == 0){break;}
    
    if(is_first != 1){
      printf("\n");
    }

    for(i = from; i <= to; i++){
      if((i % 4) == 0){
	if((i % 100) == 0){
	  if((i % 400) == 0){
	    is_NA = 0;
	    printf("%d\n",i);
	  }
	}else{
	  is_NA = 0;
	    printf("%d\n",i);
	}
      }
    }

    if(is_NA == 1){
      printf("NA\n");
    }

    if(is_first == 1){
      is_first = 0;
    }
  }
  
  return 0;
  
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

#define NMAX 1000000

int main() {
  int n, p, m, x, v;
  int a[NMAX+1];
  a[0] = a[1] = 0;
  for (int i=2; i<=NMAX; i++) {
    a[i] = 1;
  }
  for (int i=2; i*i<=NMAX; i++) {
    if (!a[i]) continue;
    for (int j=i+i; j<=NMAX; j+=i) {
      a[j] = 0;
    }
  }
  for (int i=1; i<=NMAX; i++) {
    a[i] += a[i-1];
  }

  while (1) {
    cin >> n;
    if (!n) break;
    v = 0;
    for (int i=0; i<n; i++) {
      cin >> p >> m;
      x = a[min(p+m,NMAX)] - a[max(0,p-m-1)];
      v += x-1;
    }
    cout << max(v,0) << endl;
  }
  return 0;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9 + 5;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

int main()
{
    int n, k;
    cin >> n >> k;
    vector<bool> dp(k + 1);
    vi in(n);
    for(int &x : in)
    {
        cin >> x;
    }
    for(int i = 0; i <= k; i++)
    {
        for(int j : in)
        if(i >= j && !dp[i - j])
                dp[i] = true;
    }
    if(dp[k]) printf("First");
    else printf("Second");
}


Measured memory_bytes: 256
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();
		int c = sc.nextInt();
		int d = sc.nextInt();

		while(0 < c && 0 < a) {
			c -= b;
			if(c <= 0) {
				break;
			}
			a -= d;
		}
		if(0 < a) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}

}

Measured memory_bytes: 35636
import java.util.Scanner;

/**
 * Main
 */
public class Main {
  public static void main(String[] args) {
    (new Main()).run();
  }

  public void run() {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    System.out.println(n / 2 + n % 2);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    int a = 10 ;
    int ans = 0 ;
    for (int i = 0; i < 5; i++)
    {
        if (n >= a)
        {
            if (i%2 == 0)
            {
                ans += (a-1) - (a/10 - 1) ;
            }
            
        }
        else
        {
            if (i%2 == 0)
            {
                ans += n - (a/10 - 1) ;
            }
            break ;
        }
        a *= 10 ;
    }
    cout << ans << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

using edge = struct{int to; ll cost;};
vector<edge> tree[100100];

ll depth[100100];

//
void dfs(int v, int p, ll d){
    depth[v] = d;

    for(auto e: tree[v]){
        if(e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }

}

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

    rep(i,n-1){
        int a, b;ll c; cin >> a >> b >> c; a--; b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }

    int q,k; cin >> q >> k; k--;

    dfs(k,-1,0);

    rep(i,q){
        int x,y; cin >> x >> y; x--; y--;
        cout << depth[x] + depth[y] << endl;
    }

}

    

Measured memory_bytes: 14336
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<=b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ll long long int
#define lld long double
#define endl "\n"
#define MOD 1000000007

/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

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

}
int main()
{
   IOS

    int TESTS=1;
  //  cin >> TESTS;
    while (TESTS--)
    {
        ll k;
        cin >> k;
        ll sum=0;
        rep(i,1,k)
        {
           rep(j,1,k)
           {
               rep(m,1,k)
               {
                  ll ans=gcd(gcd(i,j),m);
                   sum+=ans;
               }
           }
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3548
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int H, W, K; cin >> H >> W >> K;

    vector<string> C(H);
    for (int i = 0; i < H; i++) cin >> C[i];

    int ans = 0;

    for (int bit_h = 0; bit_h < 1<<H; bit_h++) {
        for (int bit_w = 0; bit_w < 1<<W; bit_w++) {

            vector<string> c = C; 
            
            for (int i = 0; i < H; i++) {
                if (bit_h & 1<<i) {
                    for (int j = 0; j < W; j++) {
                        c[i][j] = 'x';
                    }
                }
            }

            for (int i = 0; i < W; i++) {
                if (bit_w & 1<<i) {
                    for (int j = 0; j < H; j++) {
                        c[j][i] = 'x';
                    }
                }
            }

            int cnt = 0;

            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    //cout << c[i][j] << " ";
                    if (c[i][j] == '#') cnt++;
                }
                //cout << endl;
            }
            //cout << endl;

            if (cnt == K) ans++;
        }
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 3632
import java.util.HashMap;
import java.util.Scanner;

public class Main {

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

			HashMap<Integer, Integer> odd = new HashMap<Integer, Integer>();
			HashMap<Integer, Integer> even = new HashMap<Integer, Integer>();

			boolean allSame = true;
			int before = 0;
			for (int i = 0; i < n; i++) {
				int v = sc.nextInt();
				if (i != 0 && before != v) {
					allSame = false;
				}
				if (i % 2 == 0) {
					if (odd.containsKey(v)) {
						odd.put(v, odd.get(v) + 1);
					} else {
						odd.put(v,  1);
					}
				} else {
					if (even.containsKey(v)) {
						even.put(v, even.get(v) + 1);
					} else {
						even.put(v,  1);
					}
				}
				before = v;
			}

			if (allSame) {
				System.out.println(n / 2);
				return;
			}

			if (odd.keySet().size() == 1 && even.keySet().size() == 1 && !odd.keySet().toArray()[0].equals(even.keySet().toArray()[0])) {
				System.out.println(0);
				return;
			}

			int oddMaxValue = 0;
			int oddMaxCount = 0;
			for (int i : odd.keySet()) {
				if (oddMaxCount < odd.get(i)) {
					oddMaxValue = i;
					oddMaxCount = odd.get(i);
				}
			}
			int oddNextValue = 0;
			int oddNextCount = 0;
			for (int i : odd.keySet()) {
				if (oddNextCount < odd.get(i) && i != oddMaxValue) {
					oddNextValue = i;
					oddNextCount = odd.get(i);
				}
			}

			int evenMaxValue = 0;
			int evenMaxCount = 0;
			for (int i : even.keySet()) {
				if (evenMaxCount < even.get(i)) {
					evenMaxValue = i;
					evenMaxCount = even.get(i);
				}
			}
			int evenNextValue = 0;
			int evenNextCount = 0;
			for (int i : even.keySet()) {
				if (evenNextCount < even.get(i) && i != evenMaxValue) {
					evenNextValue = i;
					evenNextCount = even.get(i);
				}
			}

			if (oddMaxValue != evenMaxValue) {
				System.out.println(n - oddMaxCount - evenMaxCount);
			} else {
				if (oddMaxCount == evenMaxCount) {
					if (oddNextCount < evenNextCount) {
						System.out.println(n - oddMaxCount - evenNextCount);
					} else {
						System.out.println(n - oddNextCount - evenMaxCount);
					}
				} else {
					if (oddMaxCount < evenMaxCount) {
						System.out.println(n - oddNextCount - evenMaxCount);
					} else {
						System.out.println(n - oddMaxCount - evenNextCount);
					}
				}
			}
			return;
		}
	}
}


Measured memory_bytes: 65576
N = int(input())
p = list(map(int, input().split()))

err=[]
err_idx=[]

for i in range(N):
  if (i+1)!=p[i]:
    err.append(p[i])
    err_idx.append(i)
if len(err)>=3:
  print("NO")
  exit()
elif len(err)==0:
  print("YES")
  exit()
#print(err)
p[err_idx[0]] = err[1]
p[err_idx[1]] = err[0]

for i in range(N):
  if (i+1)!=p[i]:
    print("NO")
    exit()
print("YES")

Measured memory_bytes: 3064
N, M = map(int, input().split())
a = [0 for _ in range(N)]
b = [0 for _ in range(N)]
c = [0 for _ in range(M)]
d = [0 for _ in range(M)]
distance = []
for i in range(N):
    a[i], b[i] = map(int, input().split())
for j in range(M):
    c[j], d[j] = map(int, input().split())

for i in range(N):
    for j in range(M):
        distance.append(abs(a[i]-c[j])+abs(b[i]-d[j]))
    print(distance.index(min(distance))+1)
    distance = []

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

using namespace std;

int N;
string arr[100005];

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N;
    for(int i = 1; i<=N; i++){
        cin >> arr[i];
        sort(arr[i].begin(), arr[i].end());
    }
    sort(arr+1, arr+1+N);
    int lst = 0;
    long long ans = 0;
    for(int i = 2; i<=N; i++){
        lst++;
        for(int j = 0; j<10; j++){
            if(arr[i-1][j] != arr[i][j]){
                lst = 0;
                break;
            }
        }
        ans += lst;
    }
    cout << ans << endl;
}


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

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
   int u, minv;
   int d[MAX], p[MAX], color[MAX];

   // 初期化
   rep(i, n) {
      d[i] = INFTY;
      p[i] = -1;
      color[i] = WHITE;
   }

   d[0] = 0;

   while(1) {
      minv = INFTY;
      u = -1;

      rep(i, n){
         if (minv > d[i] && color[i] != BLACK) {
            u = i;
            minv = d[i];
         }
      }
      if(u == -1) break;
      // uの決定
      color[u] = BLACK;

      rep(v, n) {
         if(color[v] != BLACK && M[u][v] != INFTY) {
            if(d[v] > M[u][v]) {
               d[v] = M[u][v];
               p[v] = u;
               color[v] = GRAY;
            }
         }
      }
   }
   int sum = 0;
   rep(i, n) {
      if(p[i] != -1) sum += M[i][p[i]];
   }
   return sum;
}

void dijkstra() {
   int minv;
   int d[MAX], color[MAX];

   // 初期化
   rep(i, n) {
      d[i] = INFTY;
      color[i] = WHITE;
   }

   d[0] = 0;
   color[0] = GRAY;

   while(true) {
      minv = INFTY;
      int u = -1;
      rep(i, n) {
         if(minv > d[i] && color[i] != BLACK) {
            u = i;
            minv = d[i];
         }
      }
      if (u == -1) break;

      // 最も小さいコストのuが決まる 初回は必ず0になる
      color[u] = BLACK;

      rep(v, n) {
         // 0 ~ n-1の頂点が未訪問かつuとの経路がある場合
         if(color[v] != BLACK && M[u][v] != INFTY) {
            // 頂点uを通った方が目的地に近い場合
            if (d[v] > d[u] + M[u][v]) {
               d[v] = d[u] + M[u][v];
               color[v] = GRAY;
            }
         }
      }
   }

   rep(i, n) {
      cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
   }
}

int main(){
   cin >> n;
   rep(i, n) {
      rep(j, n) {
         M[i][j] = INFTY;
      }
   }

   int k, c, u, v;
   rep(i, n) {
      cin >> u >> k;
      rep(j, k){
         cin >> v >> c;
         M[u][v] = c;
      }
   }

   dijkstra();

   return 0;
}



Measured memory_bytes: 3108
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define umap unordered_map
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



template<class Abel> struct UF {
    vector<ll> par;
    vector<ll> rank;
    vector<Abel> diff_weight;

    UF(ll n = 1, Abel SUM_UNITY = 0) {
        reset(n, SUM_UNITY);
    }

    void reset(ll n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (ll i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(ll x) {
        if (par[x] == x) {
            return x;
        }
        else {
            ll r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(ll x) {
        root(x);
        return diff_weight[x];
    }

    bool same(ll x, ll y) {
        return root(x) == root(y);
    }

    bool unite(ll x, ll y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel dif(ll x, ll y) {
        return weight(y) - weight(x);
    }
};


int main(){
  ll n,m;
  cin>>n>>m;
  
  UF<ll> uf(n);
  
  rep(i,m){
  ll l,r,d;
  cin>>l>>r>>d;
    if(uf.same(l-1,r-1)) {
      if(uf.dif(l-1,r-1)!=d) {
      cout << "No" << endl;
      return 0;
      }
    }
    else uf.unite(l-1,r-1,d);
  }
  
  cout << "Yes" << endl;
  
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,m,To[100005];
int a[100005],d[100005],to[65][100005],pos[100005];
long long k,f[100005];

long long read(){
	long long x=0,w=0;char ch=getchar();
	while(!isdigit(ch)) w|=(ch=='-'),ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}

void print(long long x){
	if(x>=10) print(x/10);
	putchar(x%10+'0');
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) f[i]=read();
	m=read(),k=read();
	for(int i=1;i<=m;i++) a[i]=read();
	for(int i=1;i<=n;i++) d[i]=f[i]-f[i-1],pos[i]=i;
	for(int i=1;i<=m;i++) swap(pos[a[i]],pos[a[i]+1]);
	for(int i=1;i<=n;i++) to[0][pos[i]]=i;
	for(int i=1;i<=64;i++){
		for(int j=1;j<=n;j++) to[i][j]=to[i-1][to[i-1][j]];
	}
	int bit=0;
	for(int i=1;i<=n;i++) To[i]=i;
	while(k){
		if(k&1) for(int i=1;i<=n;i++) To[i]=to[bit][To[i]];
		k/=2,bit++;
	}
	for(int i=1;i<=n;i++) f[To[i]]=d[i];
	for(int i=1;i<=n;i++) f[i]+=f[i-1];
	for(int i=1;i<=n;i++){
		if(f[i]<0) putchar('-'),f[i]=-f[i];
		print(f[i]),putchar('.'),putchar('0'),puts("");
	}
	
	return 0;
}

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

template<typename T1, typename T2>
istream& operator>>(istream& os, pair<T1, T2>& p) {
	os >> p.first >> p.second;
	return os;
}

int main() {
	ll n, d, a;
	cin >> n >> d >> a;
	vector<pair<ll, ll>> v(n);
	for (ll i = 0; i < n; ++i)cin >> v[i];
	sort(v.begin(), v.end());
	vector<ll> x(n);
	vector<ll> h(n);
	for (ll i = 0; i < n; ++i) {
		x[i] = v[i].first;
		h[i] = (v[i].second - 1) / a + 1;
	}
	vector<ll> sum(n, 0);
	ll ans = 0;
	for (ll i = 0; i < n; ++i) {
		if (i != 0)sum[i] += sum[i - 1];
		ll preans = max(0ll,h[i] - sum[i]);
		ans += preans;
		sum[i] += preans;
		ll idx = distance(x.begin(), upper_bound(x.begin(), x.end(), x[i] + 2 * d));
		if (idx < n)sum[idx] -= preans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11188
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	int a[3] = { 0 }, flag = 0;
	char c;
	for (int i = 0; i < 3; i++){
		scanf("%c", &c);
		a[c - 'a']++;
	}

	for (int i = 0; i < 3; i++){
		if (!a[i]){
			flag++;
		}
	}
	
	if (flag)
		printf("No\n");
	else
		printf("Yes\n");

	return 0;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
vl vec;  
ll powe[20]; 
ll check(ll val){
	ll sumi=0;
	ll val1=val;
	while(val1!=0){
		sumi+=val1%10;
		val1/=10;
	}
	ll ans=1;
	ll haha=val;
	while(haha){
		if(haha%10!=9){
			if(ans*sumi<val){
				//cout<<val<<" "<<sumi*ans<<endl;
				return 0;
			}
		}
		haha/=10;
		ans*=10;
		
	}
	return 1;
} 
ll check3(ll num,ll sumi,ll val){
	val=powe[val];
	if(sumi*val<num)
		return 0;
	return 1;
}
int main(){
    std::ios::sync_with_stdio(false);
    ll k;
    cin>>k;
    ll i;
    powe[0]=1;
    f(i,1,20){
    	powe[i]=powe[i-1]*10;
    }
    //cout<<check(3)<<endl;
    //return 0;
    f(i,1,1000){
    	if(check(i)){
    		vec.pb(i);
    	}
    }
    ll rest,sumi;
    ll j,p,q;
    rest=0;
    sumi=0;
    f(i,4,16){
    	sumi+=9;
    	rest*=10;
    	rest+=9;
    	f(j,1,10){
    		rep(p,10){
    			rep(q,10){
    				if(q!=9){
    					if(check3(j*powe[i-1]+p*powe[i-2]+q*powe[i-3]+rest,sumi+j+p+q,i-3))
    						vec.pb(j*powe[i-1]+p*powe[i-2]+q*powe[i-3]+rest);
    				}
    				else if(p!=9){
    					if(check3(j*powe[i-1]+p*powe[i-2]+q*powe[i-3]+rest,sumi+j+p+q,i-2))
    						vec.pb(j*powe[i-1]+p*powe[i-2]+q*powe[i-3]+rest);
    				}
    				else if(j!=9){
    					if(check3(j*powe[i-1]+p*powe[i-2]+q*powe[i-3]+rest,sumi+j+p+q,i-1))
    						vec.pb(j*powe[i-1]+p*powe[i-2]+q*powe[i-3]+rest);
    				}
    				else{
    					vec.pb(j*powe[i-1]+p*powe[i-2]+q*powe[i-3]+rest);	
    				}
    			}
    		}
    	}
    }
    sort(all(vec));
    rep(i,k){
    	cout<<vec[i]<<endl;
    }
    return 0;  
    
}



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

int main()
{
  ll N; cin >> N;
  vector<ll> H(N);
  for (int i=0; i<N; i++){
    cin >> H[i];
  }
  ll ans = 0;
  ll cnt = 0;
  for (int i=0; i<N-1; i++) {
    if (H[i] < H[i+1]) {
      cnt=0;
    } else {
      cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main () {
	const int MOD = pow(10, 9) + 7;
	int H, W; cin >> H >> W;
	vector<string> a(H + 1); // 1-ind
	string temp = "";
	rep(i, W + 1) temp += '#';
	a.at(0) = temp; // 1-ind
	rep2(i, 1, H + 1) {
		cin >> temp;
		a.at(i) = '#' + temp;
	}
	// rep(i, H + 1) cout << a.at(i) << endl; // DB

	vii dp(H + 1, vi(W + 1)); dp[1][1] = 1;
	rep2(i, 1, H + 1) {
		rep2(j, 1, W + 1) {
			if (a.at(i).at(j) == '#') continue;
			if (a.at(i).at(j - 1) == '.') dp[i][j] += dp[i][j - 1];
			if (a.at(i - 1).at(j) == '.') dp[i][j] += dp[i - 1][j];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[H][W];
}

Measured memory_bytes: 5248
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;

int x[200];
int y[200];
int N, M, X, Y;

int main() {
    cin >> N >> M >> X >> Y;
    for (int i = 0; i < N; ++i) cin >> x[i];
    for (int i = 0; i < M; ++i) cin >> y[i];    

    int max_x = -110;
    int min_y = 100;

    for (int i = 0; i < N; ++i){
        max_x = max(x[i], max_x);
    }
    for (int i = 0; i < M; ++i){
        min_y = min(y[i], min_y);
    }

    if(max_x >= min_y){
        cout << "War" << endl;
    }else{
        for(int z = max_x + 1; z <= min_y; ++z){
            if((X < z) && (z <= Y)){
                cout << "No War" << endl;
                break;
            }else{
                if(z == min_y){
                    cout << "War" << endl;
                }
            }
        }
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll n;
	cin>>n;
	vector< ll > a,b,c(n,-1);
	priority_queue< pair< ll, ll > > p,q;
	for(ll i=0;i<n;i++)
	{
		ll k;
		cin>>k;
		a.push_back(k);
	}
	for(ll i=0;i<n;i++)
	{
		ll k;
		cin>>k;
		b.push_back(k);
		if(a[i]>b[i])
		p.push(make_pair(a[i]-b[i],i));
		else
		q.push(make_pair(b[i]-a[i],i));
	}
	ll f=0;
	while(!p.empty())
	{
		if(q.empty())
		break;
		ll p1=p.top().first;
		ll p2=p.top().second;
		p.pop();
		while(p1>0)
		{
			if(q.empty())
			break;
			ll q1=q.top().first;
			ll q2=q.top().second;
			q.pop();
			if(q1<p1)
			{
				p1-=q1;
				q1=0;
				c[q2]=b[q2];
			}
			else if(q1==p1)
			{
				p1=0;
				q1=0;
				c[p2]=b[p2];
				c[q2]=b[q2];
				break;
			}
			else
			{
				q1-=p1;
				p1=0;
				c[p2]=b[p2];
				q.push(make_pair(q1,q2));
				break;
			}
		}
		c[p2]=b[p2]+p1;
	}
	for(ll i=0;i<n;i++)
	{
		if(c[i]==-1)
		c[i]=a[i];
	}
	ll k=0;
	for(ll i=0;i<n;i++)
	{
	//	cout<<c[i]<<" "<<a[i]<<endl;
		if(a[i]!=c[i])
		k++;
		if(c[i]<b[i])
		{
			k=-1;
			break;
		}
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[214514],b[214514];
int main(){
	ll n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=1;i<=m;i++){
		cin>>b[i];
		b[i]+=b[i-1];
	}
	ll now=m,ans=0;
	for(int i=0;i<=n;i++){
		for(int j=now;j>=0;j--){
				if(a[i]+b[j]<=k){
					now=j;
					ans=max(ans,i+now);
					break;
				}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6688
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int M = scan.nextInt();
        int X = scan.nextInt();
        HashSet<Integer> station = new HashSet<>();
        for (int i = 0; i < M; i++) {
            station.add(scan.nextInt());
        }
        int costR = 0;
        for(int i = 0; i < X; i++) {
            if (station.contains(i)) {
                costR += 1;
            }
        }
        int costL = 0;
        for(int i = X+1; i <= N; i++) {
            if (station.contains(i)) {
                costL += 1;
            }
        }
        System.out.println(Math.min(costR, costL));
    }
}


Measured memory_bytes: 21844
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = [False]*(k+1)
for i in range(k+1):
  for aj in a:
    if i - aj >=0:
      if s[i-aj] == False:
        s[i] = True
        break
if s[k]==True:
  print("First")
else:
  print("Second")

Measured memory_bytes: 42224
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, size_t D> struct _Vec {
    using type = vector<typename _Vec<T, D-1>::type>;
};
template <class T> struct _Vec<T, 1> {
    using type = vector<T>;
};
template<class T, size_t D> using Vec = typename _Vec<T, D>::type;

template <class T>
vector<T> make_v(size_t size, const T& init){ return vector<T>(size, init); }

template<class... Ts>
auto make_v(size_t size, Ts... rest) {
    return vector<decltype(make_v(rest...))>(size, make_v(rest...));
}

int main() {
    int n, x;
    cin >> n >> x;
    Vec<int, 2> v = make_v(2, n, 0);
    for (auto &&i : v[0]) scanf("%d", &i);
    ll ans = INF<ll>;
    for (int i = 0; i < n; ++i){
        int now = i&1 , nxt = now^1;
        ans = min(ans, accumulate(v[now].begin(), v[now].end(), 0LL)+(ll)x*i);
        for (int j = 0; j < n; ++j) {
            if(j) v[nxt][j] = min(v[now][j-1], v[now][j]);
            else v[nxt][0] = min(v[now][n-1], v[now][0]);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384