akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<int> p(22);

int main()
{
    int n, ans = 0;
    cin>>n;
    REP(i,n) cin>>p[i];
    REP(i,n-2) ans += ((p[i] - p[i+1]) * (p[i+1] - p[i+2]) > 0);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
Sa = list(input())
Sb = list(input())
Sc = list(input())
player = 'a'
while True:
    if player == 'a':
        if Sa == []:
            print('A')
            sys.exit()
        player = Sa.pop(0)
    if player == 'b':
        if Sb == []:
            print('B')
            sys.exit()
        player = Sb.pop(0)
    if player == 'c':
        if Sc == []:
            print('C')
            sys.exit()
        player = Sc.pop(0)

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

int main(){
  int h,w;
  string board[1005];
  cin >> h >> w;
  for(int i=0;i<h;i++) cin >> board[i];

  int dx[]={1,1,0,-1,-1,-1,1,0};
  int dy[]={0,1,1,1,0,-1,-1,-1};
  for(int i=0;i<h;i++) {
    for(int j=0;j<w;j++) {
    int cnt=0;
    if(board[i][j]=='#') continue;
      for(int n=0;n<8;n++){
        int x=i+dx[n];
        int y=j+dy[n];
        if(x>=0 && x<h && y>=0 && y<w && board[x][y]=='#') cnt++;
      }
      board[i][j]=cnt+'0';
    }
  }

  for(int i=0;i<h;i++) cout << board[i] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int l = s - i - j;
            if(0 <= l && l <= k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, h, w;
  int a, b;
  int sum = 0;
  cin >> n >> h >> w;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a >= h && b >= w) {
      sum += 1;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int gcd(int x, int y)
{
    if (x < y)
    {
        int z = y, y = x, x = z;
    }

    if (x % y == 0)
        return y;
    else
        return gcd(y, x % y);
}

int main()
{
    int N, X, ans, x[112345];
    V v;
    cin >> N >> X;
    REP(i, N)
    {
        cin >> x[i];
        v.push_back(abs(X - x[i]));

        if (i > 0)
        {
            ans = gcd(ans, abs(X - x[i]));
        }
        else
        {
            ans = abs(X - x[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
int s(int a)
{
	int b=0;
	while(a>0)
	{
		b+=(a%10);
		a/=10;
	}
	return b;
}
int main()
{
	int n;
	cin>>n;
	int S=s(n);
	if(n%S==0)cout<<"Yes";
	else 
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 3000;
const int M = 100000007;

int C[N+1][N+1];

void init(){
  for(int i=0;i<N;i++){
    C[i][0] = C[i][i] = 1;
    for(int j=0;j<i;j++) C[i][j] = (C[i-1][j-1] + C[i-1][j]) % M;
  }
}

main(){
  int r, c, sy, sx, ty, tx, by, bx;
  init();
  int dy[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
  int dx[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
  cin >> r >> c >> sy >> sx >> ty >> tx;
  int ans = 0;
  by = bx = M;
  for(int i=0;i<9;i++){
    int ny = abs(ty + r * dy[i] - sy);
    int nx = abs(tx + c * dx[i] - sx);
    if(by + bx > ny + nx){
      by = ny; bx = nx;
      ans = C[by+bx][by];
    }else if(by + bx == ny + nx){
      ans = (ans + C[ny+nx][ny]) % M;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35048
import java.util.Scanner;

public class Main {

	public static int[] A;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		A = new int[N];
		for(int i = 0; i < N ; i++) {
			A[i] = sc.nextInt();
		}

		sc.close();

		int[] M = new int[N];
		int[] L = new int[N];
		int[] R = new int[N];

		L[0] = A[0];
		for(int i = 1; i < N; i++) {
			L[i] = gcd(L[i-1],A[i]);
			//System.out.println("L[" + i + "]: " + L[i]);
		}

		R[N-1] = A[N-1];
		for(int i = N-2 ; i >=0 ; i--) {
			R[i] = gcd(R[i+1],A[i]);
			//System.out.println("R[" + i + "]: " + R[i]);
		}


		int answer = Math.max(L[N-2], R[1]);
		for(int i = 1 ; i < N-1 ; i++) {;
			answer = Math.max(answer, gcd(L[i-1], R[i+1]));
		}

		System.out.println(answer);
	}


	public static int gcd(int a, int b) {
		int tmp;
		if(b > a) {
			tmp = a;
			a = b;
			b = tmp;
		}

		if(b == 0) {
			return a;
		}

	    int r = -1;
	    do{
	        r = a % b;
	        a = b;
	        b = r;
	    }while (r != 0);

	    return a;
	}

}


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

ll sum[200000];
vector<int>vs[200000];
int belong[200000];
ll ans[200000];

void merge(int u,int v,ll w){
	u=belong[u];v=belong[v];
	if(vs[u].size()<vs[v].size())swap(u,v);
	sum[u]+=w*vs[v].size();
	sum[v]+=w*vs[u].size();
	for(int i:vs[v]){
		vs[u].push_back(i);
		belong[i]=u;
		ans[i]-=sum[u];
		ans[i]+=sum[v];
	}
	vs[v].clear();
}
struct st{int a,b,c;};
int main(){
	int n;scanf("%d",&n);
	vector<st>v;
	rep(i,n-1){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		v.push_back({a,b,c});
	}
	sort(v.begin(),v.end(),[](st a,st b){return a.c>b.c;});
	rep(i,n){
		belong[i]=i;
		vs[i].push_back(i);
	}
	rep(i,n-1){
		merge(v[i].a,v[i].b,v[i].c);
	}
	rep(i,n){
		printf("%lld\n",ans[i]+sum[belong[i]]);
	}
}

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

int main(){

  string S; cin >> S;

  long int sum = 0;

  for(int i = 0;i < (1 << (S.size() - 1));i++){//対応させる2進数

    string plus = "";


    for(int j = 0;j < (S.size()-1);j++){//シフト桁数

      if((i >> j) & 1) plus += to_string(j+1);//j+1が,何番目の+を取るかを表す.

    }




    if(plus != "")
      for(int k = 0;k < plus.size();k++){

        char pk = plus[k];
        long int pkk = atol(&pk);

        if(k == 0)sum += stol(S.substr(0,pkk));
        else{
          string pkm = plus.substr(k-1,1);//plusのk-1要素
          long int pkkm = stol(pkm);
          sum += stol(S.substr(pkkm,pkk-pkkm));
        }


        if(k == plus.size()-1)sum += stol(S.substr(pkk,S.size()-pkk));


      }
    else if(plus == "") sum += stol(S);

  }

  cout << sum << endl;



}

Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#include <ctime>
typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)

const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int num[30];

void solve()
{
	int n, k;
	scanf("%d%d", &n, &k);
	repp(i, 1, n)
	{
		string x;
		cin >> x;
		num[x[0]-'A']++;
	}
	int res = 0;

	while (true)
	{
		int cnt = 0;
		sort(num, num + 26);
		reverse(num, num + 26);
		for (int i = 0; i < k;i++)
		{
			if (num[i])
			{
				cnt++;
				num[i]--;

			}
		}
		if (cnt != k)
		{
			break;
		}
		res++;
	}
	cout << res << endl;
}

int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> p(N),a(N),b(N);
    rep(i,N){
        cin >> p[i];
        p[i]--;
    }
    rep(i,N){
        a[i] = (i+1)*30000;
    }
    //b[p[0]] = 1e5;
    REP(i,0,N){
        b[N-1-i] = 30000*(i+1);
    }
    rep(i,N){
        b[p[i]] += i+1;
    }
    PR(a,N);
    PR(b,N);
}

Measured memory_bytes: 3884
N = int(input())
FirstPlaceNumber = N % 100 % 10

if FirstPlaceNumber == 2 or FirstPlaceNumber == 4 or FirstPlaceNumber == 5 or FirstPlaceNumber == 7 or FirstPlaceNumber == 9 :
    print('hon')
elif FirstPlaceNumber == 0 or FirstPlaceNumber == 1 or FirstPlaceNumber == 6 or FirstPlaceNumber == 8 :
    print('pon')
else :
    print('bon')

Measured memory_bytes: 9128
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var r = Number(inputs);
  // ????????????????????????
  console.log(
  	Math.PI * Math.pow(r,2)
  	,2 * Math.PI * r);
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int n;
    cin >> n;

    int ans = -1;
    REP(i, 50001) {
        if (floor(i * 1.08) == n) {
            ans = i;
            break ;
        }
    }

    if (ans == -1) cout << ":(" << '\n';
    else cout << ans << '\n';
    return 0;
}

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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    double result = 0;
    REP(n, N){
        double xn;
        string un;
        cin >> xn >> un;
        if (un == "JPY"){
            result += xn;
        }else if (un == "BTC"){
            result += xn * 380000.0;
        }
    }
    printf("%.5lf\n", result);
}


Measured memory_bytes: 256
N = int(input())
As = map(int, input().split())
count = 0
while True:
    Bs = []
    for a in As:
        if a % 2 != 0:
            break
        Bs.append(a//2)
    else:
        As = Bs
        count += 1
        continue
    break
print(count)

Measured memory_bytes: 2940
use std::io;
use std::str::FromStr;

struct Student {
  num: i32,
  index: i32,
}

fn input<T:FromStr>() -> T {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.trim().parse().ok().unwrap()
}

fn input_i32_vec() -> Vec<i32> {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
  let n: i32 = input();
  let a = input_i32_vec();
  let mut students: Vec<Student> = Vec::new();
  for i in 0..n {
    let student = Student{num: a[i as usize], index: i+1};
    students.push(student);
  }
  students.sort_by(|a, b| a.num.cmp(&(b.num)));
  for s in students {
    print!("{} ", s.index);
  }
}


Measured memory_bytes: 6908
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>
#include<deque>
#include<iomanip>
#include<ctime>
#include<bitset>
#include<map>
using namespace std;

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

	int count = 0;

	map<string, bool> goods;

	for (int i = 0; i < N; i++)
	{
		string good;
		cin >> good;

		if (goods.find(good) == goods.end())
		{
			count++;
			goods[good] = true;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 19120
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans, a[10000000];
bool f;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	n %= 500;
	if (n<=m) {
		f = 1;
	}
	yn(f);
	return 0;
}

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

const int N = 200005;

int n;
int a[N];

int solve() {
  scanf("%d", &n);

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

  for (int i = 0; i < n; ++i) {
    printf("%d ", sum ^ a[i]);
  }
  printf("\n");
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 4604
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n >> m;
  l = 1;
  lep(i,1,n-1)l *= m-1;
  l *= m;
  print(l);
  return 0;
}

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

namespace modular{
    using ll = long long;

    const int mod = 998244353;

    int mul_mod(ll a, ll b){
        a %= mod; b %= mod;
        if (a < 0) a += mod;
        if (b < 0) b += mod;
        return a * b % mod;
    }

    int plus_mod(ll a, ll b){
        a %= mod; b %= mod;
        if (a < 0) a += mod;
        if (b < 0) b += mod;
        return (a + b) % mod;
    }

    int minus_mod(ll a, ll b){
        a %= mod; b %= mod;
        if (a < 0) a += mod;
        if (b < 0) b += mod;
        return (a - b + mod) % mod;
    }

    ll ext_euclid(ll a, ll b, ll &x, ll &y){
        int g = a; x = 1; y = 0;
        if (b != 0){
            g = ext_euclid(b, a % b, y, x);
            y -= (a / b) * x;
        }
        return g;
    }

    int inverse(ll a){
        ll x, y; ext_euclid(a, ll(mod), x, y);
        return x %= mod, x < 0 ? x + mod : x;
    }

    int div_mod(ll a, ll b){
        return mul_mod(a, inverse(b));
    }

    int pow_mod(ll a, ll k){
        ll res = 1;
        for (; k; k >>= 1, a = mul_mod(a, a))
            if (k & 1) res = mul_mod(res, a);
        return res;
    }
};

using namespace modular;

const int N = 2e5 + 5;
const int C = 1e6 + 5;
int a[N], cnt[C], w[C];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, res = 0, maxv = 0; cin >> n;
    for (int i = 1, x; i <= n; i++){
        cin >> x; cnt[x]++; maxv = max(maxv, x);
    }
    for (int i = 1; i <= maxv; i++){
        w[i] += inverse(i);
        for (int j = 2 * i; j <= maxv; j += i)
            w[j] = minus_mod(w[j], w[i]);
        int x = 0, y = 0, z = 0;
        for (int j = i; j <= maxv; j += i){
            x = plus_mod(x, mul_mod(cnt[j], j));
            y = plus_mod(y, mul_mod(mul_mod(cnt[j],
                        cnt[j]), mul_mod(j, j)));
            z = plus_mod(z, mul_mod(mul_mod(j, j),
                        mul_mod(cnt[j], cnt[j] - 1)));
        }
        res = plus_mod(res, mul_mod(w[i],
                minus_mod(mul_mod(x, x), y)));
        res = plus_mod(res, mul_mod(w[i], z));
    }
    cout << div_mod(res, 2) << '\n';
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    string S, T;
    cin >> S;
    REP(i, 0, S.size()){
        if(S[i] == 'B'){ if(!T.empty()) T.erase(T.size()-1, 1); }
        else T += S[i];
    }
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 100100100100100100
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep2(i,a,n) for(int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

int main() 
{
    string s; cin >> s;
    int ans = 0;
    
    rep(i,s.size()) {
        for(int j = s.size()-1; j >= i; j--) {
            string t = "";
            for(int k = j; k >= i; k--) {
                t = s[k]+t;
            }
            int acgt = 0;
            rep(l, t.size()) {
                if(t[l] == 'A' || t[l] == 'G' || t[l] == 'C' || t[l] == 'T') {
                    acgt |= 1;
                } else {
                    acgt |= 2;
                }
            }
            //cout << acgt << "," << t << endl;
            if(acgt == 1) { 
                ans = max(ans, (int)t.size());
            }
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 384
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, l = rli()
    taste = 0
    m = 999999999
    t_min = 0
    for i in range(n):
        t = l + i
        if abs(t) < m:
            m = min(m, abs(t))
            t_min = t
        taste += t
    print(taste-t_min)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e15;
typedef pair<int,int> ii;
typedef vector<int> vi;
const int max_item_cnt=100+10;
const int max_value_possible=1e5+10;
ll W[max_item_cnt],V[max_item_cnt];
ll dp[max_item_cnt][max_value_possible];//dp[i][j]-min weight to get at least j space from 1-th to i-th element
bool sol[max_item_cnt];
int main(){
	ll n,w;
	cin>>n>>w;
	ll max_val=0;
	for(int i=1;i<=n;i++){
		cin>>W[i]>>V[i];
		max_val+=V[i];
 
	}
	for(int i=1;i<max_value_possible;i++){
			dp[0][i]=inf;
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=max_val;j++){
			if(j>=V[i]){
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-V[i]]+W[i]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
			
		}
	}
	int ans=0;
	for(int v=max_val;v>=0 && !ans;v--){
		if(dp[n][v]<=w){
			ans=v;
		}
	}
	int val=ans;
	for(int i=n;i>=1;i--){
		if(dp[i-1][val]==dp[i][val]){
			continue;
		}
		sol[i]=true;
		val-=V[i];
	}

	for(int i=1;i<=n;i++){
		//cout<<sol[i]<<" ";
	}
	//cout<<endl;
	cout<<ans;
	
 
	return 0;
}

Measured memory_bytes: 80128
n,m=map(int,input().split())
# 商品iをそれぞれN個入力
num=[int(i) for i in input().split()]
# 降順で並び替え
num=sorted(num,reverse=True)
# 総得票数
sum_num=sum(num)
# m-1番目つまり人気商品の中の一番人気がない商品が
# 総得票数の1/4Mは未満は人気商品と言えないNo
if num[m-1]<sum_num/(4*m):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9120
N = int(input())
S = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for i in range(N):
    s = input()
    S[s] += 1
print("AC x ", S["AC"])
print("WA x ", S["WA"])
print("TLE x ", S["TLE"])
print("RE x ", S["RE"])


Measured memory_bytes: 9188
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define maxn 210000
#define mod 1000000007
const int m=1e9+7;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,k,t,h,w,a,b;
ll fac[maxn],inv[maxn];
void init()
{
    fac[0]=1;
    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;
    inv[maxn-10]=qpow(fac[maxn-10],mod-2);
    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int x,int y)
{
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    //freopen("de.txt","r",stdin);
    init();
    while (~scanf("%d%d%d%d",&h,&w,&a,&b)){
        ll ans=C(h+w-2,h-1);
        for (int i=0;i<b;++i){
            ll temp1=C(i+h-1-a,i);
            ll temp2=C(w-i+a-2,a-1);
            ll temp3=(temp1*temp2)%mod;
            ans=(ans-temp3+mod)%mod;
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3584
K = int(input())

R = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(R[K - 1])

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

main() {
  int a, b, n;
  cin >> a >> b;
  n = a * b;
  if (n == 1) {
    cout << "Odd" << endl;
  } else if (n % 2 == 0) {
    cout << "Even" << endl;
  } else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <algorithm>
    #include <cmath>
    #include <vector>
    #include <set>
    #include <map>
    #include <unordered_set>
    #include <unordered_map>
    #include <queue>
    #include <ctime>
    #include <cassert>
    #include <complex>
    #include <string>
    #include <cstring>
    #include <chrono>
    #include <random>
    #include <queue>
    #include <bitset>
    #include <stack>
    #include <functional>
    
    #ifdef LOCAL
        #define eprintf(...) fprintf(stderr, __VA_ARGS__)
    #else
        #define eprintf(...) 42
    #endif
    
    #define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
    #define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
    #define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
    #define all(x) (x).begin(), (x).end()
    template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
    template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
    template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
    using namespace std;
    
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair <int,int> P;
    typedef long double ld;
    
    int main(void)
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
        int n, k; cin >> n >> k;
        if (k > (n - 1) * (n - 2) / 2) cout << "-1\n";
        else {
            int t = (n - 1) * (n - 2) / 2 - k;
            cout << n - 1 + t << "\n";
            repp (i, 1, n) cout << "1 " << i + 1 << "\n";
            int count = 0;
            bool break_flg = false;
            repp (i, 1, n) {
                repp (j, i + 1, n) {
                    if (count >= t) break_flg = true;
                    if (break_flg) break;
                    cout << i + 1 << " " << j + 1 << "\n";
                    count++;
                }
                if (break_flg) break;
            }
        }
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 50 + 5;

int arr[N];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n; cin >> n;
	for(int i=1;i<=n;i++) cin>>arr[i];
	int mx=1, mi=1;
	for(int i=2;i<=n;i++){
		if(arr[i]>arr[mx]) mx=i;
		if(arr[i]<arr[mi]) mi=i;
	}
	cout << 2*n-1 << '\n';
	if(abs(arr[mx]) >= abs(arr[mi])){
		for(int i=1;i<=n;i++){
			if(i==mx) continue;
			arr[i] += arr[mx];
			cout << mx << ' ' << i << '\n';
		}
		arr[mx] += arr[mx];
		cout << mx << ' ' << mx << '\n';
		for(int i=2;i<=n;i++){
			arr[i] += arr[i-1];
			cout << i-1 << ' ' << i << '\n';
		}
	}else{
		for(int i=1;i<=n;i++){
			if(i==mi) continue;
			arr[i] += arr[mi];
			cout << mi << ' ' << i << '\n';
		}
		arr[mi] += arr[mi];
		cout << mi << ' ' << mi << '\n';
		for(int i=n-1;i>=1;i--){
			arr[i] += arr[i+1];
			cout << i+1 << ' ' << i << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)
#define MAX 2000
using namespace std;

typedef long long ll;
typedef vector<int> vi;
struct edge{ int to, cap, rev; };
vector<edge> G[MAX];
bool used[MAX];

void add_edge(int from, int to, int cap){
    G[from].pb((edge){to, cap, G[to].size()});
    G[to].pb((edge){from, 0, G[from].size() - 1});
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    rep(i, G[v].size()){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}
int N, K;
int main() {
    while(cin >> N >> K, N||K){
        vector<int> b(N), r(K);
        rep(i, N) cin >> b[i];
        rep(i, K) cin >> r[i];
        rep(i, MAX) G[i].clear();
        int s = N+K, t = s+1;
        rep(i, N) add_edge(s, i, 1);
        rep(i, K) add_edge(N+i, t, 1);
        rep(i, N) rep(j, K) if(__gcd(b[i], r[j]) > 1) add_edge(i, N+j, 1);
        cout << max_flow(s, t) << endl;
    }
    return 0;
}

Measured memory_bytes: 7604
#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int merge(int a[], int n)
{
    int l[n / 2 + 1];
    int r[n - n / 2 + 1];

    for (int i = 0; i < n / 2; i++)
        l[i] = a[i];
    l[n / 2] = 1145141919;
    for (int i = 0; i < n - n / 2; i++)
        r[i] = a[n / 2 + i];
    r[n - n / 2] = 1145141919;

    int i = 0, j = 0;
    for (int k = 0; k < n; k++)
    {
        if (l[i] <= r[j])
        {
            a[k] = l[i];
            i++;
        }
        else
        {
            a[k] = r[j];
            j++;
            ans += n / 2 - i;
        }
    }

    return n;
}

int mergeSort(int a[], int n)
{
    int cnt = 0;
    if (n > 1)
    {
        cnt += mergeSort(a, n / 2);
        cnt += mergeSort(a + n / 2, n - n / 2);
        cnt += merge(a, n);
    }
    return cnt;
}

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    mergeSort(a, n);
    cout << ans << endl;
}


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

int main(void)
{
	unsigned int a, b;
	
	while (cin >> a >> b, a && b){
		unsigned int h, g, s, o;
		h = g = s = 0;
		o = (b - a);
		while (0 < o){
			if (1000 <= o){
				s++;
				o -= 1000;
			}
			else if (500 <= o){
				g++;
				o -= 500;
			}
			else if (100 <= o){
				h++;
				o -= 100;
			}
		}
		cout << h << " " << g << " " << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 864
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif 65 <= m + f < 80:
        print('B')
    elif 50 <= m + f < 65:
        print('C')
    elif 30 <= m + f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')



Measured memory_bytes: 5592
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!(int);

void scan(Args...)(ref Args args) {
    import std.conv : parse;
    string[] ss = readln.split;
    int i;
    foreach (ref arg ; args)
        arg = ss[i++].parse!int;
}

void main() {
    int n; scan(n);
    int[] d = reads.sort().array;
    int m = n/2;
    writeln(d[m] - d[m - 1]);
}


Measured memory_bytes: 4284
A,B,N=map(int,input().split())
if N>=B:
	x=(N//B)*B-1
	t=B-1
	ans=max((A*x)//B-A*(x//B),(A*t)//B-A*(t//B))
	print(ans)
else:
	print((A*N)//B-A*(N//B))

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> x(n);
  for(auto &a:x) cin >> a;
  int ans=1e9;
  for(int i=0;i<=2000;++i) {
    int tmp=0;
    for(int j=0;j<n;++j) tmp=max(tmp,abs(i-x[j]));
    ans=min(ans,tmp);
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 3112
import itertools
n, m, q = map(int, input().split())
comb = itertools.combinations_with_replacement(range(1, m+1), n)
a = []
b = []
c = []
d = []
score = 0
for _ in range(q):
    ai, bi, ci, di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)
for cmb in comb:
    cnt = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if cmb[bi-1] - cmb[ai-1] == ci:
            cnt += di
    score = max(score, cnt)
print(score)

Measured memory_bytes: 9248
#include <cstdio>

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

    return 0;
}

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

int main(){
    int n,a,b,c,t[150]={0},v=0;
    cin>>n>>a>>b>>c;
    for(int i=0;i<n;i++){
        cin>>t[i];
    }
    v=c/a;
    sort(t,t+n,greater<int>());
    int sum=c,money=a;;
    for(int i=0;i<n;i++){
        if(t[i]/b<v)break;
        else {
            sum+=t[i];
            money+=b;
            v=sum/money;
        }
    }
    sum/=money;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    long double a,b,c=0,d,e,f,g=0;
    int A[1000];
    while(1){
    
    cin>>b;
    if(b==0){
    	break;
    }
    for(int i=0;i<b;i++){
    	cin>>A[i];
    	c+=A[i];
    }
    c=c/b;
    for(int i=0;i<b;i++){
    	g+=pow((A[i]-c),2)/b;
    }
    g=sqrt(g);
    //cout<<printf("%.10lf\n", sqrt(e))<<endl;
    //e=sqrt(e);
    // cout << f << endl;
    std::cout << setprecision(16) << g <<endl;
    c=0;
    g=0;
    A[1000]=0;
	}
    return 0;
}



Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;long long a[1<<17],n,q,x,y;int main(){cin>>n>>q;for(x=0;x<n;x++)a[x]=2147483647;while(q--){scanf("%lld%lld%lld",&n,&x,&y);if(n)printf("%lld\n",*min_element(a+x,a+y+1));else a[x]=y;}return 0;}

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


void solve(long long N, long long M, vector<pair<long long, long long>> AB){
  sort(AB.begin(), AB.end());
  long long acc = 0;

  for(long long i = 0; i < N; i++) {
    long long a, b;
    tie(a,b) = AB[i];

    acc += a * min(M, b);
    M -= b;

    if(M <= 0) break;
  }

  cout << acc << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<pair<long long, long long>> AB;
  long long a, b;
  for(int i = 0 ; i < N ; i++){
    cin >> a >> b;
    AB.push_back(make_pair(a,b));
  }
    solve(N, M, std::move(AB));
    return 0;
}


Measured memory_bytes: 2420
// https://atcoder.jp/contests/abc168/tasks/abc168_e
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<ll,ll> P;

#define MAX_N 200005
#define M 1000000007
vector<ll> fac(MAX_N); //n!(mod M)
vector<ll> ifac(MAX_N); //k!^{M-2} (mod M)
const double INF = 1e18+1;
ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1; // n = n/2
    }
    return ans;
}
void init_comb(){
	fac[0] = 1;
	ifac[0] = 1;
	for(ll i = 1; i<MAX_N; i++){
		fac[i] = fac[i-1]*i % M; // n!(mod M)
		ifac[i] = ifac[i-1] * mpow(i, M-2) % M; // k!^{M-2} (mod M)
	}
}
ll combination(ll n,ll m){
	if(m==n || m==0) return 1;
	ll tmp = fac[n] * ifac[m] % M;
	return tmp * ifac[n-m] % M;
}
ll mdev(ll a,ll b){
	return a * mpow(b,M-2) % M;
}
ll msub(ll a,ll b){
	if(a>b)return (a-b)%M;
	return msub(a+M,b);
}

ll sum_comb(int n){
	ll sum = 0;
	rep(i,n+1){
		sum = (sum + combination(n,i)) % M;
	}
	return sum;
}

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

int main() {
	init_comb();
	int n;
	cin >> n;
	map<P,int> s;
	vector<P> keys;

	rep(i,n){
		ll a,b;
		cin >> a >> b;
		if(a<0 && b<0){
			a = -a; b = -b;
		}else if(a<0 && b>0){
			a = -a; b = -b;
		}
		if(a==0 && b==0){

		}else if(a==0){
			b = 1;
		}else if(b==0){
			a = 1;
		}else{
			ll g = gcd(a,abs(b));
			a = a/g;
			b = b/g;
		}
		P k = P(a,b);
		
		if(!is_in(k,s)){
			keys.push_back(k);
		}
		s[k]++;
	}
	int free_n = 0;
	int zero_n = 0;
	vector<P> twin;
	rep(i,keys.size()){
		ll inv_ka = keys[i].second;
		ll inv_kb = -keys[i].first;
		if(keys[i].first==0 && keys[i].second==0){
			zero_n = s[keys[i]];
			continue;
		}
		if(inv_ka<=0){
			inv_ka = -inv_ka; inv_kb = -inv_kb;
		}
		P pk = P(inv_ka,inv_kb);
		if(is_in(pk,s)){
			if(s[pk]>0){
				twin.push_back(P(s[keys[i]],s[pk]));
				s[keys[i]] = 0;
				s[pk] = 0;
			}
		}else{
			free_n+=s[keys[i]];
		}
	}
	
	ll ans = sum_comb(free_n);
	rep(i,twin.size()){
		int a = twin[i].first,b=twin[i].second;
		ll twin_comb = (sum_comb(a) + sum_comb(b)) % M;
		twin_comb = msub(twin_comb,1);
		ans = (ans * twin_comb) % M;
	}
	ans = (ans + zero_n)%M;
	ans = msub(ans,1);
	outl(ans);

    return 0;
}



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

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


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

using namespace std;

int main()
{
  int n, k, m;
  while(cin >> n >> k >> m, n || k || m){
    int stone[10000];
    for(int i = 0; i < n; i++) stone[i] = (i + 1) % n;
    m -= 2;
    if(m < 0) m += n;
    stone[m] = stone[stone[m]];
    while(stone[m] != m){
      for(int i = 0; i < k-1; i++) m = stone[m];
      stone[m] = stone[stone[m]];
    }
    cout << m+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>
#include <bits/stdc++.h>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    IO;
    int n ,k;
    cin>>n >>k;
    ll arr[n+2];
    ll dp[k+2];
    for(int i =0 ;i < n ; i++){
        cin>>arr[i];
    }
    for(int i= 0; i <=k ; i++)dp[i]=INT_MAX;
    dp[0]=0;
    for(int i = 1;i < n ; i++)
    {
        ll ans=INT_MAX;
        for(int j = 1 ; j<=k&&i-j>=0 ; j++){
            ans=min(ans,dp[(i-j)%k]+abs(arr[i]-arr[i-j]));
        }
        dp[i%k]=ans;
    }
    cout<<dp[(n-1)%k]<<endl;

    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main {
	private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	public static void main(String[] args) throws Exception {
		String[] array = br.readLine().split(" ");
		Deque<String> mainDeque = new ArrayDeque<>();
		for(String str: array){
			mainDeque.offerLast(str);
		}
		Deque<Integer> intDeque = new ArrayDeque<>();
		
		while(!mainDeque.isEmpty()){
			String str = mainDeque.pop();
			try{
				int iv = Integer.parseInt(str);
				intDeque.push(iv);
			}catch(NumberFormatException e){
				int v2 = intDeque.pop();
				int v1 = intDeque.pop();
				
				int result = 0;
				switch (str) {
				case "+":
					result = v1 + v2;
					break;
				case "-":
					result = v1 - v2;
					break;
				case "*":
					result = v1 * v2;
					break;
				}
				
				intDeque.push(result);
			}
		}
		
		System.out.println(intDeque.pop());
	}
}



Measured memory_bytes: 24504
#include <iostream>
using namespace std;
int main(){
    int a[4][3][10]={};
    int n,b,f,r,v,count=0;
    cin>>n;
    while(cin>>b>>f>>r>>v){
        a[b-1][f-1][r-1]+=v;
        count++;
        if(count==n)break;
    }
    for(b=0;b<4;b++){
        for(f=0;f<3;f++){
            for(r=0;r<10;r++){
                cout<<" "<<a[b][f][r];
            }
            cout<<endl;
        }
        if(b<3)cout<<"####################"<<endl;
    }
}

Measured memory_bytes: 3056
#include <iostream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

template <typename T1, typename T2>
bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

const int N = 1e4 + 3, D = 103;
const ll MOD = 1e9 + 7;

ll dp[N][D][2];

void add(ll& a, ll b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

void solve() {
    int d;
    string s;
    cin >> s >> d;
    
    int n = (int) s.size();
    for (int i = 0; i < n; ++i)
        s[i] -= '0';
    
    // dp[i][sum][sm] -- number of ways
    
    dp[0][0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < d; ++j) {
            for (int sm = 0; sm <= 1; ++sm) {
                for (int now = 0; now <= 9; ++now) {
                    if (!sm && now > s[i]) break;
                    
                    add(dp[i + 1][(j + now) % d][sm || now < s[i]], dp[i][j][sm]);
                }
            }
        }
    }
    
    ll ans = 0;
    add(ans, dp[n][0][0]);
    add(ans, dp[n][0][1]);
    
    --ans;
    if (ans < 0)
        ans += MOD;
    
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n, 1);
  for (int i = 1; i <= n; i++) {
    int m = i;
    for (int j = 2; j * j <= m; j++) {
      while (m % j == 0) {
        m /= j;
        x.at(j - 1)++;
      }
    }
    if (m > 1) x.at(m - 1)++;
  }
  long ans = 1;
  const long mod = 1000000007;
  for (int i = 0; i < n; i++) {
    ans *= x.at(i);
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  throws NumberFormatException{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		for (int i = 0; i < n; i++) {
			double x1 = stdIn.nextDouble();
			double y1 = stdIn.nextDouble();
			double x2 = stdIn.nextDouble();
			double y2 = stdIn.nextDouble();
			double x3 = stdIn.nextDouble();
			double y3 = stdIn.nextDouble();
			double p = 0;
			double q = 0;

			p = ((y1 - y3) * ((y1 * y1) - (y2 * y2) + (x1 * x1) - (x2 * x2))
					- (y1 - y2) * ((y1 * y1) - (y3 * y3) + (x1 * x1) - (x3 * x3)))
					/ (2 * (y1 - y3) * (x1 - x2) - 2 * (y1 - y2) * (x1 - x3));
			q = ((x1 - x3) * ((x1 * x1) - (x2 * x2) + (y1 * y1) - (y2 * y2))
					- (x1 - x2) * ((x1 * x1) - (x3 * x3) + (y1 * y1) - (y3 * y3)))
					/ (2 * (x1 - x3) * (y1 - y2) - 2 * (x1 - x2) * (y1 - y3));
			double r = Math.sqrt((x1 - p) * (x1 - q) + (y1 - p) * (y1 - q));
			System.out.println(new BigDecimal(p).setScale(3, BigDecimal.ROUND_HALF_UP)+" "+new BigDecimal(q).setScale(3, BigDecimal.ROUND_HALF_UP)+" "+new BigDecimal(Math.sqrt((x1-p)*(x1-p)+(y1-q)*(y1-q))).setScale(3, BigDecimal.ROUND_HALF_UP));
		}
	}
}

Measured memory_bytes: 20768
/**********

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*********/

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

long long gcd(long long a,long long b){
    return b?gcd(b,a%b):a;
}

long long primechk[10000];

void preprocess(long long N){
    long long i,j;
    for(i=2;i<=N;i++){
        primechk[i]=1;
    }
    for(i=2;i<=N;i++){
        if(primechk[i]==1){
            for(j=2;i*j<=N;j++){primechk[i*j]=0;}
        }
    }
}

long long Binexpo(long long a,long long b){
    if(b==0)
        return 1;
    long long res=Binexpo(a,b/2);
    if(b%2){return res*res*a;}
    else{return res*res;}
}
long long Pwr(long long a,long long b,long long m){
    a%=m;
    long long res=1;
    while(b>0){
        if(b%2){res=res*a%m;}
        a=a*a%m;
        b>>=1;
    }
    return res;
}
int main()
{   long long a,b,c,d,e,f,g,h,i,j,k,x,y,z,sum,cnt=0,cnt2=0;
    string s;
    cin>>s;
    for(i=s.length()-1;i>=0;i--){
        if(i>=6&&s[i-6]=='d'&&s[i-5]=='r'&&s[i-4]=='e'&&s[i-3]=='a'&&s[i-2]=='m'&&s[i-1]=='e'&&s[i]=='r'){g=5;i-=6;}
        else if(i>=5&&s[i-5]=='e'&&s[i-4]=='r'&&s[i-3]=='a'&&s[i-2]=='s'&&s[i-1]=='e'&&s[i]=='r'){g=5;i-=5;}
        else if(i>=4&&s[i-4]=='d'&&s[i-3]=='r'&&s[i-2]=='e'&&s[i-1]=='a'&&s[i]=='m'){g=5;i-=4;}
        else if(i>=4&&s[i-4]=='e'&&s[i-3]=='r'&&s[i-2]=='a'&&s[i-1]=='s'&&s[i]=='e'){g=5;i-=4;}
        else{g*=0;break;}
    }
    if(g==5){cout<<"YES";}
    else{cout<<"NO";}
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    long q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    long ans = 0;
    long m = n - n%2;
    ans += min(m*4*q, min(m*2*h, min(m*s, m/2*d)));
    if(n % 2 == 1)
        ans += min(4*q, min(2*h, s));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int n,k,x,y,sum=0;
	cin >> n>>k>>x>>y;
	if (n < k) {
		k = n;
	}
	for (int i = 0; i < k; i++) {
		sum += x;
	}
	for (int i = k; i < n; i++) {
		sum += y;
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let parent i = int_of_float ((float_of_int (i - 1)) /. 2.)

let left i = 2*i + 1

let right i = 2*i + 2

let to_pow_of_2 n =
  let rec doit i =
    if i >= n then i
    else doit (i * 2) in
  doit 1

let update (s : int array) n i x =
  let j = n + i - 1 in
  s.(j) <- x;
  let rec doit j =
    if j > 0 then begin
      let j = parent j in
      s.(j) <- if s.(left j) < s.(right j) then s.(left j) else s.(right j);
      doit j
    end in
  doit j

let find s n a b =
  let rec doit a b k l r =
    if r <= a || b <= l then 2147483647
    else if a <= l && r <= b then s.(k)
    else begin
      let v = doit a b (left k) l ((l + r) / 2) in
      let w = doit a b (right k) ((l + r) / 2) r in
      if v < w then v else w
    end in
  doit a b 0 0 n

let solve n q =
  let n = to_pow_of_2 n in
  let s = Array.make (2*n-1) 2147483647 in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split (read_line ()) ' ') with
      | 0 :: x :: y :: _ -> update s n x y
      | 1 :: x :: y :: _ -> Printf.printf "%d\n" (find s n x (y + 1))
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; q] -> solve n q
  | _ -> ()

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

int main() {
    int h, w, cnt = 0;
    cin >> h >> w;
    char c;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> c;
            if (c == '#') cnt++;
        }
    }
    
    cout << (cnt == h+w-1 ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 256