akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

int main(){
   double xA,yA,xB,yB,xC,yC,xD,yD;
   while(cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD){
      if(abs((yA-yB)*(yC-yD) + (xC-xD)*(xA-xB)) < 0.0000000001)
     cout << "YES" << endl;
      else cout << "NO" << endl;
   }
   return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	int a,b;
	char c;
	cin>>a>>c>>b;
	if(c == '+') cout<<a+b<<endl;
	else cout<<a-b<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int sumOfDigit(int num) {
  int sum = 0;
  while (num > 0) {
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if (sumOfDigit(i) >= a && sumOfDigit(i) <= b) ans += i;
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	int x,y,z;
	scanf("%d%d%d",&x,&y,&z);
	if((x*100+y*10+z)%4)
	{
		puts("NO");
		return 0;
	}
	 puts("YES");
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.length();
	char c[11];
	int t=0;
	for(int i=0;i<=n;i++)
	{
		if(s[i]=='B')
		{
			t--;
		}
		else
		{
			c[++t]=s[i];
		}
		t=max(t,0);
	}
	for(int i=1;i<t;i++)
	{
		cout<<c[i];
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	string X,Y;
	string alphabet="abcdefghijklmnopqrstuvwxyz";
	int ans = 0;
	int ansmax = 0;
	bool xinc,yinc;
	for(int i=0;i<N-1;i++){
        ans = 0;
		X = S.substr(0,i+1);
		Y = S.substr(i+1,N-(i+1));
		for(int j=0;j<26;j++){
			xinc = yinc = false;
			for(char x : X){
				if(x == alphabet[j]){
					xinc = true;
				}
			}
			for(char y : Y){
				if(y == alphabet[j]){
					yinc = true;
				}
			}
			if(xinc == true && yinc == true){
				ans++;
			}
		}
		if(ansmax <= ans){
			ansmax = ans;
		}
	}

	cout << ansmax << endl;
	return 0;
}


Measured memory_bytes: 256
// "include" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>
// }}}
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int x = 0,y = 0;
	int n = s.size();
	int flgs = 0,flge = 0,flgn = 0,flgw = 0;
	rep(i,n){
		if(s[i] == 'N') flgn = 1;
		else if(s[i] == 'S') flgs = 1;
		else if(s[i] == 'W') flgw = 1;
		else flge = 1;
	}
	if(flgn == flgs && flgw == flge){
		cout << "Yes\n";
	}
	else cout << "No\n";
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  bool b = true;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'L' && (i+1)%2 == 1) b = false;
    if (s.at(i) == 'R' && (i+1)%2 == 0) b = false;
  }
  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
const ll INF = (1LL << 61) - 1;
const ll MOD = 1000000007 /*998244353*/;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
ll con[365][26];
void input() {
    cin >> d;
    rep(i, 26) {
        cin >> x;
        A.pb(x);
    }
    //cout << "ok1" << endl;
    rep(i, d) {
        rep(j, 26) { cin >> con[i][j]; }
    }
    //cout << "ok2" << endl;
    rep(i, d) {
        cin >> x;
        B.pb(x);
    }
    //cout << "OK" << endl;
}
void solve() {
    vl ANS = vl(d, 0);
    vl saigo = vl(26, 0);
    rep(i, d) {
        x = B[i];
        x--;
        saigo[x] = i + 1;
        ans += con[i][x];
        rep(j, 26) { ans -= A[j] * (i + 1 - saigo[j]); }
        cout << ans << endl;
    }
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    int cnt=0;
    for(int i=1;i<=n;i+=2){
        if(a[i]%2==1)cnt++;
    }
    cout<<cnt;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
typedef long long int ll;
const ll N = 1e5 +9;
const ll p = 31;
// const ll m = 1e9 + 7;
const ll inf= 1e14;
const ll mod = 1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
ll fact[N],facti[N];
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
ll ncr(ll n,ll r){
    if(n==0 && r==0){
        return 1;
    }
    if(n==0){
        return 0;
    }
    if(r<0){
        return 0;
    }
    ll num = fact[n];
    ll denom = (facti[r]*facti[n-r])%mod;
    ll ans = (num*denom)%mod;

    return ans;
}
ll mult(ll r,ll n){
    if(r==0 && n==0){
        return 1;
    }
    return ncr(r-1,n-1);
}
ll solve(ll i,ll n,ll k){
    if(i>(n-k+1)){
        return 0;
    }
    else{
        ll ans = mult(k,i)*((2*mult(n-k,i)+mult(n-k,i+1)+mult(n-k,i-1))%mod);
        ans = ans%mod;
        return ans;
    }
}
void precalc(){
    fact[0] = 1;
    facti[0] = powm(1,mod-2);
    for(int i = 1;i<3000;i++){
        fact[i]=fact[i-1]*i;
        facti[i]=facti[i-1]*powm(i,mod-2);
        fact[i]%=mod;
        facti[i]%=mod;
    }
}
int main()
{   
    ios::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
                         

    ll T= 1;
    // cin >> T;
    precalc();
    while(T--){
        ll n,k;cin>>n>>k;
        for(int i = 1;i<=k;i++){
            ll a = solve(i,n,k);
            cout<<a<<'\n';
        }
    }
    return 0;
}   

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

const LL MAXN = 2010;
string grid[MAXN];
LL rows[MAXN][MAXN], cols[MAXN][MAXN];

int main() {
	sll(n); sll(m);
	rep(i, 0, n)	cin >> grid[i];
	rep(i, 0, n) {
		rep(j, 0, m) {
			if(grid[i][j] == '.') {
				if(i == 0 || rows[i-1][j] == -1)	rows[i][j] = 1;
				else	rows[i][j] = rows[i-1][j] + 1;

				if(j == 0 || cols[i][j-1] == -1)	cols[i][j] = 1;
				else	cols[i][j] = cols[i][j-1] + 1;
			}
			else	rows[i][j] = cols[i][j] = -1;
		}
	}

	rep(i, n, 0) {
		rep(j, m, 0) {
			if(i+1 < n && rows[i+1][j] != -1 && rows[i][j] != -1)
				rows[i][j] = rows[i+1][j];
			if(j+1 < m && cols[i][j+1] != -1 && cols[i][j] != -1)
				cols[i][j] = cols[i][j+1];
		}
	}

	LL maxCells = 0;
	rep(i, 0, n) {
		rep(j, 0, m) {
			LL cells = rows[i][j] + cols[i][j] - 1;
			maxCells = max(maxCells, cells);
		}
	}
	pll(maxCells); nl;
}


Measured memory_bytes: 67328
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
import math
#n=int(input())
#li=input().split()
#S=input()
#import fractions
#lis=list(map(int,input().split()))

n=int(input())
s=input()
k=int(input())

l=s[k-1]

ans=""
for i in range(n):
    if s[i]!=l:
        ans+="*"
    else:
        ans+=l


print(ans)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    double x[3],y[3],px,py;
    while(cin>>x[0]>>y[0]){
        for(int i=1;i<3;i++)cin>>x[i]>>y[i];
        cin>>px>>py;
        bool ok=true;
        for(int i=0;i<3;i++){
            bool plus=false;
            if(x[(i+1)%3]==x[(i+2)%3]){
                if(x[i]>x[(i+1)%3])plus=true;
            }
            else{
                double a,b;
                a=(x[i]-x[(i+1)%3])*(y[(i+2)%3]-y[(i+1)%3]);
                b=(y[i]-y[(i+1)%3])*(x[(i+2)%3]-x[(i+1)%3]);
                if(a>b)plus=true;
            }
            bool pnt=false;
            if(x[(i+1)%3]==x[(i+2)%3]){
                if(px>x[(i+1)%3])pnt=true;
            }
            else{
                double a,b;
                a=(px-x[(i+1)%3])*(y[(i+2)%3]-y[(i+1)%3]);
                b=(py-y[(i+1)%3])*(x[(i+2)%3]-x[(i+1)%3]);
                if(a>b)pnt=true;
            }
            if(pnt!=plus)ok=false;
        }
        if(ok)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#define LL long long
using namespace std;
char s[200010];
int n,last[30],pos[200010],tr[200010],num[30];
void change(int k,int c) {for(int i=k;i<=n;i+=i&-i) tr[i]+=c;}
int get(int k) {int ans=0;for(int i=k;i>=1;i-=i&-i) ans+=tr[i];return ans;}
bool vis[200010];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
	{
		int c=s[i]-'a';num[c]++;
		pos[i]=last[c];last[c]=i;
	}
	int tot=0;
	for(int i=0;i<26;i++) tot+=(num[i]&1);
	if(tot>1) return puts("-1"),0;
	memset(vis,false,sizeof(vis));
	LL ans=0;
	for(int i=1;i<=n;i++) change(i,1);
	for(int i=1;i<=n;i++) if(!vis[i])
	{
		int c=s[i]-'a';
		int j=last[c];last[c]=pos[j];
		if(i==j) continue;
		ans+=get(i-1);ans+=(get(n)-get(j));
		change(i,-1);change(j,-1);
		vis[j]=true;
		//printf("%d %d %d %lld\n",i,j,get(n),ans);
	}
	printf("%lld",ans);
}

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


int main() {
  int x, y;
  cin >> x >> y;
  x--; y--;
  vector<int> vec;
  vec = {0,2,0,1,0,1,0,0,1,0,1,0};
  string ans = "No";
  if(vec[x] == vec[y]) ans = "Yes";
  cout << ans << endl;
  return 0;
  
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vii graph;
vi dp;
/*FUNCs=================================================*/
int Maxlen(int u) {
    if(dp[u] != -1) return dp[u];
    int res = -1;
    for(auto v : graph[u]) {
        chmax(res, Maxlen(v) + 1);
    }
    dp[u] = res;
    return res;
}

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    int n,m, x,y; cin >> n >> m;
    graph.resize(n+1);
    dp.resize(n+1, -1);
    rep(i,m) {
        cin >> x >> y;
        graph[0].emplace_back(x);
        graph[x].emplace_back(y);
    }
    int ans = Maxlen(0);
    cout << ans << '\n'
;}

Measured memory_bytes: 9080
#include <iostream>
#include <string>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

ll t[201];
int main() {
	ll n, l; cin >> n >> l;
	ll all = 0;
	repe(i, 1, n) {
		t[i] = l + i - 1;
		all += t[i];
	}

	ll minV = 1e10;
	ll minI = 1e10;
	ll ans = 0;
	repe(i, 1, n) {
		ll pie = all - t[i];

		if (minV > abs(all - pie)) {
			minV = abs(all - pie);
			ans = pie;
			minI = i;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	map<char, ll> m;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		m[S[0]]++;
	}
	string s = "MARCH";
	ll ans = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += m[s[i]] * m[s[j]] * m[s[k]];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000

typedef struct{
    char number[100];
    int t;
}data;

int head,tail;
int count;
data Q[MAX];

int isEmpty();/*キューが空なら1を返し、そうでないなら0を返す*/
int isFull();/*キューにこれ以上要素が入らなければ1を返し、そうでないなら0を返す*/
void enqueue(data num);/*要素挿入*/
data dequeue();/*要素取出し*/


int main(){
    int i,n,q;
    count=0;
    scanf("%d %d",&n,&q);

    for(int i=1; i<=n; i++){
        scanf("%s",Q[i].number);
        scanf("%d",&Q[i].t);
    }

    head = 1;
    tail = n+1;

    while(tail != head){
        data num;
        num = dequeue();
        if(num.t <= q){
            count += num.t;
            num.t = 0;
            printf("%s %d\n",num.number,count);
        }

        else if(num.t > q){
            count += q;
            num.t -= q;
            enqueue(num);
        } 
    }

    return 0;
}

int isEmpty(){
    if(head == tail) return 1;
    return 0;
}

int isFull(){
    if(head == (tail+1)%MAX) return 1;
    return 0;
}

void enqueue(data num){
    if(isFull()){
        printf("Erorr,queue is full\n");
        exit(2);
    }

    Q[tail] = num;

    if(tail +1 == MAX)tail = 0;
    else tail++;
    
}

data dequeue(){
    data num;
    if(isEmpty()){
        printf("Error, queue is empty\n");
        exit(3);
    }

    num = Q[head];
    if(head + 1 == MAX) head = 0;
    else head++;

    return num;
}



Measured memory_bytes: 20936
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,A[57],B[57],K,ma=-INF,maxp,mi=INF,minp;
  vector<ll> V;
  cin >> N;
  rep(i,N){
    cin >> A[i];
    if(ma<A[i]){
      maxp=i;
      ma=max(ma,A[i]);
    }
    if(mi>A[i]){
      minp=i;
      mi=min(mi,A[i]);
    }
  }
  if(mi>=0 || ma>-mi){
    cout << 2*N << endl;
    rep(i,N){
      if(i==0){
        cout << maxp+1 << " " << 1 << endl;
        cout << maxp+1 << " " << 1 << endl;
      }
      else{
        cout << i << " " << i+1 << endl;
        cout << i << " " << i+1 << endl;
      }
    }
    return 0;
  }
  else{
    cout << 2*N << endl;
    rrep(i,N){
      if(i==N-1){
        cout << minp+1 << " " << N << endl;
        cout << minp+1 << " " << N << endl;
      }
      else{
        cout << i+2 << " " << i+1 << endl;
        cout << i+2 << " " << i+1 << endl;
      }
    }
    return 0;
  }
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,a,b = LI()
    if n == 1:
        if a == b:
            return 1
        return 0

    if a > b:
        return 0

    if n == 2:
        return 1

    return (b*(n-1)+a) - (a*(n-1)+b) + 1


print(main())


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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, inf = 0x3f3f3f3f, M = 1e9 + 7;

ll fast_pow(ll a, ll b) {
	ll ans = 1;
	while(b) {
		if(b&1) ans = ans * a % M;
		b >>= 1;
		a = a * a % M;
	}
	return ans;
}

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

	// todos - (todos diferentes de 0) U (todos diferentes de 9)
	// todos - (todos diferentes de 0 + todos difern)

	ll n; cin >> n;
	ll todos = fast_pow(10ll, n);
	ll x = 2ll * fast_pow(9ll, n)%M ;
	x -= fast_pow(8ll, n);
	x += M;
	x %= M;
	cout << (todos - x + M)%M << endl;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
	cin>>a;
	int l=a.size();
	int t1=0,t2=0,score=0;
	for(int i=0;i<l;i++)
		if(t1==t2)
		{
			t1++;
			if(a[i]=='p') score--;
		}else
		{
			t2++;
			if(a[i]=='g') score++;
		}
	printf("%d\n",score);
	return 0;
}

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

int	main()
{
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(8) << hypot(x1 - x2, y1 - y2) << endl;
}



Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
    int n; cin>>n;
    vector<int> h(n);
    for(int i = 0; i<n; i++){
        cin>>h[i];
    }
    vector<int> dp(n ,INF);
    dp[0] = 0;
    for(int i = 0; i< n; i++){
        for(int j: {i+1,i+2}){
            if(j < n){
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    cout<<dp[n-1];
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pre(i,a,b) for(int i=(a);i>(b);i--)
const int maxn=1e5+10;
const int mod=998244353;
const int inf=0x3f3f3f3f;
struct node
{
	ll data,lz;
	int l,r;
}tree[maxn*4];
void build(int l,int r,int k)
{
	tree[k].l=l;
	tree[k].r=r;
	tree[k].data=1e18;
	tree[k].lz=0;
	if(l==r) return ;
	int mid=(l+r)>>1;
	build(l,mid,2*k);
	build(mid+1,r,2*k+1);
}
void pushdown(int k)
{
	if(tree[k].lz==0) return ;
	if(tree[2*k].lz==0) tree[2*k].lz=tree[k].lz;
	else tree[2*k].lz=min(tree[2*k].lz,tree[k].lz);
	if(tree[2*k+1].lz==0) tree[2*k+1].lz=tree[k].lz;
	else tree[2*k+1].lz=min(tree[2*k+1].lz,tree[k].lz);
	tree[2*k].data=min(tree[2*k].data,tree[k].lz);
	tree[2*k+1].data=min(tree[2*k+1].data,tree[k].lz);
	tree[k].lz=0;
}
void change(int l,int r,int k,ll x)
{
	if(tree[k].l>=l&&tree[k].r<=r)
	{
		if(tree[k].lz==0) tree[k].lz=x;
		else tree[k].lz=min(tree[k].lz,x);
		tree[k].data=min(tree[k].data,x);
		return ;
	}
	pushdown(k);
	int mid=(tree[k].l+tree[k].r)>>1;
	if(mid>=l) change(l,r,2*k,x);
	if(mid<r) change(l,r,2*k+1,x);
	tree[k].data=min(tree[2*k].data,tree[2*k+1].data);
}
ll query(int l,int r,int k)
{
	ll ans=1e18;
	if(tree[k].l>=l&&tree[k].r<=r)return tree[k].data;
	pushdown(k);
	int mid=(tree[k].l+tree[k].r)>>1;
	if(mid>=l) ans=min(ans,query(l,r,2*k));
	if(mid<r) ans=min(ans,query(l,r,2*k+1));
	return ans;
}
struct abc
{
	int l,r,c;
	friend bool operator<(abc a,abc b)
	{
		return a.l<b.l;
	}
}book[maxn];
int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n,m;
	cin>>n>>m;
	build(1,n,1);
	for(int i=0;i<m;i++) cin>>book[i].l>>book[i].r>>book[i].c;
	sort(book,book+m);
	change(1,1,1,0);
	for(int i=0;i<m;i++)
	{
		ll now=query(book[i].l,book[i].l,1);
		change(book[i].l,book[i].r,1,now+book[i].c);
	}
	ll ans=query(n,n,1);
	if(ans>1e15) cout<<-1<<'\n';
	else cout<<ans<<'\n';
    return 0;
}



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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

int main()
{
    int A,B,C;
    cin >> A >> B >> C;

    int count = 0;

    int maxall = max(A,max(B,C));

    int difA = maxall - A;
    int difB = maxall - B;
    int difC = maxall - C;

    for(int i=0;i<difA/2;i++)
    {
        A+=2;
        count++;
    }
    for(int i=0;i<difB/2;i++)
    {
        B+=2;
        count++;
    }
    for(int i=0;i<difC/2;i++)
    {
        C+=2;
        count++;
    }
    if(A==B)
    {
        if(A<C)
        {
            count++;
        }
        if(A==C)
        {
            // 何もしない
        }
        if(A>C)
        {
            count+=2;
        }
    }
    if(B==C)
    {
        if(A<B)
        {
            count+=2;
        }
        if(A==B)
        {
            // 何もしない
        }
        if(A>B)
        {
            count++;
        }
    }
    if(A==C)
    {
        if(B<C)
        {
            count+=2;
        }
        if(B==C)
        {
            // 何もしない
        }
        if(B>C)
        {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

int64_t gcd(int64_t a, int64_t b)
{
    if(b)
        return gcd(b,a%b);
    return a;
}
int64_t lcm(int64_t a,int64_t b)
{
    return (a*b)/gcd(a,b);
}
int main ()
{
    int64_t n;
    cin>>n;
    string str="";
    while(n)
    {
        int rem=n%26;
        if(!rem)
        {
            str+='z';
            n=(n/26)-1;
        }
        else
        {
            str+=(rem-1)+'a';
            n/=26;
        }
    }
    reverse(str.begin(),str.end());
    cout<<str<<endl;
}



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

y = 1
q = 1
z = 1
for i in range(0, n):
  if a[i] == 0:
    q = 0

for i in range(0, n):
  z = z * a[i]
  if z > 1000000000000000000:
    y = -1
    break
 
if q == 0:
  print(0)
elif z <= 1000000000000000000:
  print(z)
else:
  print("-1")

Measured memory_bytes: 21776
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static BigInteger MOD = BigInteger.valueOf((long) 1e9 + 7);

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        int a = in.nextInt();
        int b = in.nextInt();

        out.println((a - b) % 2 == 0 ? Math.abs((a - b)/2) + Math.min(a, b) : "IMPOSSIBLE");
    }

}


Measured memory_bytes: 21204
import sys

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())

X,N = LI()
P_jyogai = LI()

P = list(range(-10000,10000))

P_difference = set(P)-set(P_jyogai)
P_difference = list(P_difference)
P_difference.sort()

sabun = 100000000
ans = 0
for p_diff in P_difference:
    temp = abs(X-p_diff)
    if sabun > temp:
        sabun = temp
        ans = p_diff
print(ans)

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

int main() {
  int N, A;
  //string op;
  cin >> N >> A;// >> B;

  if ( N % 500 > A){
    cout << "No" << endl;
  }else{
	cout << "Yes" << endl;
  }
}
  
 

Measured memory_bytes: 256
package main

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

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)

	scan := bufio.NewScanner(os.Stdin)

	for i := 0; i < n; i++ {
		// fmt.Scan(&a[i])
		if scan.Scan() {
			a[i], _ = strconv.Atoi(scan.Text())
		}

	}

	shellSort(a)

	fmt.Println(cnt)

	for i := range a {
		fmt.Println(a[i])
	}
}

var cnt int

func insertionSort(a []int, g int) {
	for i := g; i < len(a); i++ {
		v := a[i]
		j := i - g
		for j >= 0 && a[j] > v {
			a[j+g] = a[j]
			j = j - g
			cnt++
		}
		a[j+g] = v
	}
}

func shellSort(a []int) {
	g := make([]int, 0)
	g = append(g, 1)

	for i := 2; ; i++ {
		tmp := (int(math.Pow(float64(3), float64(i))) - 1) / 2
		if tmp < len(a) {
			g = append([]int{tmp}, g...)
		} else {
			break
		}
	}
	fmt.Println(len(g))

	for i := range g {
		insertionSort(a, g[i])
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(g[i])
	}
	fmt.Println()
}



Measured memory_bytes: 17464
n, m = map(int, input().split())
A = [0]*m
B = [0]*m
for i in range(m):
  A[i],B[i] =map(int, input().split())

al = n*(n-1)//2
ansl = [al]
d = list(range(n+1))
dl = [[_] for _ in range(n+1)]

for i in range(m-1,0,-1):
  x = d[A[i]]
  y = d[B[i]]
  x,y = max(x,y),min(x,y)
  if x > y:
    al -= len(dl[x])*len(dl[y])
    for i in dl[y]:
      d[i] = x
    dl[x] += dl[y]
  ansl.append(al)

for i in range(m-1,-1,-1):
  print(int(ansl[i]))


Measured memory_bytes: 39028
N=input()
if N==('SSS'):
    print(0)

if N==('SSR'):
    print(1)

if N==('SRS'):
    print(1)

if N==('RSR'):
    print(1)

if N==('RSS'):
    print(1)

if N==('SRR'):
    print(2)

if N==('RRS'):
    print(2)

if N==('RRR'):
    print(3)


Measured memory_bytes: 9116
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;
const int MAXLOG = 62;

struct basis {
  int base[MAXLOG];

  void clear() {
   for(int i = MAXLOG - 1; i >= 0; i--) base[i] = 0;
  }
  void prepare(int val) {
    for(int i = MAXLOG - 1; i >= 0; i--) {
      if((val >> i) & 1) {
      if(!base[i]) { base[i] = val; return; }
      else val ^= base[i];
    }
  } 
 }  
 int size() {
   int c = 0;
   for(int i = 0; i < MAXLOG; i++) c += (bool)(base[i]);
   return c;
 }
 int max_xor() {
  int res = 0;
  for(int i = MAXLOG - 1; i >= 0; i--)
    if(!((res >> i) & 1) && base[i]) res ^= base[i];
  return res;
 }
 bool possible(int val) {
   for(int i = MAXLOG - 1; i >= 0; i--)
     if(((val >> i) & 1) && base[i]) val ^= base[i];
   return (val == 0);
  }
};

void solve() {
  int n; cin >> n;
  int data[n+5];
  for(int i = 0; i < n; i++) cin >> data[i];
  basis b; b.clear();
  string s; cin >> s;
  for(int i = n-1; i >= 0; i--) {
     if(s[i] == '1') {
       if(!b.possible(data[i])) {
        cout << "1\n"; return;
       }
     } else {
      b.prepare(data[i]);
     }
  }
  cout << "0\n";
}

signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  cin >> t;
   for(int i = 1; i <= t; i++) {
     solve();
  }
}    


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

int main() {
  char Z;
  cin >> Z;

  if (Z == 'a'||Z == 'i'||Z == 'u'||Z == 'e'||Z == 'o') {
     cout << "vowel" << endl;
  } else {
     cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
    int N, K, i;
    cin >> N;
    cin >> K;
    vector<int> x(N);
    for (i=0; i<N; i++) {
        cin >> x[i];
    }
    
    int avg = (K+1) / 2;
    int sum_a = 0, sum_b;
    
    for (i=0; i<N; i++) {
        if (x[i] >= avg) {
            sum_b = sum_b + (K - x[i]);
        }
        else {
            sum_a = sum_a + x[i];
        }
    }
    
    cout << 2 * (sum_a + sum_b) << endl;
    
    //getline(cin, str);
    //vector < vector < int > > A(x, vector<int>(y, 0));
    //int avg = round((float)accumulate(X.begin(), X.end(), 0.0) / N);
    return 0;
}

Measured memory_bytes: 256
//AtCoder Beginner Contest 081
//B - Shift only

#include <iostream>

using namespace std;

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

    int a[n];

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

    int count = 0;
    while(true){
        for(int i=0;i<n;i++){
            if(a[i]%2==0){
                a[i] /= 2;
            }else{
                cout << count << endl;
                return 0;
            }
        }
        count ++;
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())
adj_list = defaultdict(set)

for i in range(M):
    a, b = map(int, input().split())
    adj_list[a].add(b)
    adj_list[b].add(a)

visited = set() # 隣接ノードが1つだけになるノードを順々に追加

res = 0

def backtrack(visited, num):
    global res
    if num in visited:
        return
    if len(visited | {num}) == N:
        res = res + 1
        return

    for neighbor in adj_list[num]:
        backtrack(visited | {num}, neighbor)

backtrack(visited, 1)

print(res)

Measured memory_bytes: 74404
<?php

fscanf(STDIN, '%d', $n);
$line = trim(fgets(STDIN));
$S = array_unique(explode(' ', $line));
fscanf(STDIN, '%d', $q);
$line = trim(fgets(STDIN));
$T = explode(' ', $line);
echo count(array_intersect($S, $T)), PHP_EOL;



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

import sys
sys.setrecursionlimit(300000)

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: int, B: int, C: int):
    a = sorted([A, B, C])
    if a[0] == a[1] and a[1] != a[2] or a[1] == a[2] and a[1] != a[0]:
        ret = YES
    else:
        ret = NO
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
function Main (input) {
  let N = Number(input);
  let sum = 0;
  for(let i = 1; i < (N+1); i++){
      if((i % 3 !== 0) && (i % 5 !== 0)) {
        sum += i;
      }
  }
  console.log(sum);
}
  
  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 35168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		for (int i = 0; i < s.length; i+=2) {
			System.out.print(s[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 28380
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
v_max = 10 ** 5
w_max = 10 ** 18
dp = [[w_max for _ in range(v_max + 1)] for _ in range(n + 1)]

for i in range(n):
    dp[i][0] = 0

for i in range(n):
    w_, v_ = wv[i]
    for j in range(v_max + 1):
        if j + v_ <= v_max:
            dp[i+1][j+v_] = min(dp[i][j] + w_, dp[i][j + v_])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])


ans = 0
for i in range(v_max + 1):
    w_ = dp[n][i]
    if w_ <= w:
        ans = i
print(ans)


Measured memory_bytes: 171376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << "debug: " << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  rep(i, n) {
    if (ans >= k)
      ans += k;
    else
      ans *= 2;
  }
  out(ans);
}
int main(void) { solve(); }

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
ll a,b,c;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin >> a >> b >> c;
	if (a%2==0 or b%2==0 or c%2==0) cout << 0;
	else cout << min(a*b,min(b*c,c*a));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll X, A;
	cin >> X >> A;

	if (X < A) cout << 0 << endl;
	else cout << 10 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;

int main(){
    int n;
    cin >> n;
    int ra=0,lb=0,ab=0;
    int ans = 0;
    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        bool a = false, b = false, flag = false;
        int cntAB = 0;
        for(int j=0; j<s.size(); j++){
            if(j==0 && s[j]=='B') b = true;
            if(j==s.size()-1 && s[j]=='A') a = true;
            if(s[j]=='A') flag = true;
            else if(s[j]=='B' && flag == true){
                flag = false;
                cntAB++;
            }
            else flag = false;
        }
        if(a && b) ab++;
        else if(a) ra++;
        else if(b) lb++;
        ans += cntAB;
    }
    while(ab > 1){
        ans++;
        ab--;
    }
    if(ab){
        if(ra>0){
            ans++;
            ra--;
        }
        if(lb>0){
            ans++;
            lb--;
        }
    }
    OUT(ans + min(ra,lb));
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if (A + B > C + D)
			System.out.println("Left");
		else if (A + B == C + D)
			System.out.println("Balanced");
		else if (A + B < C + D)
			System.out.println("Right");
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
mt19937 rd(time(0));
const int M=2e5+10;
int n;
int b[M],vis[M],ans[M];
pair<int,int> a[M];
bool cmp(int x,int y){return x>y;}
int main()
{
    srand(time(0));
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i].first),a[i].second=i;
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    sort(a,a+n);
    sort(b,b+n,cmp);
    int i=0,j=0;
    while(i<n)
    {
        int o=0;
        while((a[i].first==b[j] || vis[j]) && o<2*n) j=(j+1)%n,o++;
        if(a[i].first==b[j] || vis[j]) break;
        ans[a[i].second]=b[j],vis[j]=1;
        i++;
    }
    if(i==n)
    {
        puts("Yes");
        for(int i=0;i<n;i++)
            printf("%d ",ans[i]);
        //puts("?");
        exit(0);
    }
    sort(b,b+n);
    for(int i=0;i<n;i++) vis[i]=0;
    i=0,j=0;
    while(i<n)
    {
        int o=0;
        while((a[i].first==b[j] || vis[j]) && o<2*n) j=(j+1)%n,o++;
        if(a[i].first==b[j] || vis[j]) break;
        ans[a[i].second]=b[j],vis[j]=1;
        i++;
    }
    if(i==n)
    {
        puts("Yes");
        for(int i=0;i<n;i++)
            printf("%d ",ans[i]);
        exit(0);
    }
    int t=10;
    while(t--)
    {
        random_shuffle(b,b+n);
        for(int i=0;i<n;i++) vis[i]=0;
        i=0,j=0;
        while(i<n)
        {
            int o=0;
            while((a[i].first==b[j] || vis[j]) && o<2*n) j=(j+1)%n,o++;
            if(a[i].first==b[j] || vis[j]) break;
            ans[a[i].second]=b[j],vis[j]=1;
            i++;
        }
        if(i==n)
        {
            puts("Yes");
            for(int i=0;i<n;i++)
                printf("%d ",ans[i]);
            exit(0);
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 7724
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;
 
#define pai 3.14159265359
#define mod 1000000007

int main()
{
    int n;
    cin >> n;
    int a[101];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long int ans = mod;
    for(int i = -100; i < 101; i++){
        long long int nowans = 0;
        for(int j = 0; j < n; j++){
            nowans += (i - a[j]) * (i - a[j]);
        }
        ans = min(ans, nowans);
    }
    cout << ans << endl;
    return 0;
}

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

import sys


def multiply_matrix_a_b():
    n, m, l = [int(i) for i in sys.stdin.readline().split()]
    matrix_a = [[0 for col in range(m)] for row in range(n)]
    matrix_b = [[0 for col in range(l)] for row in range(m)]
    matrix_res = [[0 for col in range(l)] for row in range(n)]

    for row in range(n):
        lst = [int(element) for element in sys.stdin.readline().split()]
        for col in range(m):
            matrix_a[row][col] += lst[col]

    for row in range(m):
        lst = [int(element) for element in sys.stdin.readline().split()]
        for col in range(l):
            matrix_b[row][col] += lst[col]

    for row_a in range(len(matrix_a)):
        for col_a in range(len(matrix_b[0])):
            for row_b in range(len(matrix_b)):
                matrix_res[row_a][col_a] += \
                        matrix_a[row_a][row_b] * matrix_b[row_b][col_a]

    return matrix_res


def main():
    [print(*row) for row in multiply_matrix_a_b()]


if __name__ == '__main__':
    main()

Measured memory_bytes: 8820