akhauriyash/Code-Regression huggingface dataset:
<?php
$n = fgets(STDIN);
$t = [0];
$x = [0];
$y = [0];
for ($i = 0; $i < $n; $i++) {
    list($t[$i + 1], $x[$i + 1], $y[$i + 1]) = explode(' ', fgets(STDIN));
}
$can = true;
for ($i = 0; $i < $n; $i++) {
    $dt = $t[$i + 1] - $t[$i];
    $dist = abs($x[$i + 1] - $x[$i]) + abs($y[$i + 1] - $y[$i]);
    if ($dt < $dist) {
        $can = false;
    }
    if ($dist % 2 !== $dt % 2) {
        $can = false;
    }
}
echo $can ? 'Yes' : 'No';
?>

Measured memory_bytes: 56692
#include<iostream>
int main()
{ int a;
    std::cin>>a;
    if((a%10==2)||(a%10==4)||(a%10==5)||(a%10==7)||(a%10==9)){
        std::cout<<"hon"<<std::endl;
    }
else if((a%10==0)||(a%10==1)||(a%10==6)||(a%10==8)) {
    std::cout<<"pon"<<std::endl;}
else  {
    std::cout<<"bon"<<std::endl;}
    }


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    vector<ll> v(n);
    ll xxor=0;
    for(ll i=0;i<n;i++)
    {
        cin>>v[i];
        xxor = xxor^v[i];
    }
    for(ll i=0;i<n;i++)
    {
        v[i] = v[i]^xxor;
    }
    for(ll i:v) cout<<i<<" ";
    cout<<endl;
}

Measured memory_bytes: 4752
import sys
a,b = map(int,input().split())

if a == 0 and b == 100:
  print(101)
  sys.exit()
if a == 0:
  print(b)
if a == 1 and b == 100:
  print(10100)
  sys.exit()
if a == 1:
  print(100 * b)
if a == 2 and b == 100:
  print(1010000)
  sys.exit()
if a == 2:
  print(10000 * b)


Measured memory_bytes: 3060
N = int(input())
S = [input() for _ in range(N)]

S.sort()

maxint = 1

sdic = {}

for s in S:
    if s in sdic:
        sdic[s] += 1
        if sdic[s] > maxint:
            maxint = sdic[s]

    else:
        sdic[s] = 1

for s in sdic:
    if sdic[s] == maxint:
        print(s)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

  rep(i,m){
    int a;
    cin >> a;
    n-=a;
  }

  cout << max(-1,n) << endl;

}

Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

ll extgcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    else{
        ll d=extgcd(b,a%b,y,x);
        y-=(a/b)*x;
        return d;
    }
}

int main(){
    ll a,b;cin>>a>>b;
    ll x,y;
    extgcd(a,b,x,y);
    vll c(4);
    c[0]=x/b;
    c[1]=x/b+1;
    c[2]=-y/a;
    c[3]=-y/a-1;
    ll m=INF;
    ll ansx,ansy;
    rep(i,4){
        if(abs(-b*c[i]+x)+abs(a*c[i]+y)<m){
            m=abs(-b*c[i]+x)+abs(a*c[i]+y);
            ansx=-b*c[i]+x;
            ansy=a*c[i]+y;
        }
        else if(abs(-b*c[i]+x)+abs(a*c[i]+y)==m){
            if(-b*c[i]+x<=a*c[i]+y){
                ansx=-b*c[i]+x;
                ansy=a*c[i]+y;
            }
        }
    }
    cout<<ansx<<" "<<ansy<<endl;
}


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

int main()
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

int n,i,j;
int count,ans;

scanf("%d", &n);

ans = 0;
for(j=n;j>0;j--){
    
        count = 0;
        for(i=j;i>0;i--){//奇数で約数のものをnから1まで
                if(i%2 == 1 && j%i == 0){//奇数で約数のものを数える
                        count++;
                }   
        }   

        if(count == 8){//奇数で約数が８個ものをカウントする
                ans++;
        }   
}

printf("%d\n", ans);

return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

#define i64 long long int
#define ran 101101

int n;
int a[ran];
vector<int> e[ran];
int v[ran];
int it;

void dfs(int cur, int par) {
	for(int i=0;i<(int)e[cur].size();i++) {
		int nxt = e[cur][i];
		if(nxt==par) continue;
		
		dfs(nxt, cur);
	}
	v[cur] = a[it++];
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<n;i++) {
		int x, y; scanf("%d%d", &x, &y);
		e[x].push_back(y); e[y].push_back(x);
	}
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n);
	
	i64 ans = 0;
	for(int i=0;i<n-1;i++) ans+=a[i];
	
	it = 0;
	dfs(1, -1);
	
	printf("%lld\n", ans);
	for(int i=1;i<=n;i++)
		printf("%d%c", v[i], i<n ? ' ' : '\n');
	
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(1, 1);
    for (int i = 6; i <= n; i *= 6) {
        v.push_back(i);
    }
    for (int i = 9; i <= n; i *= 9) {
        v.push_back(i);
    }
    vector<int> res(n + 1, 0x3f3f3f3f);
    res[0] = 0;
    for (int i = 0; i <= n; i++) {
        if (res[i] == 0x3f3f3f3f) continue;
        for (int j = 0; j < v.size(); j++) {
            if (i + v[j] <= n) {
                res[i + v[j]] = min(res[i + v[j]], res[i] + 1);
            }
        }
    }
    cout << res[n] << endl;
}


Measured memory_bytes: 3596
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){

		
		Scanner stdIn = new Scanner(System.in);

		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();

		int ans = a + b;
		if(ans > a + c){
			ans = a + c;
		}
		if(ans > b + c){
			ans = b + c;
		}
		System.out.println(ans);
  
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int cnt[2][105];

int main() {
	string s;
	cin >> s;
	int n = s.length();
	bool flag = true;
	for (int i = 0;i < (n - 1) / 2;++i) {
		if (s[i] != s[n - 1 - i])flag = false;
	}
	for (int i = 0;i < (n - 1) / 4;++i) {
		if (s[i] != s[(n - 1) / 2 - 1 - i])flag = false;
		else if (s[(n + 1) / 2 + i] != s[n - 1 - i])flag = false;
	}
	if (flag)puts("Yes");
	else puts("No");
	return 0;
}


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

int main(){
    int i,N;
    int Flag;
    cin >> N;
    char S[N-1];
    for (i = 0; i <= N-1; i++){
        cin >> S[i];
    }
    
    if(N & 2 != 0){
        cout << "No";
    }
    else{
        for (i = 0 ; i < N/2; i++){
            if(S[i] != S[i + N/2]){
                 cout << "No";
                 return 0;
            }
        }
        cout << "Yes";
    }
    return 0;
}

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

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

    int a[300000],b[300000];
    for (int i = 0; i < N; i++)
    {
        cin>>a[i];
        b[i]=a[i];
        /* code */
    }

    sort(b,b+N);
    int D = 0;
    for (int i = 0; i < N; i++)
    {
        if(a[i]!=b[i])
        {
            D++;
        }
        /* code */
    }
    if(D==0)
    {
        cout<< 0 << endl;
        return 0;
    }
    int Q;
    cin>>Q;

    for (int i = 1; i <= Q; i++)
    {int x,y;
    cin>>x>>y;

    if(a[x-1]!=b[x-1])

    {
        D--;
    }
    if(a[y-1]!=b[y-1])
    {
        D--;
    }
        /* code */
    swap(a[x-1],a[y-1]);
    if(a[x-1]!=b[x-1])

    {
        D++;
    }
    if(a[y-1]!=b[y-1])
    {
        D++;
    }
    if(D==0)
    {
        cout<<i<<endl;
        return 0;
    }
    }
    cout<<-1<<endl;
    return 0;
    
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

	int X; cin >> X;

	int ans;

	if (X < 100) {
		cout << 0 << endl;
		return 0;
	}
	else if (X >= 10000){
		cout << 1 << endl;
		return 0;
	}

	int d = X % 100;
	int e;
	if (d % 5 == 0) e = d / 5;
	else {
		e = d / 5 + 1;
	}

	int f = (X - d) / 100;
	if (f >= e) cout << 1 << endl;
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
h =  list(map(int, input().split() ))
#print(h)

flag = 0
highest = h[0]
for i in range(1,n):
	if h[i] < highest-1:
		flag =1
	elif h[i]>highest:
		highest = h[i]
if flag ==0:
	print("Yes")
else:
	print("No")

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


#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define DEBUG freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
//#define int long long
using namespace std;
const int MOD = 1000000007;
const int INF = 1e9+5;

signed main() {
	FAST_IO;

	int h, w;
	cin >> h >> w;
	char grid[h][w];
	int dp[h][w];
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			cin >> grid[i][j];
			if (grid[i][j] == '#') dp[i][j] = 0;
			else dp[i][j] = -INF;
		}
	}

	int fill = 1;
	for (int i=0; i<h; i++) {
		if (dp[i][0] == 0) fill = 0;
		dp[i][0] = fill;
	}

	fill = 1;
	for (int i=0; i<w; i++) {
		if (dp[0][i] == 0) fill = 0;
		dp[0][i] = fill;
	}

	for (int i=1; i<h; i++) {
		for (int j=1; j<w; j++) {
			if (dp[i][j] != 0) dp[i][j] = dp[i-1][j] % MOD + dp[i][j-1] % MOD;
		}
	}
	cout << dp[h-1][w-1] % MOD;
	return 0;
}

Measured memory_bytes: 5120
fun main (arg: Array<String>){
	var N = readLine()!!.toInt()
    var list= readLine()!!.split(" ").map(String::toInt)
	var flag = 0
	for(i in 0..N-1){
		var tmp = list[i]
		if(tmp%2 == 0){
			if(tmp%3 != 0 && tmp%5 != 0){
				flag = 1
				break
			}
		} 
	}
	if(flag == 0){
		println("APPROVED")
	}else{
		println("DENIED")
	}
}

Measured memory_bytes: 37964
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main () {
	double r, a, b;
	double pi = acos(-1);
	cin >> r;
	a = r*r*pi;
	b = 2*pi*r;
	cout << fixed << setprecision(5);
	cout << a << " " << b << endl;
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

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

using namespace std;

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

    // AC, WA, TLE, RE
    int C[4] = {};
    string tmp;

    for (int i=0; i < N; i++) {
        cin >> tmp;
        if(tmp == "AC"){
            C[0]++;
        } else if (tmp == "WA") {
            C[1]++;
        } else if (tmp == "TLE") {
            C[2]++;
        } else if (tmp == "RE") {
            C[3]++;
        }
    }

    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;
}

Measured memory_bytes: 3184
def find_max_profit(collection):
    min_currency = collection[0]
    max_profit = -(10**9)
    for currency in collection[1:]:
        if max_profit < currency - min_currency:
            max_profit = currency - min_currency
        if min_currency > currency:
            min_currency = currency
            
    return max_profit
    
nums_currency = int(input())
collection = [int(input()) for _ in range(nums_currency)]

print(find_max_profit(collection))


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> road(2 * M);
  vector<int> town(N);
  for(int i = 0; i < 2 * M; i++) {
    cin >> road.at(i);
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 2 * M; j++) {
      if(road.at(j) == i + 1) {
        town.at(i)++;
      }
    }
    cout << town.at(i) << endl;
  }
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    ll c=0,x=1,g=0,n,h,w,k,m,l,ans=0,ptr=0;
    string s,s1,s2;
    cin >> n;
    VI a(n);
    rep(i,n){
        cin >> a[i];
	}
    rep(i,n){
        if(a[i]==0){
            ans += c;
            c=0;
            continue;
        }
        if(a[i]>0){
            c += a[i]/2;
            if(a[i]%2==0) a[i]=0;  
            else a[i] = 1;
        }
        if(i<n){
            if(a[i]==1 && a[i+1]>0){
                c++;
                a[i]=0;
                a[i+1]--;
            }
        }

        else break;
    }
    ans+=c;
    cout << ans << endl;
    return 0;
}

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

int main(){
  char str[15];
  fgets(str,sizeof(str),stdin);
  int y=atoi(strtok(str,"/"));
  int m=atoi(strtok(NULL,"/"));
  int d=atoi(strtok(NULL,"/"));
  tuple<int,int,int> date=make_tuple(y,m,d);
  tuple<int,int,int> ref=make_tuple(2019,4,30);
  if(date<=ref){
    cout<<"Heisei"<<endl;
  }else{
    cout<<"TBD"<<endl;
  }
}


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

namespace ABC122
{
    class C
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
            int N = a[0], Q = a[1];
            string S = Console.ReadLine();

            int[] c = new int[N];
            int count = 0;
            for(int i = 1; i < N; i++)
            {
                if (S[i] == 'C' && S[i - 1] == 'A') count++;
                c[i] = count;
            }

            List<int> list = new List<int>();
            for(int i = 0; i < Q; i++)
            {
                int[] b = Console.ReadLine().Split(' ').Select(z => int.Parse(z)).ToArray();
                int l = b[0], r = b[1];
                int result = c[r-1] - c[l-1];
                list.Add(result);
            }
            foreach(int v in list)
            {
                Console.WriteLine(v);
            }
        }

    }
}


Measured memory_bytes: 19508
n=int(input())
a=list(map(int,input().split()))
import collections
c = collections.Counter(a)
val_list=list(c.values())
v_count=map(lambda x: x * (x-1), val_list)
total_count=int(sum(v_count)/2)

for i in a:
    print(total_count-(c[i]-1))

Measured memory_bytes: 26140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		long sum = 0;

		for (int i = 1; i <= N; i++) {
			if (i % 3 != 0 && i % 5 != 0) {
				sum += i;
			}
		}
		System.out.println(sum);
	}

}


Measured memory_bytes: 35732
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
 
using namespace std;
 
int main()
{
	int N;
	cin >> N;
	vector<int> a(N, 0);
	for (int i = 0; i < N; ++i) cin >> a[i];
    
    vector<int> index(N+1);
    for (int i = 1; i <= N; ++i) index[a[i]] = i;

    vector<int> next(N+1, -1);
    map<int, bool> tree;
    tree.insert(tree.begin(), make_pair(index[1], true));

    for (int i = 2; i <= N; ++i) {
        auto e = tree.lower_bound(index[i]);
        if (e != tree.end()) next[i] = e->first;
        tree.insert(e, make_pair(index[i], true));
    }

    /*
    for (int i = 1; i <= N; ++i) cout << " " << index[i];
    cout << endl;
    for (int i = 1; i <= N; ++i) cout << " " << next[i];
    cout << endl;
    */
 
	vector<long> min_sum(N, 0);
    min_sum[N-1] = a[N-1];
	long sum = min_sum[N-1];
	for (int i = N-1; i != 0; ) {
		--i;
        const long ai = static_cast<long>(a[i]);
        int n = next[ai];
        min_sum[i] = n == -1 ?
            (ai * (N - i)) : (min_sum[i] = min_sum[n] + ai*(n - i));
		sum += min_sum[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <map>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

signed main(){
  int A,B,C;
  string S;
  int N;
  cin >> A >> B;
  if(B%A==0){
    cout << A+B;
  }else{
    cout << B-A;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  i64 r, d, x;

  cin >> r >> d >> x;

  i64 before = x;
  for (int i = 1; i <= 10; ++i) {
    x = r * before - d;
    cout << x << endl;
    before = x;
  }
  return 0;
}



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

import sys
sys.setrecursionlimit(300000)


def solve(S: str):
    n = len(S)
    ret = 0
    for i in range(n // 2):
        if S[i] != S[-1 - i]:
            ret += 1
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}
int main(){
	ios::sync_with_stdio(false);
	int x,a,b;cin>>x>>a>>b;
	if(x<=a) cout<<x<<endl;
	else{
		x=x-a;
		x=x-(x/b)*b;
		cout<<x<<endl;
	} 
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b int
	for {
		i, _ := fmt.Scan(&a, &b)
		if i == 0 {
			break
		}

		gcd := getGCD(a, b)
		fmt.Println(gcd, getLCM(a, b, gcd))
	}
}

func getGCD(a, b int) int {
	if b == 0 {
		return a
	}
	return getGCD(b, a%b)
}

func getLCM(a, b, gcd int) int {
	return a * b / gcd
}



Measured memory_bytes: 1120
//
// Created by yamunaku on 2019/10/06.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;


int main(){
    CFS;
    int n, m, t;
    cin >> n >> m >> t;
    map<int,int> mp[100000];
    map<int, int> st;
    int a, b, c, tt;
    rep(i, m){
        cin >> a >> b >> c;
        b--;
        if(c == 1){
            st[b] = a;
        }else{
            tt = st[b];
            st.erase(st.find(b));
            for(auto &x: st){
                mp[min(b, x.first)][max(b, x.first)] += a - max(tt, x.second);
            }
        }
    }
    while(!st.empty()){
        b = st.begin()->first;
        tt = st.begin()->second;
        st.erase(st.begin());
        for(auto &x: st){
            mp[min(b, x.first)][max(b, x.first)] += t - max(tt, x.second);
        }
    }
    vector<pair<int, int>> ans(n, {0, 0});
    ans[0] = {0, 1};
    rep(i,n){
        for(auto &q: mp[i]){
            ans[i] = min(ans[i], {-q.second, q.first});
            ans[q.first] = min(ans[q.first], {-q.second, i});
        }
    }
    rep(i, n){
        cout << ans[i].second + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 180596
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();
        int N = r.i();
        int[] P = r.ii();

        int[] Q = new int[N+1];
        {
          int i = 0;
          for(int p : P)
            Q[p] = i++;
        }

        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list, -1, -1, N, N);
        long ans = 0;
        for(int v = N; v > 0; v--){
          int i = Q[v];
          int j = binarySearch(list, i);
          long w = list.get(j-2);
          long x = list.get(j-1);
          long y = list.get(j);
          long z = list.get(j+1);
          long c = (x-w)*(y-i) + (i-x)*(z-y);
          list.add(j, i);
          ans += v*c;
        }
        println(ans);
    }

    public static int binarySearch(ArrayList<Integer> list, int key){
      int left = 0;
      int right = list.size()-1;
      while(true){
        int middle = left + (right - left)/2;
        int value = list.get(middle);
        if(value == key){
          return middle;
        } else if(value < key){
          left = middle + 1;
        } else {
          right = middle - 1;
        }
        if(right < left){
          return  left < middle ? middle : left;
        }
      }
    }

    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

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

int main() {
    int T;
    cin >> T;
    rep (_, T) {
        long long gx, gy, p, x1, x2, y1, y2, a[20][20], b[20][20];
        rep (i,20) rep (j,20) a[i][j] = b[i][j] = 0;
        a[0][0] = 1;
        cin >> gx >> gy >> p;
        rep (i,p) {
            cin >> x1 >> y1 >> x2 >> y2;
            if (x1 == x2) b[x1][min(y1, y2)] += 1;
            if (y1 == y2) b[min(x1, x2)][y1] += 2;
        }
        
        rep (i,19) rep (j,19) {
            if (b[i][j] != 1 && b[i][j] != 3)
                a[i][j+1] += a[i][j];
            if (b[i][j] != 2 && b[i][j] != 3)
                a[i+1][j] += a[i][j];
        }

       //  rep (j, 20) {
       //      rep (i,20) cout << a[i][j] << " ";
       //      cout << endl;
       //  }
       //  cout << endl;
       //  rep (j, 20) {
       //      rep (i,20) cout << b[i][j] << " ";
       //      cout << endl;
       //  }
       //       cout << endl;
       //  rep (j, 20) {
       //      rep (i,20) cout << (b[i][j] & 1) << " ";
       //      cout << endl;
       //  }
       // cout << endl;
       //  rep (j, 20) {
       //      rep (i,20) cout << (b[i][j] & 2) << " ";
       //      cout << endl;
       //  }

        if (a[gx][gy] == 0) {
            cout << "Miserable Hokusai!" << endl;
        } else {
            cout << a[gx][gy] << endl;
        }
    }
}

Measured memory_bytes: 1168
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char S = sc.next().charAt(0);
    if(S=='A' ){
      System.out.println("A");
      return;
    }
    if(S=='B' ){
      System.out.println("A");
      return;

    }
    if(S=='C' ){
      System.out.println("A");
      return;
    }
    if(S=='D' ){
      System.out.println("A");
      return;
    }
    if(S=='E' ){
      System.out.println("A");
      return;
    }
    if(S=='F' ){
      System.out.println("A");
      return;
    }
    if(S=='G' ){
      System.out.println("A");
      return;
    }
    if(S=='H' ){
      System.out.println("A");
      return;
    }
    if(S=='I' ){
      System.out.println("A");
      return;
    }
    if(S=='J' ){
      System.out.println("A");
      return;
    }
    if(S=='K' ){
      System.out.println("A");
      return;
    }
    if(S=='L' ){
      System.out.println("A");
      return;
    }
    if(S=='M' ){
      System.out.println("A");
      return;
    }    
    if(S=='N' ){
      System.out.println("A");
      return;
    }
    if(S=='O' ){
      System.out.println("A");
      return;
    }
    if(S=='P' ){
      System.out.println("A");
      return;
    }
    if(S=='Q' ){
      System.out.println("A");
      return;
    }
    if(S=='R' ){
      System.out.println("A");
      return;
    }
    if(S=='S' ){
      System.out.println("A");
      return;
    }
    if(S=='T' ){
      System.out.println("A");
      return;
    }
    if(S=='U' ){
      System.out.println("A");
      return;
    }
    if(S=='V' ){
      System.out.println("A");
      return;
    }
    if(S=='W' ){
      System.out.println("A");
      return;
    }
    if(S=='X' ){
      System.out.println("A");
      return;
    }
    if(S=='Y' ){
      System.out.println("A");
      return;
    }
    if(S=='Z' ){
      System.out.println("A");
      return;
    }
    
    System.out.println("a");


  }
  
}



Measured memory_bytes: 35668
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  double ans=0;
  double bit=0;
  rep(i,n){
    double x; cin>>x;
    string u; cin>>u;
    if(u=="JPY")
    ans+=x;
    else
    bit+=x;
  }
  ans+=bit*(380000.0);
  cout<<fixed<<setprecision(5)<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
import bisect
N, Q = list(map(int, input().split()))
S = input()
R = [0] * Q
V = []
Vp = V.append
for i in range(N - 1):
    if S[i:i+2] == 'AC':
        Vp(i)
for i in range(Q):
    l, r = list(map(int, input().split()))
    if len(V) > 0:
        l -= 1
        r -= 1
        low = bisect.bisect_left(V, l)
        up = bisect.bisect_right(V, r - 1) - 1
        R[i] = up - low + 1
    else:
        R[i] = 0
print('\n'.join(list(map(str, R))))


Measured memory_bytes: 22672
lines = $stdin.readlines
S, T = lines[0].split(" ").map{ |s| s.strip }
A, B = lines[1].split(" ").map{ |s| s.strip.to_i }
U = lines[2].strip

puts "#{A - (U == S ? 1: 0)} #{B - (U == T ? 1 : 0)}"




Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vi x(n),y(m);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    int sx=0,sy=0;
    rep(i,n)sx+=(i*2-n+1)*x[i]%mod,sx%=mod;
    rep(i,m)sy+=(i*2-m+1)*y[i]%mod,sy%=mod;
    cout<<sx*sy%mod<<endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// テーブルを作る前処理
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    vector<ll> a(n);
    vector<ll> sum(n+1,0);
    REP(i,n) cin >> a[i];
    sort(all(a));
    REP(i,n) sum[i+1] += sum[i] + a[i];

    ll ans = 1;
    REP(i,n-1) {
        if(a[n-i-1] <= 2*sum[n-i-1]) ans++;
        else break;
    }

    pl(ans)

	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
int a[105];

int isGood(int a,int b,int c){
    if(a==b || a==c || b==c) return 0;
    else{
        if(a>=b && a>=c){
            return b+c>a;
        }
        else if(b>=a && b>=c){
            return a+c>b;
        }
        else{
            return a+b>c;
        }
    }
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            for(int k = j+1; k <= n; k++){
                ans += isGood(a[i],a[j],a[k]);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1736
N, K, Q = map(int, input().split())

score = {}
for i in range(1, N+1):
    score[i] = 0

for i in range(Q):
    winner = int(input())
    score[winner] += 1

# print(score)

for i in range(1, N+1):
    player = i
    win = K - (Q - score[player]) > 0
    if win:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 57700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll a,b;cin>>a>>b;
    ll gc=__gcd(a,b);
    cout<<(a*b)/gc;
    return 0;
}   

Measured memory_bytes: 256
def Divisor(N):
    Left,RightRev = [],[]
    I = 1
    while I*I<=N:
        if N%I==0:
            Left.append(I)
            if I!=N//I:
                RightRev.append(N//I)
        I += 1
    Div = Left+RightRev[::-1]
    DivCount = len(Div)
    return Div,DivCount
  
N = int(input())
Div,_ = Divisor(N)
FABMax = len(str(N))
for A in Div:
    B = N//A
    if A>B:
        break
    FABMax = min(FABMax,max(len(str(A)),len(str(B))))
print(FABMax)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a ,b ,c;
    cin >> a >> b >> c;
    if (a == b && b == c)
    cout << 1 << endl;
    else if (a == b || a == c || b == c)
    cout << 2 << endl;
    else
    cout << 3 << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define chmax(x,y) x=max(x,y)
const ll INF = 1e18;
ll dp[200001][3]; // [N][skip]

int main() {
  int N; cin>>N;
  vector<int> A(N);
  rep(i, N) cin>>A[i];

  rep(i, N+1) dp[i][0] = dp[i][1] =  dp[i][2] =-INF;
  dp[0][0] = 0;

  rep(i, N){
		int k = 0;
		chmax(dp[i+1][k], dp[i][k] + ((i+k)%2? 0:A[i]));
		chmax(dp[i+1][k+1], dp[i][k]);
		k = 1;
		chmax(dp[i+1][k], dp[i][k] + ((i+k)%2? 0:A[i]));
		chmax(dp[i+k][k+1], dp[i][k]);
		k = 2;
		chmax(dp[i+1][k], dp[i][k] + ((i+k)%2? 0:A[i]));
  }

  cout << dp[N][N%2+1] << endl;

	// // print =====================
	// puts("---");//
	// rep(i,N)cout<<A[i]<<" ";//
	// puts("");//
	// puts("===");//
	// cout<<"i: ";
	// rep(i,N+1) printf("%5d ",i);//
	// puts("");//
	// rep(j,N%2+1+1){
	// 	cout<<j<<": ";
	// 	rep(i,N+1){
	// 		if(dp[i][j] == -INF) cout<<"----- ";
	// 		else printf("%5lld ",dp[i][j]);
	// 	}
	// 	puts("");
	// }
	// puts("===");//
	// rep(i,N+1){
	// 	cout<<i<<": ";
	// 	rep(j,N%2+1+1){
	// 		if(dp[i][j] == -INF) cout<<"----- ";
	// 		else printf("%5lld ",dp[i][j]);
	// 	}
	// 	puts("");
	// }
	// // ===========================

}


Measured memory_bytes: 8796
N=int(input())
all=[]
for i in range(N):
    A_N=int(input())
    grid=[]
    for j in range(A_N):
        a=list(map(int, input().split()))
        grid.append(a)
    all.append(grid)
ans=[]
for i in range(2**N):# 二進数のリスト作成
    b = format(i,'b').zfill(N)
    c_l = [int(p) for p in list(b)]
    for l in range(N):# checkの開始（lは人）
        for m in range(len(all[l])):# その人の主張の数
            if c_l[l]==1:# 不親切な奴は無視
                if c_l[all[l][m][0]-1]!=all[l][m][1]:
                    c_l=[0]*N
    ans.append(c_l.count(1))
print(max(ans))

Measured memory_bytes: 3444
char s[];main(){double*q=s,b;for(;~scanf("%s",s);getchar()<14&&printf("%f\n",*q))sscanf(s,"%lf",q+1)-1?b=*q--,*q=*s&1?*s-47?*q+=*s-45?b:-b:*q/b:*q*b:*++q;}

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

int main() {
    long long N, A, B;
    cin >> N >> A >> B;
    long long ans = (N / (A + B)) * A;
    long long amari = N - (N / (A + B)) * (A + B);
    if (amari >= A) ans += A;
    else ans += amari;
    cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
string strReverse(string strOrigin){
	if (strOrigin.length() == 0){
		return "";
	}
	long long i;
	string ans;
	for (i = strOrigin.length() - 1; i >= 0; --i) ans += strOrigin[i];
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	string sIn1, sIn2;
	cin >> sIn1 >> sIn2;
	if (sIn1.length() != sIn2.length()){
		cout << "NO\n";
	}
	else{
		if (strReverse(sIn2) != sIn1)
			cout << "NO\n";
		else
			cout << "YES\n";
	}
endapp:
	//system("pause > nul");
	return 0;
}

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

typedef pair<int,int> P;
typedef long long ll;

#define int ll


main(){
    int n;
    string s;
    int k;
    cin >> n >> s >> k;

    for(int i=0;i<n;i++){
        if(s[i]!=s[k-1]) s[i] = '*';
    }

    cout << s << endl;

	return 0;
}


Measured memory_bytes: 3580
import sys
import itertools
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()

# combs = list(itertools.product(range(1,int(N**0.5)), repeat=3))
combs = list(itertools.combinations_with_replacement(range(1,int(N**0.5)), 3))
sum = [0] * (N+1)

for comb in combs:
    temp = comb[0]**2 + comb[1]**2 + comb[2]**2+ comb[0]*comb[1]+ comb[1]*comb[2] + comb[2]*comb[0]
    if temp <= N:
        if comb[0] != comb[1] and comb[1] != comb[2] and comb[2] != comb[0]:
            sum[temp] += 6
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)
        elif comb[0] == comb[1] == comb[2]:
            sum[temp] += 1
            # sum.append(temp)
        else:
            sum[temp] += 3
            # sum.append(temp)
            # sum.append(temp)
            # sum.append(temp)


for i,s in enumerate(sum):
    if i == 0:
        continue
    print(s)
# for i in range(1,N+1):
#     print(sum.count(i))

# elif (comb[0] == comb[1] and comb[1] != comb[2] and comb[2] != comb[0]) or (comb[0] != comb[1] and comb[1] == comb[2] and comb[2] != comb[0]) or (comb[0] != comb[1] and comb[1] != comb[2] and comb[2] == comb[0]):  

Measured memory_bytes: 89272
// https://atcoder.jp/contests/abc088/tasks/abc088_b
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end(), greater<int>()); // 降順
    int s = 0;
    int c = 1;
    for (int i = 0; i < n; i++)
    {
        s += c * a[i];
        c = -c;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <stdio.h>

int M[100000] = {0};

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

    long _2A=0;
    for(i=1;i<n-1;i+=2){
        _2A += 2*a[i];
    }

    M[0] = sum - _2A;

    for(i=0;i<n;i++){
        if(i!=0){
            M[i] = 2*a[i-1] - M[i-1];
        }
        printf("%d", M[i]);
        i==n-1 ? printf("\n") : printf(" ");
    }

}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double rad2deg(double rad) {
    return rad * 360.0 / (2.0 * M_PI);
};

int main() {

    int a, b, x;
    cin >> a >> b >> x;

    if (x == (a * a * b)) {
        cout << 0 << endl;
        return 0;
    }

    double theta;
//    if (a <= b) {
//        int v45_mul2;
//        v45_mul2 = a * a * a;

//        // theta <= 45
//        if ((2 * x) >= v45_mul2) {
//            double rhs = (2.0 * (a * a * b - x)) / (1.0 * a * a * a);
//            theta = rad2deg(atan(rhs));
//        }
//        else {
//            double rhs = (1.0 * a * b * b) / (2.0 * x);
//            theta = rad2deg(atan(rhs));
//        }
//    }
//    else {
    if (true) {
        int v = a * a * b;
        // x >= v/2
        if ((2 * x) >= v) {
            double rhs = (2.0 * (a * a * b - x)) / (1.0 * a * a * a);
            theta = rad2deg(atan(rhs));
        }
        else {
            double rhs = (1.0 * a * b * b) / (2.0 * x);
            theta = rad2deg(atan(rhs));
        }
    }

    //cout << fixed << setprecision(15);
    cout << setprecision(15);
    cout << theta << endl;
}


Measured memory_bytes: 4092
#include <queue>
#include <iostream>
using namespace std;
const long long inf = 1234567891234567891;
struct edge {
	int to, sum;
};
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int R, C, N;
	cin >> R >> C >> N;
	vector<vector<edge> > G(R + C);
	for (int i = 0; i < N; ++i) {
		int r, c, x;
		cin >> r >> c >> x; --r, --c;
		G[r].push_back(edge{ R + c, x });
		G[R + c].push_back(edge{ r, x });
	}
	bool valid = true;
	vector<long long> pot(R + C, inf);
	for (int i = 0; i < R + C; ++i) {
		if (pot[i] != inf) continue;
		pot[i] = 0;
		queue<int> que; que.push(i);
		long long subl = inf, subr = inf;
		while (!que.empty()) {
			int u = que.front(); que.pop();
			if (u < R) subl = min(subl, pot[u]);
			else subr = min(subr, pot[u]);
			for (edge e : G[u]) {
				if (pot[e.to] == inf) {
					pot[e.to] = e.sum - pot[u];
					que.push(e.to);
				}
				else if(pot[u] + pot[e.to] != e.sum) {
					valid = false;
				}
			}
		}
		if (subl + subr < 0) valid = false;
	}
	cout << (valid ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 12800
# import itertools
# import math
import fractions

MOD = 10 ** 9 + 7


def solve(N, A):
    lcm_ans = A[0]
    for i in range(1, N):
        lcm_ans = lcm_ans * A[i] // fractions.gcd(lcm_ans, A[i])

    ans = 0
    for AA in A:
        ans += lcm_ans // AA

    return ans % MOD


N = int(input())
# S = input()
# A, B = map(int, input().split())
A = list(map(int, input().split()))

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, A))


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

string s;

int main(void)
{
	int n, k, i;

	cin >> n >> k >> s;

	int len = s.size();
	for (i = 0; i < len; i++)
		if (i == k - 1)
			cout << (char)(s[i] - 'A' + 'a');
		else
			cout << (char)s[i];
	return 0;
}

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

int main() {
	long long h, res = 0, level = 1;
	cin >> h;
	while (h > 0) {
		res += level;
		h /= 2;
		level *= 2;
	}
	cout << res << endl;
	return 0;
}


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

from typing import Iterable


def main() -> None:
    N, M = rmi()
    H = rmi()
    A, B = [], []
    for m in range(M):
        a, b = rmi()
        A.append(a)
        B.append(b)
    cand = set(range(1, N + 1))
    for m in range(M):
        a, b = A[m], B[m]
        ha, hb = H[a - 1], H[b - 1]
        if ha == hb:
            if a in cand:
                cand.remove(a)
            if b in cand:
                cand.remove(b)
        else:
            lower = a if ha < hb else b
            if lower in cand:
                cand.remove(lower)
    w(len(cand))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(data))


if __name__ == '__main__':
    main()


Measured memory_bytes: 31904
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Double[] x = new Double[n]; Double[] y = new Double[n]; 
        for(int i=0;i<n;i++)
        {
            x[i]=sc.nextDouble();
        }
        for(int i=0;i<n;i++)
        {
            y[i]=sc.nextDouble();
        }
        for(Double p =1.;p<5;p++)
        {
           Double ans = 0.;
            for(int i=0; i<n;i++)
            {
                 if(p<4)
                 {
                      ans += Math.pow(Math.abs(x[i]-y[i]), p);
                 }
                 else
                 {   
                    Double temp = Math.abs(x[i]-y[i]); 
                    if(temp>ans)
                    {
                        ans= temp;
                    }
                 }
            }
            if(p<4)
            {
                 ans = Math.pow(ans,1/p);
            }
            System.out.printf("%.5f\n",ans);
        }
    }
}




Measured memory_bytes: 29148