akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int q; std::cin >> q;
    long long sum = 0;
    std::priority_queue<long long> left;
    std::priority_queue<
        long long,
        std::vector<long long>,
        std::greater<long long>> right;
    long long leftsum = 0, rightsum = 0;
    while (q--) {
        int t; std::cin >> t;
        if (t == 1) {
            long long a, b; std::cin >> a >> b;
            sum += b;
            if (left.empty() || left.top() >= a) {
                left.push(a);
                leftsum += a;
            }
            else {
                right.push(a);
                rightsum += a;
            }
            while (left.size() > right.size() + 1) {
                long long c = left.top();
                left.pop();
                right.push(c);
                leftsum -= c;
                rightsum += c;
            }
            while (right.size() > left.size()) {
                long long c = right.top();
                right.pop();
                left.push(c);
                rightsum -= c;
                leftsum += c;
            }
        }
        else {
            long long l = left.top()*left.size() - leftsum;
            long long r = rightsum - left.top()*right.size();
            std::cout << left.top() << " " << sum + l + r << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3828
n = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()

hoge = []
count = 0
p = 0
for i in a:
    if p == i:
        hoge.append(i)
        count += 1
        p = 0
    else:
        p = i
    if count == 2:
        break
if count == 2:
    print(hoge[0] * hoge[1])
else:
    print(0)

Measured memory_bytes: 14252
import collections
n = int(input())
a = sorted([int(i) for i in input().split()])
cnt = collections.Counter(a)
max_i = a[-1] + 1
for i in a:
  if cnt[i] >= 2:
    del cnt[i]
  for j in range(i*2, max_i, i):
    del cnt[j]
print(len(cnt))

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

int main()
{
    int n;
    string c;
    int count_e = 0;
    int count_w = 0;
    int ans ;

    cin >> n;
    ans = n;
    cin >> c;
    for (int i = 0; i < n; i++) {
        if (c[i] == 'E')
            ++count_e;
    }

    for (int i = 0; i < n; i ++) {
        if (c[i] == 'E')
            --count_e;
        if (ans > (count_e + count_w))
            ans = (count_e + count_w);
        if (c[i] == 'W')
            ++count_w;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}


struct cond{
  ld l;
  ld r;
  ld v;
};

int N;
ld t[200],v[200];
umap<ld,ld> v_run;
ld T = 0;
vector<cond> conds;

ld func(cond c,ld x){
  if(x <= c.l){ return c.v+(c.l-x); }
  else if(x<= c.r){ return c.v;}
  else{ return c.v+(x-c.r); }
}


int main(){
  cin>>N;
  REP(i,N){
    int temp; cin>>temp;
    T += temp;
    if(i==0){ t[i] = temp; }
    else{ t[i] = t[i-1]+temp; }
  }
  CINA(v,N);
  conds.push_back({0,0,0});
  REP(i,N){
    if(i==0){
      conds.push_back({0,t[i],v[i]});
    }else{
      conds.push_back({t[i-1],t[i],v[i]});
    }
  }
  conds.push_back({T,T,0});
  
  for(ld a=0;a<=T; a+=0.5){
    ld temp = 200;
    for(cond c:conds){
      temp = min(temp, func(c,a));
    }
    v_run[a] = temp;
  }
  
  ld ans = 0;
  for(ld a=0;a<T; a+=0.5){
    ans += (v_run[a]+v_run[a+0.5])*0.5/2;
  }
  printf("%.4Lf\n",ans);
}

Measured memory_bytes: 3852
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int slen = s.length();
        int[][] rl = new int[slen][2];

        int i = 0;
        int j = 0;
        while (i < slen) {
            while (i < slen && s.charAt(i) == 'R') {
                rl[j][0]++;
                i++;
            }
            while (i < slen && s.charAt(i) == 'L') {
                rl[j][1]++;
                i++;
            }
            j++;
        }

        int[] ans = new int[slen];
        int m = 0;
        for (int k = 0; k < slen - 1; k++) {
            if (s.charAt(k) != 'R' || s.charAt(k + 1) != 'L') {
                ans[k] = 0;
                continue;
            }
            ans[k] = (rl[m][0] + 1) / 2 + rl[m][1] / 2;
            ans[k + 1] = rl[m][0] / 2 + (rl[m][1] + 1) / 2;
            m++;
            k++;
        }

        StringJoiner sj = new StringJoiner(" ");
        for (int k = 0; k < ans.length; k++) {
            sj.add(String.valueOf(ans[k]));
        }
        System.out.println(sj.toString());
    }

}


Measured memory_bytes: 35960
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

//const long long MOD = 1000000007;
const long long MOD = 998244353;
const long long INF = 1LL << 60;



const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;

		string tmp = ""; tmp += s[0]; tmp += s[1];
		string tmp2 = ""; tmp2 += s[2]; tmp2 += s[3];
		int a = atoi(tmp.c_str());
		int b = atoi(tmp2.c_str());
		if (0 < a && a <= 12) {
			if(0 < b && b <= 12)cout << "AMBIGUOUS" << endl;
			else cout << "MMYY";
		}
		else {
			if (0 < b && b <= 12) {
				cout << "YYMM" << endl;
			}
			else cout << "NA" << endl;
		}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		if (s.charAt(2)== s.charAt(3) && s.charAt(4)== s.charAt(5)) {
			System.out.println("Yes");}
		else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 26904
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
#define SQR(n) (n*n)
#define CHR getchar()
#define NL printf("\n")
#define PI 2.0*acos(0.0)
#define ll              long long int
#define ull             unsigned long long int
#define sc              scanf
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define pf              printf
#define MOD             1000000007
#define mx              123456789
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ff first
#define D double
#define sz size()
#define ss second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))
using namespace std;
int main()
{
    string s, s1;
    cin>>s>>s1;
    cout<<s1<<s<<endl;
    return 0;
}


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

int s,ans;

void find(int sum,int integer,int n){
  for(int i=integer;i<=9;i++){
    if(sum+i==s&&n==1) ans++;
    else if(sum+i<s&&n-1>0) find(sum+i,i+1,n-1);
  }
}

int main()
{
  int n,sum,integer;
  for(;;){
    sum=0,integer=0,ans=0;
    cin>>n>>s;
    if(!(n|s)) break;
    find(sum,integer,n);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1160
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int T = cin.nextInt();
        for (int i = 0; i < T; i++)
        {
            long A = cin.nextLong();
            long B = cin.nextLong();
            long C = cin.nextLong();
            long D = cin.nextLong();
            if (calc(A, B, C + 1, D)) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
        
    }

    bool calc(long A, long B, long C, long D)
    {
        if (A < B) return false;
        if (D < B) return false;

        long Nokori = ((A - C) % D + D) % D;
        long GCD = gcd(B, D);
        long MinNum = C + Nokori % GCD;
        if (MinNum >= B) return true;
        else return false;

    }

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


}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 11092
#include<bits/stdc++.h>
const int N=100010;
using namespace std;
typedef long long ll;
ll ans;
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int s[N],fa[N],n,m,s1,s2,d;
struct Point{
	int x,y,id;
	inline bool operator<(const Point &B)const{return x<B.x||x==B.x&&y<B.y;}
}a[N],b[N];
inline Point make_point(int x,int y,int id=0){
	Point cur;cur.x=x;cur.y=y;cur.id=id;return cur;
}
inline int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
inline void merge(int x,int y){
	int xx=find(x),yy=find(y);
	if(xx!=yy)fa[xx]=yy;
}
inline void build(){
	memset(s,0,sizeof(s));sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		int l=lower_bound(a+1,a+n+1,make_point(a[i].x-d,a[i].y-d))-a;
		int r=upper_bound(a+1,a+n+1,make_point(a[i].x-d,a[i].y+d))-a-1;
		//printf("%d %d\n",l,r);
		if(l<=r)merge(a[i].id,a[l].id),s[l]++,s[r]--;
	}
	for(int i=1;i<=n;i++){s[i]+=s[i-1];if(s[i])merge(a[i].id,a[i+1].id);}
}
inline void work(int x){
	sort(b+1,b+m+1);
	for(int i=1;i<=m;i++){
		int l=lower_bound(b+1,b+m+1,make_point(b[i].x-d,b[i].y-(d-x)))-b;
		int r=upper_bound(b+1,b+m+1,make_point(b[i].x-d,b[i].y+(d-x)))-b-1;
		//printf("%d %d\n",l,r);
		ans+=max(r-l+1,0);
	}
}
int main(){
	n=read();s1=read();s2=read();
	for(int i=1;i<=n;i++){
		int x=read(),y=read();fa[i]=i;
		a[i]=make_point(x+y,x-y,i);
	}
	d=max(abs(a[s1].x-a[s2].x),abs(a[s1].y-a[s2].y));
	build();
	for(int i=1;i<=n;i++)swap(a[i].x,a[i].y);
	build();
	for(int i=1;i<=n;i++){
		int xx=find(a[i].id),yy=find(s1);
		if(xx==yy)b[++m]=a[i];
	}
	work(0);
	for(int i=1;i<=m;i++)swap(b[i].x,b[i].y);
	work(1);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3840
<?php
        $f=0;
        while(1){
                fscanf(STDIN,"%d %d",$a,$b);
                if($a==0&&$b==0){
                        return 0;
                }
                if($f!=0){
                        echo "\n";
                }
                $f++;
                $flag=1;
                for($i=$a;$i<=$b;$i++){
                        if(checkdate(2,29,$i)){
                                echo $i."\n";
                                $flag=0;
                        }
                }
                if($flag){
                        echo "NA\n";
                }
        }
        ?>

Measured memory_bytes: 6544
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vi a(n);
		for(auto&m:a) cin >> m;
		int ans=0;
		for(int i=0;i<n;i+=2)
		{
			if(a[i]&1) ans++;
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int 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 COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int n;
string s[224514];
map<string, int>mp;
signed main() {
	cin >> n;
	rep(i, n)cin >> s[i];
	rep(i, n)mp[s[i]]++;
	int memo = -1;
	for (auto x : mp) {
		chmax(memo, x.second);
	}
	for (auto x : mp) {
		if (x.second == memo)cout << x.first << endl;
	}
	ggr
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int a, b;
	cin >> a >> b;

	if(b % a)
		cout << b - a << endl;
	else
		cout << a + b << endl;

	return 0;
}


Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var n = int.Parse(Console.ReadLine());
            var dic = new Dictionary<int,int>();
            var s = test.ConvertIntArray(test.ReadInput());
            var ans = "YES";
            for(var i = 0; i<n; i++)
            {
                if (dic.ContainsKey(s[i]))
                {
                    ans = "NO";
                    break;
                }
                else
                {
                    dic.Add(s[i], s[i]);
                }
            }

            Console.WriteLine(ans);
        }


        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public int[] ConvertIntArray(string[] x)
        {
            var convertedArray = new int[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public double[] ConvertDoubleArray(string[] x)
        {
            var convertedArray = new double[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = int.Parse(x[i]);
            }

            return convertedArray;
        }

        public long[] ConvertLongArray(string[] x)
        {
            var convertedArray = new long[x.Length];
            for (var i = 0; i < x.Length; i++)
            {
                convertedArray[i] = long.Parse(x[i]);
            }

            return convertedArray;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 39504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    deque<ll> que;
    //multiset<Pll> ms;
    //me.insert(PlP(A[0],Pll(A[0], A[0]));
    que.push_back(A[0]);
    REP(i,1,N){
        que.push_back(A[i]);
        que.push_back(A[i]);
    }
    ll ans = 0;
    rep(i,N-1){
        ans += que[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 7992
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
int main(void){
   int a,b,c;
a=0;
b=0;
c=0;
string s;
cin>>s;
string ans="YES";
int lo=s.size();
for(int i=0;i<lo;i++){
if(s[i]=='a')a++;
else if(s[i]=='b')b++;
else c++;
}
if(max({a,b,c})-min({a,b,c})>1)ans="NO";
cout<<ans<<endl;
}
    
  

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int stage[16][16];

int main(){
	int a,b;
	while(~scanf("%d %d",&a,&b)){
		if(a==b && b==0) break;
		memset(stage,-1,sizeof(stage));
		for(int x=0;x<a;x++){
			for(int y=0;y<b;y++){
				stage[y][x] = 0;
			}
		}
		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			int x,y;
			scanf("%d %d",&x,&y);
			stage[y-1][x-1] = -1;
		}

		stage[0][0] = 1;
		for(int y=0;y<b;y++){
			for(int x=0;x<a;x++){
				if(stage[y][x]==-1) continue;
				if(y-1>=0 && x >= 0 && stage[y-1][x] != -1) {
					stage[y][x] += stage[y-1][x];
				}

				if(y>=0 && x-1>= 0 && stage[y][x-1] != -1) {
					stage[y][x] += stage[y][x-1];
				}
			}
		}

		printf("%d\n",stage[b-1][a-1]);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;
using std::string;

string s;

int main () {

    string date[] = {
        "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"
    };

    cin >> s;

    int n = 0;
    while( s != date[n] )n++;

    cout << 7 - n << endl;
    
    return 0;
}

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

MOD = 10 ** 9 + 7

cache = {}
def f(k, n):
    if k == 1:
        return 1
    if k in cache:
        return cache[k]
    result = pow(k, n, MOD)
    for i in range(2, k + 1):
        result -= f(k // i, n)
        result %= MOD
    cache[k] = result
    return result


result = 0
for i in range(1, K + 1):
    result += f(K // i, N) * i
    result %= MOD
print(result)


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

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

    long long ha[n+1];
    ha[0] = 2; ha[1] = 1;

    for(int i=2; i<=n; i++) {ha[i]=0;}

    for(int i=2; i<=n; i++)
        {ha[i] = ha[i-1] + ha[i-2];}
    cout << ha[n] << endl;

    return 0;}
// done by ABO KHALED


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

int main(int argc, char **argv) {
	string s;
	cin >> s;
	bool ok = false;
	for (int i = 0; i < s.length() - 1; ++i) {
		ok |= s[i] == 'A' && s[i + 1] == 'C';
	}
	cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll N,t,ANS=0;
	vector<ll>V;
	cin>>N;
	rep(i,3*N){
		cin>>t;
		V.push_back(t);
	}
	sort(V.begin(),V.end());
	reverse(V.begin(),V.end());
	for(ll i=1;i<=2*N;i=i+2){
		ANS=ANS+V[i];
	}
	cout<<ANS<<endl;
}

Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    Int n, p;
    cin >> n >> p;
    if (n == 1) {
        dump(p);
        return 0;
    }
    Int c = 0;
    Int res = 1;
    while (p%2 == 0) {
        p /= 2;
        c++;
        if (c%n == 0) res *= 2;
    }
    for (Int i = 3; i*i <= p; i+=2) {
        if (i != 3 && i%3 == 0) continue;
        if (i != 5 && i%5 == 0) continue;
        if (i != 7 && i%7 == 0) continue;   
        if (i != 11 && i%11 == 0) continue;   
        if (i != 13 && i%13 == 0) continue;   
        if (i != 17 && i%17 == 0) continue;   
        if (i != 19 && i%19 == 0) continue;   
        c = 0;
        while (p%i == 0) {
            p /= i;
            c++;
            if (c%n == 0) res *= i;
        }
    }
    dump(res);
    return 0;  
}

Measured memory_bytes: 256
n=int(input())
r=[list(map(int,input().split()))for _ in range(n)]
b=sorted([list(map(int,input().split()))for _ in range(n)])
p=0
for i in range(n):
  c=[]
  for j in range(len(r)):
    if r[j][0]<b[i][0] and r[j][1]<b[i][1]:c.append(r[j][::-1])
  if len(c)==0:continue
  c.sort(reverse=1)
  del r[r.index(c[0][::-1])]
  p+=1
print(p)

Measured memory_bytes: 3064
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int
main ()
{
  int x, a = 0;
  cin >> x;
  char y[50]; for (int i = 0; i < x; i++){
    cin >> y[i];
}

for (int i = 0; i < x; i++)
  {
    if (y[i] == 'A')
      {
	if (y[i + 1] == 'B')
	  {
	    if (y[i + 2] == 'C')
	      {
		a++;
	      }
	  }
      }
  }

cout << a;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    char s[h+5][w+5];
    for(int i=1;i<=h;i++){
        s[i][0]='.';
        s[i][w+1]='.';
    }   
    for(int j=1;j<=w;j++){
        s[0][j]='.';
        s[h+1][j]='.';
    }
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin >> s[i][j];
    int flag=0;
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
        if(s[i][j]=='#'){
            if(s[i-1][j]=='.' && s[i+1][j]=='.' && s[i][j-1]=='.' && s[i][j+1]=='.')flag++;
        }
    }
    if(flag>0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

using namespace std;

constexpr int MAXN = 2e5 + 5;

template<typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int tc, n, m;
array<int, MAXN> a;
signed main() {
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= t * s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut hh = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    let mut ans = 0;
    let inf = usize::max_value();
    loop {
        let mut small = inf;
        let mut start = 0;

        for i in 0..n + 1 {
            if i == n || hh[i] == 0 {
                if small < inf {
                    for j in start..i {
                        hh[j] -= small;
                    }
                    ans += small;
                    break;
                } else {
                    start = i + 1
                }
            } else {
                if small > hh[i] {
                    small = hh[i]
                }
            }
        }
        if small >= inf {
            break; // rest nothing
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int N = std.nextInt();

        List<List<Integer>> to = new ArrayList<>(N);
        List<List<Integer>> cost = new ArrayList<>(N);
        for (int i = 0; i < N; i++) {
            to.add(new ArrayList<>());
            cost.add(new ArrayList<>());
        }

        for (int i = 0; i < N - 1; i++) {
            int a = std.nextInt();
            int b = std.nextInt();
            int w = std.nextInt();
            a--;
            b--;

            to.get(a).add(b);
            to.get(b).add(a);
            cost.get(a).add(w);
            cost.get(b).add(w);
        }

        int[] ans = new int[N];
        Deque<Integer> deque = new ArrayDeque<>();
        Arrays.fill(ans, - 1);
        ans[0] = 0;
        deque.add(0);
        while (!deque.isEmpty()) {
            int v = deque.pollFirst();
            for (int i = 0; i < to.get(v).size(); i++) {
                int u = to.get(v).get(i);
                int w = cost.get(v).get(i);
                if (ans[u] != -1) {
                    continue;
                }

                ans[u] = (ans[v] + w) % 2;
                deque.add(u);
            }
        }

        Arrays.stream(ans).map(Math::abs).forEach(System.out::println);
    }
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

bool arr[200001] = {};

signed main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a == 1)
        {
            if (!arr[b])
                arr[b] = true;
            else
            {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
        else if (b == n)
        {
            if (!arr[a])
                arr[a] = true;
            else
            {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


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


int main()
{
          int a,b,c,temp;

          cin >> a >> b >> c;

          while(1)
          {
                  if((a < b && b < c) || (a == b && b < c ) || (a == b && b == c ))
                              break;
                  else if(b < a)
                  {
                            temp = b;
                            b = a;
                            a = temp;
                  }
                  else if(c < b)
                  {
                            temp = c;
                            c = b;
                            b = temp;
                  }
                  else if(c < a)
                  {
                            temp = c;
                            c = a;
                            a = temp;
                  }
          }
          cout << a << " " << b << " " << c << endl;
          return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int monsterHealth, attacksDone, specialAttack;
    int attackPower = 0;
    int specialAttacks[100000];
    scanf("%d %d",&monsterHealth, &attacksDone);

    for (int i = 0; i < attacksDone; i++)
    {
        scanf("%d", &specialAttack);
        specialAttacks[i] = specialAttack;
        attackPower += specialAttacks[i];
    }

    if (attackPower >= monsterHealth)
    {
        printf("Yes \n");
    }
    else
    {
        printf("No \n");
    }

    return 0;
}


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

void convertS2vec(const string & S, vector<int> & vec0, vector<int> & vec1){
    char c = '1';
    int count = 0;
    for (auto s : S){
        if (s == c){
            ++count;
        }else{
            if (c == '0'){
                vec0.push_back(count);
                c = '1';
            }else{
                vec1.push_back(count);
                c = '0';
            }
            count = 1;
        }
    }
    if (c == '0') vec0.push_back(count);
    if (c == '1') vec1.push_back(count);
    if (vec0.size() == vec1.size()) vec1.push_back(0);
    return;
}


int solve(int N, int K, string S){
    vector<int> vec0;
    vector<int> vec1;
    convertS2vec(S, vec0, vec1);
    int n_chunk = vec0.size();
    if (n_chunk <= K) return N;
    int cum = accumulate(vec0.begin(), vec0.begin() + K, 0) + accumulate(vec1.begin(), vec1.begin()+(K+1), 0);
    int record = cum;
    for (int i = 0; i + K < n_chunk; ++i){
        cum = cum + vec0[i + K] - vec0[i] + vec1[i + K + 1] - vec1[i];
        record = max(record, cum);
    }
    return record;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    cout << solve(N, K, S) << endl;
    return 0;
}

Measured memory_bytes: 1024
S=input()

def f(s):
    sum=0
    if len(s)==1:
        return int(s)
    for i in range(1,len(s)):
        sum+=(2**(len(s)-i-1))*int(s[:i])+f(s[i:])
    return sum+int(s)

print(f(S))

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)
#define sz(x) int(x.size())

int main()
{
  int k;
  string s;
  cin >> k >> s;
  string ans = "";
  rep(i, s.size())
  {
    if (k == ans.size())
    {
      ans += "...";
      break;
    }
    ans += s[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int n,s;
    cin >> n;
    set<int> st;
    for(int i = 0; i < n; i++){
        cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int MOD = (int)1e9 + 7;

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[n];
        int pos = 0;
        for (int i=0; i<n; i++) {
            arr[i] = sc.nextInt();
            if (arr[i] == 1) pos = i;
        }

        int l = 0;
        int r = 0;

        while (arr[l] != 1) l++;

        r = n - l - 1;

        int cnt = 0;
        int rem = 0;

        n -= m;
        cnt = 1;

        while (0 < n) {
            n -= (m-1);
            cnt++;
        }

        System.out.println(cnt);


    }

}



Measured memory_bytes: 49068
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int r = Integer.parseInt(sc.next());
        
        if(r < 1200){
            System.out.println("ABC");
        }else if(r < 2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;


ll Main(int N, int M, VI& A)
{
    sort(A.begin(), A.end());
    REP(i, M) {
        int a = A[N-1] >>= 1;
        A.erase(A.end()-1);
        auto p = lower_bound(A.begin(), A.end(), a);
        A.insert(p, a);
    }
    return accumulate(A.begin(), A.end(), 0LL);
}

int main(void){
    int N, M;
    cin >> N >> M;
    VI A(N);
    REP(i, N) cin >> A[i];
    cout << Main(N, M, A) << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    T = [ (0,0)]*N
    for i in range(N):
        a, b = map( int, input().split())
        T[i] = (b,a)
    T.sort()
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][1]
        if time > T[i][0]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 29400
n = int(input())
l = []
ans = ""
for i in range(n):
  l.append(input())
for i in range(97, 123):
  count = 0
  minimum = float('inf')
  for j in l:
    temp = j.count(chr(i))
    if temp >= 1:
      minimum = min(minimum, temp)
      count += 1
  if count == n:
    ans += chr(i)*minimum

print(ans)

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

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

const int mod = 1000000007;

const int inf = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> ok(n + 1);
  vector<int> dp(n + 1);
  rep(i, m) {
    cin >> a[i];
    ok[a[i]]++;
  }
  dp[0] = 1;
  if (ok[1])
    dp[1] = 0;
  else
    dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (ok[i])
      dp[i] = 0;
    else
      dp[i] = (dp[i - 1] + dp[i - 2]) % mod;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 4572
#include <iostream>
#include <string>
#include <algorithm> 
using namespace std;
int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a,a+N);
    cout << a[N-1]-a[0] << endl;
}


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

using namespace std;
typedef long long ll;
const int p = 1e9+7;

ll qpow(ll a,ll b)
{
    ll res = 1 % p;
    while(b)
    {
        if(b & 1)res = res * a % p;
        b >>= 1;
        a = a * a % p;
    }
    return res;
}
ll inv(ll m)
{
    return qpow(m,p-2) %  p ;
}
ll C(ll m,ll n)
{
    if(m > n)return 0;
    ll up(1),down(1);
    for(int i = n - m + 1;i <= n;i++)up = up * i % p;
    for(int i = 1;i <= m;i++)down = down * i  % p;
    return up * inv(down);
}
ll Lucas(ll m,ll n)
{
    if(n == 0)return 1;
    return C(m % p,n % p) * Lucas(m / p,n / p) % p;
}
int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    ll ans = qpow(2,n) - 1 % p;
    ans -= (Lucas(a,n) % p + Lucas(b,n) % p) %p;
    ans = (ans % p + p) %p;//ans可能为负数，所以要%p+p%p
    cout << ans % p;

    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var map = new int[10, 10];
        var dxs = new int[] { 0, 1, 0, -1 };
        var dys = new int[] { -1, 0, 1, 0 };
        var dxm = new int[] { 0, 1, 1, 1, 0, -1, -1, -1 };
        var dym = new int[] { -1, -1, 0, 1, 1, 1, 0, -1 };
        var dxb = new int[] { 0, 1, 1, 1, 0, -1, -1, -1, 0, 2, 0, -2 };
        var dyb = new int[] { -1, -1, 0, 1, 1, 1, 0, -1, -2, 0, 2, 0 };
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var t = line.Trim().Split(',');
            var x = int.Parse(t[0]);
            var y = int.Parse(t[1]);
            var s = int.Parse(t[2]);
            if (s == 1) putInk(map, x, y, dxs, dys);
            else if (s == 2) putInk(map, x, y, dxm, dym);
            else putInk(map, x, y, dxb, dyb);
        }
        var zc = 0; var max = -1;
        foreach (var x in map)
        {
            if (x == 0) zc++;
            max = Math.Max(max, x);
        }
        Console.WriteLine(zc);
        Console.WriteLine(max);
    }
    public static void putInk(int[,] map, int x, int y, int[] dx, int[] dy)
    {
        map[x, y] += 1;
        for (int i = 0; i < dx.Length; i++)
        {
            var nx = x + dx[i]; var ny = y + dy[i];
            if (nx >= 0 && nx < 10 && ny >= 0 && ny < 10) map[nx, ny] += 1;
        }
    }
}

Measured memory_bytes: 9020
S=input()
char=len(S)

count=0
if char%2==0:
    low=(char//2)-1
    high=char//2
else:
    low=char//2
    high=char//2

while low>=0:
    if S[low]!=S[high]:
        count+=1
    low-=1
    high+=1

print(count)


Measured memory_bytes: 61896
a = list(map(int, input().split()))
for d in input():
	b = []
	if d == "N":
		b = [a[1], a[5], a[2], a[3], a[0], a[4]]
	elif d == "E":
		b = [a[3], a[1], a[0], a[5], a[4], a[2]]
	elif d == "S":
		b = [a[4], a[0], a[2], a[3], a[5], a[1]]
	else:
		b = [a[2], a[1], a[5], a[0], a[4], a[3]]
	a = b
print(a[0])



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
int inf=1000000000;
ll INF=10000000000000000;
 
int main(){
    int n;
    cin >> n;
    ll dp[101][4][4][4];
    rep(i,101){
        rep(j,4){
            rep(k,4){
                rep(ii,4) dp[i][j][k][ii]=0;
            }
        }
    }
    rep(i,4){
        rep(j,4){
            rep(k,4){
                if (i==0 && j==1 && k==2) continue;
                if (i==1 && j==0 && k==2) continue;
                if (i==0 && j==2 && k==1) continue;
                dp[3][i][j][k]++;
            }
        }
    }
    for (int i=4;i<101;i++){
        rep(j,4){
            rep(k,4){
                rep(ii,4){
                    rep(jj,4){
                        if (j==0 && k==1 && (ii==2 || jj==2)) continue;
                        if (j==0 && ii==1 && jj==2) continue;
                        if (j==1 && k==0 && ii==2) continue;
                        if (j==0 && k==2 && ii==1) continue;
                        dp[i][j][k][ii]=(dp[i][j][k][ii]+dp[i-1][k][ii][jj])%MOD;
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(i,4){
        rep(j,4){
            rep(k,4) ans=(ans+dp[n][i][j][k])%MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

void dijkstra(int n, vector< vector<edge> >& G, int s, vector<ll>& d) {
	fill(d.begin(), d.end(), LLONG_MAX); d[s] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > q;
	q.push(ll_i(0, s));
	while (!q.empty()) {
		ll_i p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(ll_i(d[e.v], e.v));
			}
		}
	}
}

int main() {
	for (;;) {
		int w, h; cin >> w >> h;
		if (w == 0) break;
		vector< vector<char> > s(h, vector<char>(w));
		for (int y = 0; y < h; y++)
			for (int x = 0; x < w; x++) {
				string z; cin >> z;
				s[y][x] = z[0];
			}
		vector< vector<edge> > G(h * w * 2 + 2);
		for (int y = 0; y < h; y++)
			for (int x = 0; x < w; x++) {
				if (s[y][x] == 'S') {
					s[y][x] = '0';
					edge e = {h * w * 2, y * w + x, 0};
					edge _e = {h * w * 2, h * w + y * w + x, 0};
					G[h * w * 2].push_back(e);
					G[h * w * 2].push_back(_e);
				}
				if (s[y][x] == 'T') {
					s[y][x] = '0';
					edge e = {y * w + x, h * w * 2 + 1, 0};
					edge _e = {h * w + y * w + x, h * w * 2 + 1, 0};
					G[y * w + x].push_back(e);
					G[h * w + y * w + x].push_back(_e);
				}
			}
		for (int y = 0; y < h; y++)
			for (int x = 0; x < w; x++) {
				if (s[y][x] == 'X') continue;
				for (int _y = 0; _y < h; _y++)
					for (int _x = 0; _x < w; _x++) {
						if (s[_y][_x] == 'X') continue;
						if (x >= _x || abs(x - _x) + abs(y - _y) > 3) continue;
						edge e = {y * w + x, h * w + _y * w + _x, s[_y][_x] - '0'};
						edge _e = {h * w + _y * w + _x, y * w + x, s[y][x] - '0'};
						G[y * w + x].push_back(e);
						G[h * w + _y * w + _x].push_back(_e);
					}
			}
		vector<ll> d(h * w * 2 + 2);
		dijkstra(h * w * 2 + 2, G, h * w * 2, d);
		ll ans = d[h * w * 2 + 1];
		cout << (ans < LLONG_MAX ? ans : -1) << endl;
	}
}

Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long A[2], K;
    cin >> A[0] >> A[1] >> K;
    for (int i = 0; i < K; i++) {
        if (A[i&1] & 1) A[i&1]--;
        A[i&1] /= 2;
        A[!(i&1)] += A[i&1];
    }
    printf("%lld %lld\n", A[0], A[1]);
}

Measured memory_bytes: 256
import itertools
K = int(input())

#ユーグリッド互除法（再起）
def gcd(p, q):
  # ユーグリッド互除法
  if (p%q==0):
    return q
  else:
    return gcd(q, p%q)

ans = 0

for abc in itertools.combinations_with_replacement([i+1 for i in range(K)], 3):
  a,b,c = abc
  gcd_ab = gcd(a, b)
  gcd_abc = gcd(gcd_ab, c)

  # 組み合わせ数を補整する
  if a == b == c:
    ans += gcd_abc
  elif a==b or b==c or a==c:
    ans += gcd_abc*3
  else:
    ans += gcd_abc * 6

print(ans)

Measured memory_bytes: 9172