akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int a, b, c, d;
  int start=0;
  int fin=0;
  cin >> a >> b >> c >> d;
  if(b>=c && a<=d){
    start=max(a,c);
    fin=min(b,d);
    cout << fin-start << endl;
    return 0;
  }else{
    cout << '0' << endl;
    return 0;
  }


  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int N=2e5+7;
char a[N];
int sum[N];
int f[N];
int g[(1<<26)];
inline int min(int a,int b)
{
	return a<b?a:b;
}
int main()
{
	scanf("%s",a+1);
	int len=strlen(a+1);
	for(int i=1;i<=len;i++)	sum[i]=sum[i-1]^(1<< (a[i]-'a') );
	memset(f,127,sizeof(f));
	memset(g,127,sizeof(g));
	g[0]=0;
	for(int i=1;i<=len;i++)
	{
		f[i]=min(f[i],g[sum[i]]+1);
		for(int j=0;j<=25;j++)	
		f[i]=min(f[i],g[sum[i]^(1<<j)]+1);
		g[sum[i]]=min(g[sum[i]],f[i]);
	}
	printf("%d\n",f[len]);
	return 0;
}

Measured memory_bytes: 264192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll ans = 0;
    ll n;
    cin >> n;

    vector<string> s;

    for (int i = 0; i < n; i++) {
        string temp;
        cin >> temp;
        s.push_back (temp);
    }


    for (int i = 0; i < n; i++) {
        sort(ALL(s[i]));
    }

    sort(ALL(s));

    ll ct = 0;
    for (int i = 0; i < n; i++) {
        ct++;
        if ((i < n-1 && s[i] != s[i+1]) || i == n-1) {
            ans += ct * (ct - 1) / 2;
            ct = 0;
        } 
    }

    cout << ans << endl;
}

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

#define ll long long
#define ld long double
#define db double
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr<<name<<" : "<<arg1<<nl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const ld pi=2*acos(0.0);

ll modi(ll a,ll n){
    ll x=1;
    while(n){
        if(n&1)
            x*=a;
        n>>=1;
        a*=a;
    }
    return x;
}

int main(){
    nimble
    ll n;
    cin>>n;
    ll xd=n;
    if(n==1){
        cout<<0;
        return 0;
    }
    vector<ll> div;
    for(ll i=2;i*i<=n;i++){
        int f=0;
        while(n%i==0){
            n/=i;
            f=1;
        }
        if(f)
            div.pb(i);
    }
    if(n>1)div.pb(n);
    int as=0;
    for(int i=0;i<_sz(div);i++){
        ll x=div[i];
        int cnt=0;
        ll g=x;
        while(xd%g==0){
            cnt++;
            if(xd%g==0)
                xd/=g;
            else break;
            g*=x;
        }
        as+=cnt;
    }
    cout<<as<<nl;
    return 0;
}



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

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> ans(n);
    REP(i, n) ans[a[i]-1] = i+1;

    REP(i, n) cout << ans[i] << (i==n-1?'\n':' ');

    return 0;
}

Measured memory_bytes: 2432
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M;
	static int[] C = new int[300];
	static int[][] P = new int[300][3];

	public static void main(String[] args) {
		int[] dp = new int[301];
		while (sc.hasNext()) {
			N = sc.nextInt();
			M = sc.nextInt();
			for (int i = 0; i < N; ++i) {
				sc.nextLine();
				sc.nextLine();
				C[i] = sc.nextInt();
				P[i][0] = sc.nextInt();
				P[i][1] = sc.nextInt();
				P[i][2] = sc.nextInt();
			}
			int ans = 0;
			for (int i = 0; i < 3; ++i) {
				Arrays.fill(dp, -1);
				dp[M] = 0;
				for (int j = 0; j < N; ++j) {
					for (int k = M - C[j]; k >= 0; --k) {
						if (dp[k + C[j]] != -1) {
							dp[k] = Math.max(dp[k], dp[k + C[j]] + P[j][i]);
						}
					}
				}
				for (int j = 0; j <= M; ++j) {
					ans = Math.max(ans, dp[j]);
				}
			}
			System.out.println(ans);
			System.gc();
		}
	}

}

Measured memory_bytes: 39056
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,i,cntr=0;
    cin>>n;
    string s;
    map<string, int> gacha;
    for(i=0; i<n; i++){
        cin>>s;
        gacha[s]++;
        if(gacha[s]==1){
            cntr++;
        }
    }
    cout<<cntr<<endl;
    return 0;
}

Measured memory_bytes: 19068
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a[10],i,j;
for(i=0;i<10;i++){
cin>>a[i];
}
for(i=0;i<10;i++){
for(j=9;j>i;j--){
if(a[i]<a[j]){
swap(a[i],a[j]);
}
}
}
for(i=0;i<3;i++){
cout<<a[i]<<endl;
}
return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
using namespace std;
long long int k;
char s[101];
int  len; 
int main(void){
	
	while( scanf("%s",s)!=EOF ){
  	 	  scanf("%lld",&k);
          len = strlen(s); 
	      if( len == 0)
	        break;
		  for( int i=0;i<len;i++){
		    if(  s[i] == '1' ){
		    	 if( k == 1 ){
		    	 	 printf("%c\n",s[i]);
		    	 	 break;
				 }
		    	 else k--;
		 	}
		    else{  
		   	      printf("%c\n",s[i]);
		           break;
			 }
 }
}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)

int main() {
    ll N;
    cin >> N;
    ll count = 0;
    rep(i, N + 1) {
        count += i;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;
     
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    string s;
    cin >> s;
    int bal = 0, minx = 0;
    rep(i, 0, n)
    {
        if (s[i] == '(')
            bal++;
        else
            bal--;
        minx = min(minx, bal);
    }
    bal += -minx;
    rep(i, 0, -minx)
        cout << '(';
    cout << s;
    rep(i, 0, bal)
        cout << ')';
    cout << endl;
    return 0;
}

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

int n;
int s[105] = {0};
int dp[105][15] = {0};

int solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> s[i];
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int i = 0; i < 10; ++i) dp[0][i] = -1;
  for(int i = 0; i < n; ++i) {
    if(i != 0) {
      for(int j = 0; j < 10; ++j) dp[i][j] = dp[i - 1][j];
      for(int j = 0; j < 10; ++j)
        if(dp[i - 1][j] != -1)
          dp[i][(j + s[i]) % 10] = max(
              dp[i][(j + s[i]) % 10], dp[i - 1][j] + s[i]);
    }
    dp[i][s[i] % 10] = max(dp[i][s[i] % 10], s[i]);
  }
  for(int i = 1; i < 10; ++i) ans = max(ans, dp[n - 1][i]);
  return ans;
}

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

int main(){
  int N;
  cin >> N;
  unordered_map<string,int> mp;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  
  long long ans = 0;
  
  for(auto &i : mp){
    int a = i.second;
    ans += (long long)a*(a-1)/2;
  }

  cout << ans << endl;
  
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> d(n);
	int i,s,count = 0;
	for(i = 0;i < n;i++)cin >> d.at(i);
	for(i = 0;i < n-1;i++){
		for(s = i+1;s < n;s++){
			count += d.at(i) * d.at(s);
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3612
#include <cstdio>
 
using namespace std;
 
int n, r;
int cards[2][51];
 
int main() {
  while (true) {
    scanf("%d %d", &n, &r);
    if (n == 0 && r == 0) break;
    for (int i=0;i<n;i++) cards[0][i] = n-i;
    for (int i=0;i<r;i++) {
      int p, c;
      scanf("%d %d", &p, &c);
      for (int j=0;j<c;j++) {
        cards[(i+1)&1][j] = cards[i&1][p-1+j];
      }
      for (int j=0;j<p-1;j++) {
        cards[(i+1)&1][c+j] = cards[i&1][j];
      }
      for (int j=p-1+c;j<n;j++) {
        cards[(i+1)&1][j] = cards[i&1][j];
      }
    }
    printf("%d\n", cards[r&1][0]);
  }
}


Measured memory_bytes: 2660
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	string s,t;
	cin >> s >> t;
	s += t;
	int x = stoi(s);
	for (int i = 0; i*i < 100100; i++) {
		if (i*i == x) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#define MAX_LEN 200

char w[MAX_LEN + 1];
char t[MAX_LEN + 1];

void initArray(char *array)
{
	for (int i = 0; i < MAX_LEN + 1; i++)
	{
		array[i] = 0;
	}
}

int getLength(char *w)
{
	int len = 0;
	for (int i = 0; i < MAX_LEN + 1; i++)
	{
		if (w[i] != 0)len++;
	}
	return len;
}

int match(char *w1, char *w2)
{
	int w1_len = getLength(w1);
	int w2_len = getLength(w2);

	int len = (w1_len <= w2_len) ? w1_len : w2_len;

	for (int i = 0; i < len; i++)
	{
		if (w1[i] == w2[i])
		{
			continue;
		}
		else if (w1[i] < w2[i])
		{
			return -1;
		}
		else
		{
			return 1;
		}
	}
	if (w1_len == w2_len) return 0;
	if (w1_len <  w2_len) return -1;
	if (w1_len >  w2_len) return 1;
}

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

	int p1 = 0;
	int p2 = 0;
	for (int i = 0; i < n; i++)
	{
		initArray(w);
		initArray(t);
		scanf("%s %s", w, t);

		int res = match(w, t);
		if (res > 0) p1 += 3;
		if (res < 0) p2 += 3;
		if (res == 0)
		{
			p1 += 1;
			p2 += 1;
		}
	}
	std::cout << p1 << " " << p2 << std::endl;
}


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

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    long long H, W, x, y;
    cin >> W >> H >> x >> y;
    printf("%.8lf ", 1.0 * H * W / 2.0);
    if (x * 2 == W && y * 2 == H) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).ToArray();
        var n = line[0]; var m = line[1];
        var l = new List<int>();
        for (var i = 0; n > i; i++)
        {
            l.Add(2);
        }
        for (var i = 0; m > i; i++)
        {
            l.Add(1);
        }
        var count = 0;
        for (var i = 0; n + m > i; i++)
        {
            for (var j = 0; n + m > j; j++)
            {
                if (i == j)
                    continue;
                if ((l[i] + l[j]) % 2 == 0)
                    count++;
            }
        }
        Console.WriteLine(count / 2);
    }
}



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

typedef long long lint;

int a[100010],n,k,maxn=-1e9-1,sum=0;
lint ans=0;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++){
		if(a[i]<0) sum++;
		if(-abs(a[i])>maxn) maxn=-abs(a[i]);
		ans+=abs(a[i]);
	}
	if(sum%2==0) cout<<ans<<endl;
	else cout<<ans+2*maxn;
	return 0;
}

Measured memory_bytes: 640
from collections import defaultdict as dd
from itertools import permutations as p

d=dd(list)
a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)

for i in p(range(1,5)):
  a=i[0]
  for j in i[1:]:
    if not j in d[a]:
      break
    a=j
  else:
    print("YES")
    break
else:
  print("NO")

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    repd(i, K, N) {
        if (A[i] > A[i - K]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int k,x; cin >> k >> x;
  int l = x-k+1, r = x+k-1;
  repz(i,l,r+1){
    cout << i;
    if(i==r) cout << endl;
    else cout << " ";
  }
  return 0;
}


Measured memory_bytes: 256
k = int(input())

la = [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(la[k-1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
bool sosu(int n) {
  if (n <= 1)
    return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return false;
  return true;
}
int main() {
  int b, ans[4] = {};
  string s;
  char a;
  while (cin >> b >> a >> s) {
    if (s == "A")
      ans[0]++;
    else if (s == "B")
      ans[1]++;
    else if (s == "O")
      ans[3]++;
    else
      ans[2]++;
  }
  rep(i, 4) { cout << ans[i] << endl; }
  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

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

  ll ans = (1000000 - N) % 1000;

  cout << ans << endl;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
class Main {
    static StringBuilder builder = new StringBuilder();
 
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                System.in));
        final String[] str = reader.readLine().split(" ");
        
        System.out.println(String.valueOf(getReversePolishResult(str)));
    }
 
    private static int getReversePolishResult(final String str[]){
    	ArrayList<Integer> list = new ArrayList<Integer>();
    	for(int i = 0;i < str.length;++i){
    		final int lastIndex = list.size();
    		switch(str[i].charAt(0)){
    		case '+':{
    			final int num = list.get(lastIndex - 2) + list.get(lastIndex - 1);
    			list.remove(lastIndex - 1);
    			list.remove(lastIndex - 2);
    			list.add(num);
    			break;
    		}
    		case '-':{
    			final int num = list.get(lastIndex - 2) - list.get(lastIndex - 1);
    			list.remove(lastIndex - 1);
    			list.remove(lastIndex - 2);
    			list.add(num);
    			break;
    		}
    		case '*':{
    			final int num = list.get(lastIndex - 2) * list.get(lastIndex - 1);
    			list.remove(lastIndex - 1);
    			list.remove(lastIndex - 2);
    			list.add(num);
    			break;
    		}
    		default:
    			list.add(Integer.parseInt(str[i]));
    			break;
    		}
    	}
    	
    	return list.get(0);
    }
}

Measured memory_bytes: 24436
#include <iostream>

int main() {
	int num[28]= {},getnum = 0;
	int f[31] = {};
	for (int i = 0; i < 28; i++) {
		std::cin >> num[i];
	}
	for (int j = 0; j < 28; j++) {
		getnum = num[j];
		f[getnum] = 1;
	}
	
	for (int k = 1; k < 31; k++) {
		if (f[k] == 0) {
			std::cout << k << std::endl;
		}
	}

	return 0;

}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  vector<int> red(N, 0), green(N, 0), blue(N, 0);
  
  for(int i = N - 1; i >= 0; i--){
    if(S[i] == 'R') red[i]++;
    else if(S[i] == 'G') green[i]++;
    else blue[i]++;
    
    if(i < N - 1){
      red[i] += red[i + 1];
      green[i] += green[i + 1];
      blue[i] += blue[i + 1];
    }
  }
  
  long long count = 0;
  
  for(int i = 0; i < N - 2; i++){
    for(int j = i + 1; j < N - 1; j++){
      if(S[i] == S[j]) continue;
      
      if((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')){
        count += blue[j + 1];
        if(j + j - i < N && S[j + j - i] == 'B') count--;
      }else if((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G')){
        count += red[j + 1];
        if(j + j - i < N && S[j + j - i] == 'R') count--;
      }else{
        count += green[j + 1];
        if(j + j - i < N && S[j + j - i] == 'G') count--;
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
void solve()
{
	string s;
	cin>>s;
	int n=s.size();
	if(s[n-1]=='2'||s[n-1]=='4'||s[n-1]=='5'||s[n-1]=='7'||s[n-1]=='9')
	cout<<"hon";
	else if(s[n-1]=='0'||s[n-1]=='1'||s[n-1]=='6'||s[n-1]=='8')
	cout<<"pon";
	else
	cout<<"bon";
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


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

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  int n = 1000;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; ++j) {
      if (i == j) continue;
      if (n > a[i] + a[j]) {
        n = a[i] + a[j];
      }
    }
  }
  cout << n << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void min_three(long int a,long int b,long int c){
    long  int ans = a * b;
    if(ans >= b * c){
        ans = b * c;
    }
    if(ans >= a * c){
        ans = a * c;
    }
    printf("%ld\n",ans);
}

int main(void){

    long int A,B,C,i;

    scanf("%ld %ld %ld",&A,&B,&C);

    if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
        printf("0\n");
        return 0;
    }

    min_three(A,B,C);
    return 0;
}


Measured memory_bytes: 128
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, k, s = list(map(int,ipti().split()))
    a = [s] * n

    for i in range(n-k):
        a[i] = (a[i] + i%5 + 1) % 10**9

    print(*a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 46140
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
typedef long long int ll;

int main() {
	int a, b;
	cin >> a >> b;
	std::cout << std::max({a+b, a-b, a*b}) << std::endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long N = input[0];
			long M = input[1];
			long count = 0;
			long quotient = N / M;
			count = quotient > 0 ? M / 2 : N + (M - 2 * N) / 4;
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    if (B*2 > A) {
        cout << 0 << endl;
    }
    else {
        cout << A - B * 2 << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		 int n = readInt(r);
		 int[] s = strAryToIntAry(r.readLine().split(" "));
		 int q = readInt(r);
		 int[] t = strAryToIntAry(r.readLine().split(" "));

		 System.out.println(search(s, t));
	}

	public static int search(int[] s,int[] t){
		int sum = 0;
		for(int i = 0 ; i < t.length ; i++ ){
			if(binarySearch(s,t[i])) sum++;
		}
		return sum;
	}

	public static boolean binarySearch(int[] s,int key){
		int left = 0;
		int right = s.length - 1;
		int mid;
		while(left <= right){
			mid = (left+right)/2;
			if(key == s[mid]){
				return true;
			}else if(key < s[mid]){
				right = mid - 1;
			}else{
				left = mid + 1;
			}
		}
		return false;
	}

	public static int readInt(BufferedReader r) throws Exception{
        return Integer.parseInt(r.readLine());
    }

	public static int[] strAryToIntAry(String[] strAry){
		int arraySize = strAry.length;
		int[] intAry= new int[arraySize];
		for(int i = 0 ; i < arraySize ; i++){
			intAry[i] =Integer.parseInt(strAry[i]);
		}

		return intAry;
	}

}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,k;
    cin >> n >> k;

    if(2*k-1<=n)
        cout << "YES\n";
    else
        cout << "NO\n";

    return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

using ll = long long;
int N;
ll A[302][302];
ll B[302][302];
bool used[302][302];
int main() {
    cin >> N;

    ll ans = 0;
    rep(i, N) rep(j, N) cin >> A[i][j];
    rep(i, N) rep(j, N) B[i][j] = A[i][j];
    rep(k, N) rep(i, N) rep(j, N) {
        ll t = B[i][k] + B[k][j];
        if (B[i][j] > t) {
            B[i][j] = t;
        }
        if (k != i && j != k && B[i][j] == t) {
            // printf("%d -> %d (%d)\n", i, j, k);
            used[i][j] = true;
            // printf("%d %d: %d\n", i, j, t);
            // ans -= t;
        }
    }
    rep(i, N) rep(j, N) {
        if(A[i][j] != B[i][j]) {
            cout << "-1" << endl;
            return 0;
        }
    }

    rep(i, N) rep(j, N) ans += A[i][j];
    rep(i, N) rep(j, N) if(used[i][j]) ans -= A[i][j];
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var k, a, b int
	fmt.Scan(&k)
	fmt.Scan(&a, &b)
	if k == 0 {
		fmt.Println("NG")
		return
	}
	var res = (b / k) * k
	if a <= res {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}


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

using namespace std;
#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__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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


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

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

  vector<int> p(110);

  rep(i, n){
    int tp;
    cin >> tp;
    p[tp] = 1;
  }

  int min_val = 200;
  rep(i, 0, 110){
    if(p[i] == 0){
      chmin(min_val, abs(x-i));
    }
  }

  rep(i, 0, 110){
    if(p[i]==0){
      if(min_val == abs(x-i)){
        cout << i << endl;
        break;
      }
    }
  }





  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a,b;
    char c;
    cin>>a>>c>>b;
    if(((a&&b)>=1)&&((a&&b)<=pow(10,9)))
    {
        if(c=='+')
            cout<<a+b;
        else if(c=='-')
            cout<<a-b;
    }
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

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

  ll n;
  ll a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >>e;
  ll min_cost = min({a, b, c, d, e});

  cout << (n+min_cost-1) / min_cost + 4 << '\n';
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class AtCoderB
{
    static void Main()
    {
        List<string> list = new List<string>();
        list.AddRange(new string[]{"A", "B", "C", "D", "E", "F", "G", "H", "I",
                                   "J", "K", "L", "M", "N", "O", "P", "Q", "R",
                                   "S", "T", "U", "V", "W", "X", "Y", "Z"});

        int n = int.Parse(Console.ReadLine());
        string s = Console.ReadLine();

        string answer = "";
        for (int i = 0; i < s.Length; i++)
        {
            string c = s.Substring(i, 1);
            int index = list.IndexOf(c);
            int newIndex = (index + n) % 26;
            answer += list[newIndex];
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 35028
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << "[DBG] " << #X << "=" << (X) << '\n';
	#define SAY(X) cout << "[SAY] " << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = 2007;
struct PrefixSum {
	int a[MAXN][MAXN], pref[MAXN][MAXN];
	void set(int i, int j, int v) {
		a[i][j] = v;
	}
	void init(int n, int m) {
		for(int i = 1; i <= n; ++i) {
			for(int j = 1; j <= m; ++j) pref[i][j] = pref[i][j - 1] + a[i - 1][j - 1];
			for(int j = 1; j <= m; ++j) pref[i][j] += pref[i - 1][j];
		}
	}
	int geta(int i, int j) {
		return a[i][j];
	}
	int getp(int il, int jl, int ir, int jr) {
		if(il > ir || jl > jr) return 0;
		++ir, ++jr;
		return pref[ir][jr] - pref[il][jr] - pref[ir][jl] + pref[il][jl];
	}
};

PrefixSum A, V, H;
int n, m, q;

void solve() {
	cin >> n >> m >> q;
	for(int i = 0; i < n; ++i) {
		auto S = fetch<string>();
		for(int j = 0; j < m; ++j) A.set(i, j, S[j] - '0');
	}
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m - 1; ++j) {
			H.set(i, j, A.geta(i, j) && A.geta(i, j + 1));
		}
	}
	for(int i = 0; i < n - 1; ++i) {
		for(int j = 0; j < m; ++j) {
			V.set(i, j, A.geta(i, j) && A.geta(i + 1, j));
		}
	}
	A.init(n, m);
	H.init(n, m);
	V.init(n, m);
	while(q--) {
		int il = fetch<int>() - 1;
		int jl = fetch<int>() - 1;
		int ir = fetch<int>() - 1;
		int jr = fetch<int>() - 1;
		//int vertecies = A.getp(il, jl, ir, jr);
		//DBG(vertecies);
		cout << A.getp(il, jl, ir, jr) - H.getp(il, jl, ir, jr - 1) - V.getp(il, jl, ir - 1, jr) << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

int main()
{
	int a, b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a==b)
		printf("%d\n", c);

	else if(a==c)
		printf("%d\n", b);

	else 
		printf("%d\n", a);

	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int mod = 1e9 + 7;
const int N = 1e5 + 5;
int n, m;
ll x, y, p, t;

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

    cin >> p;
    for (int i = 1; i < n; ++i) {
        cin >> t;
        ll v = t - p;
        ll left = i;
        ll right = n - i;
        x = (x + left * right * v % mod) % mod;
        p = t;
    }
    cin >> p;
    for (int i = 1; i < m; ++i) {
        cin >> t;
        ll v = t - p;
        ll left = i;
        ll right = m - i;
        y = (y + left * right * v % mod) % mod;
        p = t;
    }
    ll ans = x * y % mod;
    cout << ans << endl;
    return 0;
}


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

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '2' && n[1] == '5')
                Console.WriteLine("Christmas");

            if (n[0] == '2' && n[1] == '4')
                Console.WriteLine("Christmas Eve");

            if (n[0] == '2' && n[1] == '3')
                Console.WriteLine("Christmas Eve Eve");

            if (n[0] == '2' && n[1] == '2')
                Console.WriteLine("Christmas Eve Eve Eve");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    ll flag = 0;
    ll now = 1;
    rep(i,N){
        ll a;
        cin>>a;
        if(a==0){
            cout<<0<<endl;
            return 0;
        }
        
        if(now >1000000000000000000/a ){
            flag = 1;
        }

        now *= a;

    }

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


    return 0;
    

}

Measured memory_bytes: 3636
N_MAX = 10**6
MOD = 998244353
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX


def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD


def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
    # return fac[n] * (finv[k] * finv[n - k]) % MOD


def main():
    com_init()
    n, m, k = map(int, input().split()) 

    ans = 0
    for i in range(0,k+1):
        ans += (m * com(n-1,i) * pow(m-1,n-i-1,MOD))
        ans %= MOD
    print(ans%MOD)



if __name__ == "__main__":
    main()



Measured memory_bytes: 96496
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> h(n+1);
	for(int i=1; i<=n; i++)
		cin>>h[i];
	h[0]=h[1];
	vector<ll> dp(n+1);
	dp[0]=dp[1] = 0;
	for(int i=2; i<=n; i++)
	{
		ll h1 = h[i];  
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n];
	return 0;
}
	

Measured memory_bytes: 1792
#include <stdio.h>
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var x = Console.ReadLine().Split(' ');
            var r = int.Parse(x[0]);
            var c = int.Parse(x[1]);

            var s = new List<List<int>>();

            for (int i = 0; i < r; i++)
            {
                var a = Console.ReadLine().Split(' ');
                var list = new List<int>();

                foreach (var aa in a)
                {
                    list.Add(int.Parse(aa));
                }
                list.Add(list.Sum());
                s.Add(list);
            }

            foreach (var S in s)
            {
                for (var i = 0; i < S.Count; i++)
                {
                    Console.Write(S[i]);
                    if (i != c)
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }

            for (int i = 0; i <= c; i++)
            {
                var sum = 0;
                foreach (var S in s)
                {
                    sum += S[i];
                }
                Console.Write(sum);
                if (i != c)
                {
                    Console.Write(" ");
                }
            }

            Console.WriteLine();
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9828
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
#define mp make_pair

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef pair<int, int> P;
//typedef pair<int, pair<int, int> > PP;
//const int MAX=;



int main(){
	int N,L;
	cin>>N>>L;
	int a[205];
	rep1(i,N)a[i]=L+i-1;
	int s;
	s=0;
	rep1(i,N)s+=a[i];
	
	int ans=10000000;
	rep1(i,N)if(abs(s-ans)>abs(a[i]))ans=s-a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define mk make_pair
#define pb push_back
#define vi vector<int>
// #define x first
// #define y second
#define ms(a,b)  memset(a, b, sizeof(a))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define M 1000005
signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int n;cin>>n;
    int a,b,c,x,y,z,p,q,r;
    cin>>x>>y>>z;
    for(int i=1;i<n;i++){
        cin>>a>>b>>c;
         p= a+max(y,z);
         q= b+max(x,z);
         r= c+max(x,y);
         x=p,y=q,z=r;
    }
    cout<<max(x,max(y,z));
    return 0;
}

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

using namespace std;

int c[100][100];
int main(){
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++) cin >> a[i];
    int k,count;
    k = count = 0;
    for(int i = 0;i < h;i++){
        if(i%2){
            for(int j = 0;j < w;j++){
                c[i][j] = k+1;
                count++;
                if(count == a[k]){
                    k++;
                    count = 0;
                }
            }
        }
        else{
            for(int j = w-1;j >= 0;j--){
                c[i][j] = k+1;
                count++;
                if(count == a[k]){
                    k++;
                    count = 0;
                }
            }
        }
    }
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cout << c[i][j] << " ";
        }cout << endl;
    }
}


Measured memory_bytes: 384
let a, b, c, x, y = Scanf.sscanf (read_line ()) "%d %d %d %d %d" @@ fun a b c x y -> (a, b, c, x, y)

let buy_a n = if c * 2 < a then n * c * 2 else n * a
let buy_b n = if c * 2 < b then n * c * 2 else n * b

let () = Printf.printf "%d\n" @@
  if a + b >= c * 2 then 
    2 * c * (min x y) + if x > y then buy_a (x - y) else buy_b (y - x)
  else buy_a x + buy_b y

Measured memory_bytes: 3848
#include <stdio.h>
int main(void){
    int a,b,s;
    char op;
    scanf("%d %c %d",&a,&op,&b);
    while(op !='?'){
        if(op=='+'){
            s=a+b;
        }else if(op=='-'){
            s=a-b;
        }else if(op=='/'){
            s=a/b;
        }else if(op=='*'){
            s=a*b;
        }
        printf("%d\n",s);
        scanf("%d %c %d",&a,&op,&b);
    }
    return 0;
}



Measured memory_bytes: 2100
using System;
class Program
{
	static void Main(string[] args)
	{
    string[] value = Console.ReadLine().Split();
    int A = int.Parse(value[0]);
    int B = int.Parse(value[1]);
    int C = int.Parse(value[2]);
    int D = int.Parse(value[3]);
    int E = int.Parse(value[4]);
    int F = int.Parse(value[5]);
    double max = -1.0d;
    int swater = 0;
    int sugar = 0;

    int _swater, _sugar;
    for (int a = 0; a*100 <= F; a += A) {
      for (int b = 0; a*100 + b*100 <= F; b += B) {
        if (a == 0 && b == 0) continue;
        for (int c = 0; a*100 + b*100 + c <= F; c += C) {
          for (int d = 0; a*100 + b*100 + c + d <= F; d += D) {
            if ((a + b) * E < c + d) break;
            _swater = a*100 + b*100 + c + d;
            _sugar = c + d;
            if (_sugar / (double)_swater > max) {
              max = _sugar / (double)_swater;
              swater = _swater;
              sugar = _sugar;
            }
          }
        }
      }
    }
    Console.WriteLine("{0} {1}", swater, sugar);
	}
}


Measured memory_bytes: 13140
N, M = map(int, input().split())
P = list(map(int, input().split()))

class UnionFind:
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

res = 0
uf = UnionFind(N)
for _ in range(M):
    x, y = map(int, input().split())
    uf.union(x-1, y-1)

for i, e in enumerate(P):
    if uf.same(i, e-1):
        res += 1

print(res)


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<bool> check(200, true);
    string S;
    cin >> S;
    vector<char> stock;
    for (int i = 0; i < S.length(); ++i) {
        check[S[i]] = false;
    }
    if (S.length() == 'z' - 'a' + 1) {
        stock.push_back(S[S.length() - 1]);
        for (int i = S.length() - 2; i >= 0; --i) {
            char answer = 'z' + 1;
            for (int j = 0; j < stock.size(); ++j) {
                if (S[i] < stock[j]) {
                    answer = min(answer, stock[j]);
                }
            }
            if (answer != 'z' + 1) {
                cout << S.substr(0, i) << answer << endl;
                return 0;
            }
            stock.push_back(S[i]);
        }
        cout << -1 << endl;
    } else {
        for (int i = 'a'; i <= 'z'; ++i) {
            if (check[i]) {
                cout << S << (char)i << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=input()
    T=input()
    for i in range(len(S)):
        if S==T[i:]+T[:i]:
            YesNo(1)
            exit()
    YesNo(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;

vector<int> e[100001];

struct Data
{
  int num;
  int depth;
  int sibl;
  int parent;
};


int main(){
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n-1; i++){
    int a, b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  int mod = 1000000007;
  long long ans = 1;
  queue<Data> Q;
  Q.push({1, 0, 0, -1});
  while (!Q.empty()) {
    Data d = Q.front();
    Q.pop();
    ans = (ans * (long long)(k - min(d.depth, 2) - d.sibl)) % mod;
    int sibl = 0;
    for (int i = 0; i < e[d.num].size(); i++) {
      if (e[d.num][i] == d.parent) {
        continue;
      }
      Q.push({e[d.num][i], d.depth + 1, sibl++, d.num});
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7800