akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct unionfind{
	vector<int> data;
	void use(int n){ data.assign(n, -1); }
	void reset(void){ data.clear(); }
	bool unionset(int x, int y){
		x = root(x); y = root(y);
		if(x != y){
			if(data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y){ return root(x) == root(y); }
	int root(int x){ return (data[x] < 0) ? x : data[x] = root(data[x]); }
	int size(int x){ return -data[root(x)]; }
};

vector<int> G[500];
unionfind Uf;
int stk[500], hd = 0;

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    if(!(n | m))break;
    Uf.use(n);
    rep(i, m){
      int2(a, b);
      --a; --b;
      G[a].pb(b);
      G[b].pb(a);
      if(a * b == 0){
        stk[hd++] = max(a, b);
        Uf.unionset(a, b);
      }
    }

    rep(i, hd){
      rep(j, G[stk[i]].size())Uf.unionset(stk[i], G[stk[i]][j]);
    }

    pri(Uf.size(0) - 1);
    /*rep(i, n)if(Uf.findset(0, i))printf("%d ", i + 1);
    puts("");*/

//*/
    rep(i, n)G[i].clear();
    hd = 0;
    Uf.reset();

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3252
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
    myout("Bad");
  }else{
    myout("Good");
  }
}


Measured memory_bytes: 29952
l=input()
mod=10**9+7
dp0=[0]*(len(l)+1)
dp1=[0]*(len(l)+1)
dp0[0]=1
for i in range(len(l)):
	if l[i]=="1":
		dp0[i+1]=dp0[i]*2%mod
		dp1[i+1]=(dp0[i]+dp1[i]*3)%mod
	else:
		dp0[i+1]=dp0[i]
		dp1[i+1]=dp1[i]*3%mod
print((dp0[-1]+dp1[-1])%mod)

Measured memory_bytes: 11032
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn gcd(x: i32, y: i32) -> i32 {
    if y == 0 {
        x
    } else {
        gcd(y, x % y)
    }
}

fn f(p: i32, q: i32) -> (i32, i32) {
    if q == 1 {
        (0, 1)
    } else {
        let r = p / q;
        let s = p % q;
        let (z, w) = f(q, s);
        let x = w;
        let y = z - r * w;
        (x, y)
    }
}

fn main() {
    let ab: Vec<i32> = read_vec();
    let a = ab[0];
    let b = ab[1];
    let g = gcd(a, b);
    let c = a / g;
    let d = b / g;
    let (x, y) = f(c, d);
    println!("{} {}", x, y);
}



Measured memory_bytes: 5036
#include<iostream>
using namespace std;
int main()
{
  int N,D,X;
  cin>>N>>D>>X;
  int i;
  int A[N];
  for(i=0;i<N;i++)
  {
    cin>>A[i];
  }
  int ans=0;
  for(i=0;i<N;i++)
  {
    ans=ans+(D-1)/A[i];
  }
  cout<<ans+N+X<<endl;
  return 0;
}


Measured memory_bytes: 256
K = int(input())
A = [list(range(1, 10))]
cnt = 0

while cnt < K * 2:
    B = []
    for a in A[-1]:
        r = a % 10
        a *= 10
        for i in range(max(0, r - 1), min(r + 2, 10)):
            B.append(a + i)
    cnt += len(B)
    A.append(B)

A = [a for B in A for a in B]
A.sort()
print(A[K - 1])


Measured memory_bytes: 44648
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <set>
#include <map>
#define SIZE 30
#define MX 10005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];
int cnt[SIZE];
int dp[MX];

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%s",&str);
		int c=str[0]-'A';
		cnt[c]++;
	}
	int l=0,r=n+1;
	while(r-l>1)
	{
		int m=(l+r)/2;
		int mk=0,zan=0;
		for(int i=0;i<SIZE;i++)
		{
			if(cnt[i]>=m) mk++;
			else zan+=cnt[i];
		}
		if((k-mk)*m<=zan) l=m;
		else r=m;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int len = s.length();

		System.out.println(s.substring(0,1) + (len - 2) + s.substring(len - 1, len));


	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
ll a,b,c;
cin>>a>>b>>c;
ll ans=b*((a)/(b+c)),d;
d=(a%(c+b));
if(d<=b)ans+=d;
else ans+=b;
cout<<ans;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {

	int n;

	scanf("%d\n", &n);

	int a[100] = { 0 };

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

	for (int j = n; j > 0; j--) {
		if (j != 0 && j > 1) {
			printf("%d ", a[j - 1]);
		}
		else if (j == 1) {
			printf("%d\n", a[j - 1]);
		}
	}

	return 0;
}




Measured memory_bytes: 2036
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=105;
//i_am_noob
int n,m,k,x,cnt[30]={0},ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m;
	rep(n){
		cin >> k;
		rep1(j,k){
			cin >> x;
			cnt[x-1]++;
		}
	}
	rep(m) if(cnt[i]==n) ans++;
	print1(ans);
	return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

void func(long long n, std::vector<long long> d) {
    sort(all(d));
    int abc = d[d.size() / 2 - 1];
    int arc = d[d.size() / 2];
    if (arc == abc) {
        cout << 0 << endl;
    } else {
        cout << arc - abc << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    std::vector<long long> d(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &d[i]);
    }
    func(N, std::move(d));
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
W = input().split()
W = [int(i) for i in W]

min1 = 10**6
for i in range(N):
    ans = abs(sum(W[:i+1])-sum(W[i+1:]))
    if ans < min1:
        min1 = int(ans)
print(min1)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    string N;
    string N_r;
    cin >> N;
    
    N_r = N;
    reverse( N_r. begin(), N_r.end() );
    
    cout << (N == N_r ? "Yes" : "No" ) << endl;
    
    return 0;
}

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

int main() {
    string s; cin >> s;
    vector<char> ans(3);
    for (int bit = 0; bit < (1 << 3); bit++) {
        vector<char> vec(3);
        int val = s[0]-'0';
        for (int i = 0; i < 3; i++) {
            if (bit & (1 << i)) {
                vec[i] = '+';
                val += s[i+1]-'0';
            }
            else {
                vec[i] = '-';
                val -= s[i+1]-'0';
            }
        }
        if (val == 7) {
            ans = vec;
            break;
        }
    }

    for (int i = 0; i < 3; i++) {
        cout << s[i] << ans[i];
    }
    cout << s[3] << "=7" << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, t int
	fmt.Scan(&n, &t)
	foods := make([]Food, n)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		foods[i] = Food{a, b}
	}

	sort.Slice(foods, func(i, j int) bool {
		return foods[i].a < foods[j].a
	})

	dp := [3001][3001]int{}
	for i := 0; i < n; i++ {
		food := foods[i]
		for j := 0; j < t; j++ {
			dp[i+1][j] = max(dp[i+1][j], dp[i][j])

			nj := j + food.a
			if t <= nj {
				continue
			}
			dp[i+1][nj] = max(dp[i+1][nj], dp[i][j]+food.b)
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			ans = max(ans, dp[i+1][t-1]+foods[j].b)
		}
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// Food .
type Food struct {
	a, b int
}


Measured memory_bytes: 74812
// https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_f

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll t1, t2, a1, a2, b1, b2;

  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  ll c1 = a1 - b1;
  ll c2 = a2 - b2;

  ll diff = c1 * t1 + c2 * t2;

  if (diff == 0) drop("infinity");
  if (c1 > 0 && diff > 0 || c1 < 0 && diff < 0) drop(0);

  ll adiff = abs(diff);

  if (c1 < 0) {
    c1 *= -1;
    c2 *= -1;
    diff *= -1;
  }

  // c1 > 0 && c2 < 0 かつ diff < 0

  ll highest = c1 * t1;

  ll res = ((highest + adiff - 1) / adiff) * 2;

  if (highest % adiff == 0) {
    // 最後に 1 回だけ触れる
    res++;
  }

  // 最初の 1 回除く
  res--;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	VL t(n), a(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i] >> a[i];
	}
	LL anst = t[0], ansa = a[0];
	for (int i = 1; i < n; i++) {
		if (anst % t[i] != 0 or anst < t[i]) {
			anst += t[i] - (anst % t[i]);
		}
		if (ansa % a[i] != 0 or ansa < a[i]) {
			ansa += a[i] - (ansa % a[i]);
		}
		LL tdiv = anst / t[i];
		LL adiv = ansa / a[i];
		if (tdiv > adiv) {
			ansa = a[i] * tdiv;
		}
		else if (adiv > tdiv) {
			anst = t[i] * adiv;
		}
	}
	cout << anst + ansa << endl;
	return 0;
}


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

int main(int argc, const char * argv[]) {
    long long input;
    long long total = 0;
    
    cin >> input;
    
    while (input > 0) {
        if ((input % 3 == 0) || (input % 5 == 0)) {
            input--;
            continue;
        }else
            total += input;
        input--;
    }
    
    printf("%lld",total);
    
    return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<climits>
using namespace std;
int main(){
    int n;
    cin>>n;
    
    vector<int> v;
    for(int i = 0;i<n;i++){
        int x;
        cin>>x;
        v.push_back(x);
    }
    vector<int> dp(110000, INT_MAX);
    dp[0] = 0;
  	int K= 2;
    for(int i = 0;i<n;i++){
        for(int j = 1;j<=K && i+j<n;j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(v[i]-v[i+j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1144
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  1 22:14:11 2019

@author: Yamazaki Kenichi
"""


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

def dfs(c):
    return pow(pow(c[0],2)+pow(c[1],2),1/2)

Case = []
pn=[2];A=100
for L in range(3,A):
    for L2 in pn:
        if L % L2 == 0:
            break
    else:
        pn.append(L)
        if N % L != 0:
            Case.append(L)

ans = 0
res = 0
for i in range(N):
    now = [0,0]
    for j in range(i,i+N):
        j %= N
        tmp = [now[0]+xy[j][0],now[1]+ xy[j][1]]
        if dfs(tmp) > dfs(now):
            now = tmp
    if dfs(now) > res:
        res = dfs(now)
    for c in Case:
        now = [0,0]
        for j in range(i,i+N):
            j = (j*c)%N
            tmp = [now[0]+xy[j][0],now[1]+ xy[j][1]]
            if dfs(tmp) > dfs(now):
                now = tmp
        if dfs(now) > res:
            res = dfs(now)
print(res)

Measured memory_bytes: 46060
def calc_rev_polish(exp, stack)
  # puts "#{exp} #{stack}"

  if exp.empty?
    return stack.pop if stack.size == 1
    return nil
  end

  val = exp.shift
  return nil if val.nil?
  if val.class == Fixnum
    stack.push(val)
    return calc_rev_polish(exp, stack)
  end

  a = stack.pop
  b = stack.pop
  return nil if b.nil?
  if val == "+"
    stack.push(b+a)
  elsif val == "-"
    stack.push(b-a)
  else
    stack.push(b*a)
  end
  return calc_rev_polish(exp, stack)
    
end

def find_prev_term(exp, pos)
  par_count = 0
  pos.downto(0){|p|
    if p <= 0
      return p
    end

    if exp[p].class == Fixnum && par_count == 0
      return p
    end

    if exp[p] == ")"
      par_count += 1
    end

    if exp[p] == "("
      par_count -= 1
      if par_count == 0
        return p
      end
    end
  }

end

def rev2norm(rev)
  norm = []

  rev.each{|v|
    if v.class == Fixnum
      norm.push(v)
      next
    end

    pos1 = find_prev_term(norm, norm.size-1)
    norm.insert(pos1, v)

    pos2 = find_prev_term(norm, pos1-1)
    norm.insert(pos2, "(")
    norm.push(")")

    # p norm
  }
  return norm
end

ARGF.each{|line|
  break if line.chomp == "0 0 0 0"

  nums = line.chomp.split(/ /).map{|c| c.to_i}
  ops = " +-*".split(//)

  out = nil
  nums.permutation(4){|num_seq|
    ops.repeated_permutation(6){|ops_seq|
      exp = []
      exp << num_seq[0]
      exp << num_seq[1]
      exp << ops_seq[0]
      exp << num_seq[2]
      exp << ops_seq[1]
      exp << ops_seq[2]
      exp << num_seq[3]
      exp << ops_seq[3]
      exp << ops_seq[4]
      exp << ops_seq[5]

      # p exp
      exp.delete_if{|c| c == " "}
      exp2 = exp.dup
      if calc_rev_polish(exp, []) == 10
        out = exp2
        break
      end
    }
    break unless out.nil?
  }
  if out.nil?
    puts "0"
  else
    # p out
    puts rev2norm(out).join("")
  end
}
  

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n, ans; string A, B, S;
int main()
{
    cin>>S; for(int i = 0; i < S.size(); ++i) A += S[i], A != B?(B = A, A = "", ++ans):0;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3832
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
char in[100]={0};
while(cin>>in,in[0]-'0'){
int a=0,b=0;
loop(i,1,strlen(in)){
if(in[i]=='A')a++;
if(in[i]=='B')b++;
}
if(a>b)cout<<a+1<<" "<<b<<endl;
else cout<<a<<" "<<b+1<<endl;
}
}

Measured memory_bytes: 1140
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n;
ll a[N], sum;

int main() {
	ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> n;
	forn(i, 1, n) {
        cin >> a[i];
        sum += a[i];
	}

	sort(a + 1, a + n + 1);

	for1(i, n, 1) {
        sum -= a[i];
        if (a[i] > sum * 2) {
            cout << n - i + 1 << "\n";
            return 0;
        }
	}
    assert(0);

	return 0;
}


Measured memory_bytes: 1024
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------
int ca[1401][1401];
int sa[1401][1401];//记录第i行地第j个对应的个数
int h,w;
int ans=0;
void input(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>ca[i][j];
        }
    }
}//ok
void init(){
    for(int i=0;i<w;i++)
        sa[0][i]=ca[0][i] ? 0:1;
    for(int j=0;j<w;j++){
        for(int i=1;i<h;i++){
            sa[i][j]=ca[i][j] ? 0: sa[i-1][j]+1;
        }
    }
}//initiate
void calculate(){
    for(int i=0;i<h;i++){
        stack<int>tmp;
        int area=0,tp=-1,width=0;//area-面积 tp-top
        for(int j=0;j<w;j++)
        {
            int height=sa[i][j];
            while(!tmp.empty()&&sa[i][tmp.top()]>height){
                tp=tmp.top();tmp.pop();
                width=tmp.empty() ? j: j-tmp.top()-1;//rectangle*width
                area=sa[i][tp]*width;
                chmax(ans,area);
            }
            tmp.push(j);
        }
        int maxwidth=w;
        while(!tmp.empty()){
            tp=tmp.top();tmp.pop();
            width=tmp.empty() ? maxwidth: maxwidth-tmp.top()-1;
            area=sa[i][tp]*width;
            chmax(ans,area);
        }
    }
}
void output(){
    cout<<ans<<endl;
}//ok
//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    input();
    init();
    calculate();
    output();
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 18496
#include<stdio.h>
#include<math.h>
int main() {
  int i, n;
  double x1, y1, x2, y2, x3, y3, x, y, a, b, c, d, e, f;
  scanf("%d", &n);
  for (i = 0; i < n; i ++) {
    scanf("%lg %lg %lg %lg %lg %lg", &x1, &y1, &x2, &y2, &x3, &y3);
    x2 -= x1; y2 -= y1; x3 -= x1; y3 -= y1;
    a = x2; b = y2; c = x2 / 2 * x2 + y2 / 2 * y2; d = x3; e = y3; f = x3 / 2 * x3 + y3 / 2 * y3;
    x = (c * e - b * f) / (a * e - b * d); y = (c * d - a * f) / (b * d - a * e);
    if (-0.0005 < x && x < 0.0005) x = 0; if (-0.0005 < y && y < 0.0005) y = 0;
    printf("%.3f %.3f %.3f\n", x + x1, y + y1, sqrt(x * x + y * y));
  }
  return 0;
}

Measured memory_bytes: 664
array = Array.new

2.times do
    val = gets.split.map!{|i| i.to_i}
    array.push(val)
end

a = array[1]
check = 0

a.each{|num|
    if num % 2 == 0
        if num % 3 != 0 && num % 5 != 0
            check += 1
        end
    end
}

if check > 0
    puts("DENIED")
else
    puts("APPROVED")
end


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

using namespace std;

int main() {
  int w, a, b, mi, ma;
  scanf("%d %d %d", &w, &a, &b);
  mi = min(a, b) + w;
  ma = max(a, b);
  printf("%d\n", max(0, ma - mi));
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	long a,b,x,y,num,tmp,big,small;
	
	while(scanf("%ld %ld",&x,&y)!=EOF){
		a=x;
		b=y;
		
		if(a<b){
		tmp=a;
		a=b;
		b=tmp;
		}
		while(b!=0){
		num=a%b;
		a=b;
		b=num;
		}
		small=a;
		big=x*y/small;
	printf("%ld %ld\n",small,big);
	}
	return 0;
}

Measured memory_bytes: 596
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#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>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n, x;
  cin >> n >> x;

  int res = 1, cur = 0;
  rep(i,n) {
    int l;
    cin >> l;
    cur += l;
    if(cur <= x) res++;
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unchaed long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define Axx(x) (x).begin(), (x).cntd()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
using namespace std;
const int maxn = 100111;
int x;
int main()
{
	int k;
	k = read();
	int times = 1;
	int x = k;
	while(x != 0)
	{
		times ++;
		x += k;
		x %= 360;
	}
	cout << times;
	return 0;
}


Measured memory_bytes: 3620
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	for (int i = 0; i < 3; i++)
	{
		string str;
		cin >> str;
		cout << str[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n,a[30];
  char s[100010];
  scanf("%s",s);
  n=strlen(s);
  for(int i='a';i<='z';i++)
    a[i-'a']=1;
  for(int i=0;i<n;i++)
    a[s[i]-'a']=0;
  for(int i=0;i<30;i++)
    if(a[i]){
      printf("%c\n",i+'a');
      return 0;
    }
  printf("None\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define rep(i,a,b) for(ll i =a; i<b;++i)
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define endl "\n"
        #define pb push_back
        #define print(a)       for(auto x : a) cout << x << " "; cout << endl
        #define print1(a)      for(auto x : a) cout << x.F << " " << x.S << endl
        #define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
        #define mk(x,y)  make_pair(x,y)
        typedef  long long  int ll;
        const int N = ( 2e5 + 5 );
        const int mod = 1e9+7;
        ll n,p[100],m;
        vector<int> g[100];
ll pow_mod_m(ll a , ll n)
{
    if(!n)
        return 1;
    ll pt =  pow_mod_m(a,n/2);
    pt *= pt ; pt %= mod;
    if(n&1)
        pt *= a , pt %= mod;
    return pt;
}
//map < pair<int ,int > , int > m;
void dfs(ll u,ll pre)
{
    p[u] = pre;
    for(auto v : g[u])
        dfs(v,u);
}
int main()
{
    IOS;
    int ts = 1;
 //   cin>>ts;
	while(ts--)
    {
            cin>>n;
            ll po = 1;
            ll ans = po;
            while( n !=1)
            {
                po*=2;
                ans += po;
                n/=2;
            }
            cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <valarray>
#include <utility>
#include <set>

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP2(i,m,n) for(int i=m+1;i<=(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<=(int)(n);i++)
#define INF 500000000  //
#define INFLL 1000000000000000000  //
#define MOD (1e9)+7

typedef long long int ll;

// a 0x61  z 0x7a  0 0x30

int main() {
    ll n, z, w;
    cin >> n >> z >> w;
    ll a[n];

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

    if (n == 1) {
        cout << abs(w - a[n - 1]) << endl;
    } else {
        cout << max(abs(w - a[n - 1]), abs(a[n - 2] - a[n - 1])) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import collections
S=list(input())
T=list(input())

S1=collections.Counter(S).most_common()
T1=collections.Counter(T).most_common()
if len(S1)!=len(T1):print('No');exit()
elif all(S1[i][1]==T1[i][1] for i in range(len(S1))):print('Yes')
else:print('No')

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int r = 0;
    ll sum = 0;
    ll xo = 0;
    ll ans = 0;
    rep(l,n){
        while(r<n && (sum+a[r])==(xo^a[r])){
            sum += a[r];
            xo ^= a[r];
            r++;
        }
        ans += r-l;
        if(l==r)r++;
        sum -= a[l];
        xo ^= a[l];
    }
    cout << ans << endl;
    return 0;
}

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

#define N 100010 

using namespace std;

char *p1, *p2, buf[100000];

#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )

int rd() {
	int x = 0;
	char c = nc();
	while (c < 48) {
		c = nc();
	}
	while (c > 47) {
		x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
	}
	return x;
}

int a[N], bu[2][N], mx[2][2], id[2][2];

int main() {
	int n = rd();
	for (int i = 1; i <= n; i ++ ) {
		a[i] = rd();
	}
	for (int i = 1; i <= n; i ++ ) {
		int d = i & 1;
		bu[d][a[i]] ++ ;
		if (a[i] == id[d][0] || a[i] == id[d][1]) {
			if (a[i] == id[d][1]) {
				if (bu[d][a[i]] > bu[d][id[d][0]]) {
					swap(id[d][0], id[d][1]);
				}
			}
		}
		else {
			if (bu[d][a[i]] > bu[d][id[d][0]]) {
				id[d][1] = id[d][0];
				id[d][0] = a[i];
			}
			else if (bu[d][a[i]] > bu[d][id[d][1]]) {
				id[d][1] = a[i];
			}
		}
	}
	int mx = 0;
	for (int d1 = 0; d1 < 2; d1 ++ ) {
		for (int d2 = 0; d2 < 2; d2 ++ ) {
			if (id[0][d1] != id[1][d2]) {
				mx = max(mx, bu[0][id[0][d1]] + bu[1][id[1][d2]]);
			}
		}
	}
	cout << n - mx << endl ;
	return 0;
}

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

int main(){
  int n; 
  cin >> n;
  int v[n], c[n], ans;
  
  ans = 0;
  int a[n];
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
    if(v[i] - c[i] <= 0) a[i] = 0;
    else a[i] = v[i] - c[i];
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque, Counter as cnt

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]

# エントリーポイント
def main():
    N = input(int)
    print(((N - 1) + 1) * (N - 1) // 2)

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3456
/**
 *    author:  tourist
 *    created: 16.12.2019 12:37:38       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if (n == 2) {
    cout << -1 << '\n';
  } else {
    vector<vector<int>> a(n, vector<int>(n - 1));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - 1; j++) {
        a[i][j] = (i + j + 1) % n;
      }
    }
    if (n % 2 == 0) {
      for (int i = 0; i < n / 2; i++) {
        swap(a[i][i + (i == n / 2 - 1) * (n == 4 ? -1 : 1)], a[i][n / 2 - 1]);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n - 1; j++) {
        if (j > 0) {
          cout << " ";
        }
        cout << a[i][j] + 1;
      }
      cout << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 384
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    k=1
    while k <= N*2:
        if k*(k-1)==2*N: break
        k+=1
    else:
        print('No')
        return
    print('Yes')
    print(k)
    ans=[[] for _ in range(k)]
    v=1
    for i in range(k):
        for j in range(i+1,k):
            ans[i].append(v)
            ans[j].append(v)
            v+=1
    for a in ans:
        print(len(a),*a)

if __name__ == '__main__':
    main()

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

signed main(){
  int n;
  cin>>n;
  int a[n];
  r(i,n) cin>>a[i];
  stack<int>st;
  st.push(a[0]);

  int sum=0;

  for(int i=1;i<n;i++){
    int x=a[i];
    while(!st.empty() && st.top()>x){
      int t=st.top();st.pop();
      while(!st.empty() && st.top()==t){
	st.pop();
      }
      sum++;
    }
    st.push(x);
  }

  set<int>S;
  while(!st.empty()) S.insert(st.top()),st.pop();

  cout<<S.size()+sum<<endl;
}



Measured memory_bytes: 13176
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int s[100];
    int t=0;
    int u=100;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s[i];
        t+=s[i];
        if(s[i]%10!=0 && s[i]<u) u=s[i];
    }
    sort(s,s+n);
    if(t%10==0){
        if(u==100) cout << 0 <<endl;
        else cout << t-u <<endl;
    }
    else cout << t <<endl;


}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a<b){
    cout<<'0';
  } else if(a<2*b){
    cout<<'0';
  } else {
    cout<<a-(2*b)<<endl;
  }
}

Measured memory_bytes: 3564
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        Set<String> set = new HashSet<>();
        for(int i =0; i<n ; i++){
            set.add(sc.nextLine());
        }
        System.out.println(set.size());
    }

}


Measured memory_bytes: 79820
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    if(N==1)cout<<"Hello World"<<endl;
    else{
        int a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }
}

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

int main(){
    long long int n,k,c=0,max=0;
    cin>>n;
    vector<long long int>a(1000000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-1;i++){
        if(a[i+1]-a[i]<=0){
            c++;
        }
        else{
            c=0;
        }
        if(c>max){
            max=c;
        }
    }
    cout<<max<<endl;


   return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    ll n, m, k;
    ll ans = 0;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i, n) {
        ll A;
        cin >> A;
        a.at(i) = a.at(max(i-1, 0LL)) + A;
    }
    rep(i, m) {
        ll A;
        cin >> A;
        b.at(i) = b.at(max(i-1, 0LL)) + A;
    }
    rep(i, n) {
        ll x = k - a.at(i);
        if(x < 0) break;
        auto position = upper_bound(b.begin(), b.end(), x);
        ll low_idx = distance(b.begin(), position);
        chmax(ans, i + low_idx + 1);
    }
    rep(i, m) {
        ll x = k - b.at(i);
        if(x < 0) break;
        auto position = upper_bound(a.begin(), a.end(), x);
        ll low_idx = distance(a.begin(), position);
        chmax(ans, i + low_idx + 1);
    }
    cout << ans << endl;
}

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

typedef long long ll;
const int MAX = 210000;
const ll MOD = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
 ll ans=2*MOD-1;
ll s=1;ll t=1;
for(int i=1;i<=a;i++){
  s*=(n+1-i);t*=i;
  s%=MOD;  t%=MOD;
}
s*=modpow(t,MOD-2,MOD);
s%=MOD;
ans=ans+modpow(2,n,MOD)-s;
 s=1;t=1;
for(int i=1;i<=b;i++){
  s*=(n+1-i);t*=i;
  s%=MOD;  t%=MOD;
}
s*=modpow(t,MOD-2,MOD);
s%=MOD;
ans-=s;
 cout<<ans%MOD<<endl;

}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, ans;
    string S;
    map<string,int> mp;
    cin >> N;
    REP(int,i,0,N){
        cin >> S;
        mp[S]++;
    }
    int maxv = 0;
    priority_queue<string> pq;
    for ( auto&x : mp ){
        int v = x.second;
        if ( v > maxv ) maxv = v;
    }
    for ( auto&x : mp ){
        if ( maxv == x.second ){
            cout << x.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 26880
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, u, v, w, N, M, dist[101][101] = {}, a[1001], b[1001], c[1001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) {
		scanf("%d %d", &u, &w);
		scanf("%d", &(dist[u][w]));
		dist[w][u] = dist[u][w];
		a[i] = u;
		b[i] = w;
		c[i] = dist[u][w];
	}
	for (u = 1; u < N; u++) {
		for (w = u + 1; w <= N; w++) {
			if (dist[u][w] == 0) {
				dist[u][w] = 1 << 29;
				dist[w][u] = 1 << 29;
			}
		}
	}
	
	for (v = 1; v <= N; v++) {
		for (u = 1; u < N; u++) {
			for (w = u + 1; w <= N; w++) {
				if (dist[u][v] + dist[v][w] < dist[u][w]) {
					dist[u][w] = dist[u][v] + dist[v][w];
					dist[w][u] = dist[u][v] + dist[v][w];
				}
			}
		}
	}
	
	int sum = 0;
	for (i = 1; i <= M; i++) {
		u = a[i];
		w = b[i];
		for (v = 1; v <= N; v++) if (c[i] == abs(dist[v][u] - dist[v][w])) break;
		if (v > N) sum++;
	}
	printf("%d\n", sum);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll pw(ll x, ll y, ll mod) {
    if (y == 0) return 1;
    else if (y == 1) return x % mod;
    else if (y % 2 == 0) {
        ll p = pw(x, y / 2, mod);
        return p * p % mod;
    }
    else {
        ll p = pw(x, y / 2, mod);
        return p * p % mod * x % mod;
    }
}

ll dv(ll x, ll y, ll mod) {
    return x * pw(y, mod - 2, mod) % mod;
}
 
ll comb(ll cn, ll cr, ll mod) {
    ll v = 1;
    if (cn < cr || cn < 0 || cr < 0) return 0;
    for (int i = 1; i <= cr; i++) {
        v = v * (cn - i + 1) % mod;
        v = v * dv(1, i, mod) % mod;
    }
    return v;
}

int main() {
    ll n, m, k, mod = 1e9 + 7;
    cin >> n >> m >> k;

    ll s, t, ss, tt;
    s = pw(m, 2, mod) * comb(n * m - 2, k - 2, mod) % mod;
    ss = (n * (n - 1) / 2 % mod * n % mod) % mod;
    ss -= n * (n - 1) % mod * dv(2 * n - 1, 6, mod) % mod;
    s = s * ss % mod;
    t = pw(n, 2, mod) * comb(n * m - 2, k - 2, mod) % mod;
    tt = (m * (m - 1) / 2 % mod * m % mod) % mod;
    tt -= m * (m - 1) % mod * dv(2 * m - 1, 6, mod) % mod;
    t = t * tt % mod;
    cout << (s + t) % mod << endl;
}


Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::VecDeque;
use std::collections::HashMap;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let n:usize = buf.trim().parse().unwrap();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let s1: Vec<char> = buf.chars().collect();

    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let s2: Vec<char> = buf.chars().collect();

    let mut pos = 0;
    let mut ans = 1i64;
    let MOD = 1000000007;

    if s1[0]==s2[0] {
        pos = 1;
        ans = 3;
    } else {
        pos = 2;
        ans = 6;
    }

    while pos < n {
        if s1[pos]==s2[pos] {
            if s1[pos-1]==s2[pos-1] {
                ans *= 2;
                ans %= MOD;
            }
            pos += 1;
        } else {
            if s1[pos-1]==s2[pos-1] {
                ans *= 2;
                ans %= MOD;
            } else {
                ans *= 3;
                ans %= MOD;
            }
            pos += 2;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352