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

template<typename T1, typename T2> void cmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T1, typename T2> void cmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T> class Dijkstra {
  struct edge {
    int to; T cost;
  };
  vector<vector<edge>> G;
  vector<T> D;
  vector<int> P;
public:
  Dijkstra(int n) : G(n), D(n, numeric_limits<T>::max()), P(n) {}
  void add(int from, int to, T cost) {
    G.at(from).push_back((edge) {to, cost});
  }
  vector<T> build(int start) {
    using pit = pair<int, T>;
    priority_queue<pit, vector<pit>, greater<pit>> Q;
    D.at(start) = 0;
    Q.push(pit(start, 0));
    while (Q.size()) {
      auto [now, dist] = Q.top();
      Q.pop();
      if (dist > D.at(now)) continue;
      for (auto [next, cost] : G.at(now)) {
        if (dist + cost < D.at(next)) {
          D.at(next) = dist + cost;
          P.at(next) = now;
          Q.push(pit(next, D.at(next)));
        }
      }
    }
    return D;
  }
  void reset() {
    fill(D.begin(), D.end(), numeric_limits<T>::max());
  }
};

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;
  int sh, sw, gh, gw;
  cin >> sh >> sw >> gh >> gw;
  sh--, sw--, gh--, gw--;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }

  vector<int> mh {-1, 0, 1, 0};
  vector<int> mw {0, 1, 0, -1};
  Dijkstra<int> D(H * W);

  auto id = [&](int i, int j) {
    return W * i + j;
  };

  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      for (int i = 0; i < 4; i++) {
        int nh = h + mh.at(i);
        int nw = w + mw.at(i);
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (S.at(nh).at(nw) == '#') continue;
        D.add(id(h, w), id(nh, nw), 0);
      }
      for (int nh = h - 2; nh <= h + 2; nh++) {
        for (int nw = w - 2; nw <= w + 2; nw++) {
          if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
          if (S.at(nh).at(nw) == '#') continue;
          D.add(id(h, w), id(nh, nw), 1);
        }
      }
    }
  }

  int ans = D.build(id(sh, sw)).at(id(gh, gw));
  if (ans == INT_MAX) ans = -1;
  cout << ans << "\n";
}


Measured memory_bytes: 210468
import java.util.*;
import java.awt.Point;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		while(n-- > 0){
			Point size = new Point(sc.nextInt(),sc.nextInt());
			int[][] cost = new int[size.y+1][size.x+1];
			int m = sc.nextInt();
			Edge[] edge = new Edge[m];
			
			for(int i=0;i<m;i++){
				edge[i] = new Edge(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
			}
			
			Queue<Point> open = new LinkedList<Point>();
			open.add(new Point(0,0));
			cost[0][0] = 1;
			while(!open.isEmpty()){
				Point p = open.poll();
				Point rp = new Point(p.x+1, p.y);
				Point up = new Point(p.x, p.y+1);
				if(rp.x >= 0 && rp.x <= size.x){
					int i=0;
					for(;i<m;i++) if(edge[i].s.equals(p) && edge[i].t.equals(rp)) break;
					if(i == m){
						cost[rp.y][rp.x] += cost[p.y][p.x];
						if(!open.contains(rp)) open.add(rp);
					}
				}
				if(up.y >= 0 && up.y <= size.y){
					int i=0;
					for(;i<m;i++) if(edge[i].s.equals(p) && edge[i].t.equals(up)) break;
					if(i == m){
						cost[up.y][up.x] += cost[p.y][p.x];
						if(!open.contains(up)) open.add(up);
					}					
				}
			}
			System.out.println(cost[size.y][size.x]==0 ? "Miserable Hokusai!" : cost[size.y][size.x]);
		}
	}
}

class Edge{
	Point s,t;
	
	Edge(int x1,int y1,int x2,int y2){
		if(x1 <= x2 && y1 <= y2){
			s = new Point(x1,y1);
			t = new Point(x2,y2);
		}
		else{
			t = new Point(x1,y1);
			s = new Point(x2,y2);
		}
	}
}

Measured memory_bytes: 12000
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int n; 

int main(){

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int T;
 //    cin >> T;
 
 //    while (T--) {
        
 //    }

	cin>>n;
	vector<int> a(n);
	
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	ll ans = a[0];
	int cntr = 2;

	for(int i = 1; cntr < n && i < n; i++) {
		ans += a[i];
		cntr++;
		if(cntr == n) break;
		ans += a[i];
		cntr++;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 4048
import java.util.Scanner;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
      int K = in.nextInt();
      int A = in.nextInt();
      int B = in.nextInt();
     
       if ((B/K - A/K >=1)||(B%K==0)||(A%K==0))
            System.out.println("OK");
       else
            System.out.println("NG");
    }
}

Measured memory_bytes: 35720
#include <bits/stdc++.h>
//#pragma GCC diagnostic warning "-std=c++11"
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define MAX ((ll)(1e18+100))
#define MX ((ll)(1e6+90))
#define ARRS ((ll)(1e5+100))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define EPS ((double)(1e-8))
#define pb push_back
#define PI ((double)3.141592653)
#define LG 16

ll n,m;
ll a[ARRS];
ll pas[ARRS];

int main(){
	cin>>n;
	for(int i=0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);
	pair<ll,ll> pas={MAX,-1};
	for(int i=0; i<n-1; i++){
		pas=min(pas,{abs(a[i]-(a[n-1]+1)/2),a[i]});
	}
	cout<<a[n-1]<<" "<<pas.sc;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int A,B,C,D;
	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	vector<int> given;

	cin >> A >> B >> C >> D;

	while(1){
		A-=D;
		C-=B;

		if(C<=0){
			cout << "Yes" << endl;
			return 0;
		}

		if(A<=0){
			cout << "No" << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
int main()
{
    string s;cin>>s;
    bool yes = true;
    for(int i = 0;s[i] != '\0';i++)
    {
        if(i % 2 == 0)
        {
            if(s[i] == 'L')
                yes = false;
        }
        else
        {
            if(s[i] == 'R')
                yes = false;
        }
    }
    Yes(yes);
}

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

int main()
{
    int x ,y, z= 0;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;

    return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int m;
    cin >> m;
    cout << 48 - m << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int64
	fmt.Scanf("%d %d", &n, &m)
	as := scanInts(n)
	bs := make([]int64, n)
	for i, a := range as {
		bs[i] = a / 2
	}
	l := slice_lcm(bs)
	for _, b := range bs {
		if l/b%2 != 1 {
			l = m + 1
		}
	}
	muls := m / l
	fmt.Println((muls + 1) / 2)
}

func scanInts(length int64) []int64 {
	ints := make([]int64, length)
	for i := range iter(0, length) {
		var x int64
		_, _ = fmt.Scan(&x)
		ints[i] = x
	}
	return ints
}

func iter(l int64, r int64) chan int64 {
	var i int64 = l
	c := make(chan int64)
	run := func() {
		for i < r {
			c <- i
			i += 1
		}
		close(c)
	}
	go run()
	return c
}

func gcd(a int64, b int64) int64 {
	x, y := a, b
	for true {
		if x%y == 0 {
			break
		}
		x, y = y, x%y
	}
	return y
}

func slice_gcd(ints []int64) int64 {
	if len(ints) == 0 {
		return 1
	}
	ans := ints[0]
	for i := range iter(1, int64(len(ints))) {
		ans = gcd(ans, ints[i])
	}
	return ans
}

func lcm(a int64, b int64) int64 {
	g := gcd(a, b)
	return a * b / g
}

func slice_lcm(ints []int64) int64 {
	if len(ints) == 0 {
		return 1
	}
	ans := ints[0]
	for i := range iter(1, int64(len(ints))) {
		ans = lcm(ans, ints[i])
	}
	return ans
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  vector<ll>vec(a);
  vector<ll>veco(a);
  cin>>vec.at(0);
  veco.at(0)=vec.at(0);
  for(ll i=1;i<a;i++){
    cin>>vec.at(i);
    veco.at(i)=min(veco.at(i-1),vec.at(i));
  }
  ll c=0;
  for(ll i=0;i<a;i++){
    if(vec.at(i)==veco.at(i)){
      c+=1;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 100000000000000;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

static const int N=16;
static const int W=10010;
int dp[N+1][N+1];
int ob[N+1][N+1];

int main(){
    int a,b;
    int n;
    int x,y;
    while(cin>>a>>b,a!=0||b!=0){
        for(int i=0;i<=a;i++){
            for(int j=0;j<=b;j++){
                dp[i][j]=0;
                ob[i][j]=true;
            }
        }
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>x>>y;
            ob[x][y]=false;
        }
        for(int i=1;i<=a;i++){
            for(int j=1;j<=b;j++){
                if(!ob[i][j]){
                    continue;
                }
                if(i==1&&j==1){
                    dp[i][j]=1;
                }
                else if(i==0){
                    dp[i][j]=dp[i][j-1];
                }
                else if(j==0){
                    dp[i][j]=dp[i-1][j];
                }else{
                    dp[i][j]=dp[i-1][j]+dp[i][j-1];
                }
            }
        }
        cout<<dp[a][b]<<endl;
    }
  return 0;
}



Measured memory_bytes: 3036
program Project1;
             
{$APPTYPE CONSOLE}
         
uses
  SysUtils,math;
var
  fx,g,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t,z:Integer;
  //l:array of Integer;
  l,l1,l2:int64;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
  xc,yc,space:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);
    fx:=0;

    for i := 1 to Length(s) do
      fx:=fx+StrToInt(s[i]);

    if StrToInt(s) mod fx =0 then
      Writeln('Yes')
    else
      Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#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()
const int INF = 1<<29;

int main() {
  string s;
  while(getline(cin,s)) {
    if (s == "") break;
    string t;
    while(getline(cin,t), t!="")
      s+=t;
    string key;
    while(getline(cin,t)) {
      if (t=="") break;
      key+=t;
    }
    // cout << "hoge" << endl;
    // cout << s << " " << key << endl;

    set<char> se;
    map<char, int> mp;
    FOR(it, key) {
      se.insert(*it);
      mp[*it] = -1;
    }

    int num = 0;
    string res;
    REP(i,s.size()) {
      if (se.count(s[i])) {
        mp[s[i]] = i;
        bool f = 1;
        int pos = INF;
        FOR(it, mp) {
          if (it->second < 0) f = 0;
          pos = min(pos, it->second);
        }
        if (f) {
          if (res == "" || i-pos+1 < res.size()) {
            num = 1;
//            cout << ";"<<pos<<" "<<s.size() << endl;
            res = s.substr(pos, i-pos+1);
          } else if (i-pos+1 == res.size())
            num++;
        }
      }
    }
    cout << num << endl << endl;;
    if (num) {
      for (int i=0; i<res.size(); i+=72) {
//        cout << min((int)s.size()-i,72) << endl;
        cout << res.substr(i, min((int)res.size()-i,72)) << endl;;
      }
      cout << endl;
    }
  }
}

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

// <editor-fold>

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
// vector出力
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}
// 任意の個数の変数をスペース区切りで出力します
void dump() {
  cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) != 0)
    cout << " ";
  dump(std::move(tail)...);
}
#define YES(n) printf("%s\n", ((n) ? "YES" : "NO"));
#define Yes(n) printf("%s\n", ((n) ? "Yes" : "No"));
#define yes(n) printf("%s\n", ((n) ? "yes" : "no"));
// </editor-fold>

// ===============================================

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a * c <= b) {
    cout << c << endl;
  } else {
    cout << b / a << endl;
  }
}


Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
const int maxn=55;
int n,m;
vector<long long> x,y;
long long ax[maxn],ay[maxn];
int main(){
	int i,j,k,l,t;
	long long lx,ly,rx,ry;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&ax[i],&ay[i]);
		x.push_back(ax[i]);
		y.push_back(ay[i]);
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	long long ans=1LL*(x[n-1]-x[0])*(y[n-1]-y[0]);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			for(k=0;k<n;k++){
				for(l=k+1;l<n;l++){
					lx=x[i],rx=x[j];
					ry=y[l],ly=y[k];
					int num=0;
					for(t=0;t<n;t++){
						if(ax[t]>=lx&&ax[t]<=rx&&ay[t]>=ly&&ay[t]<=ry)
							num++;
					}
					if(num>=m)ans=min(ans,1LL*(rx-lx)*(ry-ly));
				}
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
	ll mod=1e9+7;
	ll n,m;
	cin>>n>>m;
	ll a[m];
	rep(i,0,m)cin>>a[i];

	ll dp[n+1]={0};
	dp[0]=1;
	ll x=0;
	if(a[0]!=1)dp[1]=1;
	else x++;
	rep(i,2,n+1){
		if(i!=a[x])dp[i]=(dp[i-1]+dp[i-2])%mod;
		else x++;
	}
	cout<<dp[n];
}

Measured memory_bytes: 1792
# import sys
# input = sys.stdin.readline  #これを入れるとlen(l)が実際よりも1大きくなってしまう
l = input()
mod = 10**9 + 7
n = len(l)

M2 = [1]
M3 = [1]
for i in range(1, 10**5 + 2):
    M2.append(M2[-1] * 2 % mod)
    M3.append(M3[-1] * 3 % mod)

ans = 0
m2 = 0
m3 = len(l)
# print(m3)
for i in range(n):
    m3 -= 1
    if l[i] == "1":
        ans = (ans + M2[m2] * M3[m3]) % mod
        # print(m2,m3)
        m2 += 1
ans = (ans + M2[m2] * M3[m3]) % mod
# print(m2,m3)
print(ans)

Measured memory_bytes: 51952
N = int(input())
not_N = N+1
N = N/1.08
not_N = not_N/1.08
cand1 = int(N)
cand2 = int(not_N)+1
flag = True
for one in range(cand1, cand2+1):
    if one>=N and one<not_N:
        print(one)
        flag=False
        break
if flag:
    print(':(')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define endl '\n'
#define pii pair<int,int>
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define fill(a,b) memset(a,b,sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,x,y; cin>>n>>x>>y;
    int arr[n]={0};
    for(int i=1;i<n;i++){
        for(int j=i+1;j<=n;j++){
            int dis=j-i;
            if(i<=x && j>=y) dis=x-i+j-y+1;
            else if(i>=x && j<=y) dis=min(dis,i-x+y-j+1);
            else if(i>=x && i<=y) dis=min(dis,j-y+i-x+1);
            else if(j>=x && j<=y) dis=min(dis,y-j+x-i+1);
            arr[dis]++;
        }
    }
    for(int i=1;i<n;i++) cout<<arr[i]<<endl;
}

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

#define MAX 20
#define rep(i, n) for ( int i = 0; i < (int)n; i++)
#define INFTY (1<<21)

int M[MAX][MAX], n;
bool used[MAX];
int id[MAX], pos[MAX], ans;

int md(){
    int m = 0;
    rep(i, n){
	if ( used[i] ) continue;
	for ( int j = i+1; j < n; j++ ){
	    if ( used[j] ) continue;
	    if ( i == j ) continue;
	    m = max(m, M[i][j]);
	}
    }
    return m;
}

void rec( int cur, int w ){
    if ( cur == n ){ ans = min(ans, w); return;}
    if ( w + md() >= ans ) return;

    rep(i, n){
	if ( used[i] ) continue;
	int npos = w;
	rep(j, cur){ 
	    npos = max(npos, pos[j] + M[id[j]][i]);
	}
	pos[cur] = npos;
	id[cur] = i;
	used[i] = true;	
	rec( cur+1, npos);
	used[i] = false;
    }
}

main(){
    while( cin >> n && n ){
	rep(i, n) rep(j, n) cin >> M[i][j];
	rep(i, n) rep(j, n) M[i][j] = max( M[i][j], M[j][i] );
	rep(i, n) used[i] = false;
	ans = INFTY;
	rec(0, 0);
	cout << ans << endl;
    }
}

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

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


Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int a[n];
    rep (i,n) cin >> a[i];

    int maxSpace = a[0] + k - a[n-1];

    rep (i,n) {
        if (i == 0) continue;

        int diff = a[i] - a[i-1];
        if (maxSpace < diff) {
            maxSpace = diff;
        }
    }

    cout << (k - maxSpace) << endl;
    
    return 0;
}

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

int main(){
    int N;  cin >> N;
    int even = 0,  odd = 0;
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        if(a%2==0) even++;
        else odd++;
    }

    if(odd%2 == 0 || N == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


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

typedef pair<int,int> ii;
int n,a[100005];
vector<int> V0,V1;
vector<ii> V;

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("TEST.INP","r",stdin);
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    V.push_back(ii(a[1],1));
    for(int i=2; i<=n; i++)
        if(a[i]!=a[i-1])
            V.push_back(ii(a[i],1));
        else
            V.back().second++;
    if(V.size()==1)
    {
        if(V[0].first==n-1||n%V[0].first==0)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else if(V.size()==2)
    {
        if(V[1].first>V[0].second&&V[1].second%(V[1].first-V[0].second)==0&&V[0].first==V[0].second+(V[1].first-V[0].second)-1)
            cout<<"Yes";
        else
            cout<<"No";
    }
    else
        cout<<"No\n";
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

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

    int n;cin>>n;
    ll res;
    vector<ll> t(n);
    for(int i=0;i<n;i++){
        cin>>t[i];
        if(i==0) res=t[i];
        else{
            ll g = gcd(res,t[i]);
            res= res / g * t[i];
        }
    }
    cout<<res<<endl;
}


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

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

int main(){
    int a, b, k;    cin >> a >> b >> k;
    vector<ll>  v;
    for(int i=1; i<=100; i++){
        if(a%i==0 && b%i==0)
            v.push_back(i);
        
    }
    sort(v.begin(), v.end(), greater<ll>());
    cout << v.at(k-1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
using namespace std;
#define REP(m,n) for(int i=m;i<n;++i)
#define REPj(m,n) for(int j=m;j<n;++j)
#define ll long long
#define mp make_pair

int main() {
	int n;
	cin >> n;
	if (n / 100 == n % 10) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
// 入力
$s = trim(fgets(STDIN));

$n = strlen($s);

// 答え出力用配列に0格納
$ans = array_fill(0, $n, 0);

// 計算
$top = 0;
while($top < $n) {
    if ($s[$top] === 'R') $next = 'L';
    else $next = 'R';

    $next_top = strpos($s, $next, $top);
    if (!$next_top) $next_top = $n;

    $cnt = $next_top - $top;

    if ($s[$top] === 'R') {
        $x0 = $top + $cnt - 1;
        $x1 = $x0 + 1;
    } else {
        $x0 = $top;
        $x1 = $x0 - 1;
    }
    $ans[$x0] += ceil($cnt / 2);
    $ans[$x1] += floor($cnt / 2);

    $top = $next_top;
}

// 出力
echo implode(' ', $ans).PHP_EOL;

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

int main() {
    int n,x,t;
    cin >> n >> x >> t;
    int ans=0;
    if(n%x!=0){
        ans = (n/x +1)*t;
    } else {
        ans = (n/x)*t;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
N, T = list(map(int, input().split()))

ct = [list(map(int, input().split())) for _ in range(N)]

minc = 9999

for i in range(N):
    if T >= ct[i][1] and minc >= ct[i][0]:
        minc = ct[i][0]

print(minc if minc != 9999 else 'TLE')


Measured memory_bytes: 3060
def remainder_reminder(N: int, K: int) -> int:
    if K == 0:
        return N * N

    count = 0
    for b in range(K + 1, N + 1):
        p, r = N // b, N % b
        count += p * max(0, b - K) + max(0, r - K + 1)
    return count


if __name__ == "__main__":
    N, K = map(int, input().split())
    ans = remainder_reminder(N, K)
    print(ans)


Measured memory_bytes: 2940
INF=10**20

N,K=map(int,input().split())

array=list(map(int,input().split()))
P=[]
C=list(map(int,input().split()))
for i in array:
    P.append(i-1)

ans=-1*INF

for i in range(N):
    v=i
    cycle_sum=0
    cycle_cnt=0

    while(True):
        cycle_cnt+=1
        cycle_sum+=C[v]
        v=P[v]
        if v==i:
            break

    path=0
    cnt=0

    while(True):
        cnt+=1
        path+=C[v]

        if cnt>K:
            break

        num=(K-cnt)//cycle_cnt
        score=path+max(0,cycle_sum)*num
        ans=max(ans,score)

        v=P[v]
        if v==i:
            break

print(ans)

Measured memory_bytes: 74220
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char buf[310];
int n,k;
int mx[310][310][310];
int ans;
int main()
{
	scanf("%s%d",buf,&k);
	n=strlen(buf);
	ans=1;
	for(int l=1;l<=n;l++)
	{
		for(int i=0;i+l-1<n;i++)
		{
			int j=i+l-1;
			if(l==1)mx[i][j][0]=1;
			else
			{
				for(int t=0;t<=k;t++)
				{
					mx[i][j][t]=max(mx[i+1][j][t],mx[i][j-1][t]);
					if(buf[i]==buf[j])
					{
						mx[i][j][t]=max(mx[i][j][t],mx[i+1][j-1][t]+2);
					}
					else
					{
						if(t)mx[i][j][t]=max(mx[i][j][t],mx[i+1][j-1][t-1]+2);
					}
					ans=max(ans,mx[i][j][t]);
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 112768
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
vector<int> G[100000],euler;
const int p2=262144;
int in[100000],out[100000],n,q;
int seg[p2*2-1];
void dfs(int v){
	in[v]=euler.size();
	euler.push_back(v);
	rep(i,G[v].size()) dfs(G[v][i]);
	out[v]=euler.size();
	euler.push_back(v);
}
bool anc(int x,int y){
	return in[x]<in[y]&&out[x]>out[y];
}
void change(int a,int b,int c,int l,int r,int k){
	if(b<=l||r<=a) return;
	if(a<=l&&r<=b){
		if(seg[k]==-1||anc(seg[k],c) ) seg[k]=c;
		return;
	}
	change(a,b,c,l,(l+r)/2,k*2+1);
	change(a,b,c,(l+r)/2,r,k*2+2);
}
int main(){
	while(true){
		cin >> n >> q;
		if(n==0) break;
		euler.clear();
		rep(i,n) G[i].clear();
		rep(i,p2*2-1) seg[i]=-1;
		rep(i,n-1){
			int p;
			cin >> p;
			G[p-1].push_back(i+1);
		}
		dfs(0);
		long long ans=0;
		change(in[0],out[0]+1,0,0,p2,0);
		rep(i,q){
			char c;
			int v;
			cin >> c >> v;
			v--;
			if(c=='M'){
				change(in[v],out[v]+1,v,0,p2,0);
			}else{
				int x=p2-1+in[v],ret=0;
				while(true){
					if(seg[x]!=-1 && anc(ret,seg[x])) ret=seg[x];
					if(x==0) break;
					x=(x-1)/2;
				}
				ans+=(ret+1);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 14128
//前置き
#pragma region

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

#pragma endregion

//関数定義
#pragma region 
//偶数 ->　true :: 奇数　-> false
bool EVEN(ll a){
    return a%2-1;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}  

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

#pragma endregion

int main(){
    int n, d;
    cin >> n >> d;
    int a[n + 1][d + 1];
    REP(i , n){
        REP(j, d){
            cin >> a[i][j];
        }
    }

    int ans = 0;
    REP(i, n-1){
        FOR(j , i + 1, n){
            int sum = 0;
            double dis;
            REP(k, d){
                sum += pow(abs(a[i][k] - a[j][k]), 2);
            }
            dis = sqrt(sum);
            if(ceil(dis) == floor(dis)) ans++; 
        }
    }

    cout << ans << endl;
}




Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	d := 0
	c := 1
	var l int
	for i := 0; i < N; i++ {
		fmt.Scan(&l)
		d += l
		if d > X {
			break
		}
		c++
	}
	fmt.Println(c)
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  double n;
  cin >> n;
  
  vector<double> x(n), y(n);
  for(int i = 0; i < n; i++) cin >> x.at(i) >> y.at(i);
  
  double ans = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      ans += sqrt(pow((x.at(i) - x.at(j)), 2) + pow((y.at(i) - y.at(j)), 2));
    }
  }
  
  ans = ans * 2 / n;
  cout << fixed << setprecision(10) << ans << "\n";
}

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

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

    int b[n];
    int p = 0;
    int flag = 0;
    int left = 0;
    int right = n - 1;
    for (int i = n - 1; i >= 0; i--) {
        if (flag == 0) {
            b[left++] = a[i];
            flag = 1;
        } else {
            b[right--] = a[i];
            flag = 0;
        }
    }

    cout << b[0];
    for (int i = 1; i < n; i++) {
        cout << " " << b[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define mod 1000000007
#define inf 999999999999999ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,W;
    cin>>n>>W;
    vi val(n),w(n);
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>val[i];
        sum+=val[i];
    }
    vi dp(sum+1,inf);
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=sum;j>=0;j--)
        {
            if(j>=val[i])
                dp[j]=min(dp[j],dp[j-val[i]]+w[i]);
        }
    }
    ll ma=0;
    for(ll i=0;i<=sum;i++)
    {
        if(dp[i]<=W)
        {
            ma=i;
        }
    }
    cout<<ma<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(void){
  int R[MAX],n;
  int maxv=-2000000000;
  int minv;
  

  cin>>n;

  for(int i=0;i<n;i++) cin>>R[i];
  minv=R[0];

  for(int i=1;i<n;i++){
    maxv=max(maxv,R[i]-minv);
    minv=min(minv,R[i]);
  }
  cout<<maxv<<endl;

  return 0;
}

Measured memory_bytes: 3860
import java.util.Scanner;
                                                                             
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        int h = num / 3600, m, s;
   
        num %= 3600;
        m = num/60;
        num %= 60;
        s = num;
  
        System.out.println(h + ":" + m + ":" + s);
    }
}

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

int main(){
	int a, b, c, d = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	for (int i = 0; i < b - a + 1;){
		if (c % (a + i) == 0){
			d++;
		}
		i++;
	}
	cout << d << endl;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define N 1000000

typedef long long int Int;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


bool is_prime[N+1];
vector < Int > sieve(  )
{
    Int i,j;
    
    vector < Int > prime;
    for(i=0; i<=N; i++) is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    
    for(i=2 ;i*i<=N; i++)
    {
        if (is_prime[i] == true)
        {
            for(j= i*i; j<=N; j+=i )  is_prime[j] = false;   
        }
    }
    
    for(i=0; i<=N; i++)
    {
        if (is_prime[i] == true) prime.push_back(i);
    }
    return prime;
}

int main()
{
    faster();
    vector <Int > prime = sieve();
    
    Int n;
    cin>>n;
    
    Int i,j;
    
    for(i=0; i<prime.size(); i++ )
    {
        if ( prime[i] >= n ) { j = prime[i]; break; }
    }
    
    cout<<j;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
// int N が既に与えられているとする. 

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

    vector<string> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());

    int count = 1;

    for (int i = 1; i < N; i++) {
        if(vec.at(i-1).compare(vec.at(i)) != 0){
            count++;
        }
    }

    cout << count << endl;
    
}

Measured memory_bytes: 9600
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll pdiv = 1000000007LL;

// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    // dp[i][j] := 子供 i+1 まで配って、j個残るときの配り方
    vector<vector<ll>> dp(n, vector<ll>(k+1, 0));
    REP(i, n) {
        if (!i) {
            RANGE(j, k-a[i], k) {
                dp[i][j] = 1;
            }
        } else {
            RANGE(j, 0, k) {
                (dp[i][j] += dp[i-1][j]) %= pdiv;
                if (j-a[i]-1 >= 0) {
                    (dp[i][j-a[i]-1] += pdiv - dp[i-1][j]) %= pdiv;
                }
            }
            DSRNG(j, k-1, 0) (dp[i][j] += dp[i][j+1]) %= pdiv;
        }
    }

    cout << dp[n-1][0] << endl;
    
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int func(int x) {
  if (x % 100 != 0) return 0;
  return func(x/100)+1;
}

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

  int d, n; std::cin >> d >> n;
  int cnt = 0;
  for (int x = 1; ; x++) {
    if (func(x) == d) {
      cnt++;
      if (cnt == n) {
        std::cout << x << "\n";
        return 0;
      }
    }
  }
}


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

int main(){
  int64_t A, B, C, a, b, c, count = 0;
  cin >> A >> B >> C;
  
  if (A == B && B == C && A % 2 == 0){
    cout << -1 << endl;
  }
  else{
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
      a = A / 2;
      b = B / 2;
      c = C / 2;
      
      A = b + c;
      B = c + a;
      C = a + b;
      count += 1;
    }
    cout << count << endl;
  }
}

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

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

    vector<bool> checked(N + 1, false);

    int ai = 1;
    for (int i = M; i > 0; i -= 2)
    {
        printf("%d %d\n", ai, ai + i);
        ai++;
    }

    ai = N;
    for (int i = M - 1; i > 0; i -= 2)
    {
        printf("%d %d\n", ai, ai - i);
        ai--;
    }
}

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

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long int ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;

int calc_pw(ll n, ll p){
    if(n/p==0){
        return 0;
    }else{
        return calc_pw(n/p,p)+1;
    }
}


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s,w;
    cin >> s >> w;
    if(s>w){
        cout << "safe" << "\n";
    }else{
        cout << "unsafe" << "\n";
    }
}   




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

int main() {
  int n; cin >> n;
  int a, b; cin >> a >> b;
  int ans = 0;
  for (int i=1; i<=n; ++i) {
    int num = i;
    int sum = 0;
    while (num) {
      sum += num % 10;
      num /= 10;
    }
    if (a <= sum && sum <= b) ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxn 1000+10

int top, S[maxn];

void push (int x) {
	S[++top] = x;
}

int pop () {
	top--;
	return S[top+1];
}

int main() {
	int a, b;
	top = 0;
	char s[maxn];
	while( scanf("%s", s) != EOF ) {
		if ( s[0] == '+' ) {
			a = pop();
			b = pop();
			push(a + b); 
		}
		else if ( s[0] == '-') {
			b = pop();
			a = pop();
			push(a -b);
		}
		else if ( s[0] == '*') {
			b = pop();
			a = pop();
			push(a*b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}


Measured memory_bytes: 2748
s = input()
t = ''
for i in range(len(s)):
    if s[i] == '0':
        t = t + '0'
    elif s[i] == '1':
        t = t + '1'
    elif s[i] == 'B' and len(t) != 0:
        t = t[0:len(t)-1]
print(t)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

int main(){
	string s;
	cin>>s;
	
	long long int ans=0;
	long long int sum;
	
	for(int i=0;i<1<<s.size()-1;i++){
		sum=s[0]-'0';
		for(int j=0;j<s.size()-1;j++){
			if(i&(1<<j)){
				ans+=sum;
				sum=0;
			}
			sum=sum*10+(s[j+1]-'0');
		}
		ans+=sum;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
let () =
  let a = Array.make 101 0 in
  try
    while true do
      let n = read_int () in
      a.(n) <- a.(n) + 1
    done
  with _ ->
    let m = Array.fold_left (fun v e -> max v e) 0 a in
    Array.iteri (fun i e -> if e = m then Printf.printf "%d\n" i) a

Measured memory_bytes: 2280
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;

int main() {
    long long H, W, N;
    cin >> H;
    cin >> W;
    cin >> N;
    long long res = 0;
    long long paint = 0;
    do {
        if (H > W) {
            paint += H;
            W--;
        } else {
            paint += W;
            H--;
        }
        res ++;
    } while (paint < N);
    cout << res << endl;

    return 0;
}

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

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

/*
 
 3/16/2019
 
 11:11-
 
 */

int H,W,h,w;

void solve() {
  cout<<(H-h)*(W-w)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>H>>W>>h>>w;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#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; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n;
    cin>>n;
    vector<vector<int>> table(10,vector<int>(10,0));
    rep(i,1,n+1){
        string s=to_string(i);
        int max_digit =s[0]-'0';
        int min_digit =s[s.size()-1]-'0';
        table[max_digit][min_digit]++;
    }
    ll ans=0;
    rep(i,0,10){
        rep(j,0,10){
            ans+=table[i][j]*table[j][i];
        }
    }
    cout<<ans<<endl;
}

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

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

  int abc[100010][3];
  for (int i=0; i<n; i++) {
    for (int j=0; j<3; j++) {
      scanf("%d",&abc[i][j]);
    }
  }
  int dp[100010][3];
  for (int i=0; i<3; i++) {
    dp[0][i]=abc[0][i];
  }
  for (int i=1; i<n; i++) {
    for (int j=0; j<3; j++) {
      dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+abc[i][j];
    }
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
  return 0;
}

Measured memory_bytes: 2560
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int A1,A2,A3;
    cin >> A1 >> A2 >>A3;
    if( A1+A2+A3 >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

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

int main(){
  int N;
  cin >> N;
  set<int> s;
  vector<int> v;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    if (!s.count(x)){
      s.insert(x);
    }
    else {
      v.push_back(x);
      s.erase(x);
    }
  }
  sort(v.begin(),v.end());
  int l=v.size();
  if (l>=2){
    cout << (long long)v[l-1]*v[l-2] << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    ll A[N], ans = 0;
    rep(i, N) cin >> A[i];
    rep(i, N){
        ans += A[i]/2, A[i] %= 2;
        if(i+1 < N && A[i] && A[i+1]){
            ans++;
            A[i]--, A[i+1]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main (void){

int n,i;

int a[10000];

int max,min;

long int totall=0;

scanf("%d",&n);

for(i=0;i<n;i++){

scanf("%d",&a[i]);

}

max=min=a[0];

for(i=0;i<n;i++){

if(max<a[i]){

max=a[i];

}

if(min>a[i]){

min=a[i];

}

totall+=a[i];

}

printf("%d %d %ld\n",min,max,totall);

return 0;

}

Measured memory_bytes: 636
import itertools
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
rieki = []
rieki = [v[i] - c[i] for i in range(0,n)]
rieki2 = [i for i in rieki if (i>0)]
rieki3=sum(rieki2)
print(rieki3)

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	# a_ext = {}
	b_sum_ext = {}
	b_ext = []
	# ai + aj = (j+1) - (i+1)
	# ai + i + 1 = -aj + j + 1

	for i, ai in enumerate(a):
		# a_ext[a[i] + i + 1] = 1
		log.print(a[i]+i+1, -a[i]+i+1)
		b_sum_ext[-a[i]+i+1] = b_sum_ext.get(-a[i]+i+1, 0)+1
	cnt = 0
	log.print(cnt)
	cnt = 0
	for i, ai in enumerate(a):
		b_sum_ext[-a[i]+i+1] = b_sum_ext.get(-a[i]+i+1, 0)-1
		if b_sum_ext.get(a[i] + i + 1, 0) != 0:
			log.print(i+1, a[i] + i + 1)
			cnt += b_sum_ext.get(a[i] + i + 1, 0)
	print(cnt)

	


main()

Measured memory_bytes: 112208
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()) {
			String s=sc.next();
			int JOI=0;
			int IOI=0;
			for(int i=0; i<s.length()-2; i++) {
				if(s.substring(i, i+3).equals("IOI")) {
					IOI++;
				}
				else if(s.substring(i, i+3).equals("JOI")) {
					JOI++;
				}
			}
			pl(JOI);
			pl(IOI);
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 28196