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

typedef long long ll;

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

    string S;
    cin >> S;

    int min = 1000;

    for(int i = 0; i < S.length() - 2; i++) {
        int a = static_cast<int>(S[i] - '0') * 100;
        int b = static_cast<int>(S[i + 1] - '0') * 10;
        int c = static_cast<int>(S[i + 2] - '0');

        int x = a + b + c;
        //cerr << x << endl;

        if(abs(x - 753) < min) {
            min = abs(x - 753);
        }
    }

    cout << min << endl;
}

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


int main(){
    int a, b;
    cin >> a >> b;
    a += b;
    int ans;
    if(a&1){
        ans = a/2 + 1;
    }else{
        ans = a/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
if n>399 and n<600:
    print(8)
elif n>599 and n<800:
    print(7)
elif n>799 and n<1000:
    print(6)
elif n>999 and n<1200:
    print(5)
elif n>1199 and n<1400:
    print(4)
elif n>1399 and n<1600:
    print(3)
elif n>1599 and n<1800:
    print(2)
elif n>1799 and n<2000:
    print(1)    

Measured memory_bytes: 9196
N, T = map(int, input().rstrip().split())
data = [list(map(int, input().rstrip().split())) for _ in range(N)]
data.sort(key=lambda x:x[0])
time = [i[1] for i in data]
cost = [i[0] for i in data]
answer = "TLE"
for i in range(N):
    if time[i] <= T:
        answer = cost[i]
        break
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, q;
    string s;
    char t[212345], d[212345];

    cin >> n >> q >> s;
    REP(i, q)
    cin >> t[i] >> d[i];

    //左側を求める
    int l = -1;
    int r = n;

    while (r - l > 1)
    {
        int mid = (r + l) / 2;

        bool check = false;
        int pos = mid;

        REP(i, q)
        {
            if (t[i] == s[pos])
            {
                if (d[i] == 'L')
                    pos--;
                else
                    pos++;
            }

            if (pos < 0)
            {
                check = true;
                break;
            }
        }

        if (check)
        {
            l = mid;
        }
        else
        {
            r = mid;
        }
    }

    int res = n;
    res -= l + 1;

    //右側
    l = -1;
    r = n;

    while (r - l > 1)
    {
        int mid = (r + l) / 2;

        bool check = false;
        int pos = mid;

        REP(i, q)
        {
            if (t[i] == s[pos])
            {
                if (d[i] == 'L')
                    pos--;
                else
                    pos++;
            }

            if (pos >= n)
            {
                check = true;
                break;
            }
        }

        if (check)
        {
            r = mid;
        }
        else
        {
            l = mid;
        }
    }

    res -= n - r;

    cout << res << endl;

    return 0;
}

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

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

  std::string S;
  std::cin >> S;

  std::vector<int> acc_b(N+1);

  for (int i=0; i<N; i++)
    acc_b[i+1]=acc_b[i] + (S[i]=='#' ? 1 : 0);

  std::vector<int> acc_w(N+1);

  for (int i=N-1; i>=0; i--)
    acc_w[i]=acc_w[i+1] + (S[i]=='.' ? 1 : 0);

  int ans = N;

  for (int i=0; i<N+1; i++)
    ans = std::min(ans, acc_w[i] + acc_b[i]);

  std::cout << ans << std::endl;

  return 0;
}


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



int main(){
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL); cout.tie(NULL);

  	int n, k;

  	cin >> n >> k;

  	int ans = 1;

  	for(int i=1; i<=n; i++) {
        if (ans >= k) {
            ans += k;
        }
        else {
            ans = ans*2;
        }
  	}
  	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<17;


int main(){
    int N,M;
    cin >> N >> M;
    int A[N][M];
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    vector<int> v(N,0);
    bool c[M];
    memset(c,false,sizeof(c));
    int ans=INF;
    while(1){
        vector<int> t(M,0);
        for(int i=0;i<N;i++){
            while(c[A[i][v[i]]]){
                v[i]++;
                if(v[i]==M){
                    cout << ans << endl;
                    return 0;
                }
            }
            t[A[i][v[i]]]++;
        }
        int maxi=0,l;
        for(int i=0;i<M;i++){
            if(maxi<t[i]){
                maxi=t[i];
                l=i;
            }
        }
        c[l]=true;
        ans=min(maxi,ans);
    }
    return 0;
}

Measured memory_bytes: 640
n = int(input())

k1 = n % 10
k2 = n % 100
k3 = n / 100

if k1 == 7:
    print("Yes")
elif k2 >= 70 and k2 <= 79:
    print("Yes")
elif k3 >= 7 and k3 < 8:
    print("Yes")
else:
    print("No")

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    vector<int> flag(n, 1);
    flag[n-1] = -1;
    ll ans = 0;
    REP(i, 0, n){cin >> lis[i];}
    sort(ALL(lis), greater<>());
    REP(i, 1, n-1){
        if(lis[i] < 0)
            flag[i] = -1;
    }
    REP(i, 0, n){
        ans += flag[i] * lis[i];
    }
    cout << ans << endl;
    int x = lis[0];
    int i = 0;
    while(1){
        if(flag[i] == -1){break;}
        i++;
    }
    for(; i < n-1; i++){
        cout << x << " " << lis[i] << endl;
        x = x - lis[i];
    }
    int y  = lis[n-1];
    i = 1;
    while(flag[i] == 1){
        cout << y << " " << lis[i] << endl;
        y -= lis[i];
        i++;
    }
    cout << x << " " << y << endl;
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;

    string sub=t.substr(0,t.size()-1);
    if(s==sub)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD =  1000000007;
const ll INF = 1LL << 60;

using Graph = vector<vector<int>>;
Graph g;
vector<bool> seen;
void dfs(int v, int x, int y){
    seen[v] = true;
    for(auto next_v : g[v]){
        if(seen[next_v]) continue;
        if((v == x && next_v == y) || (v == y && next_v == x)) continue;
        dfs(next_v, x, y);
    }
}

int main() {
    int n, m; cin >> n >> m;
    g.resize(n);
    V<P<int, int> > v(m);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
        v[i] = make_pair(a, b);
    }

    int ans = 0;
    for(int i = 0; i < m; i++){
        seen.assign(n, false);
        dfs(0, v[i].first, v[i].second);
        for(int i = 0; i < n; i++){
            if(seen[i]) continue;
            ans++;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

template<typename T>
class SegmentTree{
    public:
    T N;
    T INF;
    vector<T> Tree;
    SegmentTree(int N_, T INF_=(1LL<<31)-1){
        N = 1;
        while(N<N_) N*=2;
        INF = INF_;
        Tree.resize(2*N-1, INF);
    }
    void update(T k, T x){
        k += N-1;
        Tree[k] = x;
        while(k>0){
            k = (k-1)/2;
            Tree[k] = min(Tree[2*k+1], Tree[2*k+2]);
        }
    }
    // half open interval query[a, b) and half open interval node[l, r)
    T query(int a, int b, int k=0, int l=0, int r=-1){
        //cout << a << " " << b << " " << k << " " << l <<" " << r <<endl;
        if(r<0) r = N;
        if(r<=a or b<=l) return INF;
        if(a<=l and r<=b) return Tree[k];
        else{
            T lval = query(a, b, 2*k+1, l, (l+r)/2);
            T rval = query(a, b, 2*k+2, (l+r)/2, r);
            return min(lval, rval);
        }
    }
};
signed main(){
    int N, Q; cin>>N>>Q;
    SegmentTree<int> st(N);
    for(int i=0; i<Q; i++){
        int c; cin>>c;
        int a, b; cin>>a>>b;
        if(c==0) st.update(a, b);
        else cout << st.query(a, b+1) << endl; 
    }
    return 0;
}


Measured memory_bytes: 3812
S,T = open(0).read().split()
ls = len(S)
lt = len(T)
ans = float('inf')
for i in range(ls-lt+1):
    temp = S[i:i+lt]
    t2 = 0
    for j in range(lt):
        if temp[j] != T[j]:
            t2 += 1
    ans = min(ans,t2)
print(ans)

Measured memory_bytes: 9032
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
string ng="UNRESTORABLE",inf=string(58,'z');
int n,m;
string cal(string s,string t,int x){
	rep(i,n){
		if(i>=x && i<x+m){
			if(s[i]!='?' && s[i]!=t[i-x]) return inf;
			s[i]=t[i-x];
		}
		else{
			if(s[i]=='?') s[i]='a';
		}
	}
	return s;
}
int main()
{
	string s,t,out=inf;
	cin>>s;cin>>t;
	n=s.size();m=t.size();
	rep(i,n+1-m){
		//cout<<i<<' '<<cal(s,t,i)<<endl;
		out=min(out,cal(s,t,i));
	}
	if(out>=inf) cout<<ng<<endl;else cout<<out<<endl;
}


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

int vis[1000003],clr[1001][1001],fx[4]={1,-1,0,0},fy[4]={0,0,1,-1},n,m,r=0;
vector< pair<int,int> >adj[1000003];
vector<string>vst;

int bfs2(int src,int dst)
{

    vis[src]=1; int x,y,z,i,j,sz,v,u,st,fn,zt,zn,ans=-1;

    queue<int>qu; qu.push(src);

    while(!qu.empty())
    {

        v=qu.front(); qu.pop(); sz=adj[v].size();

        for(int lp=0;lp<sz;lp++)
        {

            x=adj[v][lp].first; y=adj[v][lp].second;

            st=max(0,x-2);  fn=min(n-1,x+2);
            zt=max(0,y-2);  zn=min(m-1,y+2);

            for(i=st;i<=fn;i++)
            {
                for(j=zt;j<=zn;j++)
                {
                    int e=clr[i][j];
                    if(e!=v && vis[e]==0)
                    {
                        vis[e]=vis[v]+1;

                        if(e==dst)
                        {
                            ans=vis[e]-1;  break;
                        }
                        else
                        {
                            qu.push(e);
                        }

                    }
                }

                if(ans!=-1)break;
            }


            if(ans!=-1)break;

        }


        if(ans!=-1)break;


    }


    return ans;


}

void bfs1(int sx,int sy)
{

    clr[sx][sy]=r; int x,y,z; pair<int,int>tt;

    queue< pair<int,int> >qp; qp.push( {sx,sy} ); adj[r].push_back( {sx,sy} );

    while(!qp.empty())
    {

        tt=qp.front(); qp.pop();  int p=tt.first;  int q=tt.second;

        for(int lp=0;lp<=3;lp++)
        {
            x=p+fx[lp]; y=q+fy[lp];

            if(x>=0 && y>=0 && x<=n-1 && y<=m-1)
            {
                if(clr[x][y]==0 && vst[x][y]=='.')
                {
                    clr[x][y]=r;   adj[r].push_back( {x,y} ); qp.push( {x,y} );
                }
            }

        }


    }


}

int main()
{

    int a,b,c,d,i,j,k,g,h,res;
    char s[1003]; string str;

    scanf("%d %d",&n,&m);
    scanf("%d %d",&a,&b);
    scanf("%d %d",&c,&d);

    for(i=1;i<=n;i++)
    {
        scanf("%s",s);  str=string(s);  vst.push_back(str);
    }

    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            if(vst[i][j]=='.' && clr[i][j]==0){ r++; bfs1(i,j); }

        }
    }

    g=clr[a-1][b-1]; h=clr[c-1][d-1];

    //cout<<g<<" "<<h<<endl;


    if(g==h)printf("0\n");
    else
    {
        res=bfs2(g,h);

        printf("%d\n",res);

    }




    return 0;
}


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

int main() {
  int n, i, a;
  cin >> n;
  
  vector<int> b(9);
  for(i = 0; i < n; i++){
    cin >> a;
    a /= 400;
    b.at(min(a, 8))++;
  }
  
  int keep = 0;
  for(i = 0; i < 8; i++){
    if(b.at(i) > 0) keep++;
  }
  
  if(keep == 0) cout << 1 << " " << n << endl;
  else cout << keep << " " << keep + b.at(8) << endl;
}

Measured memory_bytes: 256
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null, null);

    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null, null);
      while (x != null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      newNode.parent = y;
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  printByPreorder(n = this.root) {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root)
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  const commands = lines.map((line) => line.split(' '));
  commands.forEach(function(cmd) {
    switch(cmd[0].charAt(0)) {
    case 'i': tree.insert(Number(cmd[1])); break;
    default: tree.print();
    }
  });

})();



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;

using ll = long long; using VI=vector<int>; using pii=pair<int, int>; using VL=vector<ll>; const int MD=1e9+7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VL a(n), dp(k+2);
	rep(i, n) cin >>a[i];
	dp[0] = 1;
	
	rep(i, n){
		VL np(k+2);
		rep(j, k+1){
			np[j] = (dp[j] + (j>=1? np[j-1]: 0)) %MD;
			if(j>=a[i]+1) (np[j] += MD - dp[j-a[i]-1]) %=MD;
		}
		swap(np, dp);
	}
	cout <<dp[k] <<"\n";
	
	return 0;
}



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

using namespace std;

const int MAXN = 110;
int groups;
bool visited[MAXN];
vector<vector<int>> v1;
vector<pair<int,int>> edges;
int main(){
    int n;
    cin>>n;
    int val = n*(n+1)/2;
    for(int i=2;i<=n;i++){
        if(val%i == 0){
            groups = i;
            break;
        }
    }
    //cout<<groups<<endl;
    val/=groups;
   
    for(int i=n;i>=1;i--){
        if(visited[i]){
            continue;
        }
        int curr = val;
        curr-= i;
       
        vector<int> temp;
        temp.push_back(i);
        
        for(int j=i-1;j>=1;j--){
            if(visited[j]){
                continue;
            }
            
            if(j<=curr){
                curr-=j;
                visited[j] = true;
                temp.push_back(j);
            }
        }
        v1.push_back(temp);
    }
    for(int i=0;i<v1.size();i++){
        for(int j=i+1;j<v1.size();j++){
            for(int x=0;x<v1[i].size();x++){
                for(int y=0;y<v1[j].size();y++){
                   edges.push_back(make_pair(v1[i][x],v1[j][y]));
                }
            }
        }
    }
    cout<<edges.size()<<endl;
    for(auto x:edges){
        cout<<x.first<<" "<<x.second<<endl;
    }
}

Measured memory_bytes: 384
using System;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            string t = Console.ReadLine();
            var s = new StringBuilder();
            for (int i = 0; i < t.Length; i++)
            {
                if (t[i] == '?')
                {
                    if (i > 0 && s[ ^ 1] == 'P')
                    {
                        s.Append("D");
                    }
                    else
                    {
                        if (i == t.Length - 1 || t[i + 1] == 'P')
                        {
                            s.Append("D");
                        }
                        else
                        {
                            s.Append("P");
                        }
                    }
                }
                else
                {
                    s.Append(t[i]);
                }
            }
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 27372
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int h, n, ans = 0;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    vector<int> dp(h + 1, INF);
    dp[h] = 0;
    for(int i = 0; i < n; i++){
        for(int j = h; j > 0; j--){
            int t;
            if(a[i] <= j){
                t = j - a[i];
            }else{
                t = 0;
            }

            dp[t] = min(dp[t], dp[j] + b[i]);
        }
    }
    cout << dp[0] << endl;
    return 0;
}


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

int keta(int x) {
  int count = 0;
  while (x > 0) {
    x /= 10;
    count++;
  }
  return count;
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > v(n);
  vector<P> city(m);
  rep(i,m) {
    cin >> city[i].first >> city[i].second;
    v[city[i].first - 1].emplace_back(city[i].second);
  }
  rep(i,n) {
    if (v[i].size() == 0) continue;
    sort(all(v[i]));
    v[i].erase(unique(all(v[i])), v[i].end());
  }
  rep(i,m) {
    int ci = city[i].first - 1;
    int x = lower_bound(all(v[ci]), city[i].second) - v[ci].begin();
    x++;
    cout << string(6 - keta(city[i].first), '0') << city[i].first;
    cout << string(6 - keta(x), '0') << x << "\n";
  }
  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<vector<int>> a(n,vector<int>(m)); 
  vector<int> c(n);
  rep(i,n){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }
  int ans = 100000000;
  rep(i,(1<<n)){
    vector<int> skill(m,0);
    int cost = 0;
    rep(j,n){
      if(!(i & (1<<j))) continue;
      cost += c[j];
      rep(k,m) skill[k] += a[j][k];
    }
    if(ans < cost) continue;
    int ok = 1;
    rep(k,m){
      if(skill[k] < x){
        ok = -1;
        break;
      }
    }
    if(ok == 1) ans = cost;
  }
  if(ans == 100000000) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
ll dp[3010][3010];
vector<pii> vp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  
  int N, T; cin >> N >> T;
  vp.resize(N);
  REP(i,N) cin >> vp[i].first >> vp[i].second;
  sort(all(vp));

  ll ans = 0;
  for(int i=0; i<N; i++){

    for(int j=0; j<=T; j++){
      if(j-vp[i].first >= 0){
        dp[i+1][j] = max(dp[i+1][j], dp[i][j-vp[i].first] + vp[i].second);
      }

      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    }
  }
  
  ans = vp[0].second;
  for(int i=0; i<N; i++){
    for(int j=0; j<=T-1; j++){
      ans = max(ans, dp[i][j] + vp[i].second);
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse
#define size(collection) ((ll) (collection).size())						// collection size

#endif



int main(void)
{
	ll n; cin >> n;
	string s; cin >> s;

	if (3200 <= n)
		cout << s;
	else
		cout << "red";

	return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

K, N = map(int, input().split())
A = list(map(int, input().split()))
B = [a+K for a in A]
A.extend(B)

B = []
for i in range(1, len(A)):
    B.append(A[i]-A[i-1])

cum = [0]
cum.extend(list(accumulate(B)))

ans = float('inf')

for i in range(N-1, N*2):
    ans = min(ans, cum[i]-cum[i-N+1])

print(ans)


Measured memory_bytes: 45168
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, k;
  cin >> n >> k;
  cout << (n % k > k - (n % k) ? k - (n % k) : n % k) << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) {
 if (a < b) { a = b; return true; } return false; 
 }
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
//二項係数 nCr
const int MAX = 700000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=1;
  COMinit();
  for(int i=1;i<=min(k,n-1);i++){
    ans+=COM(n,i)*COM(i+n-i-1,n-i-1);
    ans%=MOD;
  }
  COUT(ans);
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, k, cnt = 0;
    cin >> n >> k;
    char last = 'm';
    FOR(i, 0, n) {
        char c;
        cin >> c;
        if (last != c) cnt++;
        last = c;
    }

    int ans = n - cnt + 2 * min(k, (cnt - 1) / 2);
    if (k > (cnt - 1) / 2 && cnt % 2 == 0) ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
hash = {}
n.times do |i|
  v1, v2 = gets.chomp.split
  hash[i+1] = [v1.to_s, v2.to_i]
end
res_order = hash.values.sort{|a, b|(a[0] <=> b[0]).nonzero? || b[1] <=> a[1] }

res_order.each do |i|
  hash.each do |k, v|
    puts k if v == i
  end
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define int long long int
using namespace std;
map<int,int>mp;
bool trug=false;


void prime_factor(int val)
{
    int cnt=0;
    while(val%2==0)
    {
        cnt++;
        if(cnt==1)
            mp[2]++;
        if(mp[2]>1)
        {
            trug=true;
        }
        val/=2;

    }
    for(int i=3; i<=sqrt(val); i+=2)
    {

        cnt=0;
        while(val%i==0)
        {
            cnt++;
            if(cnt==1)
                mp[i]++;
            if(mp[i]>1)
            {
                trug=true;
            }
            val/=i;
        }
    }
    if (val> 2)
    {
        mp[val]++;
        if(mp[val]>1)
        {
            trug=true;
        }
    }
}




bool co_prime(int arra[],int n)
{
    bool flag=true;
    for(int i=0; i<n; i++)
    {
        prime_factor(arra[i]);
        if(trug==true)
        {
            flag=false;
            break;
        }
    }

    if(flag==true)
        return true;
    else
        return false;
}
bool setwise_prime(int arra[],int n)
{
    int result=arra[0];
    for(int i=1; i<n; i++)
    {
        result=__gcd(result,arra[i]);
        if(result==1)
            break;

    }
    if(result==1)
        return true;
    else
        return false;
}
signed main()
{
    int n;
    cin>>n;
    int  arra[n+5];
    for(int i=0; i<n; i++)
    {
        cin>>arra[i];


    }
    if(co_prime(arra,n)==true)
        cout<<"pairwise coprime"<<endl;
    else if(setwise_prime(arra,n)==true)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;


}


Measured memory_bytes: 11496
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PA;
int main(){
  int n,ma;
  PA p[3000];
  while(scanf("%d",&n),n!=0){
    for(int i=0;i<n;i++){
      scanf("%d %d",&p[i].first,&p[i].second);
    }
    sort(p,p+n);
    ma = 0;
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	int x = p[j].first - p[i].first;
	int y = p[j].second - p[i].second;
	if(binary_search(p,p+n,PA(p[i].first-y,p[i].second+x)) == 1){
	  if(binary_search(p,p+n,PA(p[j].first-y,p[j].second+x)) == 1){
	    ma = max(ma,x*x+y*y);
	  }
	}
      }
    }
    printf("%d\n",ma);
  }
}

Measured memory_bytes: 3128
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]

dict = (
    (-1, 0),
    (0, -1),
    (0, 1),
    (1, 0),
)
achievable = True

for i in range(h):
    for j in range(w):
        count = 0
        if grid[i][j] == "#":
            for dy, dx in dict:
                y = i + dy
                x = j + dx
                if y >= 0 and h > y and x >= 0 and w > x:
                    if grid[y][x] == '#':
                        count += 1
            if count == 0:
                achievable = False

print('Yes' if achievable else 'No')

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

int main(){
  int a,b ;
  cin >> a >> b ;
  if(a==2||b==2) cout << "No" << endl ;
  else{
    vector<int> g = {4,6,9,11} ;
    for(int i=0;i<4;i++){
      if(a==g.at(i)) a = 0 ;
    }
    for(int i=0;i<4;i++){
      if(b==g.at(i)) b = 0 ;
    }
    if(a==b) cout << "Yes" << endl ;
    else if(a!=0&&b!=0) cout << "Yes" << endl ;
    else cout << "No" << endl ;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int c1,c5,c10,c50,c100,c500;
    cin >> c1>>c5>>c10>>c50>>c100>>c500;
    
    
    
    if (c1+c5*5+c10*10+c50*50+c100*100+c500*500 >= 1000)  cout <<"1" <<endl;
    
    else  cout <<"0"<<endl;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long gcd(long a, long b) {
  while (true) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    a %= b;
  }
}

int main(void) {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  rep (i, N) cin >> A[i];
  long foo = A[0];
  rep (i, N) foo = gcd(foo, A[i]);
  /*
  rep (i, N) {
    if (A[i] - K >= 0 and (A[i] - K) % foo == 0) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  */
  long max = A[0];
  rep (i, N) if (max < A[i]) max = A[i];
  if (K <= max and K % foo == 0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  vll x(n);
  rep(i,n){
    cin>>x[i];
    
  }
  ll ans=0;
  rep(i,n-1){
    if((x[i+1]-x[i])*a>b){
      ans+=b;
    }
    else{
      ans+=(x[i+1]-x[i])*a;
    }
  }
  COUT(ans);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
using ll = long long;
const int MM = 1e5+2;
int n, k, a[MM];
ll ps[MM];
ll ans, mod = 1e9+7;

ll gcd(ll gcd_a, ll gcd_b){return gcd_b == 0 ? gcd_a : gcd(gcd_b, gcd_a % gcd_b);}
ll fpow(ll fpow_b, ll fpow_exp, ll fpow_mod){if(fpow_exp == 0) return 1;ll t = fpow(fpow_b,fpow_exp/2,fpow_mod);if(fpow_exp&1) return t*t%fpow_mod*fpow_b%fpow_mod;return t*t%fpow_mod;}
ll divmod(ll divmod_i, ll divmod_j, ll divmod_mod){divmod_i%=divmod_mod,divmod_j%=divmod_mod;return divmod_i*fpow(divmod_j,divmod_mod-2,divmod_mod)%divmod_mod;}

int main(){
    
    scanf("%d %d", &n, &k);
    if(k == 1)
        return puts("0"), 0;
    
    for(int i = 0; i < n; i++)
        scanf("%d", a+i);
    
    sort(a, a+n);
    
    k--; //take one less
    ll v = 1;
    for(int i = k; i < n; i++){
        if(i != k)
            v = divmod(v*i%mod, i-k, mod);
        ans += v*a[i];
        ans %= mod;
        //print(i, v, v*a[i]);
    }
    reverse(a, a+n);
    v = 1;
    for(int i = k; i < n; i++){
        if(i != k)
            v = divmod(v*i%mod, i-k, mod);
        ans -= v*a[i];
        ans %= mod;
        //print(i, v, -v*a[i]);
    }
    
    print((ans%mod+mod)%mod);
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){
  int a,b;
  cin >> a >> b;
  ll ansa=1,ansb=1;
  ll ans=1;
  if(abs(a-b)>1){ cout << 0 << endl; return 0; }
  if(a==b){ans=2;}
  while(a>0){
    ansa *= a;
    ansa %= mod;
    a--;
  }
  while(b>0){
    ansb *= b;
    ansb %= mod;
    b--;
  }
  ans *= ansa*ansb%mod;
  ans %= mod;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

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();
	String answer = "No";
	if(a + b >= c) {
		answer = "Yes";
	}
	System.out.println(answer);
}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>



int main() {
	long long n;

	std::cin >> n;

	std::vector<std::pair<long long, long long> > v(n);

	for (long long i = 0; i < n; i++)
	{
		long long a, b;

		std::cin >> a >> b;

		v[i] = { b, a };
	}

	std::sort(v.begin(), v.end());

	long long time = 0;

	for (long long i = 0; i < n; i++)
	{
		time += v[i].second;
		if (time > v[i].first) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	std::cout << "Yes" << std::endl;

	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == "Sunny") {
        puts("Cloudy");
    } else if (s == "Cloudy") {
        puts("Rainy");
    } else {
        puts("Sunny");
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    int result = 2019;
    int tmp = 0;
    loop: for (; L < R; L++) {
      if (L % 2019 == 0) {
        result = 0;
        break;
      }
      for (long i = L + 1; i <= R; i++) {
        if (i % 2019 == 0) {
          result = 0;
          break loop;
        }
        tmp = (int) ((L * i) % 2019);
        if (tmp < result)
          result = tmp;
      }
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 23764
import java.util.Scanner;
  
class Main{
       public static void main(String[] args){
           Scanner sc = new Scanner(System.in);
           int x = sc.nextInt();
           int tmp =0;
           int[] num = new int[x];
  
           int min = 1000000;
           int max = -1000000;
           long sum = 0;
  
           for(int i=0; i<num.length; i++){
                    tmp = sc.nextInt();
                    num[i] = tmp;
           }
              
           for(int i=0; i<num.length; i++){
                    if(min > num[i]){
                       min = num[i];
                    }
           }
  
           for(int i=0; i<num.length; i++){
                    if(max < num[i]){
                       max = num[i];
                    }
           }
  
           for(int i=0; i<num.length; i++){
                    sum += num[i];
           }
            
           System.out.print(min);
           System.out.print(' ');
           System.out.print(max);
           System.out.print(' ');
           System.out.println(sum);
  
       }
}


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

int main(){
    int D;  cin >> D;
    if(D == 25) cout << "Christmas" << endl;
    if(D == 24) cout << "Christmas Eve" << endl;
    if(D == 23) cout << "Christmas Eve Eve" << endl;
    if(D == 22) cout << "Christmas Eve Eve Eve" << endl;
}


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

int main() {
  int n;
  cin>>n;
  int ans;
  for(int i=1;i<=n;i++){
    if(i<10 || (100<=i && i<1000)||(10000<=i&&i<100000)){ 
    ans++;
    }
  }
  cout<<ans<<endl;
}




 





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

int main(){
	
	int n , k , zero , one ;
	
	while(1){
		cin >> n ;
		if( n==0 ) break;
		
		zero = 0 ;
		one = 0 ;
		for( int i=0 ; i<n ; i++ ){
			cin >> k ;
			if( k == 0 ) zero++ ;
			if( k == 1 ) one++ ;
		}
		
		if( zero + one == n ) cout << "NA" << endl ;
		else cout << n - zero +1 << endl ;
	}
	
return 0; 
}

Measured memory_bytes: 1160
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = list(map(int,input().split()))
    big = 0
    I = 0
    for i in range(len(A)):
        if abs(big) < abs(A[i]):
            big = A[i]
            I = i
    
    ansN = 0
    ans = []
    
    if big > 0:
        ansN = 2*N
        ans.append([I+1,I+1])
        ans.append([I+1, 1])
        for i in range(1,N):
            ans.append([i,i+1])
            ans.append([i,i+1])
    elif big < 0:
        ansN = 2*N
        ans.append([I+1, I+1])
        ans.append([I+1, N])
        for i in range(N-1):
            j = N - i
            ans.append([j, j-1])
            ans.append([j, j-1])
    print(ansN)
    for i in ans:
        print(*i)
        j,k = i
        A[k-1] += A[j-1]
    #print(*A)
        
    
    
main()

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

#define ll long long

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(1E5 + 1);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[x]++;
	}

	vector<int> pref(1E5 + 1);
	for (int i = 1; i < pref.size(); i++) {
		pref[i] = pref[i - 1] + a[i];
	}

	int ans = 0;
	for (int i = 1; i < pref.size(); i++) {
		int left = pref[i - 1];
		int right = pref[pref.size() - 1] - pref[i - 1];
		if (left == right) ans++;
	}
	cout << ans;
}



Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop(void);

int top,S[1000];

int main()
{
  int a,b;
  top=0;
  char s[100];

  while( scanf("%s", s) != EOF )
    {

      if( s[0] == '+' )
        {
          a = pop();
          b = pop();
          push( a + b );
        }
      else if( s[0] == '-' )
        {
          b = pop();
          a = pop();
          push( a - b );
        }
      else if( s[0] == '*' )
        {
          a = pop();
          b = pop();
          push( a * b );
        }
      else
        {
          push( atoi(s) );
        }
    }

  printf("%d\n",pop());

  return 0;
}
void push(int x)
{
  S[++top] = x;
}
int pop()
{
  top--;
  return S[top+1];
}


Measured memory_bytes: 2140
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,-0};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

map<P,int> m;

class Graph{
	private:
	int V,E;
	vvp List;
	vi DIJ(int s){
		priority_queue<P> que;
		vi d(V,inf);
		d[s]=0;
		que.push(P(0,s));
		while(!que.empty()){
			P p=que.top();
			que.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(int i=0;i<List[v].size();i++){
				int F=List[v][i].first,S=List[v][i].second;
				if(d[F]>d[v]+S){
					d[F]=d[v]+S;
					que.push(P(-d[F],F));
				}
			}
		}
		return d;
	}
	public:
	Graph(int v,int e){
		V=v;
		E=e;
		List=vvp(v);
	}
	void add_edge(int s,int t,int c){
		List[s].push_back(P(t,c));
		List[t].push_back(P(s,c));
	}
	int solve(){
		vb a(E,0);
		for(int i=0;i<V;i++){
			vi d=DIJ(i);
			for(int j=0;j<V;j++) for(int k=0;k<List[j].size();k++){
				P v=List[j][k];
				if(d[j]==d[v.first]+v.second) a[m[P(j,v.first)]]=1;
			}
		}
		int ans=0;
		for(int i=0;i<E;i++) if(!a[i]) ans++;
		return ans;
	}
};

int n,e;

int main(){
	cin>>n>>e;
	Graph g(n,e);
	for(int i=0;i<e;i++){
		int s,t,c;
		cin>>s>>t>>c;
		s--;t--;
		g.add_edge(s,t,c);
		m[P(s,t)]=i;
		m[P(t,s)]=i;
	}
	cout<<g.solve()<<endl;
}

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

const long long mod=998244353;
long long n, ans, dp[200003], farthest[200003], tree[1000000];
pair<long long, long long>robot[200003];


bool cmp(pair<long long, long long>a, pair<long long, long long>b){
	if (a.first<b.first) return true;
	if (a.first>b.first) return false;
	return a.second<b.second;
}

void build(long long l, long long r, long long v){
	if (l==r) tree[v]=farthest[l];
	else{
		long long mid=(l+r)/2;
		build(l,mid,v*2);
		build(mid+1,r,v*2+1);
		tree[v]=max(tree[v*2],tree[v*2+1]);
	}
}

long long query(long long l, long long r, long long lb, long long rb, long long v){
	if (r<lb || l>rb) return -1e9;
	if (l>=lb && r<=rb) return tree[v];
	long long mid=(l+r)/2;
	return max(query(l,mid,lb,rb,v*2),query(mid+1,r,lb,rb,v*2+1));
}

void update(long long l, long long r, long long v, long long target){
	if (l==r) tree[v]=farthest[l];
	else{
		long long mid=(l+r)/2;
		if (target<=mid) update(l,mid,v*2,target);
		else update(mid+1,r,v*2+1,target);
		tree[v]=max(tree[v*2],tree[v*2+1]);
	} 
}

void init(){
	for (int i=0;i<n;i++) farthest[i]=i;
	build(0,n-1,1);
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	init();
	for (int i=0;i<n;i++) cin >> robot[i].first >> robot[i].second;
	sort(robot,robot+n,cmp);
//	for (int i=0;i<n;i++) cout << "sorted--> " << robot[i].first << " " << robot[i].second << "\n";
	for (int i=n-1;i>=0;i--){
		long long l=i, r=n-1, tmp, far=robot[i].first+robot[i].second;
		while (l<=r){
			long long mid=(l+r)/2;
			if (robot[mid].first<far){
				tmp=mid;
				l=mid+1;
			}
			else r=mid-1;
		}
		farthest[i]=query(0,n-1,i,tmp,1);
		update(0,n-1,1,i);
	}
//	for (int i=0;i<n;i++) cout << farthest[i] << "\n";
	memset(dp,0,sizeof dp);
	dp[0]=1;
	for (int i=0;i<n;i++){
		dp[i+1]+=dp[i]; // kalau i remain
		dp[i+1]%=mod;
		dp[farthest[i]+1]+=dp[i]; // kalau i tidak remain
		dp[farthest[i]+1]%=mod;
	}
	cout << dp[n] << "\n"; 
}

Measured memory_bytes: 12288
fn main() {
    proconio::input! {
    a:usize,
    b:usize,
    c:usize,
    d:usize,
    }
    let mut e=0;
    for i in 0..=a {
        for j in 0..=b {
            for k in 0..=c {
                if 10*i+2*j+k==d/50 {
                    e+=1
                }
            }
        }
    }
    println!("{}",e)
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI 3.1415926535897932384
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int ar[5], temp=0;
	for(int i=0;i<5;i++) cin>>ar[i];
	for(int i=0;i<5;i++){
		if(ar[i]==0) cout<<temp+1<<endl;
		temp = ar[i];
	}
	return 0;
}


Measured memory_bytes: 3624