akhauriyash/Code-Regression huggingface dataset:
// AOJ 1568: String Conversion
// 2018.2.16 bal4u

#include <stdio.h>
#include <stdlib.h>

int a['z'+1], b['z'+1];
char buf[100005];

int cmp(int *a, int *b) { return *b - *a; }

int main() 
{
	int i, x, ans;
	char *p;

	fgets(buf, 10, stdin);
	fgets(p=buf, sizeof(buf), stdin);
	while (*p > ' ') a[*p++]++;
	fgets(p=buf, sizeof(buf), stdin);
	while (*p > ' ') b[*p++]++;
	qsort(a + 'a', 26, sizeof(int), cmp);
	qsort(b + 'a', 26, sizeof(int), cmp);
	
	ans = 0;
	for (i = 'a'; i <= 'z'; i++) {
		x = a[i] - b[i];
		if (x >= 0) ans += x; else ans -= x;
	}
	printf("%d\n", ans >> 1);
	return 0; 
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, a, b) for (int i = a; i <= b; i++)
#define FORD(i, a, b) for (int i = a; i >= b; i--)
#define REP(i, n) FOR(i, 0, (int)n - 1)
#define pb push_back
#define pi 3.141592653589793
#define sll signed long long int // -10^9 to 10^9
#define ll long long int// for 0 to 10^18
#define ull unsigned long long int // for 0 to 10^18
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin(),x.end()
#define MOD 1000000007
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T> T power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
typedef vector<int> vi;
/* 
ll sum_ofGP_modM(ll a , ll n, ll mod)  //// (1 + A^1 +A^2 + A^3 + A^4 + -------+ A^N) % M  usually here n= Total terms in series-1
////and  if series is something for eg 3^2 + 3^4 here a= 9,r=9  our ans can be found out as 
// let a1= first term 3^2 just do ans = a1*sum_ofGP_modM(9 , N-1, ull mod)
	if(n == 0) return 1;
	if(n == 1) return (1 + a) % mod;
	ll res;
	if(n % 2)
		res = (a + 1) * GPSumWithMod((a*a) % mod , (n-1)/2);
	else{ res = (a + 1) * GPSumWithMod((a*a) % mod , n/2 - 1);res %= mod;res = (res * a) + 1;}
    return res % mod;
}
//Whenever we have (a/b)%P == (a * fast_pow(b,P-2))%P
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
} */



int main() {
  FAST
  int n;cin>>n;
  vi a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  set<int> s;
  for(int i=0;i<n;i++){
    s.insert(a[i]);
  }
  cout<<s.size();
  
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int n, d, h, w, p;
int main() {
	while(scanf("%d", &n), n) {
		double s = 1.0e6;
		for(int i = 0; i < n; i++) {
			scanf("%d%d%d", &d, &h, &w);
			double r = abs(22.0 - 10000.0 * w / h / h);
			if(r < s) s = r, p = d;
		}
		printf("%d\n", p);
	}
	return 0;
}

Measured memory_bytes: 3132
x,y=map(int,input().split())
ans=0
if x==1:
  ans+=300000
if x==2:
  ans+=200000
if x==3:
  ans+=100000
if y==1:
  ans+=300000
if y==2:
  ans+=200000
if y==3:
  ans+=100000
if x==1 and y==1:
  ans+=400000
print(ans)

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

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

using namespace std;

using ll = long long;

using P = pair<int,int>;



int main() {
    string s ;
    cin>> s;
    ll red=0 ;
    ll blue=0 ;
    ll n = s.size() ;
    rep(i,n){
        if(s.at(i)=='0')
        red++ ;
        else
        blue++ ;
    }
cout <<min(red,blue)*2<<endl ;
  return 0;

}

Measured memory_bytes: 512
'use strict';

function Main(INPUT) {
    const N = INPUT.split(" ").map(n => Number(n));
    let ans = Math.max(N[0] + N[1], N[0] - N[1], N[0] * N[1]);
    if (ans === -0) ans = 0;
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8460
N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

expected_value = []
for i in range(len(p)):
    expected_value.append((p[i] + 1)/ 2)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)
# print(f"N:{N} K:{K} expected_value:{expected_value} cumsum:{cumsum}")

print(max(cumsum))



Measured memory_bytes: 24548
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<ll>dic(n+1);
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j+=i){
            dic[j]++;
        }
    }
    ll ans = 0;
    rep(i, n+1) ans += i*dic[i];
    cout << ans << endl;
}


Measured memory_bytes: 81328
o=input()
e=input()
print()
ans = ""

if len(o)==len(e):
    for x in range(len(o)):
        ans += o[x]
        ans += e[x]
else:
    for x in range(len(e)):
        ans += o[x]
        ans += e[x]
    ans += o[len(o)-1]
print(ans)

Measured memory_bytes: 3060
from collections import deque
n,k=map(int, input().split())
a=list(map(int, input().split()))
arr=[-1]*n
arr[0]=0
que=deque([a[0]])
i=1
loop=0

while loop==0:
    x=que.popleft()
    if arr[x-1]==-1:
        arr[x-1]=i
        i+=1
        que.append(a[x-1])
    else:
        loop=i-arr[x-1]
        break
b_loop=i-loop

if k<i:
    print(arr.index(k)+1)
else:
    print(arr.index(b_loop+(k-b_loop)%loop)+1)

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a[0];
    for(int i = 1; i < n; i++) {
        cin >> a[i];
        a[i] += a[i-1];
    }
    vector<ll> b(n-1);
    for(int i = 0; i < n-1; i++) {
        b[i]=abs(a[i]-(a[n-1]-a[i]));
    }
    sort(b.begin(),b.end());
    cout << b[0] << endl;

    return 0;
}

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

#define vi vector<int>
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main (void) {
    ios_base::sync_with_stdio(false);

    int INF = 1e9;
    int n;
    int dp[1000010];
    cin >> n;

    fill(dp, dp+n+1, INF);
    vi vals {1};
    int a = 6, b = 9;
    for (int i = 1; i < 8; i++) {
        vals.pb(a);
        vals.pb(b);
        a *= 6;
        b *= 9;
    }

    dp[0] = 0;
    for (int v : vals) {
        for (int i = v; i <= n; i++) {
            if (dp[i-v] != -1) {
                dp[i] = min(dp[i], dp[i-v]+1);
            }
        }
    }

    cout << dp[n] << endl;

    return 0;
}


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

int main(void){
	string str;
	cin >> str;
	bool flag=false;
	int N=str.size();

	while(str.size()>=5){
		int N=str.size();
		if(str.size()>=7){
			if(str.at(N-5)=='d'){
				if(str.at(N-4)=='r'&&str.at(N-3)=='e'&&str.at(N-2)=='a'&&str.at(N-1)=='m'){
					str.erase(N-1);
					str.erase(N-5,N-1);
					flag=true;
				}
			}else if(str.at(N-7)=='d'){
				if(str.at(N-6)=='r'&&str.at(N-5)=='e'&&str.at(N-4)=='a'&&str.at(N-3)=='m'&&str.at(N-2)=='e'&&str.at(N-1)=='r'){
					str.erase(N-1);
					str.erase(N-7,N-1);
					flag=true;
				}
			}else if(str.at(N-2)=='s'){
				if(str.at(N-5)=='e'&&str.at(N-4)=='r'&&str.at(N-3)=='a'&&str.at(N-1)=='e'){
					str.erase(N-1);
					str.erase(N-5,N-1);
					flag=true;
				}
			}else if(str.at(N-3)=='s'){
				if(str.at(N-6)=='e'&&str.at(N-5)=='r'&&str.at(N-4)=='a'&&str.at(N-2)=='e'&&str.at(N-1)=='r'){
					str.erase(N-1);
					str.erase(N-6,N-1);
					flag=true;
				}
			}		
		}else if(str.size()==6){
			if(str.at(N-3)=='s'){
				if(str.at(N-6)=='e'&&str.at(N-5)=='r'&&str.at(N-4)=='a'&&str.at(N-2)=='e'&&str.at(N-1)=='r'){
					str.erase(N-1);
					str.erase(N-6,N-1);
					flag=true;
				}
			}	
		}else{
			if(str.at(N-5)=='d'){
				if(str.at(N-4)=='r'&&str.at(N-3)=='e'&&str.at(N-2)=='a'&&str.at(N-1)=='m'){
					str.erase(N-1);
					str.erase(N-5,N-1);
					flag=true;
				}
			}else if(str.at(N-2)=='s'){
				if(str.at(N-5)=='e'&&str.at(N-4)=='r'&&str.at(N-3)=='a'&&str.at(N-1)=='e'){
					str.erase(N-1);
					str.erase(N-5,N-1);
					flag=true;
				}
			}
		}		

		if(flag==true){
			flag=false;
		}else{
			break;
		}
	}
	
	if(str.size()==0){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 512
class dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
    
    def setnum(self,s):
        self.number = s

    def kai(self,h):
        tmp = self.number
        if h == 'E':
            self.number = [tmp[3],tmp[1],tmp[0],tmp[5],tmp[4],tmp[2]]
        elif h == 'S':
            self.number = [tmp[4],tmp[0],tmp[2],tmp[3],tmp[5],tmp[1]]
        elif h == 'W':
            self.number = [tmp[2],tmp[1],tmp[5],tmp[0],tmp[4],tmp[3]]
        elif h == 'N':
            self.number = [tmp[1],tmp[5],tmp[2],tmp[3],tmp[0],tmp[4]]

    def Qright(self,up,flont,num):
        uf = (up,flont)
        if uf == (num[1],num[2]) or uf ==(num[2],num[4]) or uf ==(num[4],num[3]) or uf ==(num[3],num[1]):
            ans = num[0]
        elif uf == (num[0],num[3]) or uf ==(num[3],num[5]) or uf ==(num[5],num[2]) or uf ==(num[2],num[0]):
            ans = num[1]
        elif uf == (num[0],num[1]) or uf ==(num[1],num[5]) or uf ==(num[5],num[4]) or uf ==(num[4],num[0]):
            ans = num[2]
        elif uf == (num[0],num[4]) or uf ==(num[4],num[5]) or uf ==(num[5],num[1]) or uf ==(num[1],num[0]):
            ans = num[3]
        elif uf == (num[0],num[2]) or uf ==(num[2],num[5]) or uf ==(num[5],num[3]) or uf ==(num[3],num[0]):
            ans = num[4]
        elif uf == (num[1],num[3]) or uf ==(num[3],num[4]) or uf ==(num[4],num[2]) or uf ==(num[2],num[1]):
            ans = num[5]
        print(ans)



n=int(input())
num_list=[]
for i in range(n):
    num = list(map(int,input().split()))
    num_list.append(num)
#kaitenn = input()
testall = 'NNNNENNNNENNNNENNNNENWNNNNEENNNN'
#q = int(input())
flg=0
for i in range(n):
    dice1 = dice()
    dice1.setnum(num_list[i])

    temp_num=[]
    temp_num = num_list.copy()
    temp_num.remove(num_list[i])
    for j in range(n-1):
        cnt = 0
        for k in range(len(testall)):
            dice1.kai(testall[k])
            #print(i,j,k)
            if dice1.number == temp_num[j]:
                flg = 1
                #print('k break')
                break
        if flg == 1:
            #print('j break')
            break
    if flg == 1:
        #print('i break')
        break
    del dice1
if flg==0:
    print('Yes')
else:
    print('No')
#dice = dice()
#dice.setnum(num)
#for i in range(len(testall)):
##    up,flont = map(int,input().split())
##    dice.Qright(up,flont,num)
#    dice.kai(testall[i])
#    if dice.number == num:
#        print("Yes")
#        break
#    if i == len(testall)-1:
#        print("No")
##print(dice.number[0])


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

int n, q;
string s;
vector<set<int>> moji(30, set<int>());

int main()
{
    cin >> n >> s >> q;
    rep(i, n)
    {
        moji[s[i] - 'a'].insert(i);
    }

    rep(i, q)
    {
        int f;
        cin >> f;
        if(f == 1)
        {
            int num;
            char c;
            cin >> num >> c;
            num--;
            moji[s.at(num) - 'a'].erase(num);
            moji[c - 'a'].insert(num);
            s.at(num) = c;
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--; r--;
            int res = 0;
            rep(j, 26)
            {
                if(moji[j].lower_bound(l) != moji[j].upper_bound(r))
                {
                    res++;
                }
            }
            cout << res << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    A.push_back(K + A[0]);
    int maxElement = 0;
    for (int i = 1; i <= N; i++) {
        maxElement = max(maxElement, A[i] - A[i - 1]);
    }
    cout << K - maxElement << '\n';
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

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

	cout<<r*r<<endl;

	return 0;
}
	


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

#define FOR(i, a, b) for (int i = a; (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<int>;
using vvi = vc<vi>;

template <class T>
using va = valarray<T>;
using vad = va<ld>;


int main() {
    cout << setprecision(20) << fixed;

    while (true) {
        long double n;
        cin >> n;
        if (n == 0) break;
        auto      s = vad(n);
        for (auto i = std::size_t(0); i < n; ++i) {
            cin >> s[i];
        }

        const auto ave = s.sum() / n;

        cout << sqrt(((s - ave) * (s - ave)).sum() / n) << endl;
    }
    return 0;
}



Measured memory_bytes: 3284
using System;
using System.Linq;
namespace algo
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var abc = input.Select(x => int.Parse(x)).ToArray();
            var tmp = 0;
            tmp = abc[0];
            abc[0] = abc[1];
            abc[1] = tmp;

            tmp = abc[0];
            abc[0] = abc[2];
            abc[2] = tmp;
            Console.WriteLine("{0} {1} {2}", abc[0], abc[1], abc[2]);
        }
    }
}


Measured memory_bytes: 13396
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
#include <string>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }

    vector<vector<char>> maze(h + 2, vector<char>(w + 2, '#'));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            maze[i + 1][j + 1] = s[i][j];
        }
    }

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

    int res = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (maze[i + 1][j + 1] == '#') {
                continue;
            }

            vector<vector<int>> d(h + 2, vector<int>(w + 2, inf));
            d[i + 1][j + 1] = 0;

            priority_queue<pair<int, pair<int, int>>,
                    vector<pair<int, pair<int, int>>>,
                    greater<pair<int, pair<int, int>>>> que;
            que.push(make_pair(0, make_pair(i + 1, j + 1)));
            while (!que.empty()) {
                pair<int, pair<int, int>> p = que.top();
                que.pop();

                int y = p.second.first;
                int x = p.second.second;

                for (int k = 0; k < 4; k++) {
                    if (maze[y + dy[k]][x + dx[k]] == '.' && d[y][x] + 1 < d[y + dy[k]][x + dx[k]]) {
                        d[y + dy[k]][x + dx[k]] = d[y][x] + 1;
                        que.push(make_pair(d[y + dy[k]][x + dx[k]], make_pair(y + dy[k], x + dx[k])));
                    }
                }
            }

            for (int k = 0; k < h; k++) {
                for (int l = 0; l < w; l++) {
                    if (maze[k + 1][l + 1] == '.') {
                        res = max(res, d[k + 1][l + 1]);
                    }
                }
            }
        }
    }

    cout << res << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline int ubnd(T&v,ET(T) x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T) x){return lower_bound(begin(v),end(v),x)-begin(v);}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline void inpt(T&v,int n,function<ET(T)()>f=In<ET(T)>){for(v.reserve(n);n--;v.emplace_back(f()));}
TT inline void show(T&v,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),cout<<x;cout<<e;}
#undef TT
#undef ET

inline void fast_io(){ios::sync_with_stdio(0); cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline string instr(){string x;cin>>x;return x;}
inline ll pow_mod(ll a, ll k, ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a, ll p){return pow_mod(a,p-2,p);}

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

int main()
{
  deque<char> dq;
  string s;
  cin >> s;
  for (const auto& c : s) dq.push_back(c);
  int cnt = 0;
  while (dq.size() > 1u){
    char a, b;
    a = dq.front();
    b = dq.back();
    dq.pop_front();
    dq.pop_back();
    if ((a == 'i' || a == 'w') && a == b) continue;
    if (a == '(' && b == ')') continue;
    if (a == ')' && b == '(') continue;
    cnt++;
  }
  if (dq.size() == 1u){
    if (dq[0] != 'i' && dq[0] != 'w') cnt++;
  }
  cout << cnt << endl;
  return (0);
}

// priority_queue queue deque front top push pop map set stringstream max_element min_element insert count find get tie make_tuple

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

int main(){
	int n, i;
	long long k, pt[55] = {1}, bg[55] = {1}, ans = 0;
	scanf("%d%lld", &n, &k);
	for(i = 1; i <= n; i++){
		bg[i] = 2*bg[i-1] + 3;
		pt[i] = 2*pt[i-1] + 1;
	}
	for(int i = n-1; i >= 0; i--){
		if(k == bg[i+1]){
			ans += pt[i+1];
			break;
		}else if(k > bg[i] + 2){
			ans += pt[i] + 1;
			k -= bg[i] + 2;
			if(!i) ans++;
		}else if(k == bg[i] + 2){
			ans += pt[i] + 1;
			break;
		}else if(k > 1){
			k--;
			if(!i) ans++;
		}else break;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 998244353;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int a[100005];
set <int> S;

signed main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if(i % 2 == 1)
		{
			S.insert(a[i]);
		}
	}	
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i = i + 2)
	{
		if(S.count(a[i]) == true)
		{
			S.erase(a[i]);
		}
	}
	cout << int(S.size());
}

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

int main() {
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T'<<endl;
  }
  else if(b=='T'){
    cout<<'A'<<endl;
  }
     else if(b=='G'){
       cout<<'C'<<endl;
     }
     else{
       cout<<'G'<<endl;
     }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define INPUT()              freopen("input.txt", "r", stdin)
                #define OUTPUT()             freopen("output.txt", "w", stdout)
                #define F                    first
                #define S                    second
            //Templatefunctions
                template<typename T>T gcd(T x, T y) { if (y == 0)return x; else return gcd(y, x%y);}
                template <class T> T euclideanDistance(T x1 , T x2 , T y1 , T y2){return sqrt(( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ));}
                template <class T> T digitSum(T n){T sum = 0;while(n > 0)sum += n % 10,n /= 10;return sum;}
            //datatypes
                typedef long long int ll;
                typedef unsigned long long int ull;
                typedef long double ld;
            //constants
                const double INF = 1e+9;
                const double INFLL = 1e+18;
                const double EPS = 1e-9;
                const double PI = acos(-1);
                const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
                       //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
                       //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
                const int dx[] = {0 , 1 , 0 , -1};
                const int dy[] = {1 , 0 , -1 , 0};
            //helpers
                //#define MOD         1000000007LL
                #define MAX         1000005
                const ll MOD = 1000000000 + 7;
                int arr[MAX];
            //Global Variables


                int manhattanDis(int  x , int y , int x1 , int y1)
                {
                    return abs(x - x1) + abs(y - y1);
                }
                int main()
                {
                    string a , b;
                    cin>>a>>b;

                    int lena = a.length();
                    int lenb = b.length();
                    string ans = "";
                    for(int i = 0 ; i < lenb ; i++)
                    {
                        ans += a[i];
                        ans += b[i];
                    }
                    if(lena > lenb)
                    {
                        ans += a[lena-1];
                    }
                    cout<<ans<<endl;
                }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>; using vi = vector<int>; using vl = vector<ll>;

signed main() {
    int n;
    cin >>n;
    vi a(n), b(n), c(n);
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    int dp[n][3];
    dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
    FOR(i, 1, n) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c[i];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;

    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;


LL modpow(LL x,int a){
  LL ans=1;
  while(a){
    if(a&1) ans=ans*x%MOD;
    a>>=1;
    x=x*x%MOD;
  }
  return ans;
}

int main(){
  LL b,w;
  cin >> b >> w;
  vector<int> inv(b+w+1);
  for(int i=1;i<=b+w;i++) inv[i]=modpow(i,MOD-2);
  LL p=0,q=0,cp=modpow(inv[2],b),cq=modpow(inv[2],w);
  for(int i=0;i<b+w;i++){
    if(i>=b){
      p=(p+cp)%MOD;
      cp=cp*i%MOD*inv[i-b+1]%MOD*inv[2]%MOD;
    }
    if(i>=w){
      q=(q+cq)%MOD;
      cq=cq*i%MOD*inv[i-w+1]%MOD*inv[2]%MOD;
    }
    cout << ((1-p+q)*inv[2]%MOD+MOD)%MOD << endl;
  }
  return 0;
}


Measured memory_bytes: 2944
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
}

signed main() {
	bool is_prime[10010] = {};
	eratos(10010, is_prime);
	for (int n; cin >> n&&n;) {
		int cnt = 0;
		rep(i, 1, n + 1) {
			if (is_prime[i] && is_prime[n - i + 1])cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

using namespace std;

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

int main() {
  int N, K;
  cin >> N >> K;
  int res = 1;
  for (int i = 0; i < N; ++i) {
    res = min(2 * res, res + K);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long c = sc.nextInt();
    long d = sc.nextInt();

    long lcmCD = lcm(c, d);

    long cMultiples = b / c - (a - 1) / c;
    long dMultiples = b / d - (a - 1) / d;
    long cdMultiples = b / lcmCD - (a - 1) / lcmCD;

    System.out.println(b - a + 1 - cMultiples - dMultiples + cdMultiples);
  }

  public static long gcd(long a, long b) {
    return (a == 0) ? b : gcd(b % a, a);
  }

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

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

int main() {
    int n,k;cin>>n>>k;
    int mod=1e9+7;
    int c[2000][2000];
    for (int i=0;i<2000;i++)
        c[i][0]=c[i][i]=1;
    for (int i=2;i<2000;i++)
        for (int j=1;j<i;j++)
            c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
    for (int i=1;i<=k;i++)
        cout<<(n-k+1<i?0:(ll)c[n-k+1][i])*c[k-1][i-1]%mod<<endl;
    return 0;
}

Measured memory_bytes: 15744
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if((a <= 8)&&(b <= 8)) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}
		
		
	}
}

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

int main()
{
    string s,t;
    long long n=0,sz;
    cin>>s>>t;
    sz=s.size();
    for(int i=0;i<sz;i++)
    {
        if(s[i]!=t[i])
            n++;
    }
    cout<<n<<endl;
    return 0;
}



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K,S;
int X[2222][3];

int table[2222][2222];

int f(int a,int b){
    if(a>b)swap(a,b);
    return max(0ll,a+S-b);
}
vint G[2222];

bool used[2222];
int dfs(int v,int c,int p){
    if(c==K){
        if(c<=2)return 0;
        return table[v][p];
    }

    used[v]=true;
    int ret=LLONG_MIN;
    for(auto u:G[v]){
        if(used[u])continue;
        int tmp=dfs(u,c+1,p);
        if(tmp!=LLONG_MIN)chmax(ret,tmp+table[v][u]);
    }
    used[v]=false;
    return ret;
}

void solve(){
    rep(i,N)rep(j,3)cin>>X[i][j];
    memset(table,0,sizeof(table));
    rep(i,N)G[i].clear();
    rep(i,N)rep(j,N)if(i!=j){
        vint v;
        bool flag=true;
        rep(k,3){
            int tmp=f(X[i][k],X[j][k]);
            if(tmp==0){
                flag=false;
            }
            v.pb(tmp);
        }
        if(!flag)continue;
        G[i].pb(j);
        rep(k,3)table[i][j]+=v[k]*v[(k+1)%3];
    }

    memset(used,0,sizeof(used));
    int ma=LLONG_MIN;
    rep(i,N){
        chmax(ma,dfs(i,1,i));
    }

    if(ma==LLONG_MIN){
        cout<<-1<<endl;
        return;
    }
    cout<<(3*S*S*K-ma)*2<<endl;
}

signed main(){
    while(cin>>N>>K>>S,N||K||S)solve();
    return 0;
}

Measured memory_bytes: 41780
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, X int
	fmt.Scan(&N)

	var Xs []int
	for i := 0; i < N; i++ {
		fmt.Scan(&X)
		Xs = append(Xs, X)
	}

	original := make([]int, N)
	copy(original, Xs)
	sort.Ints(Xs)

	left := Xs[N / 2 - 1]
	right := Xs[N / 2]
	for i := 0; i < N; i++ {
		if original[i] <= left {
			fmt.Println(right)
		} else {
			fmt.Println(left)
		}
	}
}

Measured memory_bytes: 10496
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}


int main() {
	IOS;
	string s;
	cin >> s;
	bool exist[26];
	MEM(exist,false);
	REP(i, s.size())exist[s[i] - 'a'] = true;
	ll ans = LMAX;
	REP(i, 26) {
		if (!exist[i])continue;
		char unko = 'a' + i;
		ll tmp = 0;
		string t = s;
		while (1) {
			bool ok = true;
			REP(j, t.size())if (t[j] != unko)ok = false;
			if (ok) {
				if (ans > tmp)ans = tmp;
				break;
			}
			string hoo = "";
			REP(j, t.size() - 1) {
				if (t[j] == unko || t[j + 1] == unko)hoo = hoo + unko;
				else hoo = hoo + t[j];
			}
			tmp++;
			t = hoo;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt(),b=s.nextInt(),c=s.nextInt();
        int diff = a-b;
        if(c<=diff) System.out.println(0);
        else System.out.println(c-diff);
    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main()
{
  int N; cin >> N;
  string S; cin >> S;
  if(N % 2 == 1) cout << "No" << endl;
  else
  {
    bool check = false;
    rep(i, N/2)
    {
      if(S.at(i) != S.at(i + N/2)) check = true;
    }
    if(check) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a=100000;
	while(cin>>n){
		for(int i=1;i<=n;i++){
			int b=a*0.05;
			if(b%1000)
				b=(b/1000+1)*1000;
			a+=b;
		}
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
"""
& C:/Users/Takuki/Anaconda3/python.exe c:/Users/Takuki/Documents/competitive/main2.py
"""
n = int(input())
p = list(map(int, input().split()))
ans = 0
mn = n + 1
for i in range(n):
    if p[i] < mn:
        ans += 1
        mn = p[i]
print(ans)


Measured memory_bytes: 24872
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

int dig(int x){
  // 1,2,3,4,5
  int ss=x%10+(x-(x/100)*100)/10+(x-(x/1000)*1000)/100+(x-(x/10000)*10000)/1000+(x-(x/100000)*100000)/10000;
  return ss;
}

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  int minn=INF;
  for(int i=1;i<n;i++){
    // P(dig(i));
    minn=min(minn, dig(i)+dig(n-i));
  }
  P(minn);
  return 0;
}


Measured memory_bytes: 256
n,t=map(int,input().split())
cost=[]
time=[]
for i in range(n):
    x,y=map(int,input().split())
    cost.append(x)
    time.append(y)
z=[]
for i in range(n):
    if time[i]<=t:
        z.append(cost[i])
if len(z)==0:
    print('TLE')
else:
    print(min(z))

Measured memory_bytes: 3064
n, m, x, y = map(int, input().split())
xl = [int(i) for i in input().split()]
yl = [int(i) for i in input().split()]
xl.append(x)
yl.append(y)

if(max(xl) < min(yl)):
    print("No War")
else:
    print("War")


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

int main() {
  int N;
  cin >> N;
  int dmin = 100;
  for(int i = 0; i < N; i++){
    int A;
    int d = 0;
    cin >> A;
    while(A % 2 == 0){
        A /= 2;
        d++;
    }
    dmin = min(dmin, d);
  }
  cout << dmin << endl;
}


Measured memory_bytes: 256
//write：Sakura
//id：
//problem：
//note：

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

typedef long long ll;

int n;
int snum=0;

void work(int x){
	while(x>0){
		snum+=x%10;
		x/=10;
	}
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	work(n);
	if(snum%n==0 || n%snum==0){
		puts("Yes");
		exit(0);
	}
	else{
		puts("No");
		exit(0);
	}
	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using R=long double;
using edge=tuple<R,int>;

const int limit=310;
int x[limit],y[limit];

int main(void){
	int n,m;
	while(cin >> n >> m,n){
		rep(i,n) cin >> x[i] >> y[i];

		vector<edge> graph[limit];
		vector<int> used[limit];

		rep(i,m){
			int s,t;
			cin >> s >> t;
			s--,t--;
			graph[s].push_back(make_tuple(atan2(y[t]-y[s],x[t]-x[s]),t));
			used[s].push_back(-1);
			graph[t].push_back(make_tuple(atan2(y[s]-y[t],x[s]-x[t]),s));
			used[t].push_back(-1);
		}

		rep(v,n) sort(_all(graph[v]));
		
		int all=0;
		rep(v,n){
			rep(i,graph[v].size()){
				if(used[v][i]!=-1) continue;
				
				int cur=v,idx=i;
				do{
					used[cur][idx]=all;
					int nxt=get<1>(graph[cur][idx]),nidx=0;
					rep(j,graph[nxt].size()) if(get<1>(graph[nxt][j])==cur) nidx=(j+1)%int(graph[nxt].size());
					cur=nxt,idx=nidx;
				}while(cur!=v);
				all++;
			}
		}
	
		int dual[limit][limit];
		rep(i,all)rep(j,all) dual[i][j]=(i==j)?0:(1<<20);

		int outer=used[min_element(x,x+n)-x][0];
		
		rep(v,n){
			rep(i,graph[v].size()){
				int v2=get<1>(graph[v][i]),j=0;
				while(get<1>(graph[v2][j])!=v) j++;

				dual[used[v][i]][used[v2][j]]=1;
				dual[used[v2][j]][used[v][i]]=1;
			}
		}

		rep(k,all)rep(i,all)rep(j,all) chmin(dual[i][j],dual[i][k]+dual[k][j]);
		int ans=1;
		rep(v,all) chmax(ans,dual[outer][v]);
		cout << ans << endl;
	}		
	return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
 
const int mnx = 3e5 + 9;
const int mod = 1e9 + 7;
 
ll n, ans;
ll a[mnx];
 
int main(){
 
cin>>n;
 
for(int i=1; i<=n; i++){
    cin>>a[i];
}
 
for(int i=1; i<=n; i++){
    ans += a[i] / 2;
    if(a[i] % 2 != 0 && a[i+1] != 0){ ans++; a[i+1]--; }
}
 
cout<<ans<<'\n';
 
return 0;
 
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    ll n, t;
    cin >> n >> t;
    ll start = 0;
    ll end = t;
    ll ans = 0;
    rep(i, n) {
        int tmp_t;
        cin >> tmp_t;
        if ( tmp_t < end ) {
            end = tmp_t + t;
            continue;
        }
        else {
            ans += end - start;
            start = tmp_t;
            end = tmp_t + t;
        }
    }
    ans += ( end - start );
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  string str;
  cin >> str;
  int happy = 0;
  for(int i=1; i<(n-1); i++){
    if(str[i] == 'L'){
      if(str[i-1] == 'L'){
        happy++;
      }
    }
    if(str[i] == 'R'){
      if(str[i+1] == 'R'){
        happy++;
      }
    }
  }
  if(str[0] == 'R' && str[1] == 'R') happy++;
  if(str[n-1] == 'L' && str[n-2] == 'L') happy++;
  int nothappy = n - happy;
  for(int i=0; i<k; i++){
    nothappy -= 2;
    if(nothappy <= 1){
      cout << n-1 << endl;
      return 0;
    }
  }
  cout << n - nothappy << endl;
  return 0;
}
  
  

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        if(a % 2 == 1 && i % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
n = int(input())
c = 100000000000000000
for i in range(1,int(n/2)+2):
    a = list(str(i))
    b = list(str(n-i))
    a1 = [int(s) for s in a]
    b1 = [int(s) for s in b]
    if sum(a1) + sum(b1) < c:
        c = sum(a1) + sum(b1)

print(c)

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

int main()
{
  int n,d; cin >> n >> d;
  int counter=0;
  for(int i=0; i<n; ++i){
    long double x,y; cin >> x >> y;
    long double dist=pow(x,2)+pow(y,2);
    dist=sqrt(dist);
    if(dist<=d) ++counter;
  }
  cout << counter << endl;
}


Measured memory_bytes: 3836
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

s = input()
li = []
for i in range(len(s)):
    for j in range(len(li)):
        if s[i] == li[j]:
            print("no")
            sys.exit()
    li.append(s[i])
print("yes")

Measured memory_bytes: 12508
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

typedef long long ll;

ll n,x;

ll solve(ll n,ll x)
{
	if (n == x)
		return 0;
	x = min(x,n - x);
	ll t = (n - x) / x;
	return solve(n - t * x,x) + t * 3 * x;
}

int main()
{
	cin >> n >> x;
	cout << solve(n,x) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll W, H;
ll X, Y;
pl P[MAX_N];

void solve() {
	X = 0; Y = 0;
	cin >> W >> H;
	rep(i, 0, W) {
		ll a; cin >> a;
		P[i] = pl(a, 0);
	}
	rep(i, 0, H) {
		ll a; cin >> a;
		P[i + W] = pl(a, 1);
	}
	sort(P, P + H + W);
	ll ans = 0;
	rep(i, 0, H + W) {
		if(P[i].sec == 0) {
			ans += (H + 1 - X) * P[i].fst;
			Y++;
		}
		else {
			ans += (W + 1 - Y) * P[i].fst;
			X++;
		}
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main(){
	int a, b, q;
	cin >> a >> b >> q;
	vector<ll> s(1);
	vector<ll> t(1);
	s.at(0) = -1000000000000;
	t.at(0) = -1000000000000;
	rep(i, a){
		ll in;
		cin >> in;
		s.push_back(in);
	}
	rep(i, b){
		ll in;
		cin >> in;
		t.push_back(in);
	}
	s.push_back(1000000000000);
	t.push_back(1000000000000);
	vector<ll> an(q);
	rep(i, q){
		ll x;
		cin >> x;
		int k = lower_bound(s.begin(), s.end(), x) - s.begin();
		int l = lower_bound(t.begin(), t.end(), x) - t.begin();
		vector<ll> ans(8);
		ans.at(0) = abs(s.at(k)-x) + abs(t.at(l) - s.at(k));
		ans.at(1) = abs(s.at(k)-x) + abs(t.at(l-1) - s.at(k));
		ans.at(2) = abs(x-s.at(k-1)) + abs(t.at(l) - s.at(k-1));
		ans.at(3) = abs(x-s.at(k-1)) + abs(t.at(l-1) - s.at(k-1));
		ans.at(4) = abs(t.at(l)-x) + abs(s.at(k) - t.at(l));
		ans.at(5) = abs(t.at(l)-x) + abs(s.at(k-1) - t.at(l));
		ans.at(6) = abs(x-t.at(l-1)) + abs(s.at(k) - t.at(l-1));
		ans.at(7) = abs(x-t.at(l-1)) + abs(s.at(k-1) - t.at(l-1));
		ll anser = 1000000000000;
		rep(i, 8){
			anser = min(anser, ans.at(i));
		}
		an.at(i) = anser;
	}
	rep(i, q){
		cout << an.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 3828
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！

def BELLMANFORD(point,n,d,p):
    cost       = [-float("inf")]*(n+1)  #infじゃないと閉路検出がうまくいかない
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for nownode,nextnode,c in d:
            if cost[nextnode]<cost[nownode]+c-p:
                cost[nextnode]=cost[nownode]+c-p

    negative=[0]*(n+1)                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定 negativeの1は閉路に入っている部分を表す
        for nownode,nextnode,c in d:
            if negative[nownode]==1:
                negative[nextnode]=1
            if cost[nextnode]<cost[nownode]+c-p:
                cost[nextnode]=cost[nownode]+c-p
                negative[nownode]=1
 
    return cost,negative

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

    d=[tuple(map(int,input().split()))for i in [0]*m]
    
    x,y=(BELLMANFORD(1,n,d,p))
    
    if y[n]==1:
        print(-1)
    else:
        print(max(x[n],0))

    
if __name__ == '__main__':
    main()

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s, t;
  cin >> s >> t;
  unordered_map<char, char> mp, imp;
  bool flg = true;

  for (int i = 0; i < s.length(); ++i) {
    char cs = s[i], ct = t[i];
    if (mp.count(cs))
      if (mp[cs] != ct) flg = false;
    if (imp.count(ct))
      if (imp[ct] != cs) flg = false;
    mp[cs] = ct, imp[ct] = cs;
  }

  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}


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

int main()
{
    string s;
    int sm = 0;
    cin >> s;
    for(int i = 0; i < 4; i++)
    {
        if(s[i] == '+') sm++;
        else sm--;
    }
    cout << sm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main(void)
{
  int n;
  cin >> n;
  
  long long count=0;
  int tmp;
  for(int i=0; i<n; i++){
   cin >> tmp;
   count += tmp-1;
  }
  cout << count << endl;
   
  return 0;
}


Measured memory_bytes: 256