akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string S;
	cin >> S;
	string S2 = S;
	reverse(S2.begin(), S2.end());
	FOR(i, 0, S2.length()) {
		if (S2[i] == 'b')   S2[i] = 'd';
		else if (S2[i] == 'd') S2[i] = 'b';
		else if (S2[i] == 'p')S2[i] = 'q';
		else S2[i] = 'p';
	}
	if (S2 == S) {
		O("Yes");
	}
	else {
		O("No");
	}


	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
	using namespace std;
	int  m[1000000];
	vector<int>h;
	int n;
	int fun(int i,int k)
	{
	  if(i==n-1)
	   return 0;
	   
	   if(m[i]!=-1)
	      return m[i];
	      
	      int ans=fun(i+1,k)+abs(h[i]-h[i+1]);
	      
	      for(int j=2;j<=k && i+j<n;j++)
	      ans=min( ans , fun(i+j,k)+abs(h[i]-h[i+j]) );
	
	
         return m[i]=ans;	
	
	}
	
	
	
	int main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		
	    memset(m, -1, sizeof(m));	
	   int k;
		cin>>n>>k;
		h.resize(n);
		for(int i=0;i<n;i++)
		 cin>>h[i];
		 
		 int ans=fun(0,k);
		 cout<<ans<<endl;
	
	return 0;
	}


Measured memory_bytes: 12416
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef complex<double> P;

// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

// ベクトルaの絶対値を求める
//double length = abs(a);

// 2点a,b間の距離を求める
//double distance = abs(a-b);

// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
int main()
{
//	cut here before submit 
//	freopen ("testcase.Area_of_Polygons", "r", stdin );
	int n;
	int cnt = 0;
	while (scanf ("%d", &n ), n  ){
		vector<P> p (n );
		rep (i, n ){
			cin >> p[i].real() >> p[i].imag();
		} // end rep
		double sum = 0.0;
		rep (i, n ){
			sum += (cross(p[i], p[(i+1)%n] )/2.-EPS );
		} // end for
		printf ("%d %.1f\n", ++cnt, -sum );		
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    ll k; cin >> k;
    int a[n];
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    //doubling
    int logK=log2(k)+1;
    int doubling[logK][n];
    rep(i,n){
        doubling[0][i]=a[i];
    }
    rep(j,logK-1){
        rep(i,n){
            doubling[j+1][i]=doubling[j][doubling[j][i]];
        }
    }
    int now=0;
    for(int j=0;k>0;j++){
        if(k&1)now=doubling[j][now];
        k=k>>1;
    }
    cout << now+1 << endl;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<pair<pair<string,int>,int>> p;
    
    for (int i = 0; i < n; i++){
        string temp;
        int t;
        cin >> temp >> t;
        p.emplace_back(make_pair(make_pair(temp,-t),i));
    }
    
    sort(p.begin(),p.end());
    for (auto a : p){
        cout << a.second + 1 << endl;
    }
}

Measured memory_bytes: 3540
# 解説放送の方針
# 平面走査をし、各点について、左上、左下、右上、右下にある点を数え、計算する。
# 解説放送ではBITを2本使っていたが、座標圧縮の結果を利用してBIT１本で済むようにした

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

mod = 998244353

class BIT:
    '''https://tjkendev.github.io/procon-library/python/range_query/bit.html'''
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def query(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)

# 平面走査のためのソート（高速化のため１次元にしてソート）
xy2 = []
for i in range(N):
  x,y = xy[i]
  x += 10**9
  y += 10**9
  xy2.append(y<<80 | x << 40 | i)

# ソート後の復元+座標圧縮用の辞書作成
# 座標圧縮: 小さいyから順に1,2,3...と値を割り振る。
xy2 = sorted(xy2)
mask = (1<<40)-1
y_order=[0]*N
y_compress={}
for j,y in enumerate(xy2):
  i = y & mask
  y >>= 40
  x = y & mask
  x -= 10**9
  y >>= 40
  y -= 10**9
  y_order[i] = j
  y_compress[y] = j+1

xy2 = []
for i in range(N):
  x,y = xy[i]
  x += 10**9
  y += 10**9
  xy2.append(x<<80 | y << 40 | i)
  
xy2 = sorted(xy2)
mask = (1<<40)-1
bit=BIT(N)
ans = 0
memo=[0]*N

# いちいち2^nを計算していると遅いのでテーブル作成
pow2 = [1]*(N+1)
for i in range(1,N+1):
  pow2[i] = pow2[i-1]*2 %mod

for x in xy2:
  i = x & mask
  x >>= 40
  y = x & mask
  y -= 10**9
  x >>= 40
  x -= 10**9
  
  y = y_compress[y]
  bit.add(y,1)
  '''
  今現在みている点より左上と左下にある点の個数（今の点は含まない。以下同じ）。
  BITを使って求める。
  '''
  n1 = bit.query(y-1,N)-1
  n2 = bit.query(0,y)-1 
  '''
  右上と右下。座標圧縮の結果を利用。(N-y(座標圧縮済))はある点より上にある点の総数。
  そこからn1（走査済みの点の個数)を引くことで、まだ走査していない点の個数を求めることができる。
  '''
  n3 = N-y-n1 
  n4 = y-n2-1
  
  prod14 = (pow2[n1]-1)*(pow2[n4]-1)*pow2[n2+n3] %mod
  prod23 = (pow2[n2]-1)*(pow2[n3]-1)*pow2[n1+n4] %mod
  prod1234 = (pow2[n1]-1)*(pow2[n4]-1)*(pow2[n2]-1)*(pow2[n3]-1) %mod
  ans += pow2[N-1]+prod14+prod23-prod1234
  ans %= mod
  
print(ans)

Measured memory_bytes: 208496
#include <iostream>
 
using namespace std;
 
int main()
{
    int n,i;
    
    cin>>n;
    int h[n+1];
 
    for(i=1;i<=n;i++)
    {
        
        cin>>h[i];
    }
    int dp[n+1];
 
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]) + dp[1];
    for(i=3;i<=n;i++)
    {
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1] , abs(h[i]-h[i-2]) + dp[i-2] );
    }
 
    cout<<dp[n];
 
    return 0;
 
   
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,d;
	cin>>n>>d;
	ll ans=n/(2*d+1)+(n%(2*d+1)>0);
	cout<<ans;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))

minus_num=len([el for el in A if el<0])
#print(minus_num)
new=[abs(el) for el in A]
#print(new)
if minus_num%2==1:
    #print('a')
    #print(sum(new))
    #print(min(new), sum(new))
    print(sum(new)-min(new)*2)
else:
    print(sum(new))

Measured memory_bytes: 14284
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

int ai = -1;
int aj = -1;
string st;
int bal[N][27], best_bal[N],
best_pos[N];

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	for (int i = 0; i < 26; i++)
		best_bal[i] = 1e9;

	cin >> st;
	for (int i = 0; i < st.size(); i++)
	{
		for (int j = 0; j < 26; j++)
		{
			bal[i+1][j] = bal[i][j]-1;
		}
		bal[i + 1][st[i] - 'a'] += 2;

		if (i >= 1)
		{
			for (int j = 0; j < 26; j++)
			{
				if (bal[i - 1][j]<best_bal[j])
				{
					best_bal[j] = bal[i - 1][j];
					best_pos[j] = i - 1;
				}
			}
		}

		for (int j = 0; j < 26; j++)
		{
			if (bal[i+1][j]>best_bal[j])
			{
				ai = best_pos[j]+1;
				aj = i + 1;
					break;
			}
		}
	}

	cout << ai << " " << aj << endl;

	cin.get(); cin.get();
	return 0;
}

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

typedef long long ll;

int main(){
	string s;
	cin>>s;
	int ans=700;
	for(int i=0;i<sizeof(s);i++){
		if(s[i]=='o'){
			ans+=100;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	int a;
	scanf("%d",&a);
	
	char str[a+1];
	scanf("%s", &str);

 	int sama = 0;
 	
	for (int i = 0, j = a/2; i < a; i++, j++)
	{
		if (str[i] == str[j])
		{
			sama++;
		}
	}
	
	if (a % 2 == 1)
	{
		puts("No\n");
		return 0;
	}
	
	sama == a/2 ? puts("Yes\n") : puts("No\n");
	
	return 0;
}

Measured memory_bytes: 1588
N, Q = map(int, input().split())
S = input()
t = [0 for _ in range(len(S)+1)]

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:(i+2)] == "AC" else 0)
    
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    int A, B, K;
    cin >> A >> B >> K;

    set<int> ans;

    for (int i = 0; i < K and A + i <= B; ++i)
        ans.insert(A + i);

    for (int i = 0; i < K and B - i >= A; ++i)
        ans.insert(B - i);

    for (const auto x : ans)
        cout << x << '\n';

    return 0;
}


Measured memory_bytes: 256
import math
a,b,h,m=map(int,input().split())
zi=(h*60+m)/720*2*math.pi
hun=m/60*2*math.pi
xzi=a*math.sin(zi)
yzi=a*math.cos(zi)
xhun=b*math.sin(hun)
yhun=b*math.cos(hun)
p=(xzi-xhun)**2+(yzi-yhun)**2
print('{:.18f}'.format(math.sqrt(p)))

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

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}

//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}



int main(){
  ll a, b;
  cin >> a >> b;
  if(a != b) {
    rep(i, max(a, b)){
      cout << min(a, b);
    }
  }
  else{
    rep(i, a){
      cout << a ;
    }
  }
}

 

Measured memory_bytes: 256
from bisect import bisect_left

N, M = map(int, input().split())
P, Y = [], []
v = [[] for _ in range(N+1)]

for i in range(M):
    p, y = map(int, input().split())
    P += [p]
    Y += [y]
    v[p] += [y]

for i in range(N+1):
    v[i].sort()

for x, y in zip(P, Y):
    print ("%06d" % x, end = "")
    print ("%06d" % int(bisect_left(v[x], y) + 1))


Measured memory_bytes: 24172
import itertools
import sys
input = sys.stdin.readline

def warshall_floyd(D, n):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    D[i][j] = min(D[i][j], D[i][k]+D[k][j])

def main():
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))
    D = [[float('inf')]*N for _ in range(N)]
    for i in range(N):
        D[i][i] = 0
    for _ in range(M):
        a, b, c = map(int, input().split())
        D[a-1][b-1] = c
        D[b-1][a-1] = c

    warshall_floyd(D, N)

    ans = float('inf')
    for P in itertools.permutations(r):
        cost = 0
        for i in range(R-1):
            cost += D[P[i]-1][P[i+1]-1]
        ans = min(ans, cost)

    print(ans)


if __name__ == '__main__':
    main()

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

int main()
{
  int n,i;
  cin >> n;
	for (i = n; ; i++)
    {
      bool f = true;
     for (int j = 2; j * j <= i; j++) 
     {
       if (__gcd(j,i) != 1)
         f = false;
     }
      if (f)
        break;
    }
  cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
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;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n;
    cin>>n;
    vector<vector<ll>>cnt(n,vector<ll>(26,0));
    rep(i,0,n){
        string o;
        cin>>o;
        rep(j,0,o.size()){
            cnt[i][o[j]-'a']++;
        }
    }
    vector<ll>ans(26,0);
    rep(j,0,26){
        ll t=LLONG_MAX;
        rep(i,0,n){
            t=min(cnt[i][j],t);
        }
        ans[j]=t;
    }
    string s; 
    rep(j,0,26){
        if(ans[j]>0){
            string t=string(ans[j],j+'a');
            s+=t;
        }
    }
    cout<<s<<endl;


    
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void printMissing(String str, boolean[] tar) {
        for(int i=0;i<13;i++) {
            if(tar[i] == false) {
                System.out.println(str + " " + (i+1));
            }
        }
    }
    public static void main(String[] args) {
        boolean[] s = new boolean[13];
        boolean[] h = new boolean[13];
        boolean[] c = new boolean[13];
        boolean[] d = new boolean[13];
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        in.nextLine();
        for(int i=0;i<n;i++) {
            String str = in.nextLine();
            String[] lr = str.split(" ");
            int target = Integer.parseInt(lr[1]) - 1;
            switch (lr[0]) {
                case "S":
                    s[target] = true;
                    break;
                case "H":
                    h[target] = true;
                    break;
                case "C":
                    c[target] = true;
                    break;
                case "D":
                    d[target] = true;
                    break;
            }
        }
        printMissing("S", s);
        printMissing("H", h);
        printMissing("C", c);
        printMissing("D", d);
    }
}

Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

template<typename T, typename U> 
T modpow(T a, U n, ll M) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % M;
        a = a * a % M;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll K;
    cin >> K;
    if(K%2 == 0){
        cout << -1 << endl;
        return 0;
    }
    if(K == 7){
        cout << 1 << endl;
        return 0;
    }
    vector<ll> v(10*K);
    v[0] = 0;
    rep(i,10*K){
        v[i+1] = (v[i]*10 % K) + 7;
        v[i+1] %= K;
        if(v[i+1] == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 81336
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    ret = 1
    while N:
        N -= 1
        if ret+K < ret*2:
            ret = ret+K
        else:
            ret = ret*2
    
    print(ret)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))

minus_cnt = 0
abs_sum = 0
min_abs_val = 1000000000
for i in range(N):
    val = A[i]
    abs_val = abs(val)
    abs_sum += abs_val
    if abs_val < min_abs_val:
        min_abs_val = abs_val
    if val < 0:
        minus_cnt += 1

B_max_sum = abs_sum
if (minus_cnt % 2 != 0) and (min_abs_val != 0):
    B_max_sum -= (min_abs_val * 2)

print(B_max_sum)



Measured memory_bytes: 19988
import java.util.Scanner;

public class Main {
	public static void main(String[] rags) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int[] list = new int[n];

		for(int i =0;i < n - 1;i++) {
			list[scan.nextInt() - 1] += 1;
		}

		for(int i = 0;i < n;i++) {
			System.out.println(list[i]);
		}
	}
}


Measured memory_bytes: 70348
import numpy as np

_,*_t=[list(map(int,i.split())) for i in open(0)]
n=_[0]
m=_[1]
x=_[2]
table=np.array(_t)
value=9000000


def boolAchieve(nums):
  for i in range(1,m+1):
    if nums[i]<x:
      return False
  return True

  
def makeBoolList(nums):
  ls=[]
  sNums=str(nums)
  for i in range(len(sNums)):
    if sNums[i]=="0":
      ls.append(False)
    else:
      ls.append(True)
  return ls


tmp=np.sum(table,axis=0)
if not boolAchieve(tmp):
  print(-1)
  exit()


for i in range(1,2 ** n):
  row=format(i,'b').zfill(n)
  selects=makeBoolList(row)
  picks=np.sum(table[selects,:],axis=0)
  if not boolAchieve(picks):
    continue
  value=min(value,picks[0])

  
print(value)

Measured memory_bytes: 27340
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int n,a[999];
int main(){
int i;
for (n=read(),i=1;i<=n*2;++i) a[i]=read();
int llx=0;
for (sort(a+1,a+n*2+1),i=1;i<=n*2;i+=2) llx+=a[i];
write(llx);
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    long double v[n];
    for(int i=0; i<n; i++) {
        cin >> v[i];
    }
    long double dp[n+1][n+1];
    memset(dp, 0, sizeof dp);
    for(int i=0; i<=n; i++) {
        if(i*2>n)
            dp[n][i] = 1;
    }
    for(int i=n-1; i>=0; i--) {
        for(int j=i; j>=0; j--) {
            dp[i][j] = dp[i+1][j+1] * v[i] + dp[i+1][j] * (1-v[i]);
        }
    }
    cout << fixed << setprecision(10) << dp[0][0] << '\n';
    return 0;
}

Measured memory_bytes: 140928
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a <= b) cout << a << endl;
	else cout << a - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                ll a, b, c, d;
                cin>>a>>b>>c>>d;
                cout<< max(a*c, max(a*d, max(b*c, b*d)));
        }
        return 0;
}

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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    for(int i=1;i<B+1;i++){
        if(A*i%B==C){
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}

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

int main() {
    int mod=1e9+7;
    int h,w,k;cin>>h>>w>>k;
    int dp[h+1][w]{};
    dp[0][0]=1;
    for (int i=0;i<h;i++)
        for (int j=0;j<1<<w-1;j++) {
            int f=0;
            for (int l=0;l<w-2;l++)
                f|=(j>>l&3)==3;
            if (f)
                continue;
            for (int l=0;l<w;l++) {
                if (j>>l&1)
                    dp[i+1][l+1]=(dp[i+1][l+1]+dp[i][l])%mod;
                else if (1<=l&&j>>l-1&1)
                    dp[i+1][l-1]=(dp[i+1][l-1]+dp[i][l])%mod;
                else
                    dp[i+1][l]=(dp[i+1][l]+dp[i][l])%mod;
            }
        }
    cout<<dp[h][k-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        Set<Integer> multi = new HashSet<>();

        for (int i = 1 ; i <= 9 ; i++) {
            for (int j = 1 ; j <= 9 ; j++) {
                multi.add(i * j);
            }
        }

        int N = scanner.nextInt();
        if (multi.contains(N)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35704
n = int(input())
arr = list(map(int, input().split()))
k = 0
f = 0
while f == 0:
  for i in range(n):
    if arr[i] % 2 != 0:
      f = 1
    else:
      arr[i] //= 2
  k += 1
print(k - 1)

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys


def solve(X: int):
    f=(X//500)*1000
    ft=((X%500)//5)*5
    print(f+ft)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int K, N; cin >> K >> N;
  if (K==1) {
    rep(i,(N+1)/2) cout << 1 << " ";
    cout << endl;
  }
  else if (K%2==0) {
    cout << K/2 << " ";
    rep(i,N-1) cout << K << " ";
    cout << endl;
  }
  else {
    int num[N]; fill_n(num,N,(K+1)/2);
    rep(i,N/2) {
      int pos = N-1;
      while(!num[pos]) pos--;
      if (pos!=N-1) {
        if (num[pos]!=1) repr(i,pos+1,N) num[i] = K;
        num[pos]--;
      }
      else num[pos]--;
      // debug(num,num+N);
    }
    rep(i,N) if (num[i]) cout << num[i] << " "; cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3456
/*
    WRITER:kakitamasziru
*/
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
//#include <unordered_map> // unordered_map
//#include <unordered_set> // unordered_set
#include <bitset> // bitset
//#include <cctype> // isupper, islower, isdigit, toupper, tolower
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const int INF = 1001001000;
const int MOD = 1000000007;
typedef pair<long,long> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

int main() {
    int N,M;cin >> N >> M;
    vector<P> retu(N);
    vector<P> za(M);
    for(int i = 0;i<N;i++) cin >> retu.at(i).first >> retu.at(i).second;
    for(int i = 0;i<M;i++) cin >> za.at(i).first >> za.at(i).second;
    long long count = INF;
    long long num = INF;
    vector<int> ans(N);

    for(int i = 0;i<N;i++){
        for(long long j = 1;j<=M;j++){
            long long dist = abs(retu.at(i).first-za.at(j-1).first)+abs(retu.at(i).second-za.at(j-1).second);
            if(dist <= count){
                if(dist == count) continue;
                count = min(count,dist);
                
                num = j;
            }
            //cout << num << endl;
        }
        ans.at(i) = num;
        //num = INF;
        count = INF;
    }

    for(int i = 0;i<N;i++)cout << ans.at(i) << endl;

    /*
    g++ abc.cpp
    ./a.out
    */
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <cctype>
using namespace std;

int main(){
    int n;
    int x, y, z;
    cin >> n;
    x = n / 500;//五百円の数//
    y = n % 500;//五百で割った数//
    z = y / 5;//五で割った数//
    cout << 1000*x + z*5 << endl;
    return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        String input = Console.ReadLine();
        String input2 = Console.ReadLine();
        bool flag = true;
        for(int i = 0; i < input.Length; i++)
        {
            if (input[i] != input2[i]) flag = false;
        }
        if (flag) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }
    }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n,x[maxn];
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cin>>n;
  for (int i=0; i<n; i++) {
    cin>>x[i];
  }

  int ans = 2e9;
  for (int j=1; j<=100; j++) {
    int cur = 0;
    for (int i=0; i<n; i++) {
      cur += (x[i]-j)*(x[i]-j);
    }
    ans = min(ans,cur);
  }
  cout<<ans<<endl;
  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 256
N = int(input())
A_list = [int(e) for e in input().split()]

#全通りは 2**(N-1)なのでTLEする

#操作を考えると、-に対しては移動or打ち消しとなる。
#繰り返していくと-はどんどん打ち消される。
#最終的には
# - が奇数個 : 1個だけ残る。absをsumしたものから、abs最小分を引けばよい
# - が偶数個 : 全てが打ち消される。 ∴absをsumればOK

min_abs_A = 7 + 10**9
cnt_minus_in_A = 0
sum_abs_A = 0

for A in A_list:
    if A < 0:
        cnt_minus_in_A += 1
        
    if abs(A) < min_abs_A:
        min_abs_A = abs(A)
    
    sum_abs_A += abs(A)
    
if cnt_minus_in_A % 2 == 0:
    print(sum_abs_A)
else:
    print(sum_abs_A - 2*min_abs_A)

Measured memory_bytes: 19912
#include <stdio.h>

void print_day (int d){
	int i = d % 7;
	if (i==0) printf ("Monday\n");
	else if (i==1) printf ("Tuesday\n");
	else if (i==2) printf ("Wednesday\n");
	else if (i==3) printf ("Thursday\n");
	else if (i==4) printf ("Friday\n");
	else if (i==5) printf ("Saturday\n");
	else printf ("Sunday\n");
}

int main(void) {
	const int DAY_JUN_1ST = 3;
	const int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int i, m, d, date;
	while (1){
		scanf ("%d %d", &m, &d);
		if (m==0) break;
		date = DAY_JUN_1ST;
		for (i=0; i<m-1; i++) date += month[i];
		date += (d-1);
		print_day (date);
	}
	return 0;
}

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

namespace Atcoder070_C_GoHome
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputFirstLine = long.Parse(Console.ReadLine());

            GoHome goHome = new GoHome();
            Console.WriteLine(goHome.GetEarliestTime(inputFirstLine));

            //Console.ReadKey();
        }
    }

    class GoHome
    {
        public long GetEarliestTime(long position)
        {
            long sum = 0, time = 1;
            for (; sum < position; time++)
            {
                sum += time;
            }

            return time - 1;
        }
    }
}


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


int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    ll c = k - a;
    if(c >= 0) {
        a = 0;
        if(c-b >= 0) b = 0;
        else b = b-c;
    }
    else a = a - k;
    cout << a << ' ' << b <<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[2*n];
  for(int i=0; i<2*n; i++){
    cin >> a[i];
  }
  sort(a,a+2*n);
  int i=0;
  int sum = 0;
  for(; i<2*n; i+=2){
    sum+=a[i];
    //cout << sum<<"\n";
  }
  cout <<sum;
  return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
a = list(map(int, input().split()))

lower_a = list(map(lambda x: x - 1, a))
upper_a = list(map(lambda x: x + 1, a))
extended_a = collections.Counter(a + lower_a + upper_a)

print(extended_a.most_common()[0][1])

Measured memory_bytes: 34620
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    string s;
    cin >> s;
    int n = s.size();

    int now = 0;
    int ans = 0;
    rep(i,n){
        int nx = s[i] - 'A';
        if(nx <= now){
            ans++;
        }
        now = nx;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef	pair<int,int>P;
typedef vector<P>V; 
int main(void){
	int n,m;
	int flg[201]={0};
	int i;
	int a,b;
	V v;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a>>b;
		v.push_back(P(a,b));
	}
	cin>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		v.push_back(P(a,b));
	}
	sort(v.begin(),v.end());
	for(i=0;i<(int)v.size()-1;i++){
		if(flg[i]==0){
			if(v[i].F==v[i+1].F&&v[i].S==v[i+1].S){
				flg[i+1]=1;
			}
		}
	}
	for(i=0;i<(int)v.size();i++){
		if(flg[i]==0){
			if(i)	printf(" ");
			printf("%d:%02d",v[i].F,v[i].S);
		}
	}
	printf("\n");
	return 0;
}
	


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

import collections
import itertools
import sys


INVALID = -1
INF = sys.maxsize // 2


def solve(n, vs):
    up_vals = vs[::2]
    up_ctr = collections.Counter(up_vals)
    up_ctr[INVALID] = 0
    down_vals = vs[1::2]
    down_ctr = collections.Counter(down_vals)
    down_ctr[INVALID] = 0
    up_mcs = up_ctr.most_common(3)
    down_mcs = down_ctr.most_common(3)
    cost = INF
    for (k_up, v_up), (k_down, v_down) in itertools.product(up_mcs, down_mcs):
        if k_up != k_down:
            new_cost = n - v_up - v_down
            cost = min(new_cost, cost)
    return cost


def main():
    n = int(input())
    vs = [int(v) for v in input().split()]
    print(solve(n, vs))


if __name__ == '__main__':
    main()

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

int main() {
    string word;
    stack<int> S;
    while (cin >> word) {
        if (word == "+") {
            int a = S.top(); S.pop();
            int b = S.top(); S.pop();
            S.push(a+b);
        }
        else if (word == "-") {
            int a = S.top(); S.pop();
            int b = S.top(); S.pop();
            S.push(b-a);
        }
        else if (word == "*") {
            int a = S.top(); S.pop();
            int b = S.top(); S.pop();
            S.push(a*b);
        }
        else {
            S.push(stoi(word));
            //S.push(atoi(word.c_str()));
        }
    }
    cout << S.top() << endl;
    return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
// lower_boundは二分探索
struct edge { int to, cost; };
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

llint binary_search(vector<int>&s,llint a) {
	llint l = -1;
	llint r = (int)s.size();
	while (r - l > 1) {
		llint mid = l + (r - l) / 2;

		if (s[mid]>=a) r = mid;
		else l = mid;
	}
	return r;
}
int k(ll n) {
	int x=0;
	while (n) {
		x+=n % 10;
		n /= 10;
	}
	return x;
}
ll max(ll x, ll y) {
	if (x < y)return y;
	return x;
}

int main() {
	string s;
	cin >> s;
	rep(i, 0, s.size()) {
		if (s[i] == 'A') {
			s[i] = 'T';
		}
		else {
			if (s[i] == 'T') {
				s[i] = 'A';
			}
			else {
				if (s[i] == 'C') {
					s[i] = 'G';
				}
					else if (s[i] == 'G')s[i] = 'C';
			}
		}
	}
	cout << s << endl;
	return 0;
}


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

int main() {
	string str; cin >> str;
	bool ans = true;
	
	if (str.size() < 6) ans = false;
	else {
		{ // suuzi
			bool f = false;
			for (int i = 0; i < str.size(); ++i) {
				if ('0' <= str[i] && str[i] <= '9') f = true;
			}
			if (!f) ans = false;
		}
		{ // suuzi
			bool f = false;
			for (int i = 0; i < str.size(); ++i) {
				if ('a' <= str[i] && str[i] <= 'z') f = true;
			}
			if (!f) ans = false;
		}
		{ // suuzi
			bool f = false;
			for (int i = 0; i < str.size(); ++i) {
				if ('A' <= str[i] && str[i] <= 'Z') f = true;
			}
			if (!f) ans = false;
		}
	}
	
	if (ans) cout << "VALID" << endl;
	else cout << "INVALID" << endl;
}

Measured memory_bytes: 1180
#include<cstdio>
#include<iostream>
using namespace std;
int a[200005];
int main(void)
{
    int k,n,mx=0;
    cin >> k >> n;
    for(int i=0;i<n;i++)
        scanf("%d" ,&a[i]);
    a[n]=a[0]+k;
    for(int i=0;i<n;i++)
        mx=max(mx,a[i+1]-a[i]);
    cout << k-mx;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		S = S.replaceAll("eraser", "");
		S = S.replaceAll("erase", "");
		S = S.replaceAll("dreamer", "");
		S = S.replaceAll("dream", "");
		if (S.length() == 0){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 28760
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
	double a;
	cin>>a;
	double b;
	b = ceilf(a / 2) / a;
	cout<< b <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n;
int a[25], b[25], c[25];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 1; i <= n-1; i++) cin >> c[i];
	
	int ans = 0;
	for(int i = 1; i <= n; i++) ans += b[i];
	for(int i = 1; i <= n-1; i++){
		if(a[i+1] == a[i]+1) ans += c[a[i]];
	}
	cout << ans << endl;
	
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define ll long long

int main(){
    int a,b;
    cin>>a>>b;
    if(a==b) cout<<2*a<<endl;
    else cout<<2*max(a,b)-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll n, m;
    cin >> n >> m;
    set<ll> a;
    rep(i, m) {
        ll tmp;
        cin >> tmp;
        tmp--;
        a.insert(tmp);
    }
    vector<ll> dp(n + 1, 0);
    dp[0] = 1;
    rep(i, n) {
        if (a.count(i) > 0) continue;
        dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
        if (i > 0) dp[i + 1] = (dp[i + 1] + dp[i - 1]) % mod;
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include <iostream>
#include<stdlib.h>
//#include <algorithm>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
bool same(vector<char> str1, vector<char> str2){

  rep(k,10){
    if(str1[k]==str2[k]){
      continue;
    }else{
      /*rep(j,10){
        cout << str1[j];
      }
      cout << endl;
      rep(j,10){
        cout << str2[j];
      }*/
      return false;
    }
  }
  return true;
}

int main(void){
  ll N;
  cin >> N;
  vector<vector<char>> str(N,vector<char>(10));
  char tmp[11];
  rep(i,N){
    cin >> tmp;
    rep(j,10){
      str[i][j] = tmp[j];
      //cout << tmp[j];
    }
    sort(str[i].begin(),str[i].end());
  }
  sort(str.begin(),str.end());
  ll now = 0;
  ll sum = 0;
  /*rep(i,N){
    rep(j,10){
      cout << str[i][j];
    }
    cout << endl;
  }*/
  for(ll i=0;i<N-1;i++){
    if(same(str[i],str[i+1])==true){
      now+=1;
    }else{
      //cout << "now" << now << endl;
      sum += ((now)*(now+1))/2;
      now = 0;
    }
  }
    sum += ((now)*(now+1))/2;
  cout << sum;
	return 0;
}

Measured memory_bytes: 5760
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    println!("{}",
             if a=="ooo"{"1000"}
             else if a=="oox"{"900"}
             else if a=="oxo"{"900"}
             else if a=="xoo"{"900"}
             else if a=="oxx"{"800"}
             else if a=="xox"{"800"}
             else if a=="xxo"{"800"}
             else {"700"}
    )
}

Measured memory_bytes: 2132
#include <iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using ll=long long ;
int main(){
	int n,m=100,M=-100,ans=1000000;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
		M = max(M,a[i]);
		m = min(m,a[i]);
	}
	for(int i=m;i<=M;i++){
		int s=0;
		for(int j=0;j<n;j++)	s+=pow((a[j]-i),2);
		ans = min(ans,s);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256