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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

  string oks[16] = {
    "AKIHABARA",
    "KIHABARA",
    "AKIHBARA",
    "AKIHABRA",
    "AKIHABAR",
    "KIHBARA",
    "KIHABRA",
    "KIHABAR",
    "AKIHBRA",
    "AKIHBAR",
    "AKIHABR",
    "KIHABR",
    "KIHBRA",
    "KIHBAR",
    "AKIHBR",
    "KIHBR"
  };

  bool ok=false;
  REP(i,16){
    if(s==oks[i])ok=true;
  }

  cout << (ok ? "YES" : "NO") << endl;

}



Measured memory_bytes: 3612
import static java.lang.System.out;
import java.util.ArrayList;
import java.util.Scanner;

class PrintTestCases {
}

public class Main {
    public static void main(String... args) {
        ArrayList<Integer> data = new ArrayList<Integer>();

        // scan
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            data.add(scan.nextInt());
        }

        // print
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i) == 0) break; // 0???????????????
            out.printf("Case %d: %d\n", i+1, data.get(i) );
        }
    }
}

Measured memory_bytes: 63920
N = int(input())
a = list(input() for i in range(N))
a.sort()
count = 1
max = 0
ls = []
for i in range(N - 1):
  if a[i] == a[i + 1]:
    count += 1
  else:
    if count > max:
      ls = []
      ls.append(a[i])
      max = count
    elif count == max:
      ls.append(a[i])
    count = 1
if count > max:
  ls = []
  ls.append(a[N - 1])
elif count == max:
  ls.append(a[N - 1])
ls.sort()
for i in range(len(ls)):
  print(ls[i])

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

using namespace std;

typedef long long LL;

const int N = 2e5 + 10;

int n;
LL a[N];
LL res;

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);

	LL sum1 = 0, sum2 = 0;
	for (int i = 1, j = 1; i <= n; i++)
	{
		while (j <= n + 1 && sum1 == sum2) //j可以枚举到n
		{
			//printf("sum1 sum2: %lld %lld\n", sum1, sum2);
			sum1 ^= a[j]; sum2 += a[j];
			j++;
		}

		//printf("sum1 sum2: %lld %lld\n", sum1, sum2);
		//printf("---%d %d\n", i, j);
		
		//[i, i...j - 2]之间都是合法的
		res += (j - 2) - i + 1;

		sum1 ^= a[j - 1]; sum2 -= a[j - 1];
		j--; //最后一个不合法的退掉

		sum1 ^= a[i]; sum2 -= a[i];
	}

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

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  ll n,a,b,t,count = 0;
  cin >> n >> a >> b;
  for(int i=0;i<n;i++){
    cin >> t;
    if(t<a || b<=t) count++;
  } 
  cout << count << endl;
}


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

namespace abc119_a
{
    class Program
    {
        public static string ADDecision(int A, int B, int C)
        {
            if (A > 2019) return "TBD";
            if (B >= 5) return "TBD";
            return "Heisei";
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split('/');
            int yyyy = int.Parse(input[0]);
            int mm = int.Parse(input[1]);
            int dd = int.Parse(input[2]);

            Console.WriteLine(ADDecision(yyyy, mm, dd));
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int n=0;
int u=0;
int k[101]={0};
int v[101][101]={0};
int d[101];//d[]=short[].
int cur=0;
int fptr=0;
int lptr=0;
int queue[1024]={};
int q2[1024]={};
int max=sizeof(queue)/sizeof(queue[0]);    //データの数/1データの使用メモリ
void enqueue(int p,int m){
	queue[lptr]=p;
	q2[lptr]=m;
	lptr=(lptr+1)%max;//エンキュー
}
void bfs(void){
	int id=0,m=0;
	while(lptr!=fptr){
	id=queue[fptr];
	m=q2[fptr];
	fptr=(fptr+1)%max;//デキュー
	if(d[id]!=-1){
		continue;
	}
	d[id]=m;
	for(int i=0;i<k[id];i++){
		enqueue(v[id][i],m+1);
	}
	}
	return;
	}
	int main(void)
{
	for(int r=0;r<101;r++){
	d[r]=-1;
	}
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&u);
		scanf("%d",&k[u]);
		for(int j=0;j<k[u];j++){
			scanf("%d",&v[u][j]);
		}
	}
		enqueue(1,0);
		
		bfs();
	for(int i=1;i<n+1;i++){
		printf("%d %d\n",i,d[i]);
	}
	return(0);
}


Measured memory_bytes: 2736
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define int ll
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010;
int x[N],n,L,nxt[N][20];
signed main(){
	n=gi();
	for(int i=1;i<=n;i++)x[i]=gi();
	L=gi();
	for(int i=1;i<=n;i++){
		int l=i+1,r=n,ans=i;
		while(l<=r){
			int mid=(l+r)>>1;
			if(x[mid]-x[i]<=L){ans=mid;l=mid+1;}
			else r=mid-1;
		}
		nxt[i][0]=ans;
	}
	for(int j=1;j<=18;j++)
		for(int i=1;i<=n;i++)
			nxt[i][j]=nxt[nxt[i][j-1]][j-1];
	int q=gi();
	while(q--){
		int a=gi(),b=gi();if(a>b)swap(a,b);
		int ans=0;
		for(int i=18;~i;i--)
			if(nxt[a][i]<b){a=nxt[a][i];ans+=1ll<<i;}
		printf("%lld\n",ans+1);
	}
	return 0;
}

//ORz hyj

Measured memory_bytes: 17280
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll n;
    cin>>n;
    string a[n];
    map<string,ll>mpp;
    ll mxVal=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        ++mpp[a[i]];
        mxVal=max(mxVal,mpp[a[i]]);
    }
    set<string>ans;
    for(ll i=0;i<n;i++){
        if(mpp[a[i]]==mxVal){
            ans.in(a[i]);
        }
    }
    for(auto it:ans){
        cout<<it<<"\n";
    }
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 34816
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L, *rest = map(int, sys.stdin.buffer.read().split())
in_, out, weight = rest[0:3*M:3], rest[1:3*M:3], rest[2:3*M:3]

graph = csr_matrix((weight, (in_, out)), shape=(N+1, N+1))
graph = floyd_warshall(graph, directed=False)
graph = floyd_warshall(graph <= L, directed=False)
graph[np.isinf(graph)] = 0

S, T = rest[3*M+1::2], rest[3*M+2::2]
print(*(graph[S, T] - 1).astype(int), sep='\n')


Measured memory_bytes: 36272
n=int(input())
w=list(map(int,input().split()))
d=sum(w)
e=0
f=0
for i in range(n):
   e=w[i]+e
   if(e>d-e):
       f=min([2*e-d,d-2*e+2*w[i]])
       print('{0}'.format(f))
       break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int a,b,c,k,ans;
int main(){
	cin>>a>>b>>c>>k;
	if(a>k) ans+=k,k=0;
	else ans+=a,k-=a;
	if(k>=b) k-=b;
	if(k>0) ans-=k;
	cout<<ans;
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,A,B;
ll X[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	
	ll ret=0;
	FOR(i,N) cin>>X[i];
	FOR(i,N-1) ret+=min((X[i+1]-X[i])*A,B);
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 1024
rows, columns = [int(x) for x in input().split()]

numbers_list = []

for _ in range(rows):
  numbers = [int(y) for y in input().split()]
  numbers.append(sum(numbers))

  numbers_list.append(numbers)

column_sums = [sum(x) for x in zip(*numbers_list)]

numbers_list.append(column_sums)

string_list = []

for number_list in numbers_list:
  string_list.append([str(x) for x in number_list])

for number_list in string_list:
  print(" ".join(number_list))



Measured memory_bytes: 6240
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;


int n;
int dp[100007][4];
int a[100007][4];
int main() {
    
    scanf("%d",&n);
    for(int i = 0; i < n; i ++) {
        for(int j = 0; j < 3; j ++) {
            scanf("%d",&a[i][j]);
        }
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i = 1; i < n; i ++) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + a[i][1];
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + a[i][2];
    }
    int ans = max(dp[n-1][0],dp[n-1][1]);
    ans = max(ans, dp[n-1][2]);
    printf("%d\n",ans);
}

Measured memory_bytes: 3456
def dist(p, X, Y):
    s = 0
    for x, y in zip(X, Y):
        s += abs(x-y)**p
    return s**(1/p)
N = int(input())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
print(dist(1,X,Y))
print(dist(2,X,Y))
print(dist(3,X,Y))
print(max(abs(x-y)for x, y in zip(X, Y)))


Measured memory_bytes: 5644
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin>>N;
    int D,X; cin>>D>>X;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int count=0;
    for(int i=0;i<N;i++){
        for(int j=0;1+j*A[i]<=D;j++){
            count++;
        }
    }
    int ans=X+count;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	ll a;
	long double b;
	cin>>a>>b;

	ll t=a*b;
	cout<<t<<endl;


	return 0;
}


Measured memory_bytes: 3736
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int a, b, k;
  vector<int> g;
  cin >> a >> b >> k;
  for (int i = 1; i <= min(a,b); ++i) {
    if (a % i == 0 && b % i == 0) {
      g.push_back(i);
      // clog << i << endl;
    }
  }

  reverse(ALL(g));
  cout << g[k-1] << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline ll read(){
	ll res=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){res=(res<<3)+(res<<1)+ch-'0';ch=getchar();}
	return res*f;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10|'0');
}
const int N=1e5;
int a[N][3];
int n,f[N][3];

signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i][1]=read(),a[i][2]=read(),a[i][3]=read();
	for(int i=1;i<=n;i++){
		f[i][1]=max(f[i-1][2],f[i-1][3])+a[i][1];
		f[i][2]=max(f[i-1][1],f[i-1][3])+a[i][2];
		f[i][3]=max(f[i-1][1],f[i-1][2])+a[i][3];
	}
	int ans=max(f[n][1],max(f[n][2],f[n][3]));
	cout<<ans<<endl;
}


Measured memory_bytes: 4864
N, M = map(int, input().split())
SC = [[int(x) for x in input().split()] for _ in range(M)]

ans = []
for i in range(1000):
    if len(str(i)) != N:
        continue
    
    flg = True
    for s, c in SC:
        if str(i)[s-1] == str(c):
            continue
        else:
            flg = False
            break
    if flg:
        ans.append(i)

if len(ans)==0:
    print(-1)
else:
    print(min(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    string s; cin>>s;
    int a=0;
    rep(i,0,3) if(s[i]=='o') a++;
    cout<<700+100*a<<endl;
}

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

template<typename T>
class BinTree;

template<typename T>
class Node {
    T value;
    Node<T> *parent, *left, *right;
    Node (T _value) : value(_value) {
        parent = nullptr;
        left = nullptr;
        right = nullptr;
    }
    Node (){
        parent = nullptr;
        left = nullptr;
        right = nullptr;
    }
    friend BinTree<T>;
    public:
    void inorder(std::vector<T> &ret) {
        if(left) left->inorder(ret);
        ret.push_back(value);
        if(right) right->inorder(ret);
    }
    void preorder(std::vector<T> &ret) {
        ret.push_back(value);
        if(left) left->preorder(ret);
        if(right) right->preorder(ret);
    }
    void postorder(std::vector<T> &ret) {
        if(left) left->postorder(ret);
        if(right) right->postorder(ret);
        ret.push_back(value);
    }
};

template<typename T> 
class BinTree{
    Node<T> *root;
    size_t size;
    void insert_main(Node<T> *z) {
        Node<T> *y = nullptr, *x = root;
        while(x) {
            // std::cout << x << '\n';
            y = x;
            if(z->value < x->value) {
                x = x->left;
            }
            else {
                x = x->right;
            }
        }
        z->parent = y;
        if(y == nullptr) {
            root = z;
        }
        else if(z->value < y->value) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
    public:
    BinTree() {
        root = nullptr;
        size = 0;
    }
    bool empty() {return size == 0;}
    void insert(T x) {
        Node<T> *z = new Node<T>(x);
        insert_main(z);
    }
    void preorder(std::vector<T> &ret) {root->preorder(ret);}
    void inorder(std::vector<T> &ret) {root->inorder(ret);}
    void postorder(std::vector<T> &ret) {root->postorder(ret);}
};

template<typename T>
void vdeb(std::vector<T> &da) {
    size_t size = da.size();
    for(int i = 0; i < size; ++i) {
        std::cout << ' ' <<  da[i];
    }
    std::cout << '\n';
}

int main() {
    int n; std::cin >> n;
    BinTree<int> bt;
    for(int i = 0; i < n; ++i) {
        std::string s;
        std::cin >> s;
        if(s == "insert") {
            int x; std::cin >> x;
            bt.insert(x);
        }
        else if(s == "print") {
            std::vector<int> pre(0), mid(0);
            bt.preorder(pre);
            bt.inorder(mid);
            vdeb(mid);
            vdeb(pre);
        }
    }
}


Measured memory_bytes: 31380
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;

int main(){
  int N;
  while(cin>>N){
    vector<P> v(N);
    REP(i,N)cin>>v[i].second>>v[i].first;
    sort(v.begin(), v.end());
    int dp[1002];
    fill(dp, dp + 1002, INF);
    dp[0] = 0;
    REP(i,N){
      for(int j = 1000; j >= 0; j--){
        if(dp[j] + v[i].second <= v[i].first) dp[j+1] = min(dp[j+1], dp[j] + v[i].second);
      }
    }
    for(int i = 1000; i >= 0; i--){
      if(dp[i]!=INF){
        cout<<i<<endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>



using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int main()
{
	int n, m; cin >> n >> m;
	vector<pair<int, int>> pp(m);
	rep(i, m) cin >> pp[i].first >> pp[i].second;

	rep(i, 1000) {

		int t = i;
		vector<int> d(1,t%10);
		int keta = 1;
		t /= 10;
		while (t) {
			d.push_back(t % 10);
			t /= 10;
			keta++;
		}
		if (keta != n) continue;
		reverse(d.begin(), d.end());
		bool ok = true;
		rep(j, m) {
			if (d[0, pp[j].first - 1] != pp[j].second)
				ok = false;
		}
			if (ok) {
				cout << i;
				return 0;
			
		}
	}cout << "-1";
}


Measured memory_bytes: 3592
# -*- coding:utf-8 -*-

n = input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0

for i in range(len(b)):

    if b[i] <= a[i]:        # 街のモンスターの方が多い場合
        cnt += b[i]
        a[i] -= b[i]
        b[i] = 0 


    else:                   # 街のモンスターの方が少ない場合
        cnt += a[i]
        b[i] -= a[i]
        a[i] = 0

        # 隣街のモンスターを倒しに行く
        if b[i] <= a[i+1]:  # 隣町のモンスターが多い場合
            a[i+1] -= b[i]
            cnt += b[i]
            b[i] = 0
        else:               # 隣町のモンスターが少ない場合
            cnt += a[i+1]
            b[i] -= a[i+1]
            a[i+1] = 0

print(cnt)

Measured memory_bytes: 18476
def solve():
  n,k,q = (int(i) for i in input().split())
  query = [0]*n
  for i in range(q):
    ans = int(input())-1
    query[ans] += 1
  for i in range(n):
    if k-q+query[i] <= 0:
      print("No")
    else:
      print("Yes")
solve()

Measured memory_bytes: 4680
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int l=sc.nextInt();
        int r=sc.nextInt();
        int d=sc.nextInt();
        int count=0;
        for(int i=l;i<=r;i++)
        {
           if(i%d==0)
           {
               count++;
           }


        }
        System.out.println(count);

    }
}


Measured memory_bytes: 35632
#pragma GCC optimize(2)

#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define All(a) a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a) (int)a.size()
#define F first
#define S second
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d) cout<<"Yes\n";
	else if(abs(a-b)<=d && abs(b-c)<=d) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)
n=int(input())
memo=[-1]*(10**7)
memo[0]=0
def rec(a:int):
    if a==0:
        return 0
    if memo[a]!=-1:
        return memo[a]
    res=100000
    for i in range(1,9):
        if 0<=a-6**i:
            res=min(res,rec(a-6**i)+1)
    for j in range(1,9):
        if 0<=a-9**j:
            res=min(res,rec(a-9**j)+1)
    res=min(res,rec(a-1)+1)

    memo[a] = res

    return res
print(rec(n))

Measured memory_bytes: 175868
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<queue>
#include<limits>
#include<map>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;
namespace Arithmetics {
	template<typename T>
	T original_pow(T a, T b) {
		T ans = 1;
		rep(i, b) {
			ans *= a;
		}

		return  ans;
	}
	template<typename T>
	T gcd(T a, T b) {
		if (a > b) {
			T c = a;
			a = b;
			b = c;
		}
		if (a == 0) {
			return b;
		}

		return gcd(b % a, a);
	}
	template<typename T>
	T gcd_of_all(vector<T> v) {
		T temp = v[0];
		for (T elem : v) {
			temp = gcd(temp, elem);
		}

		return temp;
	}
	template<typename T>
	T lcm(T a, T b) {
		T GCD = gcd(a, b);
		return a * b / GCD;
	}
	template<typename T>
	T lcm_of_all(vector<T> v) {
		T temp = v[0];
		for (T elem : v) {
			temp = lcm(temp, elem);
		}
		return temp;
	}
}
using namespace Arithmetics;

int main() {
	int N, M;
	cin >> N >> M;
	vi vec(N,-1);
	bool flag = true;
	int ans = 0;
	if (N == 1) {
		rep(times, M) {
			int s, c; cin >> s >> c; s--;
			if (vec[s] == -1) {
				vec[s] = c;
			}
			else {
				if (vec[s] != c) {
					flag = false;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			if (vec[i] == -1) {
				vec[i] = 0;
			}
		}
		if (flag) {
			cout << vec[0] << endl;
		}
		else {
			cout << -1 << endl;
		}
		
	}
	else {
		rep(times, M) {
			int s, c; cin >> s >> c; s--;
			if (vec[s] == -1) {
				vec[s] = c;
				if (c == 0 and s == 0) {
					flag = false;
				}
			}
			else {
				if (vec[s] != c) {
					flag = false;
				}
			}
		}
			for (int i = 0; i < N; i++) {
				if (vec[i] == -1) {
					vec[i] = 0;
				}
			}
			vec[0] == 0 ? vec[0] = 1 : 1;

			for (int i = 0; i < N; i++) {
				ans += vec[i] * pow(10, N - i - 1);
			}

			if (flag) {
				cout << ans << endl;
			}
			else {
				cout << -1 << endl;
			}
		
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
int ps[1000];
int main(){
    int n,m;
    for(;;){
        scanf("%d%d",&n,&m);
        if(n==0&&m==0) break;
        for(int i=0;i<n;i++){
            scanf("%d",&ps[i]);
        }
        sort(ps,ps+n,greater<int>());
        int sum=0;
        for(int i=0;i<n;i++){
            if(i%m!=m-1) sum+=ps[i];
        }
        printf("%d\n",sum);
    }
}

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

int main() {

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

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

int main() {
    int n, m;
    cin >> n >> m;
    int count[n + 1] = {};
    for (int a, b; cin >> a >> b; ) {
        count[a]++;
        count[b]++;
    }
    for (int i = 1; i <= n; i++) {
        if (count[i] % 2 == 1) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
/*

*/
int main(void){
    int k;
    scanf("%d",&k);
    int val;
    if(k%2==1){
        val = (k/2)*(k/2+1);
        printf("%d\n",val);
    }
    else{
        val = (k/2)*(k/2);
                printf("%d\n",val);

    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

using namespace std;

u_int64_t f(u_int64_t a)
{
    u_int64_t tail = (a % 2 == 0 ? a : 0);
    u_int64_t body = ((a + 1) & ~1) / 2 % 2 == 0 ? 0 : 1;

    return body ^ tail;
}

int main()
{
    u_int64_t a, b;

    cin >> a >> b;

    const u_int64_t c = a > 0 ? f(a - 1) : 0;
    const u_int64_t d = f(b);

    const u_int64_t result = c ^ d;

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll ans = 0;
    if(K >= A){
        ans += A;
        K -= A;
    }else{
        cout << K << endl;
        return 0;
    }
    if(K >= B){
        K -= B;
    }else{
        cout << ans << endl;
        return 0;
    }
    cout << ans - K << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	ll c = 0;
	for (ll i = 0; i < n; i++) {
		ll a, b;
		cin >> a >> b;
		if (a == b) {
			c++;
			if (c == 3) {
				cout << "Yes";
				return 0;
			}
		}
		else
			c = 0;
	}
	cout << "No";
}


Measured memory_bytes: 3644
#include<stdio.h>

int main(void)
{
	int n, r, s, p, k;
	char t[100002];
	int i, j;
	long long int ret;
	int index;
	char cur;
	char next;
	char past;
	int index_c;
	int index_n;
	int prc;
	int flag;

	int jdg[3][3];
	int point[3];

	scanf("%d %d", &n, &k);
	scanf("%d %d %d", &r, &s, &p);
	scanf("%s", t);

	ret = 0;

	//r				//s				//p
	point[0] = p;	point[1] = r;	point[2] = s;

	for (i = 0; i < 3; i++){
		for (j = 0; j < 3; j++){
			if (point[i] >= point[j])
				{ jdg[i][j] = 1; }
			else{ jdg[i][j] = 0; }
		}
	}




	for (i = 0; i < k; i++){
		flag = 0;
		past = '0';
		for (j = 0; j * k + i < n; j++){
			index = j * k + i;

			cur = t[index];
			if (cur == past && flag == 1){
				prc = 0;
				flag = 0;
			}
			else if (index + k >= n){
				// 次の手を気にしなくていい場合 -> 無条件で勝ち
				prc = 1;

			}
			else{
				// 次の手を気にする場合
				next = t[index + k];

				/*
				switch (cur){
				case 'r':
					index_c = 0;
					break;
				case 's':
					index_c = 1;
					break;
				case 'p':
					index_c = 2;
					break;
				default:
					// No Operation
					break;
				}

				switch (next){
				case 'r':
					index_n = 0;
					break;
				case 's':
					index_n = 1;
					break;
				case 'p':
					index_n = 2;
					break;
				default:
					// No Operation
					break;
				}
				*/
				//prc = jdg[index_c][index_n];
				if (cur == next){ flag = 1; }
				prc = 1;
			}
			// 勝ったときの加算処理
			if (prc == 1){
				switch (cur){
				case 'r':
					ret += p;
					break;

				case 's':
					ret += r;
					break;

				case 'p':
					ret += s;
					break;

				default:
					// No Operation
					break;

				}
			}
//			printf("%d : %d ( ret = %lld )\n", index, prc, ret);
			past = cur;
		}
	}

	printf("%lld\n", ret);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long i, j, k ,l, a, b, c, d, sum = 0;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  int d1[a][b];
  int d2[b][c];
  for(i = 0; i < a; i++) {
    for(j = 0; j < b; j++){
      scanf("%d", &d);
      d1[i][j] = d;
    }
  }
  for(i = 0; i < b; i++) {
    for(j = 0; j < c; j++){
      scanf("%d", &d);
      d2[i][j] = d;
    }
  }
  for(i = 0; i < a; i++) {
    for(j = 0; j < c; j++) {
      for(k = 0; k < b; k++) {
        sum += d1[i][k] * d2[k][j];
      }
      printf("%ld", sum);
      sum = 0;
      if(j < c - 1) {
        printf(" ");
      }
    }
   if(i < a - 1) {
      printf("\n");
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2732
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < n; i++) {
            int amount = 0;
            for (int j = 0; j < m; j++) {
                amount += sc.nextInt() * b[j];
            }
            amount += c;
            if (amount > 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23380
#include<stdio.h>

#define MAX 101
static const int INF = (1 << 21);

int n;
int d[MAX],key1[MAX],key2[MAX],G[MAX][MAX];

void SingleSourceShortestPathI(void){

  int i,j;
  int min,youso;

  for(i = 0;i < n;i++){
    d[i] = INF;
   key1[i] = 0; 
   key2[i] = -1;
  }

  d[0] = 0;

  while(1){
    min = INF;
    youso = -1;

    for(i = 0;i < n;i++){
      if(!key1[i] && d[i] < min){
	youso = i;
	min = d[i];
      }
    }
    if(youso == -1){
      break;
    }
    key1[youso] = 1;

    for(j = 0;j < n;j++){
      if(d[j] > d[youso]+G[youso][j]){
	d[j] = d[youso] + G[youso][j];
	key2[j] = youso;
      }
    }
  }
}

int main(){
  int i,j;
  int u,k,v,c;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      G[i][j] = INF;
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    for(j = 0;j < k;j++){
      scanf("%d%d",&v,&c);
      G[u][v] = c;
    }
  }
  SingleSourceShortestPathI();

 for(i = 0;i < n;i++){
    printf("%d %d\n",i,(d[i] == INF?-1:d[i]));
  }
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0;
    for(int i = 0;i < s.size();i ++){
        if(s.at(i) == '0'){
            cnt0 ++;
        }else{
            cnt1 ++;
        }
    }
    int m;
    if(cnt0 < cnt1){
        m = cnt0;
    }else{
        m = cnt1;
    }

    cout << m*2 << endl;
}

Measured memory_bytes: 512
n = int(input())
L = []
for i in range(n):
    a,b = map(int,input().split())
    L.append([b,a])
L.sort()
cur = 0
flag = True
for i in range(n):
    cur += L[i][1]
    if cur > L[i][0]:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 35620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(c>=a && c<=b){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
edges = [[]for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    edges[a].append(b)
    edges[b].append(a)

next_v = deque([0])
prev = [-1]*n
while next_v:
    v = next_v.popleft()
    for v2 in edges[v]:
        if prev[v2] != -1:
            continue
        prev[v2] = v+1
        next_v.append(v2)

print('Yes')
for x in prev[1:]:
    print(x)


Measured memory_bytes: 37664
#define DEBUG 0
/**
 * File    : D.cpp
 * Author  : Kazune Takahashi
 * Created : 6/22/2019, 9:15:47 PM
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
typedef long long ll;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

typedef tuple<ll, ll> work;

int N;
vector<work> V;

int main()
{
  // init();
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    ll a, b;
    cin >> a >> b;
    V.push_back(work(b, a));
  }
  sort(V.begin(), V.end());
  ll t = 0;
  for (auto i = 0; i < N; i++)
  {
    ll a, b;
    tie(b, a) = V[i];
    t += a;
    if (t > b)
    {
      No();
    }
  }
  Yes();
}

Measured memory_bytes: 29936
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	set <string> st;
	cin >> n;
	while(n--) {
        string k;
        cin >> k;
        st.insert(k);
	}
	cout << st.sz;
	return 0;
}


Measured memory_bytes: 19240
package main

import (
    "fmt"
    "os"
)

func main() {

    var N, A, B int

    fmt.Fscanf(os.Stdin, "%d %d %d", &N, &A, &B)
    ans := 0
    for n := 1; n <= N; n++ {
        s := fmt.Sprintf("%d", n)
        sum := 0
        for _, c := range s {
            sum += int(c) - '0'
        }
        if A <= sum && sum <= B {
            //fmt.Printf("%d %d\n", n, ans)
            ans += n
        }
    }
    fmt.Printf("%d\n", ans)

}

Measured memory_bytes: 640
use proconio::{input, fastout};
use std::cmp::max;

#[fastout]
fn main() {
    input!{
        n: i32,
        mut h: [i32; n],
    }
    let mut a = 0;
    for &i in h.iter() {
        if i < a {
            println!("No");
            return
        }
        a = max(a, i - 1);
    }
    println!("Yes");
}


Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
int main(){
  bool ans = 1;
  int N,tpre = 0,tpost,xpre = 0,xpost,ypre = 0,ypost;
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> tpost >> xpost >> ypost;
    if(abs(xpost - xpre) + abs(ypost - ypre) > tpost - tpre)ans = 0;
    if((abs(xpost - xpre) + abs(ypost - ypre))%2 != (tpost - tpre)%2)ans = 0;
    tpre = tpost;
    xpre = xpost;
    ypre = ypost;
  }
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b,c) make_pair(make_pair(a,b),c)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()

typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}

int main(){
	int l = in();
	while(1){
		char c;
		cin >> c;
		if( c == '=' ){
			cout << l << endl;
			return 0;
		}
		int t;
		cin >> t;
		if( c == '+' ) l += t;
		if( c == '*' ) l *= t;
		if( c == '/' ) l /= t;
		if( c == '-' ) l -= t;
		
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
using namespace std;
int main() {

	int a, b, c,d,n,m;
	cin >> a >> b >> c >> d;

	if (a*b == c*d) {
		cout << a*b << endl;
	}
    if (a*b < c*d) {
		cout << c*d << endl;
	}
	if (a*b > c*d) {
		cout << a*b << endl;
	}

		
		

	return 0;
}

Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

n = gets_i
t, a = gets_i_list
hlist = gets_i_list

t, a = t * 1000, a * 1000

index = 0
min = Float::INFINITY
hlist.each_with_index do |h, i|
  diff = (t - h * 6 - a).abs
  if min >= diff
    index = i
    min = diff
  end
end

puts index + 1

Measured memory_bytes: 14500
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>

using namespace std;

int main() {
    string  s;
    cin >> s ;
    
    int flag = 0;
    for (int i = 0; i < 2; i++) {
        if (s[i] != s[i + 1])
            flag = 1;
    }
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 5100;
const int MOD = 1000000007;

ll m[MAX][MAX];

int main(){
  ll H,W,A,B; cin>>H>>W>>A>>B;

  rep(i,A){
    m[0][i] = 1;
  }
  repn(i,H-B-1){
    rep(j,A){
      m[i][j] = m[0][j];
    }
  }

  for(int i = H - B; i < H; i++){
    for(int j = A; j < W; j++){
      m[i][j] = 1;
    }
  }

  rep(i,H){
    rep(j,W){
      cout<<m[i][j];
    }
    cout<<endl;
  }

}


Measured memory_bytes: 40448
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

vector<vector<int>>g;
ll ans = 1, n, k;
void dfs(int v, int p, int c1, int c2) {
	int t = 1;
	ans = (ans * (k - c1 - c2)) % mod;
	for (int i = 0; i < g[v].size(); ++i) {
		if (g[v][i] != p) {
			dfs(g[v][i], v, 1, c1 + t - 1);
			++t;
		}
	}
}

int main() {
	speed;
	int a, b;
	cin >> n >> k;
	g.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		cin >> a >> b;
		--a, --b;
		g[a].push_back(b), g[b].push_back(a);
	}
	dfs(0, -1, 0, 0);
	cout << ans;
}

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

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

int ori[10][10];
int arr[10][10];
int arr2[10][10];
    
void flip(int i, int j) {
  arr[i][j] = 1 - arr[i][j];
  arr2[i][j] = 1 - arr2[i][j];
  for(int k=0; k<4; k++) {
    int nx = j+dx[k], ny = i+dy[k];
    if(0<=ny && ny<10 && 0<=nx && nx<10) {
      arr[ny][nx] = 1 - arr[ny][nx];
    }
  }
}

int main() {
  int Tc; cin >> Tc;
  
  while(Tc--) {
    
    for(int i=0; i<10; i++)
      for(int j=0; j<10; j++)
	cin >> ori[i][j];
    
    bool good = 0;
    for(int I=0; I<(1<<10); I++) {
      memset(arr2, 0, sizeof(arr2));
      memcpy(arr, ori, sizeof(ori));
      bool ok = 1;
      for(int i=0; i<10; i++) {
	for(int j=0; j<10; j++) {
	  
	  if(i == 0) {
	    if((I>>j) & 1) {
	      if(arr[0][j] == 0) flip(0, j);
	    }
            else {
	      if(arr[0][j] == 1) flip(0, j);
            }
          }
	  else {
	    if(arr[i-1][j] == 1) flip(i, j);
	  }
	  
	} 
      }
      
      for(int i=0; i<10; i++) {
	if(arr[9][i]) ok = 0;
      }
      if(ok) {
	good = 1;
	break;
      }
    }
    if(good) {
      for(int i=0; i<10; i++) {
	for(int j=0; j<10; j++) {
	  if(j) cout << " ";
	  cout << arr2[i][j];
	}
	cout << endl;
      }
    }
  }
  
  return 0;
}

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

int main(){
    long int x;
    cin >> x;
    long int a=100;
    for (int i=1; i<=3761; i++){
        a=floor(a*1.01);
        if(a>=x){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

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

const int MAX = 100000;
int N;
int DP[MAX + 1];
int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    DP[i] = 1e9;
  }
  
  vector<int> v;
  for (int b = 1; b <= MAX; b *= 6) v.push_back(b);
  for (int b = 1; b <= MAX; b *= 9) v.push_back(b);
  
  for (int i = 1; i <= N; ++i) {
    for (int k : v) {
      if (i - k < 0) continue;
      DP[i] = min(DP[i], DP[i - k] + 1);
    }
  }
  cout << DP[N] << endl;
}


Measured memory_bytes: 640
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0 }, dy[] = { 0,1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑



int main() {
	int n, k[25], ans = 0;
	cin >> n;
	vector < pair<int, pair<int, int>>>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i].second.first;
	}
	for (int i = 0; i < n; ++i) {
		cin >> v[i].second.second;
		v[i].first = v[i].second.first - v[i].second.second;
	}

	for (int i = 0; i < v.size(); ++i) {
		if (v[i].first > 0) { ans += v[i].first; }
	}
	cout << ans << endl;
}

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

int main()
{
	int i,j,k,n;
	cin>>n>>k;
	int sum=0;
	for (i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		int ans=min(x,abs(k-x));
		sum+=2*ans;
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <boost/range/irange.hpp>

using namespace std;

int main()
{
    int x;
    for (auto const i : boost::irange(5)) {
        cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
            break;
        }
    }

    return 0;
}


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

int main(){
  vector<string> week = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string S;
  cin >> S;
  for (int i=0; i<7; i++) {
    if (S == week.at(i)) {
      cout << 7-i << endl;
      break;
    }
  }
}

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

using namespace std;
typedef long long ll;

char s[101], t[101];

int main(void) {
    int n;
    cin >> n >> s >> t;
    for(int i=0; i<n; i++) {
        for(int j=0; i+j<n; j++) {
            if(s[i+j] != t[j]) break;
            if(i+j == n-1) return !printf("%d\n", n + i);
        }
    }

    return !printf("%d\n", 2*n);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<cfloat>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

#define PI (3.1415926535)
#define EPS (1e-10)

int main(){
  vector<int> v(5);
  REP(i,5) cin>>v[i];
  sort(v.rbegin(),v.rend());
  REP(i,5) cout<<v[i]<<(i==4?'\n':' ');
  return 0;
}

Measured memory_bytes: 0