akhauriyash/Code-Regression huggingface dataset:
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            var stack = new Stack<int>(100);

            foreach(var elem in input) {
                if(elem == "+") {
                    var val1 = stack.pop();
                    var val2 = stack.pop();
                    stack.push(val1 + val2);
                }
                else if(elem == "-") {
                    var val1 = stack.pop();
                    var val2 = stack.pop();
                    stack.push(val2 - val1);
                }
                else if(elem == "*") {
                    var val1 = stack.pop();
                    var val2 = stack.pop();
                    stack.push(val1 * val2);
                }
                else {
                    stack.push(int.Parse(elem));
                }
            }
            Console.WriteLine(stack.pop());
        }

    }

    class Stack<T>
    {
        private int _top;
        private T[] _buf;

        public Stack(int n)
        {
            _top = 0;
            _buf = new T[n];
        }
        public void push(T data)
        {
            _buf[_top++] = data;
        }

        public T pop()
        {
            return _buf[--_top];
        }
    }
}



Measured memory_bytes: 17976
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    ll n;
    cin>>n;
    ll ans = n*n*3;
    cout<<ans<<endl;
}


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

long long A[128], N;
int main(){
	A[0] = 1;
	for (int i = 1; i <= 32; i++){
		A[i] = A[i - 1];
		if (i > 1)A[i] += A[i - 2];
		if (i > 2)A[i] += A[i - 3];
	}

	for (;;){
		cin >> N;
		if (N == 0)break;
		cout << (A[N] / 3650) + 1 << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
using namespace std;
  
int main(){
   string s;
   cin>>s;
   if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]){
     cout<<"Yes"<<endl;
   }  
   else if (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]){
     cout<<"Yes"<<endl;
   }
   else if (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]){
     cout<<"Yes"<<endl;
   }  
   else {
     cout<<"No"<<endl;
   }   
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  ldouble n;
  cin >> n;
  cout << fixed << setprecision(3) << n*3.1415926535*2 << endl;
  return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(long long N, std::vector<long long> T, long long M, std::vector<long long> P, std::vector<long long> X)
{
    ll sum = accumulate(T.begin(), T.end(), 0);

    for (int i = 0; i < M; i++)
    {
        cout << sum - (T[P[i] - 1] - X[i]) << endl;
    }
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> T(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &T[i]);
    }
    long long M;
    scanf("%lld", &M);
    std::vector<long long> P(M);
    std::vector<long long> X(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &P[i]);
        scanf("%lld", &X[i]);
    }
    solve(N, std::move(T), M, std::move(P), std::move(X));
    return 0;
}


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

void input_vector(std::vector<int>& v) {
  int N;
  int temp;
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> temp;
    v.push_back(temp);
  }
}

void print_vector(std::vector<int> v) {
  for(int i = 0; i < v.size()-1; ++i) {
    std::cout << v[i] << " ";
  }
  std::cout << v[v.size()-1] << std::endl;
}

void bubbleSort(std::vector<int>& A) {
  int count = 0;
  for(int i = 0; i < A.size(); ++i) {
    for(int j = 1; j < A.size()-i; ++j) {
      if( A[j-1] > A[j] ) {
	std::swap(A[j-1], A[j]);
	count += 1;
      }
    }
  }
  print_vector(A);
  std::cout << count << std::endl;
}

int main() {

  std::vector<int> A;

  input_vector(A);
  bubbleSort(A);

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int r,g;cin>>r>>g;
  // (r+ans)/2=g
  int ans=2*g-r;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

const int MAXN = 100001;
const int MOD = 1000000007;

long fact[MAXN];

long long pw(long long a, int b) {
    if (b == 0) return 1;
    long long x = pw(a, b / 2);
    x *= x;
    x %= MOD;
    if (b % 2 == 0) return x;
    return x * a % MOD;
}

long long dv(long long a, long long b) {
    return a * pw(b, MOD - 2) % MOD;
}

long long c(int n, int k) {
    if (k > n) return 0;
    return dv(dv(fact[n], fact[k]), fact[n - k]);
}

int main() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    int n;
    scanf("%d", &n);
    vector<int> a(n + 1);
    for (int i = 0; i < n + 1; i++) {
        scanf("%d", &a[i]);
        a[i]--;
    }
    vector<int> ind(n, -1);
    int i1 = -1, i2 = -1;
    for (int i = 0; i < n + 1; i++) {
        if (ind[a[i]] != -1) {
            i1 = ind[a[i]];
            i2 = i;
            break;
        } else {
            ind[a[i]] = i;
        }
    }

    const int MOD = 1000000007;
    for (int k = 1; k <= n + 1; k++) {
        long long cur = 0;
        // none of those
        cur += c(n - 1, k);
        // one
        cur += 2 * c(n - 1, k - 1);
        cur -= c(i1 + (n - i2), k - 1);
        // both
        if (k >= 2) {
            cur += c(n - 1, k - 2);
        }

        cout << (cur % MOD + MOD) % MOD << "\n";
    }
}

Measured memory_bytes: 2816
#include<stdio.h>

int main(void)
{
	int a, b;
	int i, j;
	int result[200];
	int x;
	int n;
	
	i = 0;
	j = 0;
	
	while (scanf("%d %d", &a, &b) != EOF) {
		x = a + b;
		n = 1;
		
		while (x >= 10) {
			x = x / 10;
			n++;
		}
		result[i] = n;
		
		i++;
	}
	
	for (j = 0; j < i; j++) {
		printf("%d\n", result[j]);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
 
#define 	pi 				3.14159265358979
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
// get<0>(v[i])
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }
 
vll pwx(40);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 40)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 200005

void solve(){
	ll n, k;
	cin>>n>>k;

	vector<ll> a(n+1), b(n+2, 0), c(n+2,  0), d(n+2, 0);

	for(ll i = 1 ; i <= n ; i++){
		cin>>a[i];
	}

	for(ll i = 1 ; i <= n ; i++){
		b[max(0ll, i - a[i])]++;
		b[min(n+1, i + a[i] + 1)]--;
	}

	for(ll i = 1 ; i <= n+1 ; i++){
		b[i] += b[i-1];
	}

	k--;

	while(k--){
		c = b;
		b = d;
		for(ll i = 1 ; i <= n ; i++){
			b[max(0ll, i - c[i])]++;
			b[min(n+1, i + c[i] + 1)]--;
		}

		for(ll i = 1 ; i <= n+1 ; i++){
			b[i] += b[i-1];
		}

		bool ok = 1;
		for(ll i = 1 ; i <= n ; i++){
			if(b[i] != n)
				ok = 0;
		}
		if(ok)
			break;
	}

	for(ll i = 1 ; i <= n ; i++){
		cout<<b[i]<<' ';
	}
	cout<<nl;
}
 
int main(){
    // boost;
    // cal(3);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 9596
import sys

X, N = map(int, input().split(' '))

if N == 0:
    print(X)
    sys.exit()

p = list(map(int, input().split(' ')))

if not X in p:
    print(X)
    sys.exit()

for i in range(1, 101):
    if not X - i in p:
        print(X - i)
        sys.exit()

    if not X + i in p:
        print(X + i)
        sys.exit()


Measured memory_bytes: 9188
N,A,B,C = map(int,input().split())
l=[int(input()) for _ in range(N)]
INF=10**4

def dfs(cur,a,b,c):
    if cur==N:
        return abs(A-a)+abs(B-b)+abs(C-c)-30 if min(a,b,c)>0 else INF
    else:
        cost0 = dfs(cur+1,a,b,c)
        cost1 = dfs(cur+1,a+l[cur],b,c)+10
        cost2 = dfs(cur+1,a,b+l[cur],c)+10
        cost3 = dfs(cur+1,a,b,c+l[cur])+10
        return min(cost0,cost1,cost2,cost3)

print(dfs(0,0,0,0))

Measured memory_bytes: 3064
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
bool find(string s){
	return s.find("the",0)!=string::npos
		|| s.find("this",0)!=string::npos
		|| s.find("that",0)!=string::npos;
}
string rotate(string s,int n){
	for(int i=0;i<s.size();i++){
		if(isalpha(s[i]))s[i] = (s[i]-'a'+n)%26+'a';
	}
	return s;
}
int main(){
	string s;
	while(getline(cin,s)){
		for(int i=0;i<26;i++){
			if(find(rotate(s,i))){
				cout<<rotate(s,i)<<endl;
				break;
			}
		}
	}
	return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s;cin>>s;
  for(int i=0;i<s.size();i++){
    cout<<'x';
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	int N, P;
	cin >> N >> P;

	bool even = true;
	for (int i = 0; i < N; i++)
	{
		int A;
		cin >> A;
		if (A % 2 == 1)
			even = false;
	}
	if (even)
	{
		if (P == 0)
			cout << (ll)pow(2, N) << endl;
		else
			cout << 0 << endl;
	}
	else
	{
		cout << (ll)pow(2, N-1) << endl;
	}
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

void print(string str, int a, int b)
{
	//出力

	//aからb-aまでの文字を抽出
	cout << str.substr(a, b - a + 1) << endl;
}

string reverse(string str, int a, int b)
{
	//aからb文字目までを逆順
	string str2 = str.substr(a, b - a + 1);
	
	//逆順化
	reverse(str2.begin(), str2.end());
	
	str.replace(a, b - a + 1, str2);
	
	return str;
}

string replace(string str, int a, int b)
{
	string str2;
	cin >> str2;
	str.replace(a, b - a + 1, str2);
	return str;
}

int main()
{
	string str, comand;
	int a, b, q;

	//文字列と命令数
	cin >> str >> q;

	for (int i = 1; i <= q; i++) {
		cin >> comand;
		cin >> a >> b;
		if (comand == "print") {//出力
			print(str, a, b);
		}
		else if (comand == "reverse") {//逆順
			str = reverse(str, a, b);
		}
		else {//置き換え
			str = replace(str, a, b);
		}
	}


	return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

struct edge{int to,cost;};
int V;
vector<edge> G[100010];
ll d[100010];

void dijkstra(int s){
  priority_queue<pint,vector<pint>,greater<pint>> que;
  fill(d,d+V,longinf);
  d[s]=0;
  que.push(pint(0,s));
  ll cnt=0;
  while(!que.empty()){
    cnt++;
    if(cnt>=200020){
      return;
    }
    pint p=que.top(); que.pop();
    int v=p.second;
    if(d[v]<p.first)continue;
    rep(i,G[v].size()){
      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));
      }
    }
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  V=n;
  rep(i,m){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    G[x].push_back({y,z});
  }
  for(int i=1;i<n;i++){
    G[i].push_back({i-1,0});
  }
  dijkstra(0);
  if(d[n-1]>=longinf)d[n-1]=-1;
  cout << d[n-1] << endl;
return 0;}

Measured memory_bytes: 7548
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;
    cin >> r;
    
    std::cout << std::fixed;
    std::cout << std::setprecision(6) << M_PI * r * r << " ";
    std::cout << std::setprecision(6) << M_PI * 2 * r << "\n";
}

//20608595.232153 16092.707837



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

int main()
{
  int s, w;

  cin >> s >> w;

  string ans;
  if(s <= w){
    ans = "unsafe";
  } else {
    ans = "safe";
  }

  cout << ans << endl;
}

Measured memory_bytes: 3636
alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
s = input()
ans = []
for i in range(len(s)):
    for j in range(len(alpha)):
        if s[i] == alpha[j]:
            if j+n<25:
                ans.append(alpha[j+n%26])
            else:
                ans.append(alpha[n%26-(26-j)])
print("".join(ans))

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

using namespace std;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;

template <typename T>
T gcd(T a, T b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int g = 0;
  for (int i = 0; i < N; i++) {
    g = gcd(g, A[i]);
  }
  cout << g << '\n';
  return 0;
}


Measured memory_bytes: 640
def main():
  l, r = map(int, input().split())
  if r - l >= 2019:
    print(0)
  else:
    ans = 2020
    for li in range(l, r+1):
      for ri in range(li+1, r+1):
        if (li*ri)%2019 < ans:
          ans = (li*ri)%2019
    print(ans)


if __name__ == '__main__':
  main()


Measured memory_bytes: 40048
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll N;
	ll A[100000];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		if(A[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	ll ans = 1;
	float ansF = 1.0;
	for(int i = 0; i < N; i++){
		ans *= A[i];
		ansF *= A[i];
		if(ans > (ll)1000000000000000000 || ans < 0 || ansF > 10e18){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4416
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	ps := make([]pair, n)
	for i := 0; i < n; i++ {
		ps[i] = pair{scanInt(), scanInt()}
	}
	sort.Slice(ps, func(i, j int) bool { return ps[i].a < ps[j].a })
	for i := 0; i < n; i++ {
		k -= ps[i].b
		if k <= 0 {
			fmt.Fprintln(wr, ps[i].a)
			return
		}
	}
}

type pair struct{ a, b int }


Measured memory_bytes: 5096
def main():
    A, B, N = map(int, input().split())

    f = lambda x: int(A*x/B) - A * int(x / B)

    if B == 1:
        print(0)
    else:
        ans = 0
        x = B * (N // B) - 1 if N >= B else N
        ans = max(f(x), ans)
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9196
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			float sumLen=0;
			int[] len = new int[10];
			String[] t = sc.nextLine().split(",");
			for(int i=0; i<10; i++){ len[i] = Integer.parseInt(t[i]); sumLen +=len[i]; }
			int v1 = Integer.parseInt(t[10]); int v2 = Integer.parseInt(t[11]); int s = len[0];
			double jdg = v1*sumLen/(v1+v2);
			
			for(int i=1; i<=10; i++){
				if(jdg<=s){ System.out.println(i); break;}
				s += len[i];
			}
			
			
		}

	}

}

Measured memory_bytes: 11000
<?php

fscanf(STDIN, "%d %d", $a, $b);

if ($a >=  $b) {
  answer($a, $b);
} elseif ($b > $a) {
  answer($b, $a);
}

function answer($a, $b)
{
  for ($i=0; $i < $a; $i++) {
    echo $b;
  }
}


Measured memory_bytes: 4856
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
#define ALL(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された

    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

int main(void){
    int n, k, xi;
    int ans = 0;
    cin >> n >> k;
    rep(i, n) {
        cin >> xi;
        if (xi < k - xi) ans += xi;
        else ans += (k - xi);
    }
    cout << ans * 2 << endl;
    return 0;
}

Measured memory_bytes: 3620
// A.cpp
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int base[] = {2, 3, 5};

int T;
ll n, prices[4];
map<ll, ll> dp;

ll dfs(ll u)
{
    if (dp.count(u))
        return dp[u];
    dp[u] = 0x7fffffffffffffff;
    for (int i = 0; i < 3; i++)
    {
        int x = base[i];
        ll lft = u / x, rig = (u + x - 1) / x;
        dp[u] = min(dp[u], dfs(lft) + prices[i] + 1LL * prices[3] * abs(u - 1LL * lft * x));
        dp[u] = min(dp[u], dfs(rig) + prices[i] + 1LL * prices[3] * abs(u - 1LL * rig * x));
    }
    if (u < dp[u] / prices[3])
        dp[u] = min(dp[u], 1LL * prices[3] * u);
    return dp[u];
}

int main()
{
    scanf("%d", &T);
    while (T--)
    {
        scanf("%lld%lld%lld%lld%lld", &n, &prices[0], &prices[1], &prices[2], &prices[3]), dp.clear(), dp[0] = 0, dp[1] = prices[3];
        printf("%lld\n", dfs(n));
    }
    return 0;
}

Measured memory_bytes: 4600
n = int(input())
h = list(map(int, input().split()))
hantei = [0 for _ in range(n)]
hantei.append(1)
result = 0
h.append(10*3)

while any(hantei[i] != 1 for i in range(n)):
    min_h = min(h)
    cost = 0
    for i in range(len(h)):
        if hantei[i]==1:
            result += cost
            cost = 0
            h[i] = 10**3
        else:
            h[i] -= min_h
            if h[i] == 0:
                hantei[i] = 1
            cost = min_h
print(result)

Measured memory_bytes: 3064
import math
K = int(input())

# table = np.zeros((K,K), dtype="int16")
table = [[0] * K for i in range(K)]

for a in range(K):
    for b in range(a, K):
        tmp = math.gcd(a+1, b+1)
        table[a][b] = tmp
        table[b][a] = tmp

res = 0
for a in range(K):
    for b in range(K):
        for c in range(K):
            res += table[table[a][b]-1][c]
print(res)     

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

int main() {
  int n;
  cin >> n;
  double sum = 0.0;
  while (n--) {
    double x;
    cin >> x;
    sum += 1.0 / x;
  }
  cout << 1.0 / sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int N, M, X;
    cin >> N >> M >> X;

    vector<vector<int>> memo(N);
    vector<int> cost(N);
    rep(i,N) memo[i].resize(M,0);
    rep(i,N){
        cin >> cost[i];
        rep(j,M) cin >> memo[i][j];
    }

    int ans = INF32;
    for(int bit=0; bit<(1<<N); bit++){
        vector<int> vec;
        vec.resize(M,0);
        int total = 0;
        bool ok = 1;

        for(int i=0; i < N; i++){
            if(bit & (1<<i)){
                total += cost[i];
                rep(k,M) vec[k] += memo[i][k];
                //rep(k,M) cout << memo[i][k] << " "; cout << endl;
            }
        }

        rep(i,M){
            if(vec[i] < X){
                ok = 0;
                break;
            }
        }

        if(ok) ans = min(ans,total);
    }

    if(ans!=INF32) {
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3660
object Main extends App {
  val nmx =  scala.io.StdIn.readLine()
  val nmxArray =  nmx.split(" ").map(_.toInt).toSeq
  val n = nmxArray(0)
  val m = nmxArray(1)
  val x = nmxArray(2)

  var caVector = Vector.empty[Vector[Int]]
  (1 to n).foreach { _ =>
    val ca =  scala.io.StdIn.readLine()
    val caArray =  ca.split(" ").map(_.toInt).toVector
    caVector :+= caArray
  }

  var resultVector = Vector.empty[Int]
  (1 to n).foreach { i =>
    caVector.combinations(i).foreach { cas =>
      var rikaiSum = scala.collection.mutable.Seq.empty[Int]
      cas.foreach { ca =>
        if (rikaiSum.length == 0) {
          rikaiSum = scala.collection.mutable.ListBuffer(ca.tail: _*)
        } else {
          (0 to m - 1).foreach { i =>
            rikaiSum(i) = rikaiSum(i) + ca(i + 1)
          }
        }

      }
      if (!rikaiSum.exists(r => r < x)) {
        resultVector :+= cas.map(ca => ca.head).sum
      }
    }
  }
  if (resultVector.length == 0) {
    println(-1)
  } else {
    println(resultVector.min)
  }
}

Measured memory_bytes: 60148
#include <iostream>
using namespace std ;
int main()
{
  int a ;
  string s ;
  
  cin >>a ;
  cin >>s ;
  
  if(a >=3200){
    cout << s <<endl ;
  }
  else if(a <= 3200){
    cout <<"red"<<endl ;
  }
  
  return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  for(int i=0;i<m;++i)
  {
    cin>>a[i]>>b[i];
  }
  sort(a,a+m);
  sort(b,b+m);
  if(b[0]<a[m-1]) cout<<"0";
 	else
      cout<<b[0]-a[m-1]+1;
  return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    ll k; cin >> k;
    ll x = 7%k;
    rep2(i, 1, k+1){
        if(!x){
            cout << i << endl;
            return 0;
        }
        x = (x*10+7)%k;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, q; cin >> n >> q;
	vector<ll> a(n);
	rep(i, 0, n - 1)cin >> a[i];
	
	rep(_, 1, q)
	{
		ll x; cin >> x;
		ll ans = 0;
		ll sum = 0;
		int right = 0;
		rep(left, 0, n - 1)
		{
			while (right < n && sum + a[right] <= x)
			{
				sum += a[right];
				++right;
			}
			ans += right - left;

			sum -= a[left];
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3544
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if 500*a+100*b+50*c == X:
        ans += 1;
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int MAX=1001;
int lcs(string X,string Y) {
    int i=0,j=0,c[MAX][MAX],x=X.length(),y=Y.length();
    for(i=0;i<=x;i++)c[i][0]=0;
    for(i=0;i<=y;i++)c[0][i]=0;
    for(i=1;i<=x;i++) 
        for(j=1;j<=y;j++) 
            if(X[i-1]==Y[j-1])c[i][j]=c[i-1][j-1]+1; 
            else c[i][j]=max(c[i][j-1],c[i-1][j]);
    /*cout<<"???????????????????????????????????????"<<endl;
    for(i=1;i<=x;i++){
        for(j=1;j<=y;j++)cout<<c[i][j]<<" ";
        cout<<endl;
    }*/
    return c[x][y];
}
int main(){
    int n;cin>>n;
    string X,Y;
    while(n--){
        cin>>X>>Y;
        cout<<lcs(X,Y)<<endl;
    }
}

Measured memory_bytes: 7064
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 1; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;cin>>n;
    vector<int> ret(n+1);
    for(int i=1;i<=n;i++)
    {
        int a;cin>>a;
        ret[a] = i;
    }
    printv(ret);
}


Measured memory_bytes: 1280
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0 for _ in range(n)]
for i in range(1, n):
    arr = []
    for j in range(1, k + 1):
        if 0 <= i - j <= n:
            arr.append(dp[i - j] + abs(h[i - j] - h[i]))
    dp[i] = min(arr)
print(dp[n - 1])

Measured memory_bytes: 58080
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int len =s.size() ;
	int f=0;
	for(int i=0;i<len/2;i++) {
		if(s[i]!=s[len-1-i] ) f++;
	}
	cout << f<<endl;
	return 0;
} 

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int P = 12;
int pw[P];

int m,n;
vector<int> x;

int in(){
    string s;
    cin >>s;

    int ret = 0;
    rep(i,m)if(s[i]=='1') ret |= (1<<i);
    return ret;
}

int check(const vector<int> &s){
    int ct = 0;

    int must = 0;
    rep(i,m)if(s[i]==1) must ^= (1<<i);

    int cover = (1<<m)-1;
    rep(i,m)if(s[i]==2) cover ^= (1<<i);

    rep(i,n){
        int t = x[i];
        t ^= must;
        t &= cover;
        ct += !t;
    }
    return ct;
}

int make_mask(const vector<int> &s){
    int ret = 0;
    for(int i=m-1; i>=0; --i){
        ret *= 3;
        ret += s[i];
    }
    return ret;
}

int dp[540000];
int dfs(int mask){
    if(dp[mask]>=0) return dp[mask];

    vector<int> s(m);
    int tmp = mask;
    rep(i,m){
        s[i] = tmp%3;
        tmp /= 3;
    }

    if(check(s)<=1){
        int ct = 0;
        rep(i,m) ct += (s[i]!=2);
        return dp[mask] = ct;
    }

    int ret = 101010;

    // 次にどこを聞くか
    rep(i,m)if(s[i]==2){
        int zero,one;
        s[i] = 0;
        zero = make_mask(s);
        s[i] = 1;
        one = make_mask(s);
        s[i] = 2;
        ret = min(ret, max(dfs(zero),dfs(one)));
    }

    return dp[mask] = ret;
}

int main(){
    pw[0] = 1;
    for(int i=1; i<P; ++i) pw[i] = pw[i-1]*3;

    while(cin >>m >>n,m){
        x = vector<int>(n);
        rep(i,n) x[i] = in();

        memset(dp,-1,sizeof(dp));
        cout << dfs(pw[m]-1) << endl;
    }
    return 0;
}



Measured memory_bytes: 5260
// ITP1_2_D ????????¢??????????????????????????????
#include<stdio.h>
int main()
{
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

	if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h){
		printf("Yes\n");
	}else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
N, C = map(int, input().split())
d = []
for i in range(C):
    tmp = [int(x) for x in input().split()]
    d.append(tmp)

c = []
for i in range(N):
    tmp = [int(x)-1 for x in input().split()]
    c.append(tmp)

x = [[], [], []] # 0,1,2
for cc in range(C):
    tx = [0] * 3
    for i in range(N):
        for j in range(N):
            tx[(i+j)%3] += d[c[i][j]][cc]
    for i in range(3):
        x[i].append(tx[i])

ans = 10 ** 9
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i == j or j == k or k == i:
                continue
            tmp = x[0][i] + x[1][j] + x[2][k]
            if tmp < ans:
                ans = tmp
print(ans)

Measured memory_bytes: 48960
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>

using namespace std;

vector<vector<int>> Graph(200001); // 要素数0の2次元配列 無向グラフ
vector<long long> counter(200001, 0);
vector<bool> seen(200001, false);

void dfs(int now){
    seen[now] = true;

    for (int next : Graph[now]){
        if (seen[next] == false){
            counter[next] += counter[now];
            dfs(next);
        }
    }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    vector<int> a(N-1), b(N-1), p(Q), x(Q);
    for (int i = 0; i < N-1; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        Graph[a[i]].emplace_back(b[i]);
        Graph[b[i]].emplace_back(a[i]);
    }
    for (int i = 0; i < Q; i++){
        cin >> p[i] >> x[i];
        p[i]--;
        counter[p[i]] += x[i];  // 各クエリの頂点のみに加算
    }

    dfs(0);

    for (int i = 0; i < N-1; i++){
        cout << counter[i] << " ";
    }
    cout << counter[N-1] << endl;

    return 0;
}


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

int main(){
  int n;
  cin >> n;
  int cnt = 0;
  for(int i = 0;i < n;i++){
    char p;
    int x;
    cin >> p >> x;
    if(p == '('){
      cnt += x;
    }
    else{
      if(x > cnt){
	cout << "NO" << endl;
	return 0;
      }
      cnt -= x;
    }
  }
  cout << (cnt ? "NO" : "YES") << endl;
}



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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    stack<int> st;
    int ans = 0;
    rep(i, S.length()){
        if(st.empty()) st.push(S[i]-'0');
        else{
            int num = S[i]-'0';
            if(st.top() != num){
                ans += 2;
                st.pop();
            }
            else st.push(num);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 720
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, q = map(int, input().split())
    S = [-f_inf] + list(int(input()) for _ in range(a)) + [f_inf]
    T = [-f_inf] + list(int(input()) for _ in range(b)) + [f_inf]

    for _ in range(q):
        res = f_inf
        x = int(input())

        idx_s = bisect_left(S, x)
        idx_t = bisect_left(T, x)
        for s in [S[idx_s - 1], S[idx_s]]:
            for t in [T[idx_t - 1], T[idx_t]]:
                d1 = abs(s - x) + abs(s - t)
                d2 = abs(t - x) + abs(t - s)
                res = min(res, d1, d2)
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 17780
// https://atcoder.jp/contests/abc070/tasks/abc070_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << (s.front() == s.back() ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
<?php

$s = trim(fgets(STDIN));
$n = floor($s/2);
  
$sum = 0;
for($i=1; $i<=$n; $i++){
  for($j=1; $j<=2; $j++){
    $sum +=$i;
  }
}

echo $s%2 == 0? $sum-$n : $sum;

?>

Measured memory_bytes: 4604
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<string>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<algorithm>
typedef long long ll;
using namespace std;

struct p{
	ll x;
	ll y;
};

bool cmp(p p1,p p2)
{
	return p1.x < p2.x ; 
}

int main()
{
	ll n,k,sum = 0;
	p ps[100010];
	cin >> n >> k;
	for(int i = 0;i < n;i++)
	{
		cin >> ps[i].x >> ps[i].y ;
	}
	sort(ps,ps+n,cmp);
	for(int i = 0;i < n;i++)
	{
		sum += ps[i].y;
		if(sum >= k)
		{
			cout << ps[i].x << endl;
			break; 
		}
	 } 

	return 0;
} 

Measured memory_bytes: 1792
N = int(input())
S = input()

op1 = 0
l_lack = 0
for c in S:
    if c == '(':
        op1 += 1
    else:
        op1 -= 1
        l_lack = min(l_lack, op1)

op2 = 0
r_lack = 0
for c in S[::-1]:
    if c == ')':
        op2 += 1
    else:
        op2 -= 1
        r_lack = min(r_lack, op2)

print('(' * -l_lack + S + ')' * -r_lack)

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

using namespace std;

int main()
{
    long long int a,b,c,cnt=0,e,f,g;
    scanf("%lld%lld%lld",&a,&b,&c);
    //if(a==b&&b==c)
    //printf("%d\n",-1);
    while(a%2==0&&b%2==0&&c%2==0)
        {
        cnt++;
        e=a/2.0;
        f=b/2.0;
        g=c/2.0;
        a=f+g;
        b=e+g;
        c=e+f;
        if(a==b && b==c){
        cnt=-1;
        break;
        }
        }
       printf("%lld\n",cnt);

}


Measured memory_bytes: 256
import sys
read = sys.stdin.read

def main():
  MOD = 10**9+7
  n, *A = map(int, read().split())
  ans = 0
  for j in range(61):
    c = 0
    for i in A:
      if i>>j & 1:
        c += 1
    ans += 2**j*((n-c)*c)
    ans %= MOD
  print(ans%MOD)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 38884
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct Node{
  int key;
  struct Node *right,*left,*parent;
};
 
struct Node *root,*NIL;
 
struct Node* find(struct Node *u,int k){
  while(u != NIL && k != u -> key){
    if(k < u -> key){
      u = u -> left;
    }
    else {
      u = u -> right;
    }
  }
  return u;
}
 
void insert(int k){
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;
  z = (struct Node*)malloc(sizeof(struct Node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;
  while(x != NIL){
    y = x;
    if(z -> key < x -> key){
      x = x -> left;
    }
    else{
      x = x -> right;
    }
  }
  z -> parent = y;
  if(y == NIL){
    root= z;
  }
  else{
    if(z -> key < y -> key){
      y -> left = z;
    }
    else{
      y -> right = z;
    }
  }
}
 
void inorder(struct Node *u){
  if(u == NIL) return ;
  inorder(u -> left);
  printf(" %d",u -> key);
  inorder(u -> right);
}
 
void preorder(struct Node *u){
  if(u == NIL) return ;
  printf(" %d",u -> key);
  preorder(u -> left);
  preorder(u -> right);
}
 
int main(){
  int n,i,x;
  char com[7];
  struct Node *t;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%s",com);
    if(strcmp(com,"find") == 0){
      scanf("%d",&x);
      t = find(root,x);
      if(t != NIL) {
	printf("yes\n");
      }
      else{
	printf("no\n");
      }
    }
    else if(strcmp(com,"insert") == 0){
      scanf("%d",&x);
      insert(x);
    }
    else if(strcmp(com,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 19364
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, n;
	double xa,ya,ra,xb,yb,rb,d;

	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%lf%lf%lf%lf%lf%lf",&xa,&ya,&ra,&xb,&yb,&rb);
		d = sqrt(pow(xa-xb,2)+pow(ya-yb,2));
		if(ra + rb < d)
			printf("0\n");
		else if(d + rb < ra)
			printf("2\n");
		else if(d + ra < rb)
			printf("-2\n");
		else
			printf("1\n");
	}
	return 0;
}

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

int main(){
  char r[10],a[5];
  while(1){
  int hit=0,blow=0;
  cin>>r>>a;
  if(r[0]=='0'&&a[0]=='0'){
     break;
   }
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
        if(r[i]==a[j]){
          if(i==j){
            hit++;
          }else{
            blow++;
          }
        }
    }
  }
  cout<<hit<<" "<<blow<<"\n";
}
  return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <string>


int main(void){
  int n;
  std::string s;

  std::cin >> n >> s;

  if(n%2){
    std::cout << "No" << std::endl;
    return 0;
  }

  for(int i=0; i<n/2; i++){
    if(s[i] != s[i+n/2]){
      std::cout << "No" << std::endl;
      return 0;
    }
  }

  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define inf 1<<30
int n,k;
int mem[2005];
int mem1[2005];
vector<int> from[2005];
queue<int> q;
int bfs(int x)
{
    int i,ans = 0;
    for(i=1;i<=n;i++) mem[i] = inf;
    mem[x] = 0;
    q.push(x);
    while(!q.empty())
    {
        x = q.front(); q.pop();
        for(i=0;i<from[x].size();i++)
        {
            if(mem[from[x][i]] > mem[x] + 1)
            {
                mem[from[x][i]] = mem[x] + 1;
                q.push(from[x][i]);
            }
        }
    }
    x = 1;
    for(i=1;i<=n;i++) if((mem[i]>mem[x]||mem[x]>k) && mem[i]<=k) x = i;
    for(i=1;i<=n;i++) mem1[i] = inf;
    mem1[x] = 0;
    q.push(x);
    while(!q.empty())
    {
        x = q.front(); q.pop();
        if(mem[x]<=k && mem1[x]<=k) ans++;
        for(i=0;i<from[x].size();i++)
        {
            if(mem1[from[x][i]] > mem1[x]+1)
            {
                mem1[from[x][i]] = mem1[x] + 1;
                q.push(from[x][i]);
            }
        }
    }
    return ans;
}
main()
{
    int i,x,y;
    int ans;
    scanf("%d%d",&n,&k);
    for(i=0;i<n-1;i++)
    {
        scanf("%d%d",&x,&y);
        from[x].push_back(y);
        from[y].push_back(x);
    }
    ans = 0;
    for(i=1;i<=n;i++) ans = max(ans,bfs(i));
    printf("%d",n-ans);
}


Measured memory_bytes: 384