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

int main() {
    string T;
    cin >> T;

    for(int i=0; i<T.length(); i++) {
        if(T[i] == '?') {
            cout << "D";
        } else {
            cout << T[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetString();

            if (input == "ABC")
            {
                Console.WriteLine("ARC");
                return;
            }
            Console.WriteLine("ABC");
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 25792
int main(int argc, char const *argv[])
{
	int a, b, c;
//	char s[101];

	scanf("%d", &a);
	scanf("%d", &b);
//	scanf("%d", &c);
//	scanf("%s", &s);

//	printf("%d ", a+b+c);
//	printf("%s\n", s);

	c = a * b;
	if (c%2 == 1)
	{
		printf("Odd\n");
	}else{
		printf("Even\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  // find x s.t. a^x = b
  static T log(T a,T b){
    const T sq=40000;
    unordered_map<T, T> dp;
    dp.reserve(sq);
    Mint res(1);
    for(Int r=0;r<sq;r++){
      if(!dp.count(res.v)) dp[res.v]=r;
      res*=a;
    }
    Mint p=Mint(a).inv().pow(sq);
    res=b;
    for(Int q=0;q<=MOD/sq+1;q++){
      if(dp.count(res.v)){
        T idx=q*sq+dp[res.v];
        if(idx>0) return idx;
      }
      res*=p;
    }
    assert(0);
    return T(-1);
  }

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  string s;
  cin>>s;

  vector<Int> ds(n*2+1,0);
  string t='W'+s+'W';
  for(Int i=0;i<=n*2;i++){
    ds[i]=t[i]!=t[i+1];
  }

  using M = Mint<Int>;
  M ans{1};
  Int cnt=0;

  for(Int i=0;i<n*2;i++){
    if(ds[i]==1){
      ds[i]=0;
      cnt++;
    }else{
      if(cnt==0) drop(0);
      ds[i+1]^=1;
      ans*=M(cnt);
      cnt--;
    }
  }
  if(ds[n*2]) drop(0);
  if(cnt) drop(0);
  for(Int i=1;i<=n;i++) ans*=M(i);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2308
#include <bits/stdc++.h>
using namespace std;
const int N=2005;
int n,k,q,cnt;
int a[N],b[N],c[N];

struct node{
	int pos,mn,sz,ls,rs;
	unsigned key;
	node(){memset(this,0,sizeof(node));}
	node(int _val):key((unsigned)rand()*rand()),sz(1){
		pos=mn=_val; ls=rs=0;
	}
}d[N];

class Treap{
	public:
		int rt,sz;
		struct dual_rt{
			int lrt,rrt;
			dual_rt(int _lrt=0,int _rrt=0):lrt(_lrt),rrt(_rrt){}
		};
		int new_nd(int val){
			d[++cnt]=node(val);
			return cnt;
		}
		void upd(int u){
			d[u].sz=d[d[u].ls].sz+d[d[u].rs].sz+1;
			d[u].mn=d[u].pos;
			if(c[d[u].mn]>c[d[d[u].ls].mn]) d[u].mn=d[d[u].ls].mn;
			if(c[d[u].mn]>c[d[d[u].rs].mn]) d[u].mn=d[d[u].rs].mn;
		}
		dual_rt split(int u,int val){
			dual_rt ret;
			if(!u) return ret;
			if(val<d[u].pos){
				ret=split(d[u].ls,val);
				d[u].ls=ret.rrt;
				ret.rrt=u;
			}
			else{
				ret=split(d[u].rs,val);
				d[u].rs=ret.lrt;
				ret.lrt=u;
			}
			upd(u);
			return ret;
		}
		int merge(int u,int v){
			if(!u || !v) return u|v;
			if(d[u].key<d[v].key){
				d[u].rs=merge(d[u].rs,v);
				upd(u);
				return u;
			}
			else{
				d[v].ls=merge(u,d[v].ls);
				upd(v);
				return v;
			}
		}
		void clear(){rt=sz=0;}
		void ist(int x){++sz,rt=merge(rt,new_nd(x));}
		int del_mn(){
			int pos=d[rt].mn;
			dual_rt x=split(rt,pos);
			dual_rt y=split(x.lrt,pos-1);
			rt=merge(y.lrt,x.rrt);
			--sz;
			return c[pos];
		}
}T[N];

struct data{
	int id;
	data(int _id=0):id(_id){};
	bool operator <(const data &that)const{
		return c[d[T[id].rt].mn]<c[d[T[that.id].rt].mn] || c[d[T[id].rt].mn]==c[d[T[that.id].rt].mn] && id<that.id;
	}
};

int main(){
	srand((size_t)new(char));
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	int tot=unique(b+1,b+n+1)-b-1;
	int ans=INT_MAX;
	for(int i=1,mn;i<=tot;++i){
		mn=b[i];
		int now=1;
		cnt=0;
		T[now].clear();
		bool flag=false;
		int _=0;
		c[0]=INT_MAX;
		int __=0;
		for(int j=1;j<=n;++j)
			c[++__]=a[j];
		for(int j=1;j<=__;++j){
			if(c[j]<mn){
				if(flag) T[++now].clear();
			}
			else flag=true,T[now].ist(j);
		}
		set<data> se;
		for(int j=1;j<=now;++j){
			if(T[j].sz>=k) se.insert(data(j));
		}
		int mx=mn;
		for(int j=1;j<=q;++j){
			if(se.empty()){
				mx=INT_MAX;
				break;
			}
			int iter=se.begin()->id;
			se.erase(se.begin());
			mx=T[iter].del_mn();
			if(T[iter].sz>=k) se.insert(iter);
		}
		ans=min(ans,mx-mn);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
import numpy as np

k, x = [int(ii) for ii in input().split()]

min_k = max(-1000000, x - (k - 1))
max_k = min(1000000, x + (k - 1))

s = ""
for ii in np.arange(min_k, max_k + 1):
    s += "{} ".format(ii)

print (s)


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

#define SWAP(x, y) {char *z; z = x; x = y; y = z;}

void dispIsStable(char **cards1, char **cards2, int card_num) 
{
	int i;

	for(i = 0; i < card_num; i++) {
		if(strcmp(cards1[i], cards2[i]) != 0) {
			printf("Not stable\n");
			return;
		}
	}
	printf("Stable\n");
}

int cardtoi(char *card)
{
	return atoi(card + 1);
}

void dispCards(char **cards, int card_num) 
{
	int i;

	printf("%s", cards[0]);
	
	for(i = 1; i < card_num; i++) {
		printf(" %s", cards[i]);
	}
	printf("\n");
}

void bubbleSort(char **cards, int card_num)
{
	int i, j;

	for(i = 0; i < card_num - 1; i++) {
		for(j = card_num - 1; j > i; j--) {
			if(cardtoi(cards[j]) < cardtoi(cards[j - 1]))
				SWAP(cards[j], cards[j - 1]);
		}
	}

}

void selectionSort(char **cards, int card_num) 
{
	int i, j, min_index;

	for(i = 0; i < card_num; i++) {
		min_index = i;
		for(j = i; j < card_num; j++) {
			if(cardtoi(cards[j]) < cardtoi(cards[min_index]))
				min_index = j;
		}
		if(min_index != i)
			SWAP(cards[i], cards[min_index]);
	}

}

int main(void) 
{
	int n, i;
	char **cards4bubble, **cards4selection;

	scanf("%d", &n);
	cards4bubble = malloc(sizeof(char *) * n);	
	cards4selection = malloc(sizeof(char *) * n);
	for(i = 0; i < n; i++) {
		cards4bubble[i] = malloc(sizeof(char) * 2);
		scanf("%s", cards4bubble[i]);
		cards4selection[i] = strdup(cards4bubble[i]);
	}
	bubbleSort(cards4bubble, n);
	selectionSort(cards4selection, n);
	dispCards(cards4bubble, n);
	printf("Stable\n");
	dispCards(cards4selection, n);
	dispIsStable(cards4bubble, cards4selection, n);
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,q,a,t,x;
    cin >> n;
    priority_queue<int> que[n];
    cin >> q;
    for (int i=0;i<q;i++) {
        cin >> a;
        if ( a==0 ) {
            cin >> t >> x;
            que[t].push(x);
        } else if ( a==1 ) {
            cin >> t;
            if ( que[t].empty()!=true ) {
                cout << que[t].top() << endl;
            }
        } else if ( a==2 ) {
            cin >> t;
            if ( que[t].empty()!=true ) {
                que[t].pop();
            }
        }
    }
}



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

int main(){
    int N,Y;
    cin >> N >> Y;

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

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
            sum = 10000 * i + 5000 * j + 1000 * (N - i - j);
            if(sum == Y && (N - i - j) >= 0){
                x = i;
                y = j;
                z = N - i - j;
                break;
            }
        }
    }

    if(x != 0 || y != 0 || z != 0){
        cout << x << " " << y << " " << z << endl;
    }else{
        cout << -1 << " " << -1 << " " << -1 <<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz size
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int A, B;
    cin >> A >> B;

    if (A <= 5)
        cout << 0;
    else if (A <= 12)
        cout << B / 2;
    else
        cout << B;

    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
string s;
int main(){
    cin >> s;
    int l = 0, r = s.length()-1;
    int cnt = 0;
    while(l<r){
        if(s[l]!=s[r]) cnt++;
        l++, r--;    
    }
    cout << cnt << endl;
    return 0;
}

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

struct Trie{
    struct node {
      char c;
      node* v[26];
      node* p;
      node(node* p,char c):p(p),c(c){
        for(int i=0;i<26;i++) v[i] = NULL;
      }
      node(){
        for(int i=0;i<26;i++) v[i] = NULL;
        p = NULL;
      }
    };

    Trie() {
      root = new node();
    };

    node* root;
    void add( const string& s, int id, node* p ){
      if( id == s.size() ) return;
      int to = s[id]-'a';
      if( p->v[to] == NULL ) {
        p->v[to] = new node(p,s[id]);
      }
      add( s, id+1, p->v[to] );
    }
    void add( const string& s ){
      add( s, 0, root );
    }


    string solve(){
      queue<node*> q;
      q.push( root );
      while( !q.empty() ){
        node* p = q.front(); q.pop();
        int sc = -1;
        for(int i=0;i<26;i++)
          if( p->v[i] == NULL ) { sc = i; break; }
        if( sc != -1 ){
          string ans = ""; ans += (char)(sc+'a');
          while( p != root ){
            ans += p->c;
            p = p->p;
          }
          reverse( ans.begin(), ans.end() );
          return ans;
        } else {
          for(int i=0;i<26;i++)
            q.push( p->v[i] );
        }
      }

    }

};

Trie T;

int main() {
  int N; cin >> N;
  for(int i=0;i<N;i++){
    string s; cin>> s;
    for(int j=0;j<s.size();j++) {
      string ns;
      for(int k=0;k<5;k++){
        if( j+k >= s.size() ) continue;
        ns += s[j+k];
      }
      T.add(ns);
    }
  }
  cout << T.solve() << endl;
}

Measured memory_bytes: 196052
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,r,tmp;
  cin>>a>>b;
  long long x=a*b;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  cout<<x/b<<endl;
  return 0;
}  

Measured memory_bytes: 256
package main

import (
	"bytes"
	"fmt"
	"strconv"
)

func main() {
	var k, x int
	fmt.Scan(&k, &x)
	min := x - k + 1
	if min < -1000000 {
		min = -1000000
	}
	max := x + k - 1
	if max > 1000000 {
		max = 1000000
	}
	var buffer bytes.Buffer
	for i := min; i <= max; i++ {
		n := strconv.Itoa(i)
		buffer.WriteString(n)
		if i != max {
			buffer.WriteString(" ")
		}
	}
	fmt.Println(buffer.String())
}


Measured memory_bytes: 640
def main2():
    x, k, d = map(int, input().split())

    now = x
    i = 0
    if (now == 0):
        if k%2 == 0:
            print(0)
        else:
            print(d)
    elif (now > 0):
        if (now - d * k >=0):
            print(now - d * k)
            return
        i = int(now/d)
        now = now%d
        if (k-i)%2 == 0:
            print(now)
        else:
            print(d-now)
    elif (now < 0):
        if (now + d * k <=0):
            print(-(now + d * k))
            return
        i = int((-now)/d)
        now = -((-now)%d)
        if (k-i)%2 == 0:
            print(-now)
        else:
            print(now+d)
    
if __name__=='__main__':
    main2()

Measured memory_bytes: 9232
// abc147_a
#include <iostream>
#include <math.h>
#include <cstring>
#include <iomanip>
#include <algorithm>

#define US unsigned short
#define UI unsigned int
#define UC unsigned char
#define UL unsigned long
#define ULL unsigned long long
using namespace std;

int main(int argc, char const *argv[])
{
    US t, o = 0;
    for (US i = 0; i < 3; i++)
    {
        cin >> t;
        o += t;
    }
    if (o > 21)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
}


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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
	int N;
	string S;

	cin >> N >> S;
	int ans = 1;

	if (N % 2 == 0){
		for (int i = 0; i < N/2; i++)
		{
			if (S[i] == S[N/2+i])
				continue;
			else {
				ans = 0;
				break;
			}
		}

		if (ans == 0)
			cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int minX = 0;
    int maxX = W;
    int minY = 0;
    int maxY = H;

    rep(i, N) {
        int xi, yi, ai;
        cin >> xi >> yi >> ai;

        if (ai == 1) {
            minX = max(minX, xi);
        } else if (ai == 2) {
            maxX = min(maxX, xi);
        } else if (ai == 3) {
            minY = max(minY, yi);
        } else if (ai == 4) {
            maxY = min(maxY, yi);
        }
    }

    int result = (maxX - minX) * (maxY - minY);
    if ((maxX - minX) <= 0  || (maxY - minY) <= 0) {
        cout << 0 << endl;
    } else {
        cout << result << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    int ans;
    
    scanf("%d%d", &a, &b);
    
    ans=a-2*b;
    
    if (ans<=0) {
        ans=0;
    }
    
    printf("%d", ans);
    
    return 0;
}



Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000*1000+10;
int n, t[MAX], curr, maxi;
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> t[i];
        if(t[i] > t[i - 1])
            curr = 0;
        else
            curr++;
        maxi = max(maxi, curr);
    }
    cout << maxi << "\n";
}


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

using namespace std;

int x[10][10];

char get(string &T)
{
  int now = 0;
  for(int i = 0; i < T.size(); i++) {
    now = x[now][T[i] - '0'];
  }
  return (now + '0');
}


int main()
{
  for(int i = 0; i < 10; i++) {
    for(int j = 0; j < 10; j++) {
      cin >> x[i][j];
    }
  }
  int ret = 0;
  for(int i = 0; i < 10000; i++) {
    string K = to_string(i);
    while(K.size() < 4) K = "0" + K;
    K += get(K);
    bool flag = true;
    for(int j = 0; j < K.size(); j++) {
      for(char k = '0'; k <= '9'; k++) {
        if(K[j] == k) continue;
        swap(K[j], k);
        flag &= get(K) != '0';
        swap(K[j], k);
      }
      if(j > 0 && K[j - 1] != K[j]) {
        swap(K[j - 1], K[j]);
        flag &= get(K) != '0';
        swap(K[j - 1], K[j]);
      }
    }
    ret += 1 ^ flag;
  }
  cout << ret << endl;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1<<18;
using ll = long long;
using pll = pair<ll, ll>;
int h[200001];
struct LiChao{
	struct Node{
		int l=0,r=0;
		pll line = pll(0, (ll)1e18);
	} node[2*SIZE];
	int cnt;
	inline ll f(pll line, int x){
		return line.first*x + line.second;
	}
	void update(int nn, int ns, int ne, pll newLine){
		auto &cur = node[nn];
		pll l1 = cur.line, l2 = newLine;
		if(f(l1, ns) > f(l2, ns)) swap(l1, l2);
		if(f(l1, ne) <= f(l2, ne)){
			cur.line = l1;
			return;
		}
		int m = (ns+ne)>>1;
		if(f(l1, m) <= f(l2, m)){
			cur.line = l1;
			if(!cur.r) cur.r = ++cnt, node[cnt].line = l1;
			update(cur.r, m+1, ne, l2);
		}
		else{
			cur.line = l2;
			if(!cur.l) cur.l = ++cnt, node[cnt].line = l2;
			update(cur.l, ns, m, l1);
		}
	}
	ll query(int nn, int ns, int ne, int x){
		auto &cur = node[nn];
		if(ns==ne) return f(cur.line, x);
		int m = (ns+ne)>>1;
		if(m<x) return min(f(cur.line, x), cur.r?query(cur.r, m+1, ne, x):(ll)1e18);
		return min(f(cur.line, x), cur.l?query(cur.l, ns, m ,x):(ll)1e18);
	}
} L;
int N;
ll dp[200001], C;
int main(){
	scanf("%d%lld",&N,&C);
	for(int i=1; i<=N; ++i) scanf("%d",h+i);
	L.update(0, 0, 1e6, pll(-2ll*h[1], 1ll*h[1]*h[1]));
	for(int i=2; i<=N; ++i){
		dp[i] = 1ll*h[i]*h[i]+C+L.query(0, 0, 1e6, h[i]);
		L.update(0, 0, 1e6, pll(-2ll*h[i], 1ll*h[i]*h[i]+dp[i]));
	}
	printf("%lld",dp[N]);
	return 0;
}

Measured memory_bytes: 14848
import sys
import heapq
n = int(input())
tasks = []
for i in range(n):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    heapq.heappush(tasks, (b, a))
_sum = 0
flg = True
for i in range(n):
    b, a = heapq.heappop(tasks)
    if _sum + a > b:
        flg = False
        break
    _sum += a
if flg:
    print("Yes")
else:
    print("No")

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
//const int INF = 1e9 + 10;
const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
const ll MOD = 1e9 + 7;
//const int MOD = 1e9 + 7;

int n, m;
int a[100010];

ll dp[100010];

int main(void){
	cin>>n>>m;
	for (int i = 0; i < m; i++) {
		cin>>a[i];
		a[i]--;
	}

	dp[0] = 1; dp[1] = 2;
	for (int i = 0; i < m; i++) dp[a[i]] = INF;

	if (dp[0] == INF && dp[1] != INF) dp[1] = 1;

	for (int i = 2; i < n; i++) {
		if (dp[i] == INF) continue;

		dp[i] = ((dp[i - 1] != INF ? dp[i - 1] : 0) + (dp[i - 2] != INF ? dp[i - 2] : 0)) % MOD;
	}

	printf("%lld\n", dp[n - 1] % MOD);
	
	return 0;
}

Measured memory_bytes: 1408
from collections import deque
n = int(input())
zyun = []
route = [[] for i in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    zyun.append([a,b])
    route[a].append(b)
iro = [0 for i in range(n+1)]
ans = {}
q = deque()
q.append(1)
while q:
    now = q.popleft()
    cou = 1
    for k in route[now]:
        if iro[now] == cou:
            cou += 1
        ans[str(now) + "+" + str(k)] = cou
        iro[k] = cou
        q.append(k)
        cou += 1
print(max(iro))
for i,j in zyun:
    print(ans[str(i)+"+"+str(j)])

Measured memory_bytes: 99360
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  ll N,M; cin >> N >> M ;
  cout << pow(2,M)*(100*(N-M)+1900*M) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct dice{
    int a[6];
    void b(char c){
        int d;
        if(c=='N'){
            d=a[0];
            a[0]=a[1];
            a[1]=a[5];
            a[5]=a[4];
            a[4]=a[0];
            a[4]=d;
        }
        if(c=='W'){
            d=a[0];
            a[0]=a[2];
            a[2]=a[5];
            a[5]=a[3];
            a[3]=a[0];
            a[3]=d;
        }
        if(c=='E'){
            d=a[0];
            a[0]=a[3];
            a[3]=a[5];
            a[5]=a[2];
            a[2]=a[0];
            a[2]=d;
        }
        if(c=='S'){
            d=a[0];
            a[0]=a[4];
            a[4]=a[5];
            a[5]=a[1];
            a[1]=a[0];
            a[1]=d;
        }
    }
    int top() {
        return a[0];
    }
};
int main(){
    dice e;
    for(int i=0;i<6;i++) cin >> e.a[i];
    string a;cin >> a;
    for(int i=0;i<a.size();i++) e.b(a[i]);
    cout << e.top() << endl;
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;
    vector<int> A;
    cin>>n>>d>>x;
    int ans=x;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        ans+=1+(d-1)/a;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
    int N;
    cin>>N;
    string resultl, resultr, resultmiddle;;
    int l=0, r=N;
    int middle;
    cout<<l<<endl<<flush;
    cin>>resultl;
    while((resultl != "Vacant") & (resultr != "Vacant")){
        middle = (l+r)/2;
        cout<<middle<<endl<<flush;
        cin>>resultmiddle;
        if(((middle - l) % 2 == 0) & (resultl == resultmiddle)){
            l = middle;
            resultl = resultmiddle;
        }
        else if(((middle - l) % 2 != 0) & (resultl != resultmiddle)){
            l = middle;
            resultl = resultmiddle;
        }
        else {
            r = middle;
            resultr = resultmiddle;
        }
    }
    /**
    if(resultl == "Vacant") cout<<l<<endl;
    else cout<<r<<endl;
    **/
}


Measured memory_bytes: 852
#![allow(non_snake_case)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

#[fastout]
fn main() {
    input!{
        n: usize,
        l: [i32; n]
    }
    let m = l.iter().max().unwrap();
    let s: i32 = l.iter().sum();
    println!("{}", if m * 2 < s {"Yes"} else {"No"})
}


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

vector<int> ch[1000];
string s[1000];
void dfs(int x,int d=0){
	cout << string(d,'.') << s[x] << endl;
	for( auto e : ch[x]) dfs(e,d+1);
}
int main(){
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		int t;
		cin >> t;
		--t;
		if(i!=0) ch[t].push_back(i);
		cin >> s[i];
	}
	dfs(0);

}

Measured memory_bytes: 1444
#include <iostream>

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a <= b && b <= c)
    {
        std::cout << a << ' ' << b << ' ' << c << std::endl;
    }
    else if (a <= c && a <= b)
    {
        std::cout << a << ' ' << c << ' ' << b << std::endl;
    }
    else if (b <= a && a <= c)
    {
        std::cout << b << ' ' << a << ' ' << c << std::endl;
    }
    else if (b <= c && c <= a)
    {
        std::cout << b << ' ' << c << ' ' << a << std::endl;
    }
    else if (c <= a && a <= b)
    {
        std::cout << c << ' ' << a << ' ' << b << std::endl;
    }
    else if (c <= b && b <= a)
    {
        std::cout << c << ' ' << b << ' ' << a << std::endl;
    }
    return 0;
}



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

int main(){
   int n;
   int sum=0;
   string s;
   cin >> n >> s;
   for(int i=0; i<n; i++){
      if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
       sum++;
      }
    }

   cout << sum << endl;
   
   
    return 0;
}


Measured memory_bytes: 256
n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353

dp = [[0 for i in range(s + 1)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s + 1):
        dp[i + 1][j] = dp[i][j] * 2 % mod
        if a[i] <= j:
            dp[i + 1][j] += dp[i][j - a[i]]
            dp[i + 1][j] %= mod

print(dp[n][s])


Measured memory_bytes: 153028
//55
#include<iostream>
#include<algorithm>

using namespace std;

const int N=1048576;
const int B=N-1;
int c[N];
int pa[N*2];

void rec(int x){
  if(x==0)return;
  int p=(x-1)/2;
  pa[p]=(c[pa[p*2+1]]>=c[pa[p*2+2]])?pa[p*2+1]:pa[p*2+2];
  // if(pa[p]>=100){
  //   cout<<x<<' '<<p*2+1<<' '<<p*2+2<<endl;
  //   cout<<c[pa[p*2+1]]<<' '<<c[pa[p*2+2]]<<endl;
  //   cout<<pa[p*2+1]<<' '<<pa[p*2+2]<<endl;
  // }
  rec(p);
}

int main(){
  int n,q;
  cin>>n>>q;
  for(int i=0;i<N;i++){
    pa[B+i]=i;
  }
  for(int i=B-1;i>=0;i--){
    pa[i]=pa[i*2+1];
  }
  while(q--){
    int a,v;
    cin>>a>>v;
    c[a-1]+=v;
    rec(B+a-1);
    cout<<pa[0]+1<<' '<<c[pa[0]]<<endl;
  }
  return 0;
}

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


int main(){
  int n,r;
  cin >> n >> r;
  int ans=0;
  if(n>=10){
    ans=r;
  }else{
    ans=100*(10-n);
    ans+=r;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int main() {
  int n, a;
  cin >> n >> a;
  if (n%500<=a) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
use proconio::*;
use std::iter::FromIterator;

#[fastout]
fn main() {
    input!(n: marker::Chars);

    let aaa: Vec<char> = n
        .iter()
        .map(|&x| if x == '1' { '9' } else { '1' })
        .collect();

    println!("{}", String::from_iter(aaa));
}


Measured memory_bytes: 2120
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]*(n+1)
sum1=sum(a)
for i in range(n):
	A[i]=max(0,a[i]-b[i])
	A[i+1]=max(0,min(a[i+1]-b[i]+a[i],a[i+1]))
	a[i]=A[i]
	a[i+1]=A[i+1]
print(int(sum1)-int(sum(a)))

Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k,a[100], tong=0,dem=0,max=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
         cin>>a[i];
    }
    for(int i=0;i<n;i++){
        k-=a[i];
        dem++;
    }
    // cout<<k;
    for(int i=0;i<n;i++){
        if(tong=k/a[i]){
            if(max<tong){
                max=tong;
            }
        }
    }
    cout<<dem+max;
    
    return 0;
}

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

const int N = 10 + 5;
const int M = 1e3 + 10;

int n , m , k , col[N][M] , bel[N] , ans = 2e9;
char s[M];

void check(int cut){
	int cnt[N] , tot = 0;
	memset(cnt , 0 , sizeof(cnt));
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++)
			cnt[bel[j]] += col[j][i];
		for(int j = 1; j <= cut; j++)
			if(cnt[j] > k){
				memset(cnt , 0 , sizeof(cnt));
				for(int l = 1; l <= n; l++)
					cnt[bel[l]] += col[l][i];
				for(int l = 1; l <= cut; l++)
					if(cnt[l] > k) tot = 1e9;
				tot++; break;
			}
	}
	ans = min(ans , tot + cut - 1);
}

void dfs(int p , int d){
	bel[p] = d;
	if(p == n){ check(d); return; }
	dfs(p + 1 , d) , dfs(p + 1 , d + 1);
}

int main(){
	scanf("%d %d %d" , &n , &m , &k);
	for(int i = 1; i <= n; i++){
		scanf("%s" , s + 1);
		for(int j = 1; j <= m; j++)
			col[i][j] = s[j] - '0';
	}
	dfs(1 , 1) , printf("%d" , ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
vector<string> a;
int main()
{
	 ios::sync_with_stdio(false);
	 int n;
	 bool flag;
	 string temp,last;
	 while(cin>>n)
	 {
	 	 flag=true;
		 for(int i=0;i<n;i++)
		 {
		 	 cin>>temp;
		 	 vector<string>::iterator result = find( a.begin( ), a.end( ), temp ); 
		 	 if(result!=a.end()) flag=false;
		 	 if(last.size()!=0) if(temp.at(0)!=last.at(last.length()-1)) flag=false;
		 	 a.push_back(temp);
		 	 last=temp;
			} 
		 if(flag==true) cout<<"Yes\n";
		 else cout<<"No\n";
		 a.clear();
	 }
	 
	 return 0;
}


Measured memory_bytes: 256
#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>
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)
lint a[514],b[514],d[514];
lint co[810][893];
lint zyo[514][514],zs[514][514];
lint dp[514][514];
lint mo=1000000007,pro=1;
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
lint cal(int a,int b){
	if(a==0 || b==0) return 1LL;
	return co[a+b-1][b-1];
}
int main()
{
	int n,c;lint out=0;
	cin>>n>>c;
	rep(i,n) cin>>a[i];rep(i,n) cin>>b[i];
	rep(i,n) d[i]=b[i]-a[i]+1;rep(i,n){pro*=d[i];pro%=mo;}
	rep(i,805){
		co[i][0]=co[i][i]=1;
		REP(j,1,i) co[i][j]=(co[i-1][j]+co[i-1][j-1])%mo;
	}
	memset(zs,0,sizeof(zs));
	rep(i,510){
		zyo[i][0]=1;zs[i+1][0]=(zs[i][0]+zyo[i][0])%mo;
		rep(j,510){
			zyo[i][j+1]=(zyo[i][j]*i)%mo;
			zs[i+1][j+1]=(zs[i][j+1]+zyo[i][j+1])%mo;
		}
	}
	memset(dp,0,sizeof(dp));dp[0][0]=1;
	rep(i,n) rep(j,c+1){
		rep(k,c-j+1){
			lint t=zs[b[i]+1][k]-zs[a[i]][k];dp[i+1][j+k]+=dp[i][j]*t;dp[i+1][j+k]%=mo;
		}
		/*REP(j,a[i],b[i]+1) rep(k,c+1){
			out+=(t*zyo[j][k])%mo*cal(c-k,n-1);
			out%=mo;
		}*/
	}
	out=dp[n][c];out%=mo;out+=mo;out%=mo;
	cout<<out<<endl;
}


Measured memory_bytes: 11520
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

main(){
  int ans,t,a,b;
  while(cin>>a>>b){
    if ( a == 0 && b == 0)break;
    ans=a+b;
    t=0;
    REP(i,1,5){
      cin>>a>>b;
      if ( a+b>ans){ans=a+b;t=i;}
    }
    cout << (char)(t+'A')<<" " << ans << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b,c;
  cin>>a>>b>>c;
  if(a%2 || b%2 || c%2){
    cout<<0<<endl;
    return 0;
  }
  if(a==b && b==c){
    cout<<-1<<endl;
    return 0;
  }
  rep(i,INF){
    int ta=a,tb=b,tc=c;
    a=tb/2+tc/2;
    b=ta/2+tc/2;
    c=ta/2+tb/2;
    if(a%2 || b%2 || c%2)break;
  }
  cout<<i+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define   nl   <<'\n'
#define   pi   acos(-1.0);
#define   ll   long long
#define   pb   push_back
#define   eb   emplace_back
#define   tc   int t; cin>>t; while(t--)
#define   fio  ios_base::sync_with_stdio(0); cin.tie(0)

int main()
{
    string s;
    cin>>s;
    cout<<s[0];
    cin>>s;
    cout<<s[1];
    cin>>s;
    cout<<s[2];
}  

Measured memory_bytes: 3508
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
public static void main(String[] args) {
	Scanner stdin = new Scanner(System.in);
	List<String> output = new ArrayList<String>();

	boolean[] spade=new boolean[13];
	boolean[] dia    =new boolean[13];
	boolean[] club    =new boolean[13];
	boolean[] heart    =new boolean[13];
	
	int n=stdin.nextInt();
for(int i=0;i<n;++i) {
		String markChar = stdin.next();
		int number = stdin.nextInt();		
		boolean[] mark=null;
		if(markChar.equals("S")) {
			mark=spade;
		}
		if(markChar.equals("H")) {
			mark=heart;
		}
		if(markChar.equals("C")) {
			mark=club;
		}
		if(markChar.equals("D")) {
			mark=dia;
		}
		mark[number-1]=true;
	}
	for(int i=0;i<spade.length;++i) {
	if(!spade[i]) {
		System.out.println("S "+(i+1));
	}		
	}
	for(int i=0;i<heart.length;++i) {
		if(!heart[i]) {
			System.out.println("H "+(i+1));
		}
	}
	for(int i=0;i<club.length;++i) {
		if(!club[i]) {
			System.out.println("C "+(i+1));
		}	
	}
	for(int i=0;i<dia.length;++i) {
		if(!dia[i]) {
			System.out.println("D "+(i+1));
		}	
	}
}
}

Measured memory_bytes: 26048
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        sc.nextLine();
        String s = sc.nextLine();

        int[] arr = new int[n];
        for (int i = 1; i < n; i++) {
            if (s.charAt(i-1) == 'A' && s.charAt(i) == 'C') arr[i]++;
            arr[i] += arr[i-1]; // plus curr with prev value
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int start = sc.nextInt() - 1;
            int end = sc.nextInt() - 1;

            sb.append(arr[end] - arr[start]).append('\n');
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 72892
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	long long int n;
	long long int k, tmp, div=1000000007, ans=0;
	vector<long long int> v;
	vector<long long int> rec(2002, 0), tent(2001, 0);

	cin>> n >> k;
	v.resize(n+1);
	for(int i=1;i<=n;i++){
		cin>> v[i];
		rec[v[i]]++;
		for(int j=1;j<i;j++){
			if(v[j]>v[i]) tent[i]++;
		}
	}

	for(int i=2000;i>=2;i--) rec[i-1]+=rec[i];

	//for(int i=1;i<=20;i++) cout<< rec[i] << " " << tent[i] <<endl;

	for(int i=1;i<=n;i++){
		//tmp=rec[v[i]+1]*(k-1)+tent[i];
		tmp=k*tent[i]+(k*(k-1)/2)%div*rec[v[i]+1];
		ans+=tmp%div;
		ans=ans%div;
	}

	cout<< ans << endl;

}

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

bool h2(char a, char b)
{
  if (a == b) return true;
  else return false;
}

bool h3(char a, char b, char c)
{
  if (a == c) return true;
  else return false;
}
int main()
{
  string s;
  int len, str, end;
  bool f = false;
  cin >> s;

  len = s.length();

  for (int i = 0; (len >= 2)&&(i < len-1)&&(!f); i++)  { // 2 words
    //    cout << s[i] << s[i+1] << h2(s[i], s[i+1])<< endl;
    if (h2(s[i], s[i+1])) {
      f = true;
      str = i+1;
      end = str+1;
      //      cout << "2" << endl;
    }
  }
  for (int i = 0; (len>=3)&&(i < len-2)&&(!f); i++) { // 3words
    if (h3(s[i], s[i+1], s[i+2])) {
      f = true;
      str = i+1;
      end = str+2;
    }
  }

  if (f) {
    cout << str << " " << end << endl;
  }
  else {
    cout << -1 << " " << -1 << endl;
  }
}

Measured memory_bytes: 512
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

var n = null;
var index = 0;
while (line = lines.shift()) {
    const isN = index % 2 === 0;
    const numberArray = line.split(' ').map(Number);

    if(isN){
        n = numberArray[0];
    } else {
        var smallestScore = null;
        for(var i = 0; i < numberArray.length; i++){
            for(var j = 0; j < numberArray.length; j++){
                if (i!==j) {
                    let scoreDifference = Math.abs(numberArray[i] - numberArray[j]);
                    if(smallestScore === null){
                        smallestScore = scoreDifference;
                    } else {
                        if(scoreDifference < smallestScore){
                           smallestScore = scoreDifference; 
                        }
                    }
                }
            }    
        }
        console.log(smallestScore);
        n = null;
    }
    // const [n, max] = line.split(' ').map(Number);
    // if (n === 0 && max === 0) {break;}
    // let prices = lines.shift().split(' ').map(Number);

    // // write something here

    // if(isN){
    //     m
    // }

    // console.log(...);
    index ++;
} 

/*const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');
while (line = lines.shift()) {
    const [n, max] = line.split(' ').map(Number);
    if (n === 0 && max === 0) {break;}
    let prices = lines.shift().split(' ').map(Number);

    console.log('HEY');
    // write something here

    // console.log(...);
} 
*/


Measured memory_bytes: 18324
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <bitset>

using namespace std;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	// for (int i = 0; i < n; i++) {
	// 	bitset<10> b(a[i]);
	// 	printf("%2d: %4d, %s\n", i, a[i], b.to_string().c_str());
	// }

	long long ans = 0;
	int l = 0, r = 1;
	int stat = 0;
	while (r <= n) {

// printf("l %2d, r %2d: ", l, r);

		if ((stat & a[r-1]) == 0) {
			stat ^= a[r-1];
			ans += r - l;
// printf(" r++: add %d, ans %d\n", r - l, ans);
			r++;
			continue;
		}

// printf(" l++: \n");
		stat ^= a[l];
		l++;
	}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int sumDigit(int x){
	int ret = 0;
	while(true){
		if (x == 0) return ret;
		ret = ret + (x % 10);
		x = x / 10;
	}
}

int main(){
	int N; SCD(N);
	int ans = 1000000007;
	FORq(i,1,N-1){
		int A = i;
		int B = N-i;
		ans = min(ans,(sumDigit(A) + sumDigit(B)));
	}
	
	PRINTD(ans);
		
	
	return 0;
}


Measured memory_bytes: 256
bingo = [list(map(int,input(' ').split())) for i in range(3)]
N = int(input())
number = list()
for a in range(N):
    number.append(int(input()))

def check(card):
    if (card[0][0] == card[0][1] == card[0][2] == 'x') or (card[1][0] == card[1][1] == card[1][2] == 'x') or (card[2][0] == card[2][1] == card[2][2] == 'x'):
        return 'Yes'
    elif (card[0][0] == card[1][0] == card[2][0] == 'x') or (card[0][1] == card[1][1] == card[2][1] == 'x') or (card[0][2] == card[1][2] == card[2][2] == 'x'):
        return 'Yes'
    elif (card[0][0] == card[1][1] == card[2][2] == 'x') or (card[0][2] == card[1][1] == card[2][0] == 'x'):
        return 'Yes'
    else:
        return 'No'

for a in number:
    for b in bingo:
        for c in b:
            if a == c:
                bingo[bingo.index(b)][bingo[bingo.index(b)].index(c)] = 'x'

print(check(bingo))

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w := intScanner(), intScanner()
	as := make([]string, h)
	for i := 0; i < h; i++ {
		as[i] = Scanner()
	}
	x := make([][]int, h)
	for i := 0; i < h; i++ {
		x[i] = make([]int, w)
		for j := 0; j < w; j++ {
			if string(as[i][j]) == "." {
				x[i][j] = mod
			} else {
				x[i][j] = 0
			}
		}
	}
	for i := 0; i < h; i++ {
		for j := 1; j < w; j++ {
			x[i][j] = smaller(x[i][j], x[i][j-1]+1)
		}
	}
	for i := 0; i < h; i++ {
		for j := w - 2; j >= 0; j-- {
			x[i][j] = smaller(x[i][j], x[i][j+1]+1)
		}
	}
	for j := 0; j < w; j++ {
		for i := 1; i < h; i++ {
			x[i][j] = smaller(x[i][j], x[i-1][j]+1)
		}
	}
	for j := 0; j < w; j++ {
		for i := h - 2; i >= 0; i-- {
			x[i][j] = smaller(x[i][j], x[i+1][j]+1)
		}
	}
	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			ans = larger(ans, x[i][j])
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 10112
# ARC093C - Traveling Plan (ABC092C)
# 累積和
def main():
    N = int(input())
    A = [0] + list(map(int, input().rstrip().split())) + [0]
    S = 0
    for i in range(1, N + 2):
        S += abs(A[i - 1] - A[i])

    for i in range(1, N + 1):
        ans = S + abs(A[i - 1] - A[i + 1]) - (abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]))
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll l=s.length(),ans=0;
  rep(i,l/2) if(s[i]!=s[l-1-i]) ans++;
  print(ans);
  return 0;
}


Measured memory_bytes: 256
//abc149_c.cpp
//Sun Jan 12 11:21:42 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	while (1){
		int flag = 0;
		for (int i=2;i*i<x;i++){
			if (x%i==0){
				flag = 1;
				break;
			}
		}
		if (flag){
			x++;
		}else {
			cout << x << endl;
			return 0;
		}
	}

}

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

int main() {
  string o,e,ans="";
  cin >> o >> e;
  for(long i=0;i<e.size();i++) ans=ans+o[i]+e[i];
  if(o.size()!=e.size()) ans=ans+o[o.size()-1];
  cout << ans << endl;
}

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

using namespace std;

int main(){

  string n;
  cin>>n;
  
  long long int sum=0;
  
  for(int i=0; i<n.size(); i++){
    int dig=n[i]-'0';
    sum+=dig;
  }
  

  if(sum%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200010];
int main() {
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)    cin>>a[i];
    ll ans=0;
    for(ll i=2;i<=n;i++){
        if(a[i]<a[i-1]){
            ans+=abs(a[i]-a[i-1]);
            a[i]=a[i-1];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5160