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

#define ll long long
#define ull unsigned long long
#define openfiles ifstream cin("input10.txt"); ofstream cout("output10.txt");

using namespace std;

ll dp[3][200000];

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        {
            ll a, b, c;
            cin >> a >> b >> c;
            dp[0][i] = max(dp[0][i], max(dp[1][i-1], dp[2][i-1]) + a);
            dp[1][i] = max(dp[1][i], max(dp[0][i-1], dp[2][i-1]) + b);
            dp[2][i] = max(dp[2][i], max(dp[1][i-1], dp[0][i-1]) + c);
        }
    cout << max(dp[0][n], max(dp[1][n], dp[2][n]));
}


Measured memory_bytes: 3584
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    final String LINE_SPR = System.getProperty("line.separator");
    final int BIG_MOD = 1000000007;

    void run() throws Exception {
        String line;
        while((line = br.readLine()) != null) {
            String[] nums = line.split(" ");
            long a = Integer.parseInt(nums[0]);
            long b = Integer.parseInt(nums[1]);
            System.out.println(gcd(a, b) + " " + lcm(a, b));
        }
    }


    /*
     * Templates
     */
    void dumpObjArr(Object[] arr, int n) {
        for(int i = 0; i < n; i++) {
            System.out.print(arr[i]);
            if(i < n - 1)
                System.out.print(" ");
        }
        System.out.println("");
    }

    void dumpObjArr2(Object[][] arr, int m, int n) {
        for(int j = 0; j < m; j++) 
            dumpObjArr(arr[j], n);
    }

    int ni() throws Exception {
        return Integer.parseInt(br.readLine().trim());
    }

    long nl() throws Exception {
        return Long.parseLong(br.readLine().trim());
    }

    String ns() throws Exception {
        return br.readLine();
    }

    boolean isPrime(int n) {
        for(int i=2;i<n;i++) {
            if(n%i==0)
                return false;
        }
        return true;
    }

    int getPrime(int n) {
        List<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        int count = 1;

        int x = 1;
        while(primes.size() < n) {
            x+=2;
            int m = (int)Math.sqrt(x);
            for(int p : primes) {
                if(p > m) {
                    primes.add(x);
                    break;
                }

                if(x % p == 0) 
                    break;
            }
        }

        return primes.get(primes.size() - 1);
    }

    long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    long gcd(long a, long b) {
        if(a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        // a >= b
        long mod = a % b;
        if(mod == 0) 
            return b;
        else 
            return gcd(b, mod);
    }

    void gcjPrint(String str, int t) {
        System.out.println("Case #" + t + ": " + str);
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}

Measured memory_bytes: 16932
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    v a(3);
    cin>>a[0]>>a[1]>>a[2];
    ll x;
    cin>>x;
    sort(all(a));
    rep(i,0,x){
        a[2]*= 2;
    }
    cout<<a[0]+a[1]+a[2];
    return 0;
}

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

int main(){
    int N,M;
    std::cin >> N >> M;
    const Int max_size = (1LL << (N));
    const Int inf = (1LL << 60);
    std::vector<Int>dp(max_size,inf);
    std::vector<Int>d(M);
    std::vector<Int>c(M);
    for(Int i = 0; i < M; ++i){
        int c_num;
        std::cin >> d[i] >> c_num;
        Int val = 0;
        for(int j = 0; j < c_num; ++j){
            Int t; std::cin >> t;
            val += (1LL << (t-1));
        }
        c[i]  = val;
    }
    dp[0] = 0;
    for(Int S = 0; S < dp.size(); ++S){
        if(dp[S] == inf)continue;
        for(int j = 0; j < M; ++j){
            if(S | (c[j] > S)){
                Int tS = std::min(max_size - 1, S | c[j]);
                dp[tS] = std::min(dp[tS],dp[S] + d[j]);
            }
        }
    }
    std::cout << (dp.back() == inf ? -1 : dp.back()) << std::endl;
}


Measured memory_bytes: 256
//    https://youtu.be/N3oCS85HvpY

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,temp,flag,ans=0;
    cin>>n;
    map<ll,ll>mp;
    vector<ll>v;
    for(i=0;i<n;i++){
        cin>>temp;
        mp[temp]++;
        if(mp[temp]==2){
            v.pb(temp);
        }else if(mp[temp]==4){
            ans=max(ans,temp*temp);
        }
    }
    sort(all(v));
    if(v.size()>=2){
        ans=max(ans,v[v.size()-1]*v[v.size()-2]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

  ll N;
  cin >> N;
  ll ans = 0;
  for(ll i = 2; i * i <= N; i++){
    if(N % i != 0) continue;
    ll num = 0;
    while(N % i == 0){
      N /= i;
      num++;
    }

    for(ll j = 1; ; j++) {
      if(num >= j) {
        num -= j;
        ans++;
      }else break;
    }
  }
  if(N != 1) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()




int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> v(n, vector<int>(m));
    vector<int> c(n);
    rep (i, n) {
        cin >> c[i];
        rep (j, m) {
            cin >> v[i][j];
        }
    }
    int ans = 1e9;
    rep (i, (1 << n)) {
        vector<int> und(m, 0);
        int cost = 0;
        rep (j, n) {
            if (i & (1 << j)) {
                cost += c[j];
                rep (o, m) {
                    und[o] += v[j][o];
                }
            }
        }
        sort(all(und));
        if (und[0] >= x) {
            chmin(ans, cost);
        }
    }
    if (ans == 1e9) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int n;
int k;
int x[1000],y[1000];

int cl(int x,int y){
    int d;
    if(y >= x){
        if(y <= n - x)
            d = x;
        else
            d = n - y + 1;
    }else{
        if(y > n - x)
            d = n - x + 1;
        else
            d = y;
    }
    d %= 3;
    if(d == 0)
        d = 3;
    return d;
}

int main(){
    scanf("%d%d",&n,&k);
    REP(i,k)
        scanf("%d%d",x + i,y + i);
    REP(i,k)
        printf("%d\n",cl(x[i],y[i]));
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define int long long 
using namespace std;

signed main() {
  int N, M;
  cin >> N >> M;
  
  vector<pair<int, int>> task(N);
  for( int i = 0; i < N; i++ ){
    int A, B;
    cin >> A >> B;
    task.at(i) = make_pair(A, B);
  }
  sort(task.begin(), task.end());
  
  priority_queue<int> pq;
  int ans = 0;
  int cnt = 0;
  for( int i = 1; i <= M; i++ ){
    while( cnt < N && task.at(cnt).first <= i ){
      pq.push(task.at(cnt).second);
      cnt++;
    }
    if( !pq.empty() ){
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;

  
  
    
  
}

Measured memory_bytes: 2936
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<ll> a(n);

  int c = 0;
  ll sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += abs(a[i]);
    if(a[i] < 0) c++;
  }

  if(c % 2 == 1) {
    ll mi = INF;
    REP(i, n)  {
      mi = min(abs(a[i]), mi);
    }
    sum -= (mi * 2);
  }

  cout << sum << endl;
}


Measured memory_bytes: 3956
import java.util.*;
import java.io.*;
class Main{
	public static void main(String[]args){
		Scanner in=new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out, true);
		int k = in.nextInt();
		if(k%2 == 0 || k%5 == 0)
			out.println(-1);
		else{
			int cur = 7%k;
			int ans = 1;
			while(cur != 0){
				cur = cur*10 + 7;
				cur %= k;
				ans ++;
			}
			out.println(ans);
		}
	}
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int X, N;
    cin >> X >> N;
    vector<int> v(N);
    int t[SIZE] = {};
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
        t[v[i]]++;
    }

    int mn = X + 1;
    int m = -1;
    for(int i = 0; i <= 101; ++i) {
        if(t[i] != 0) continue;
        if(mn > abs(X - i)) {
            mn = abs(X - i);
            m = i;
        }
    }
    cout << m << endl;

    return 0;
}



Measured memory_bytes: 4436
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op== "?":
        break
    if op== "+":
        print(a+b)
    elif op== "-":
        print(a-b)
    elif op== "*":
        print(a*b)
    else:
        print(a//b)


Measured memory_bytes: 5596
x, y = map(int, input().split())

if x == 0 and y < 0:
  print(abs(y) + 1)

elif x < 0 and y == 0:
  print(abs(x))

elif x > 0 and y == 0:
  print(x+1)

elif x >= 0 or y >= 0:
  if x == y:
    print(0)

  elif x == -y:
    print(1)

  elif x > y:
    # (11, 7)
    if y >= 0:
      ans = 2
      ans += x - y
      print(ans)

    # (11, -7)
    else:
      print(1 + abs(abs(x) + y))

  else:
    # (7, 11)
    if x >= 0:
      print(y - x)

    # (-7, 11)
    else:
      print(1 + abs(abs(y) + x))

else:
  if x == y:
    print(0)


  else:
    if x > y:
      print(abs(y) - abs(x) + 2)
    else:
      print(abs(x) - abs(y))


Measured memory_bytes: 3064
N, K = gets.split.map(&:to_i)
sushi = {}
N.times do
  t, d = gets.split.map(&:to_i)
  sushi[t] ||= []
  sushi[t] << d
end

maxes = []
others = []

sushi.each_value do |v|
  v.sort!
  maxes << v.pop
  others.concat(v)
end


maxes = maxes.sort_by! {|m| -m}
others = others.sort_by! {|o| -o}

# p maxes, others

sum_max = [0]
maxes.each do |m|
  sum_max << sum_max[-1] + m
end
sum_other = [0]
others.each do |o|
  sum_other << sum_other[-1] + o
end

# p sum_max, sum_other

max = 0
1.upto([K, maxes.size].min) do |kind|
  tmp = sum_max[kind] + sum_other[K-kind].to_i + kind**2
  if tmp > max
    max = tmp
  end
end

p max


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

using namespace std;

template <class T>inline T updmax(T &a, T b) { return a = max(a, b); }
template <class T>inline T updmin(T &a, T b) { return a = min(a, b); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> a(n+1, 0), b(n, 0);
	for(int i=0; i<n+1; i++)cin >> a[i];
	for(int i=0; i<n; i++)cin >> b[i];
	long long ret = 0;
	for(int i=0; i < n; i++){
		int x = min(a[i], b[i]);
		a[i]-=x;
		b[i]-=x;
		int y = min(a[i+1], b[i]);
		a[i+1]-=y;
		b[i]-=y;
		ret += x+y;
	}
	cout << ret << "\n";
	
	return 0;
}

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

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    double ans = 0.0;
    for(int i=1;i<=n;i++) {
        double temp = 1.0/n;
        int val = i;
        while(val<k) {
            val*=2;
            temp/=2;
        }
        ans+=temp;
    }
    cout<<setprecision(25)<<ans;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000000
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int H, W;
vector<string> S;
queue<pair<int, int>> det;
vector<vector<int>> mv(20, vector<int>(20, INF));

void bfs(int x, int y, int d){
  if(x < 0 || x >= H || y < 0 || y >= W){
    return;
  }
  if(mv.at(x).at(y) < INF){
    return;
  }
  if(S.at(x).at(y) == '#'){
    return;
  }
  mv.at(x).at(y) = d + 1;
  det.push(make_pair(x, y));
}

int main(){
  cin >> H >> W;
  S.resize(H);
  rep(i, H){
    cin >> S.at(i);
  }
  int ans = 0;
  rep(i, H){
    rep(j, W){
      rep(k, H){
        rep(l, W){
          mv.at(k).at(l) = INF;
        }
      }
      if(S.at(i).at(j) == '#'){
        continue;
      }
      bfs(i, j, -1);
      while(!det.empty()){
        pair<int, int> q = make_pair(det.front().first, det.front().second);
        det.pop();
        int d = mv.at(q.first).at(q.second);
        bfs(q.first+1, q.second, d);
        bfs(q.first-1, q.second, d);
        bfs(q.first, q.second+1, d);
        bfs(q.first, q.second-1, d);
      }
      rep(k, H){
        rep(l, W){
          if(mv.at(k).at(l) < INF){
            chmax(ans, mv.at(k).at(l));
          }
        }
      }
    }
  }
  cout << ans << endl;          
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		List<Edge> li = new ArrayList<>();
		int max = -1, idx = 0;
		for(int i = 1; i <= n / 2; i++) {
			int val = c2(n - i) + c2(i);
			if(max < val) {
				max = val;
				idx = i;
			}
		}
		//System.out.println(max + " " + idx);
		if(max < k) {
			System.out.println(-1);
			return;
		}
		for(int i = 0; i < idx; i++) {
			for(int j = idx; j < n; j++) {
				li.add(new Edge(i, j));
			}
		}
		for(int i = 0; i < idx -1 && max != k; i++) {
			for(int j = i + 1; j < idx -1 && max != k; j++) {
				li.add(new Edge(i, j));
				max--;
			}
		}
		for(int i = idx; i < n && max != k; i++) {
			for(int j = i + 1; j < n && max != k; j++) {
				li.add(new Edge(i, j));
				max--;
			}
		}
		if(k != max) System.out.println(-1);
		System.out.println(li.size());
		for(Edge e : li) {
			System.out.println((e.f + 1 )+ " " + (e.t + 1));
		}
	}
	
	int c2(int n) {
		if(n < 2) return 0;
		else return n * (n - 1) / 2;
	}
	
	class Edge{
		int f, t;
		Edge(int from, int to){
			f = from; t = to;
		}
	}
	
	class Work implements Comparable<Work>{
		int c, l;//cost, limit
		Work(int cost, int limit) {
			c = cost; l = limit;
		}
		@Override
		public int compareTo(Work arg0) {
			if(this.l != arg0.l) {
				return (this.l < arg0.l)?-1:1;
			}
			else if(this.c != arg0.c) {
				return (this.c < arg0.c)?-1:1;
			}
			return 0;
		}
	}

	long gcd(long a, long b) {
		long w;
		while(b != 0) {
			w = a % b;
			a = b;
			b = w;
		}
		return a;
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

x1,y1,x2,y2 = list(map(int, input().rstrip().split()))
#-----

dx = x2-x1
dy = y2-y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

print(x3,y3,x4,y4)


Measured memory_bytes: 2940
def prime_factorize(P):
    prime = list()
    for i in range(2, P + 1):
        if i**2 <= P:
            if P % i == 0:
                c = 0
                while P % i == 0:
                    P //= i
                    c += 1
                prime.append([i, c])
            else:
                continue
        else:
            break

    if P != 1:
        prime.append([P, 1])

    return prime

def main2():
    N, P = map(int, input().split())

    prime = prime_factorize(P)
    ans = 1
    for p in prime:
        n, c = p
        ans *= (n ** (c // N)) 

    print(ans)

if __name__ == "__main__":
    main2()

Measured memory_bytes: 9020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CAntiDivision solver = new CAntiDivision();
        solver.solve(1, in, out);
        out.close();
    }

    static class CAntiDivision {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a, b, c, d;
            a = in.nextLong();
            b = in.nextLong();
            c = in.nextLong();
            d = in.nextLong();
            long x = b / c - (a - 1) / c;
            long y = b / d - (a - 1) / d;
            long e = gcd(c, d);
            long k = b - a + 1;
            e = (c * d) / e;
            long h = b / e - (a - 1) / e;
            out.println(b - a + 1 - x - y + h);
        }

        private long gcd(long c, long d) {
            if (d == 0) return c;
            else return gcd(d, c % d);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 21332
import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInt' = fst.fromJust.C.readInt
readLnInt = map readInt'.C.words<$>C.getLine
readCsInt n = concat<$>replicateM n readLnInt

x ? (a,b) = if x then a else b

main = do
 [n,x] <- readLnInt
 inputs <- readLnInt
 print $ solve (x:inputs)

solve (x:ls) = calc 1 0 x ls

calc ans temp bound (s:ss) = (temp'>bound)?(ans,(null ss)?(ans',calc ans' temp' bound ss)) where
  temp' = temp + s
  ans' = ans + 1


Measured memory_bytes: 508
#include <array>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <limits>
#include <fstream>
#include <numeric>
#include <stack>
#include <queue>
#include <list>
#include <cstring>
#include <unordered_set>

namespace
{
	template<int N>
	std::array<int, N> GetValue(std::istream& stream)
	{
		std::string buf;
		std::getline(stream, buf);

		std::stringstream sstr(buf);
		std::array<int, N> retval;

		for (int i = 0; i < N; ++i)
		{
			std::getline(sstr, buf, ' ');
			retval[i] = std::stoi(buf);
		}

		return retval;
	}

	std::vector<int> GetValue(std::istream& stream, int num)
	{
		std::string buf;
		std::getline(stream, buf);
		std::stringstream sstr(buf);

		std::vector<int> retval;
		retval.reserve(num);

		int input;
		for (int i = 0; i < num; ++i)
		{
			sstr >> input;
			retval.push_back(input);
		}

		return retval;
	}

	int GetValue(std::istream& stream)
	{
		int in;
		stream >> in;

		return in;
	}

	std::vector<std::string> GetValueString(std::istream& stream, int num, char delim)
	{
		std::string buf;
		std::vector<std::string> retval;
		retval.reserve(num);

		std::getline(stream, buf);
		std::stringstream sstr(buf);

		for (int i = 0; i < num && std::getline(sstr, buf, delim); ++i)
		{
			retval.push_back(std::move(buf));
		}

		return retval;
	}

	template<typename T>
	void PrintLine(const std::vector<T>& sequence)
	{
		std::cout << sequence[0];

		for (size_t i = 1; i < sequence.size(); ++i)
		{
			std::cout << ' ' << sequence[i];
		}

		std::cout << std::endl;
	}

	template<typename T>
	void Print(const std::vector<T>& sequence)
	{
		for (const auto& e : sequence)
		{
			std::cout << e << '\n';
		}

		std::cout << std::flush;
	}
}

int main(int argc, char* argv[])
{
	/*auto file = (argc == 1) ? std::ifstream() : std::ifstream(argv[1]);
	std::istream& stream = (argc == 1) ? std::cin : file;
	if (argc == 1)
	{
		std::cin.tie(0);
		std::ios::sync_with_stdio(false);
	}

	int num = GetValue<1>(stream)[0];*/
	int num;
	scanf("%d", &num);

	std::unordered_set<std::string> str;
	char command[10], s[13];

	for (int i = 0; i < num; ++i)
	{
		//std::vector<std::string> input =
			//GetValueString(stream, 2, ' ');
		scanf("%s %s", command, s);

		switch (command[0])
		{
		case 'i':
			if (str.find(s) == str.end())
			{
				str.emplace(s);
			}
			break;
		case 'f':
			if (str.find(s) != str.end())
			{
				std::cout << "yes\n";
			}
			else
			{
				std::cout << "no\n";
			}
			break;
		}
	}

	std::cout << std::flush;
}



Measured memory_bytes: 28932
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def main():
    N, K = li_input()

    ans = 1

    for i in range(N):
        if i == 0:
            ans *= K
        else:
            ans *= (K - 1)

    print(ans)


main()


Measured memory_bytes: 4724
import qualified Data.IntMap.Strict as M
import Data.List

mapKeysValue p f g = filter p . map (\(k,v) -> (f k, g v)) . M.toList

main = do
 [_,w] <- map read . words <$> getLine
 wvs <- map (map read . words) . lines <$> getContents
 print (knap w wvs)

knap w = maximum . M.elems . foldl' (dp w) (M.singleton 0 0)

dp w im [w',v'] = foldl' (\ acc (k,v) -> M.insertWith max k v acc) im (mapKeysValue ((<=w).fst) (+w') (+v') im)

Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
vector<int> V[maxn];
int64_t SUM[maxn << 2], LZ[maxn << 2];
void upd(int rt, int l, int r, int ll, int rr, int v) {
  if (ll <= l && rr >= r) {
    LZ[rt] += v;
    SUM[rt] += (r-l+ 1) * v;
    return;
  }
  int mid = (l + r) >> 1;
  if (LZ[rt]) {
    LZ[rt << 1 | 1] += LZ[rt];
    LZ[rt << 1] += LZ[rt];
    SUM[rt << 1] += (mid - l + 1) * LZ[rt];
    SUM[rt << 1 | 1] += (r - mid) * LZ[rt];
    LZ[rt] = 0;
  }
  if (ll <= mid) upd(rt << 1, l, mid, ll, rr, v);
  if (rr > mid) upd(rt << 1 | 1, mid + 1, r, ll, rr, v);
  SUM[rt] = SUM[rt << 1 | 1] + SUM[rt << 1];
}
int64_t query(int rt, int l, int r, int ll, int rr) {
  if (ll <= l && rr >= r) {
    return SUM[rt];
  }
  int mid = (l + r) >> 1;
  if (LZ[rt]) {
    LZ[rt << 1 | 1] += LZ[rt];
    LZ[rt << 1] += LZ[rt];
    SUM[rt << 1] += (mid - l + 1) * LZ[rt];
    SUM[rt << 1 | 1] += (r - mid) * LZ[rt];
    LZ[rt] = 0;
  }
  int64_t res = 0;
  if (ll <= mid) res += query(rt << 1, l, mid, ll, rr);
  if (rr > mid) res += query(rt << 1 | 1, mid + 1, r, ll, rr);
  return res;
}
int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    V[u].PB(v);
    V[v].PB(u);
  }
  for (int i = 1; i <= n; ++i) {
    int q = 1;
    for (int v : V[i])
      if (v <= i) q--;
    upd(1, 1, n, i, n, q);
  }
  int64_t ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += query(1, 1, n, i, n);
    for (int v : V[i])
      if (v > i) {
        upd(1, 1, n, v, n, 1);
      }
    upd(1, 1, n, i, n, -1);
  }
  cout << ans << "\n";

  return 0;
}
//2020.07.05 23:20:13


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;

ll cir[5000][5001];
ll sum[5000][5001];

int n;
ll k;
int p[5000];
ll c[5000];

ll solver1(){
	int num[5000];

	for(int s=0;s<n;s++){
		int t = p[s];
		int u = 0;
		cir[s][u] = c[t];
		u++;
		while(t!=s){
			t = p[t];
			cir[s][u] = c[t];
			u++;
		}
		num[s] = u;
	}

	for(int i=0;i<n;i++) sum[i][0] = 0ll;
	
	
	for(int i=0;i<n;i++){
		for(int j=1;j<=min(k,num[i]);j++){
			sum[i][j] = sum[i][j-1] + cir[i][(j-1)%num[i]];
		}
	}

	//for(int i=0;i<n;i++) cout << sum[i][num[i]] << endl;

	ll ans = -1000000000000000000;
	
	for(int i=0;i<n;i++){
		for(int j=1;j<=min(k,num[i]);j++){
			ans = max(((k-j)/num[i]*max(0ll,sum[i][num[i]])) + sum[i][j], ans);
		}
	}

	return ans;
}

main(){
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> p[i];
		p[i]--;
	}
	for(int i=0;i<n;i++) cin >> c[i];


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

	return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	set<char> st(s.begin(),s.end());
	cout << (st.size()==3 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VB vector<bool>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVL vector<VL>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    VS c(h);
    rep(i, h){
        cin >> c[i];
    }
    rep(i, h*2){
        cout << c[i/2] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
mod = 10**9+7
N, K = map(int, input().split())
ans = 0
cnt = np.zeros(K+1, np.int64)
for X in reversed(range(1,K+1)):
	a = K // X
	cnt[X] = pow(a,N,mod)
	x = 2
	res = 0
	while True:
		tmp = X * x
		if tmp > K:
			break
		res += cnt[tmp]
		res %= mod
		x += 1

	cnt[X] -= res
	cnt[X] %= mod
	ans += cnt[X] * X
	ans %= mod

print(ans)

Measured memory_bytes: 27424
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int n,a[101],al=0,bo=0;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++){
		if(i%2==0)al+=a[i];
		else bo+=a[i];
	}
	cout<<abs(al-bo)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#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,A;
  cin>>N>>A;
  if(N%500<=A){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,a,b;
  cin >> n >> a >> b;
  if(a*n > b) cout << b << endl;
  else cout << a*n << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

vector<vector<int> > dist;
int N,M;

int buildDist(vector<int> a, vector<int> b, vector<int> c){
    bool update = true;
    while(update){
        update = false;
        for(int i=1;i<=N;i++){
            for(int j=i+1;j<=N;j++){
                for(int k=1;k<=N;k++){
                    if(dist[i][j]>dist[i][k]+dist[k][j]){
                        dist[i][j]=dist[i][k]+dist[k][j];
                        dist[j][i]=dist[i][k]+dist[k][j];
                        update = true;
                    }
                }
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    dist = vector<vector<int>>(N+1,vector<int>(N+1,INF));
    REP(i,N+1) dist[i][i]=0;
    vector<int> a(M);
    vector<int> b(M);
    vector<int> c(M);
    int A,B;
    REP(i,M){
        cin >> A >> B >> c[i];
        if(A<B){
            a[i]=A;
            b[i]=B;
        }else{
            a[i] = B;
            b[i] = A;
        }
        dist[a[i]][b[i]]=c[i];
        dist[b[i]][a[i]]=c[i];
    }
    buildDist(a,b,c);
    bool used[M] ={false};
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            for(int k=0;k<M;k++){
                if(dist[i][j]==dist[i][a[k]]+c[k]+dist[b[k]][j]) used[k]=true;
                if(dist[i][j]==dist[i][b[k]]+c[k]+dist[a[k]][j]) used[k]=true;
            }
        }
    }
    int count = 0;
    REP(i,M){
        if(used[i]==false){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int N;
int M;
int X;
vector<vector<ll>> A;
vector<ll> C;
vector<ll> used;
ll minValue = LONG_LONG_MAX;
void dfs(int n) {
    if(n == N) {
        ll temp_C = 0;
        vector<ll> sum_X(M);
        rep(i, N) {
            if(used[i]) {
                temp_C += C[i];
                rep(j, M) {
                    sum_X[j] += A[i][j];
                }
            }
        }
        bool judge = true;
        rep(i, M) {
            if(sum_X[i] < X) judge = false;
        }
        if(judge) {
            minValue = min(minValue, temp_C);
        }

        return;
    }
    for(int i = 0; i <= 1; i++) {
        used[n] = i;
        dfs(n + 1);
    }
}

int main() {
    cin >> N >> M >> X;
    A.resize(N);
    C.resize(N);
    used.resize(N);
    rep(i, N) {
        A[i] = vector<ll>(M);
    }
    rep(i, N) {
        cin >> C[i];
        rep(j, M) {
            cin >> A[i][j];
        }
    }
    dfs(0);
    if(minValue != LONG_LONG_MAX)
        cout << minValue << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 3632
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    N = sc.intarr()[0]
    A = sc.intarr()

    new = sorted(A, reverse=True)
    alice = 0

    for i in range(0, N):
        if i % 2 == 0:
            alice += new[i]
        else:
            alice -= new[i]

    print(alice)


class Scan():

    def intarr(self):
        num_array = list(map(int, input().split()))
        return num_array

    def intarr_ver(self, n):
        return [int(input()) for _ in range(n)]

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


def display(array):
    for a in range(len(array)):
        if len(array) - a != 1:
            print(array[a], end=' ')
        else:
            print(array[a])


def gcd(a, b):  # 最大公約数
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):  # 最小公倍数
    return a * b // gcd(a, b)


main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
ll binpow(ll a,ll b)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=res*a;
        a=a*a;
        b/=2;
    }
    return res;
}
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int x=0;x<n;x++)cin>>a[x];
    map<ll,ll> ae;
    ll ans=0;
    for(int x=0;x<n;x++)
    {
        ans+=ae[x-a[x]];
        ++ae[x+a[x]];
    }
    cout<<ans;
}


Measured memory_bytes: 27676
#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>;

const int M = 1000005;

int main()
{
    int N;
    cin >> N;
    vector<unsigned long long> A(N);
    rep(i, N) cin >> A[i];

    if (find(A.begin(), A.end(), 0) != A.end())
    {
        cout << 0 << endl;
        return 0;
    }

    unsigned long long ans = 1;
    rep(i, N)
    {
        auto oldAns = ans;
        ans *= A[i];
        if (oldAns != ans / A[i] || ans > 1000000000000000000)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
using namespace std;
int main() {
    int A, B, d, r;
    double a, b, f;
    cin >> a >> b;
    A = a;
    B = b;
    d = A / B;
    r = A % B;
    f = a / b;
    cout << fixed;
    cout << d << " " << r << " " << f << endl;
    return 0;
}


Measured memory_bytes: 3272
n = int(input())
s = input()
cnt, L = 0, 0
for i in range(len(s)):
    if s[i] == '(':
        cnt += 1
    else:
        cnt -= 1

    if cnt < 0:
        L = min(L, cnt)

ans = '('*abs(L) + s
R = ans.count('(') - ans.count(')')
ans += ')'*R

print(ans)


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int R, G, B;
    cin >> R >> G >> B;
    int N;
    cin >> N;

    int ans = 0;
    for(int i=0; i<=(N+R-1)/R; i++)
    {
        for(int j=0; j<=(N+G-1)/G; j++)
        {
            if(N >= R*i + G*j && (N - R*i - G*j)%B==0)
            {
                // cout << i << ", " << j << ", " << (N - R*i - G*j)/B << '\n';
                ans++;
            }
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

#define PI (3.1415926535898)

int main(void) {

	double a, b, C, rad;
	double S, L, h;

	scanf("%lf %lf %lf", &a, &b, &C);

	rad = C * PI / 180.0;

	h = b * sin(rad);
	S = a * h / 2.0;
	L = a + b + sqrt((h * h) + ( (a - b * cos(rad)) * (a - b * cos(rad))));


	printf("%10.8lf\n", S);
	printf("%10.8lf\n", L);
	printf("%10.8lf\n", h);

}

Measured memory_bytes: 2928
n = gets.to_i
ss = []
n.times do
  s = gets.chomp.chars.sort.join
  ss << s
end

ss.sort!

ans = 0
h = Hash.new(0)
ss.size.times do |i|
  h[ss[i]] += 1
end

h.each do |k,v|
  if v > 0
    ans += (1..v).to_a.combination(2).size
  else
    ans += v
  end
end

# puts ss.size - ss.uniq.size
puts ans


Measured memory_bytes: 38376
#include <iostream>
#include <iterator>
#include <vector>
#include <string>
using namespace std;

int const MAX = 1000;
int top;
int s[MAX];

void initalise() {
  top = 0;
}

bool isEmpty() {
  return top == 0;
}

bool isFull() {
  return top >= MAX - 1;
}

void push(int x) {
  if (isFull()) cout << "エラー(オーバーフロー)" << endl;
  top++;
  s[top] = x;
}

int pop() {
  if (isEmpty()) cout << "エラー(アンダーフロー)" << endl;
  top--;
  return s[top + 1];
}

int main() {
  using ite_t = istream_iterator<string>;
  ite_t it(cin);
  ite_t last;

  while (it != last) {
    if (*it == "+") {
      int ope2 = pop();
      int ope1 = pop();
      push(ope1 + ope2);
    } else if (*it == "-") {
      int ope2 = pop();
      int ope1 = pop();
      push(ope1 - ope2);
    } else if (*it == "*") {
      int ope2 = pop();
      int ope1 = pop();
      push(ope1 * ope2);
    } else {
      push(stoi(*it));
    }
    it++;
  }

  cout << pop() << endl;
}



Measured memory_bytes: 3156
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        sc.close();

        // 主処理
        int lenA = a.length();
        while (lenA < 100) {
            a = "0" + a;
            lenA = a.length();
        }
        int lenB = b.length();
        while (lenB < 100) {
            b = "0" + b;
            lenB = b.length();
        }

        int compare = a.compareTo(b);
        String result = "EQUAL";
        if (0 < compare) {
            result = "GREATER";
        } else if (compare < 0) {
            result = "LESS";
        }

        // 出力
        System.out.println(result);
    }
}


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

int main(){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  double max = 0;
  int sugar = 0;
  int water = 0;

  for(int i = 0; i*100*a < f; ++i){
    for(int j = 0; j*100*b < f; ++j){
      for(int k = 0; k*c< f; ++k){
        for( int l = 0; l*d < f; ++l ){
          if( i == 0 && j == 0 ) continue;
          if(100*a*i + 100*b*j + c*k + d*l > f) continue;
          double density = double(double(k*c + l*d)/double(a*100*i + 100*b*j + c*k + d*l));
          if( max <= density && (k*c+d*l) <= e*(a*i+b*j) ){ max = density;
          sugar = k*c+l*d;
          water = a*100*i+100*b*j;
          }
        }
      }
    }
  }
  cout << water+sugar <<" " << sugar << endl;
  return 0;
}


Measured memory_bytes: 256
from functools import reduce
import math
import collections

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    A = list(int(_) for _ in input().split())
    A_fixed = []
    for i in range(N):
        A_fixed.append(A[i]-i-1)
    cnt = 0
    A_fixed.sort()
    b = A_fixed[N//2]
    for i in range(N):
        cnt += abs(b-A_fixed[i])
    # print(A_fixed)
    # print(b)
    print(cnt)    
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 25692
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#define ALLRANGE(x) x.begin(), x.end()
using namespace std;

int main(){
  string a, b;
  cin >> a >> b;
  reverse(ALLRANGE(b));
  if (a==b) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

#include<cmath>
#include<string>
#include <algorithm> 

using namespace std;

# define p(s) cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) cout << (j ? "Yes" : "No") << endl;

string lpad(string l,int s,int n){
    string temp = to_string(n);
    string res = "";
    int loop = s - temp.size();
    while(loop--) res+=l;

    return res+temp;
}

int main()
{
    int a,b;
    cin >> a >> b ;

    printIf(b%a==0,b+a,b-a)
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var S, T string
	fmt.Scan(&S, &T)
	ans := 0
	for i := 0; i < 3; i++ {
		if S[i] == T[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include<stdio.h>
#include<string.h>

#define X_SIZE 1000
#define Y_SIZE 1000
int buff[X_SIZE+1][Y_SIZE+1];

int max(int a, int b)
{
	int max = a;
	if(max < b){
		max = b;
	}
	return(max);
}

int lcs(char* x, char* y)
{
	int i, j;
	int x_length, y_length;

	x_length = strlen(x);
	y_length = strlen(y);

	for(i = 0; i <= x_length; i++){
		for(j = 0; j <= y_length; j++){
			if((i == 0) || (j == 0)){
				buff[i][j] = 0;
			}else if(x[i-1] == y[j-1]){
				buff[i][j] = buff[i-1][j-1] + 1;
			}else{
				buff[i][j] = max(buff[i][j-1],buff[i-1][j]);
			}
		}
	}

	return(buff[x_length][y_length]);
}

int main(int argc, char* argv[])
{
	char x[X_SIZE+1], y[Y_SIZE+1];
	int i, n;

	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%s", x);
		scanf("%s", y);
		printf("%d\n", lcs(x, y));
	}

	return(0);
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint dp[55][55][1305];
 
int main() {
  int n, score;
  cin >> n >> score;
  dp[0][0][0] = 1;
  rep(i,n) {
    rep(j,i+1)rep(k,score/2+1) {
      {
        int nj = j;
        dp[i+1][nj][k+nj] += dp[i][j][k];
      }
      {
        int nj = j+1;
        dp[i+1][nj][k+nj] += dp[i][j][k];
      }
      {
        int nj = j;
        mint x = j*2;
        dp[i+1][nj][k+nj] += dp[i][j][k]*x;
      }
      if (j >= 1) {
        int nj = j-1;
        mint x = j*j;
        dp[i+1][nj][k+nj] += dp[i][j][k]*x;
      }
    }
  }
  mint ans = dp[n][0][score/2];
  if (score&1) ans = 0;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 31104