akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 100;
/* global variables */
/* function */
/* main */
int main(){
    int A, B;
    cin >> A >> B;
    vector<vector<int> > grid(MAX, vector<int>(MAX));
    for (int i = 0; i < MAX / 2; i++) for (int j = 0; j < MAX; j++) grid[i][j] = 1;

    for (int i = 0; i < MAX / 2 - 1; i+=2)
        for (int j = 0 + i % 2; j < MAX && A > 1; j += 2) {
            grid[i][j] = 0; A--;
    }
    for (int i = MAX / 2 + 1; i < MAX; i+=2)
        for (int j = 0 + i % 2; j < MAX && B > 1; j += 2) {
            grid[i][j] = 1; B--;
    }

    cout << MAX << ' ' << MAX << '\n';
    for (int i = 0; i < MAX; i++) {for (int j = 0; j < MAX; j++) {cout << ((grid[i][j]) ? '#' : '.'); } cout << '\n';}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <list>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define ll long long int
#define repeat(n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()

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

    vector<int> va, vb;

    repeat(n) {
        int a, b;
        cin >> a >> b;
        va.push_back(a);
        vb.push_back(b);
    }

    sort(all(va));
    sort(all(vb));

    if (n % 2 == 1) {
        cout << vb[n / 2] - va[n / 2] + 1;
    } else {
        cout << vb[n / 2] + vb[n / 2 - 1] - va[n / 2] - va[n / 2 - 1] + 1;
    }

    return 0;
}

Measured memory_bytes: 4704
from collections import Counter

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


f = True
A_Counter = Counter(A)
B_Counter = Counter(B)
for a in A_Counter.keys():
    if N-A_Counter[a] < B_Counter[a]:
        f = False

if f:
    print('Yes')
    B.sort(reverse=True)
    n = 0
    sw = True
    for i in range(N):
        if A[i] == B[i]:
            if sw:
                B[i], B[n] = B[n], B[i]
                sw = False
            else:
                B[i], B[-1-n] = B[-1-n], B[i]
                n += 1
                sw = True
    print(*B)
else:
    print('No')

Measured memory_bytes: 145392
n = int(input())
ac = 0
re = 0
tle = 0
wa = 0
for i in range(n):
    t = input()
    if t[0]=="A":
        ac+=1
    if t[0] == "T":
        tle +=1
    if t[0] == "W":
        wa += 1
    if t[0] == "R":
        re += 1
print("AC","x",ac)
print("WA","x",wa)
print("TLE","x",tle)
print("RE","x",re)



Measured memory_bytes: 9204
import           Data.Char (ord)

solve :: String -> String
solve = solve' []
  where solve' s []           = s
        solve' s ('@':n:c:xs) = solve' (s ++ replicate (ord n - 0x30) c) xs
        solve' s (x:xs)       = solve' (s ++ [x]) xs

main :: IO ()
main = getContents >>= mapM_ (putStrLn . solve) . lines

Measured memory_bytes: 3552
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s,t;
    cin>>s>>t;
    ll n=s.size(),m=t.size();
    if(n>m){
        cout<<"GREATER"<<endl;
        return 0;
    } else if(n<m){
        cout<<"LESS"<<endl;
        return 0;
    }
    rep(i,n){
        if((s[i]-'0')>(t[i]-'0')){
            cout<<"GREATER"<<endl;
            return 0;
        } else if((s[i]-'0')<(t[i]-'0')){
            cout<<"LESS"<<endl;
            return 0;
        }
    }
    cout<<"EQUAL"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 int main(){
 ll n ; cin>>n ;
 vector<P> A(n),B(n) ;
 rep(i,n) cin>>A[i].fi>>A[i].se ;
 rep(i,n) cin>>B[i].fi>>B[i].se ;
 vector<ll> flag(n) ;
 sort(A.begin(),A.end()) ;
 sort(B.begin(),B.end()) ;
 ll ans=0 ;
 rep(i,n){
   ll x= B[i].fi ;
   ll y= B[i].se ;
   ll now= -1 ;
   ll memo =-1 ;
   rep(j,n){
    if(A[j].fi<x&&A[j].se<y&&now<A[j].se&&flag[j]==0){
      memo=j ;
      now= A[j].se ;
    }
   }
   if(now!=-1){
     ans++ ;
     flag[memo]=1 ;
   }

 }
  cout<<ans<<endl;
   return 0 ;
}



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

int main(void)
{
	int M, N;
	char A[50][50], B[50][50];
	cin >> N >> M;
	int x = 0, y = 0;
	for (; y < N; ++y) {
		cin >> A[y];
	}
	for (y = 0; y < M; ++y) {
		cin >> B[y];
	}
	for (y = 0; y + M <= N; ++y) {
		for (x = 0; x + M <= N; ++x) {
			int count = 0;
			for (int i = 0; i < M; ++i) {
				for (int j = 0; j < M; ++j) {
					if (A[y + i][x + j] == B[i][j])++count;
				}
			}
			if (count == M*M) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
0 0 2
2 0 2

output:
1.00000000 -1.73205080 1.00000000 1.73205080
"""

import sys
from math import sin, cos, atan2, acos


class Circle(object):
    __slots__ = ('centre', 'radius')

    def __init__(self, centre=float('inf'), radius=-1):
        self.centre = complex(centre)
        self.radius = float(radius)


def arg(p_vector):
    return atan2(p_vector.imag, p_vector.real)


def polar(a, r):
    return cos(r) * a + sin(r) * a * 1j


def get_circles_cross_points(c1, c2):
    centre_distance = abs(c1.centre - c2.centre)
    a = acos((pow(c1.radius, 2) + pow(centre_distance, 2) - pow(c2.radius, 2)) /
             (2 * c1.radius * centre_distance))
    t = arg(c2.centre - c1.centre)
    p1, p2 = c1.centre + polar(c1.radius, t + a), c1.centre + polar(c1.radius, t - a)

    if p1.real < p2.real:
        ans = (p1, p2)
    elif p1.real == p2.real:
        if p1.imag < p2.imag:
            ans = (p1, p2)
        else:
            ans = (p2, p1)
    else:
        ans = (p2, p1)
    return ans


def solve(_circle_info):
    for i, circle in enumerate(_circle_info):
        cx, cy, r = map(int, circle)
        circles[i].centre = cx + cy * 1j
        circles[i].radius = r

    cp1, cp2 = get_circles_cross_points(*circles)
    print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    circle_info = map(lambda x: x.split(), _input)

    circles = [Circle() for _ in range(2)]
    solve(circle_info)

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

using namespace std;

int main(){
	string s;
	cin>>s;
	int num1 =0;
	int num2 =0;
	for(int i =0;i<s.length();i++){
		if(s[i] == 'A') num1++;
		else num2++;
	}
	if(num1 ==0 || num2 ==0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	Stack s = new Stack();
	while(kbd.hasNext()){
	    int n = kbd.nextInt();
	    if(n==0){
		int a = (Integer)s.pop();
		System.out.println(a);
	    }
	    else {
		s.push(n);
	    }
	}
    }
}

class Stack{
    Object[] stack;
    int sp;
    public Stack(){
	stack = new Object[1000000];
	sp = 0;
    }
    public void push(Object x){
	stack[sp++] = x;
    }
    public Object pop(){
	return stack[--sp];
    }
}

Measured memory_bytes: 22016
#include <bits/stdc++.h>
// #pragma GCC optimize("O3")

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ std::cerr << std::endl; for(const auto& v : vv){ view(v); } }
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; }
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n,m,k;

int main(){
    cin >> n >> m >> k;
    for(ll i = 0;i <= n;i++){
        for(ll j = 0;j <= m;j++){

            ll x = i*m + j*n - i*j*2;
            // debug(i);debug(j);debug(x);
            if(x == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

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

int main() {

    ll x,k,d ;
    cin >> x >> k >> d ;
    x = abs(x) ;
    ll tmp = min(x/d,k) ;
    k-= tmp ;
    x-= tmp*d ;

    if(k%2){
        cout <<  min(abs(x-d),abs(x+d)) << endl ;
    }else{
        cout << x << endl ;
    }

    return 0 ;
}

Measured memory_bytes: 3584
import sys,collections as cl,bisect as bs,heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0][0]
    su = [x[0]]
    for i in range(len(x)-1):
        if aa != x[i+1][0]:
            a.append(su)
            aa = x[i+1][0]
            su = [x[i+1]]
        else:
            su.append(x[i+1])
    a.append(su)
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))


n,m = l()

a = []

for i in range(n):
    z,x = l()
    a.append([z,x])

a.sort(key = lambda x:(x[0],-x[1]))
kkk = s(a)
co = 0
p = 0
al = []
for i in range(m):
    k = i + 1
    if p <= len(kkk)-1:
        if k >= kkk[p][0][0]:
            for ppp in kkk[p]:
                hq.heappush(al,-ppp[1])
            p += 1
    if len(al) != 0:
        an = hq.heappop(al)
        co -= an 
print(co)


Measured memory_bytes: 32844
import sys
if __name__ == '__main__':
    N,K= map(int, input().split())
    bads=[int(x) for x in input().split()]
    nums=[i for i in range(10)]
    nums=list(set(nums)-set(bads))
    nums_set=set(nums)
    yen=N
    #print(nums_set, set([ int(x) for x in str(yen)]))
    flag=1
    while flag:
        yen_set=set([int(x) for x in str(yen)])
        if yen_set <= nums_set:
            print(yen)
            flag=0
        else:
            yen += 1

Measured memory_bytes: 3064
import itertools
from collections import Counter

n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
le = [i for i in range(4)]

bb = list(itertools.product(le, repeat=n))
new = []
ans = 1145141919810

for ll in bb:
    aa = 0
    con = [0]*4
    amo = [0]*4
    for i in range(n):
        con[ll[i]] += l[i]
        amo[ll[i]] += 1
        
    if con[1] > 0 and con[2] > 0 and con[3] > 0:
        for j in range(1,4):
            aa += (amo[j] - 1) * 10
        aa += abs(con[1] - a)
        aa += abs(con[2] - b)
        aa += abs(con[3] - c)
        
        ans = min(ans,aa)
        
    else:
        continue
        
print(ans)

Measured memory_bytes: 82908
#include <iostream>
#include <string>
#include <cmath>

using namespace std;


int main(){
  long a,b;
  cin >> a >> b;
  long x,y;
  x = a;
  y = b;
  long d = 1;
  long i;
  long long ans;
  int l,m,yakusuu;
  for(l=1;l<=5000;l++){
    yakusuu = 0;
    for(m=1;m<=l;m++){
      if(l % m == 0){
        yakusuu++;
      }
    }
    if(yakusuu == 2){
    i = 1;
    while(l^i <= 10^5){
      if(a % l == 0 && b % l == 0){
        a /= l;
        b /= l;
        d *= l;
        i++;
      }else{
        break;
      }
    }
    }
  }
  ans = x * y / d;

  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	int n,m,a;
	while(cin>>n>>m>>a,n|m|a){
		vvi bars(1010,vi(n+1));
		for (int i = 0; i < m; i++)
		{
			int h,p,q;
			cin>>h>>p>>q;
			bars[1001-h][p]=1;
		}
		int pos=a;
		for (int i = 0; i <= 1005; i++)
		{
			if(pos<n&&bars[i][pos]){
				pos++;
			}else if(pos>1&&bars[i][pos-1]){
				pos--;
			}
		}
		cout<<pos<<endl;
	}
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
cout<<fixed<<setprecision(10);

  char x;
  cin >> x;
  if (x=='A') cout << 'T';
  if (x=='T') cout << 'A';
  if (x=='C') cout << 'G';
  if (x=='G') cout << 'C';

	
}

Measured memory_bytes: 256
n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]
#h != 0 であるようなｈをさがし、そのときのx,y.hを変数に保存(このようなｈが少なくとも一つ存在)
for i in range(n):
    if(xyh[i][2]!= 0):
        x = xyh[i][0]
        h = xyh[i][2]
        y = xyh[i][1]
        break
for i in range(101):
    for j in range(101):
        #中心座標を(i,j)で決め打つ
        H = h+ abs(x - i)+abs(y - j)#さっきの(x,y,h)をつかうと、ピラミッドの高さはこうなる
        ok = True#フラグをTrueで初期化、もし条件を満たさないものが一つでもあればダメなので、ok= Falseしてbreak
        #すべての(x,y,h)が条件を満たすものがあれば、それが答え。出力してbreak
        for k in range(n):
            nowx = xyh[k][0]
            nowy = xyh[k][1]
            nowh = xyh[k][2]
            if nowh != max(H - abs(nowx - i) - abs(nowy - j),0):
                ok = False
                break
        if ok :
            print(i,j,H)
            break

                

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int yen = scanner.nextInt();
        int sum = 0;
        int x1 = -1;
        int y1 = -1;
        int z1 = -1;

        for(int x = 0;x <= n;x++){
            for(int y = 0;y <= n - x;y++){
                sum = 10000 * x + 5000 * y + 1000 * (n - x - y);
                if(sum == yen){
                    x1 = x;
                    y1 = y;
                    z1 = n - x - y;
                }
                sum = 0;
            }
        }

        System.out.println(x1+" "+y1+" "+z1);
    }
}

Measured memory_bytes: 23764
# include <iostream>
# include <vector>

using namespace std;

int main(){
    int N,Y;
    cin >> N >> Y;
    Y /= 1000;
    for (int i=0; i<=(Y/10); i++) {
        int j_max = (Y-10*i)/5;
        for (int j=0; j<=j_max; j++) {
            if (N - i - j >= 0) {
                if (10 * i + 5 * j + 1 * (N-i-j) == Y) {
                    cout << i << " " << j << " " << (N-i-j) << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

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


using namespace std;


int toNum(const string & str)
{
	int tmp = 1;
	int rtn = 0;

	for (const auto & c : str)
	{
		if (c == 'm')
		{
			rtn += 1000 * tmp;
			tmp = 1;
		}
		else if (c == 'c')
		{
			rtn += 100 * tmp;
			tmp = 1;
		}
		else if (c == 'x')
		{
			rtn += 10 * tmp;
			tmp = 1;
		}
		else if (c == 'i')
		{
			rtn += tmp;
			tmp = 1;
		}
		else
		{
			tmp = (int)(c - '0');
		}
	}
	return rtn;
}


void printNum(int num)
{
	list<int> lst;
	for (; num != 0; num /= 10)
	{
		lst.emplace_front(num % 10);
	}

	string keta = "ixcm";

	while (!lst.empty())
	{
		if (lst.front() > 1)
		{
			cout << lst.front();
		}
		if (lst.front() > 0)
		{
			cout << keta[lst.size() - 1];
		}
		lst.pop_front();
	}
	cout << endl;
}


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

	for (int i = 0; i < n; ++i)
	{
		string s1, s2;
		cin >> s1 >> s2;

		printNum(toNum(s1) + toNum(s2));
	}
	return 0;
}


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

public class Main{
    public static void main(String args[]) throws Exception{
    	Scanner sc= new Scanner(System.in);
    	int N;
    	int ans, sum, leng_seq;
    	while( (N= sc.nextInt())>0  ){
    		ans= 0;
    		for(leng_seq=2, sum=1+2; sum<= N; leng_seq++, sum+=leng_seq){
    			if( (N-sum)%leng_seq==0 ){ ans++; }
    		}
    		System.out.println(ans);
    	}
    }
}

Measured memory_bytes: 18340
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> a(n),b(n),c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  sort(all(a));sort(all(b));sort(all(c));
  std::vector<ll> ab,bc;
  // rep(i,n) ab.pb(upper_bound(all(b), a[i])-b.begin());
  ll ans = 0;
  rep(i,n) ans += (lower_bound(all(a), b[i])-a.begin()) * (c.end() - upper_bound(all(c), b[i]));
  // rep(i,ab.size())repl(j,ab[i],bc.size())ans += bc[j];
  cout<<ans<<endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>

#include <vector>

using namespace std;

 

#define INF 200000000

 

int main()

{

    int e, n, k;

    int a, b, cost, time, r;

    while(cin >> e >> n && e && n)

    {

        vector<vector<int> > costs(n+1, vector<int>(n+1, INF)),

                            times(n+1, vector<int>(n+1, INF));

        for(int i=0; i<costs.size(); i++)

        {

            costs[i][i] = 0;

            times[i][i] = 0;

        }

 

        for(int i=0; i<e; i++)

        {

            cin >> a >> b >> cost >> time;

            costs[a][b] = cost;

            costs[b][a] = cost;

            times[a][b] = time;

            times[b][a] = time;

        }

 

        cin >> k;

        for(int q=0; q<k; q++)

        {

            cin >> a >> b >> r;

            vector<vector<int> > v;

            if(r == 0) v = costs;

            else v = times;

 

            vector<int> distance(n+1, INF); distance[a] = 0;

            vector<int> reached(n+1, 0);

 

            while(true)

            {

                int im = -1;

                for(int i=0; i<reached.size(); i++) if(reached[i] == 0)

                {

                    if(im == -1 || distance[i] < distance[im]) im = i;

                }

                if(im == b) { cout << distance[im] << endl; break; }

 

                reached[im] = 1;

               for(int j=0; j<v[im].size(); j++)

                {

                    if(distance[im] + v[im][j] < distance[j])

                        distance[j] = distance[im] + v[im][j];

                }

            }

        }

    }

    return 0;
}

Measured memory_bytes: 1348
#include<stdio.h>

int main(void) {
	int d1[10] = { 20,19,20,19,20,19,20,19,20,19 };
	int d2[10] = { 20,20,20,20,20,20,20,20,20,20 };
	int y1 = 195;
	int y2 = 200;

	int n;
	int Y, M, D;

	scanf("%d", &n);

	int i,j;
	int days;
	for (i = 0; i < n; i++) {
		days = 0;
		scanf("%d", &Y);
		scanf("%d", &M);
		scanf("%d", &D);

		if (Y % 3 == 0) {
			days += 20 - D + 1;
			j = M;
			while (j < 10) {
				days += d2[j];
				j++;
			}
		}else {
			days += d1[M - 1] - D + 1;
			j = M;
			while (j < 10) {
				days += d1[j];
				j++;

			}
		}
		//printf("%d ", days);
	

		j = Y + 1;
		//int day2 = 0;
		while (j < 1000) {
			if (j % 3 == 0) {
				days += y2;
			}else {
				days += y1;
			}
			j++;
		}
		//printf("%d ", day2);

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


	}
	return 0;

}


Measured memory_bytes: 2044
#include <iostream>
#include <sstream>
#include <fstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
// #include <unordered_map>
#include <set>
#include <utility>
#include <bitset>
#include <limits>
#include <climits>
using namespace std;

int main() {
    int N; cin >> N;
    if (N%10 == 9 || N/10 == 9)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

using namespace std;



int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    int cnt  = b-a-1;
    if (cnt%2!=0)
    {
        printf("Alice\n");
    }
    else printf("Borys\n");
    return 0;
}


Measured memory_bytes: 256
### subroutines

def isA?(s)
  (s =~ /^>'(=+)#(=+)~$/ && $1.length == $2.length) ? true : false
end

def isB?(s)
  (s =~ /^>\^(Q=)+~~$/) ? true : false
end

### main

n = gets.strip.to_i

n.times.each do
  s = gets.strip

  if isA?(s)
    puts "A"
  elsif isB?(s)
    puts "B"
  else
    puts "NA"
  end
end

Measured memory_bytes: 6164
import sys
s = list(input())
ans = 0
# print(s)
if len(s) == 1:
    print(0)
    sys.exit()

for i in range(len(s)//2):
    # print(s[i], s[-i-1])
    if s[i] != s[-(i+1)]:
        ans += 1
#         print(s[i])
# print(len(s)//2-1)
print(ans)


Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

int main() {
	ll a, b, c, k;
	ll res = 0;
	scanf("%lld", &a);
	scanf("%lld", &b);
	scanf("%lld", &c);
	scanf("%lld", &k);
	FOR(i, 1, k) {
		if (a > 0) {
			res++;
			a -= 1;
		}
		else if(b>0) {
			b -= 1;
		}
		else {
			res--;
		}
	}
	printf("%lld\n", res);
	return(0);
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,k;
    cin>>n>>k;
    int a[n],dp[k+1];
    for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if((i-a[j] >= 0) && (dp[i-a[j]] == 0))dp[i]=1;
        }
    }
    if(dp[k]==1)cout<<"First\n";
    else cout<<"Second\n";
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1e10
using namespace std;
typedef long long llong;
int A[200000];

llong merge(int left,int mid,int right)
{
	int n1=mid-left,n2=right-mid;
	int L[n1+1],R[n2+1];
	for(int i=0;i<n1;i++) L[i] = A[left+i];
	for(int i=0;i<n2;i++) R[i] = A[mid+i];
	L[n1] = R[n2] = INF;
	llong ans=0; 
	int i=0,j=0;
	for(int k=left;k<right;k++)
		if(L[i]>R[j]) 
			A[k] = R[j++], ans += n1-i;
		else A[k] = L[i++];
	return ans;
}
llong mergeSort(int left,int right)
{
	if(left+1<right){
		int mid = (left+right)/2;
		llong n1,n2;
		n1 = mergeSort(left,mid);
		n2 = mergeSort(mid,right);
		return n1+n2+merge(left,mid,right);
	}
	return 0;
}
int main(){
	
	int n; cin>>n;
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	cout<<mergeSort(0,n)<<endl;
	return 0;
}


Measured memory_bytes: 4724
#!/usr/bin/env python3
from collections import Counter
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: "List[int]"):
    ctr = Counter(A)
    print(sum(1 for key in ctr.keys() if ctr[key] % 2 == 1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pback pop_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vis vector<string>
#define vii vector<vector<int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi,greater<int>>
#define setbits(x) __buitin_popcountll(x)
#define zrobits(x) __buitln_ctzll(x)
#define mod 1000000007 //1e9+7
#define inf 1e18
#define ps(x,y) fixed<<setpresicion(y)<<x
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x; while(x--)
#define rg 1000005
#define deg(v) cout<<"Value is: "<<v<<endl
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(a,b) for(int i=a;i<b;i++)
#define frev(a,b) for(int i=(int)a;i>(int)b;--i)
//mt19937  ring(chrono: stready_clock::now().time_since_epoch().count)


void IO() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int dp[100007];

int MinFrogCost(int *a, int i, int n) {

	if (i > n) return 0;
	if (dp[i] != -1) return dp[i];

	int left = MinFrogCost(a, i + 1, n);
	int right = MinFrogCost(a, i + 2, n);

	if (i + 1 > n && i + 2 > n) return dp[i] = 0;
	if (i + 2 > n) return dp[i] = abs(a[i] - a[i + 1]) + left;
	//cout << left << " " << right << endl;
	dp[i] = min(abs(a[i] - a[i + 1]) + left, abs(a[i] - a[i + 2]) + right);
	//cout << dp[i] << " ";

	return dp[i];
}


int32_t main() {

	FASTIO;
	//IO();

	memset(dp, -1, sizeof(dp));
	int n; cin >> n;

	int *arr = new int[n + 3];

	arr[0] = 0;
	arr[n + 1] = 0;
	arr[n + 2] = 0;
	for (int i = 1; i <= n; i++)cin >> arr[i];

	cout << MinFrogCost(arr, 1, n) << endl;
	// for (int i = 1; i <= n; i++) {
	// 	cout << dp[i] << " ";
	// }
	return 0;


}


Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
 int main()
{
    string s;
    cin>>s;
    long long int b=0;
    long long int sum=0;
    for(long long int i=0;i<s.length();i++)
    {
        if(s[i]=='B')
        {
            b++;
        }
        else
        {
            sum=sum+b;
        }
    }
    cout<<sum<<endl;
}


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

int main()
{
  int n, i;
  cin >> n;
  int a[n];

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

  for(i=n-1;i>0;i--)
    cout << a[i] << " ";
  cout << a[0] << endl;
}

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

using namespace std;

typedef long long ll;

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

    int n; cin >> n;
    vector<pair<int,int>> v;

    for(int i = 0; i < n; i++){
        int x, y; cin >> x >> y;
        v.push_back({x, y});
    }
    for(int i = 0; i < n; i++){
        if(i + 2 == n)break;
        if(v[i].first != v[i].second)continue;
        if(v[i + 1].first != v[i + 1].second)continue;
        if(v[i + 2].first != v[i + 2].second)continue;
        cout << "Yes" << '\n';
        return 0;
    }
    cout << "No"<<'\n';

}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\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;}
//------------------------------------------------------------------

int main(void){
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;

  double ans;
  if(x>a*b/2.0){
    double t = 2.0*x/a-b;
    t = b-t;
    ans = 360.0/(2.0*M_PI)*atan(t/a);
  } else {
    double t = 2.0*x/b;
    ans = 360.0/(2.0*M_PI)*atan(b/t);
  }

  prtd(10,ans);
}


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

using namespace std;

template <typename T>
T gcd(T a, T b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

template <typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main() {
    
    long long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
import math
ABN = list(map(int,input().split()))

A = ABN[0]
B = ABN[1]
N = ABN[2]

    

if (N < B):
    max_value = int(math.floor(A*N/B))

else:
    max_value = int(math.floor(A*(B-1)/B))
    
print(max_value)

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
string ch;

int main(void){
    cin >> ch; bool flag = 0;
    if(ch[0] != 'A')
        return cout << "WA",0;
    if(ch[1] < 'a' ||ch[1] > 'z') 
        return cout << "WA",0;
    for(int i=2;i<ch.length()-1;++i)
        if(ch[i] == 'C') if(flag) return cout << "WA",0;
                         else flag = 1;
            else if(ch[i] < 'a' || ch[i] > 'z') return cout << "WA",0;
    if(!flag||ch[ch.length()-1] > 'z' || ch[ch.length()-1] < 'a')
        return cout << "WA" , 0;
    cout << "AC"; return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

n, y = map(int, input().split())

if n * 10000 < y or y % 1000:
	print('-1 -1 -1')
	sys.exit()

for i in range(n + 1):
	for j in range(n - i + 1):
		k = n - i - j
		if k * 10000 + j * 5000 + i * 1000 == y:
			print('{0} {1} {2}'.format(k, j, i))
			sys.exit()

print('-1 -1 -1')

Measured memory_bytes: 3060
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
vector<int> v[300];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < s.length(); i++)
	{
		v[s[i]].push_back(i);
	}
	int cur = -1;
	int ans = 0;
	for (auto& c : t)
	{
		if (v[c].empty()) puts("-1"), exit(0);
		auto iter = upper_bound(v[c].begin(), v[c].end(), cur);
		if (iter == v[c].end()) iter = v[c].begin(), ans++;
		cur = *iter;
	}
	printf("%lld\n", 1LL * ans * s.length() + cur + 1);
	return 0;
}

Measured memory_bytes: 1216
/* You can't hack me! */
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define fo(i,n) for(ll i=0; i<(n); i++)
#define FO(i,a,b) for(auto i=a; i!=(b); i+=(b)>(a)?1:-1)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(c) c.begin(), c.end()
#define F first
#define S second
#define os(x) cout<<x<<' '
#define on(x) cout<<x<<"\n"
#define nl cout<<"\n"
#define maxe(x) max_element(all(x))-(x).begin()
#define mine(x) min_element(all(x))-(x).begin()
const ll P=998244353;
const ll MaxN=2000010;
const long double pi=3.14159265358979323846264338;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\ASISH\\Desktop\\coding\\input.txt", "r", stdin);
    freopen("C:\\Users\\ASISH\\Desktop\\coding\\output.txt", "w", stdout);
#endif

    ll T=1;
    // cin>>T;
    fo(q, T)
    {
        ll N, ans=0;
        cin>>N;
        vll cnt(3);
        string s;
        cin>>s;
        for(auto x : s){
            if(x=='R') cnt[0]++;
            else if(x=='G') cnt[1]++;
            else cnt[2]++;
        }
        ans=cnt[0]*cnt[1]*cnt[2];
        // on(ans);
        fo(i, N-2){
            FO(k, i+2, N){
                // os(i); on(k);
                if((i+k)%2) continue;
                ll j=(i+k)/2;
                if(s[k]!=s[j] && s[j]!=s[i] && s[i]!=s[k]) ans--;
            }
        }
        on(ans);
    }
    cerr << "Time : " << ((double)clock()) / (double)CLOCKS_PER_SEC << "s\n";
    return 0;
}

Measured memory_bytes: 3724
// C - Average Length
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)
using DBL = double;

int N;
DBL ans = 0.0;

vi visited(8, false);
void dfs(int p, int depth, vvi &XY, DBL dist){
	if(depth >= N-1){
		ans += dist;
		return;
	}
	rp(c, 0, N){
		if(c == p) continue;
		if(visited[c]) continue;
		int dx = XY[p][0] - XY[c][0];
		int dy = XY[p][1] - XY[c][1];
		DBL d = sqrt(dx*dx + dy*dy);
		visited[c] = true;
		dfs(c, depth+1, XY, dist+d);
		visited[c] = false;
	}
}

int main(){
	cin>>N;
	vvi XY(N, vi(2));//[i]<x,y>
	rpz(i,N) cin>>XY[i][0]>>XY[i][1];
	rpz(r, N){
		visited[r] = true;
		dfs(r, 0, XY, 0.0);
		visited[r] = false;
	}
	int n = 1; rp(i, 2, N+1) n *= i;
	printf("%.10f\n",ans/n);
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

X = i()
cnt = 0
for i in range(1,10**7):
    cnt += i
    if cnt >= X:
        print(i)
        exit()

Measured memory_bytes: 77012
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<iomanip>
#define INF INT_MAX
using namespace std;

int N;
double x;
string u;
double ans;

int main(){
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> x >> u;
		if (u == "BTC"){
			x *= 380000.0;
		}
		ans += x;
	}

	printf("%6lf\n", ans);
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn],n,sum,tmp,ans_1=0,ans_2=0;
int main(){
    cin>>n;
    for (int i=1; i<=n ;i++) cin>>a[i];
    sum=0;
    for (ll d,tmp,i=1; i<=n ;i++){
        if(i%2){
            if(sum+a[i]>0) {
                sum+=a[i];
                continue;
            }
            d=abs(sum+a[i])+1;
            ans_1+=d;
            sum=1;
        }
        else {
            if(sum+a[i]<0) {
                sum+=a[i];
                continue;
            }
            d=abs(sum+a[i])+1;
            ans_1+=d;
            sum=-1;
        }
    }
    sum=0;
    for (ll d,tmp,i=1; i<=n ;i++){
        if(i%2==0){
            if(sum+a[i]>0) {
                sum+=a[i];
                continue;
            }
            d=abs(sum+a[i])+1;
            ans_2+=d;
            sum=1;
        }
        else {
            if(sum+a[i]<0) {
                sum+=a[i];
                continue;
            }
            d=abs(sum+a[i])+1;
            ans_2+=d;
            sum=-1;
        }
    }
    cout<<min(ans_1,ans_2)<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			int[] count = new int[n + 1];
			Arrays.fill(count, 0);
			IntStream.range(0, m).forEach(i -> {
				count[scanner.nextInt() - 1]++;
				count[scanner.nextInt()]--;
			});
			IntStream.rangeClosed(1, n).forEach(i -> count[i] += count[i - 1]);
			System.out.println(IntStream.range(0, n).filter(i -> m == count[i]).count());
		}
	}
}


Measured memory_bytes: 60008
import math

n, m = (int(i) for i in input().split())
alist = list(int(i) for i in input().split())
alist=sorted(alist)
blist=[]
clist=[]
for al in alist:
    blist.append(math.floor(math.log(al, 2)))
    clist.append(0)

#print(blist)
nowcount=0
now=n-1
while nowcount<=m:
    #print(clist, now, nowcount)
    if now!=0:
        if blist[now-1]==blist[now]-clist[now]:
            now-=1
        else:
            if nowcount+n-now<=m:
                nowcount+=(n-now)
                clist[now]+=1
            else:
                amari=(m-nowcount)
                #print("!")
                nowcount+=(n-now)
    else:
        if nowcount+n-now<=m:
            nowcount+=(n-now)
            clist[now]+=1
        else:
            amari=(m-nowcount)
            #print("!")
            nowcount+=(n-now)
answer=0
now=0
option=0
dlist=[]
for i in range(n):
    nowat=alist[i]
    now+=clist[i]
    for i in range(now+option):
        nowat=nowat//2
    dlist.append(nowat)

dlist=sorted(dlist)
for i in range(amari):
    dlist[n-i-1]=dlist[n-i-1]//2

print(sum(dlist))

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

int main() {
    string w;
    cin >> w;

    string res = "Yes";
    int cnt;
    for (char c = 'a'; c <= 'z'; c++) {
        cnt = 0;
        for (int i = 0; i < w.size(); i++) {
            if (w.at(i) == c) cnt++;
        }
        if (cnt % 2 == 1) res = "No";
    }

    cout << res << endl;

    return 0;
}
            


Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int j=0;
void huiwen(int n) 
{
	int s=0;
	int t=n;
	while(n>0)
	{
		s=s*10+n%10;
		n/=10;
	}
	if(s==t)
		j++;
}
int main()
{
	int m,n;
	scanf("%d%d",&m,&n);
	for(int i=m;i<=n;i++)
	{
		huiwen(i);
	}
	printf("%d\n",j);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MAX_N = 100000;

int prime[100010];
bool is_prime[100010];
int num_2017_like[100010];

// エラストテネスの篩, o(n)程度
// n以下の素数の数を返す, prime[i]: i番目の素数, is_prime[i]: iが素数であるか
int sieve(int n, int prime[] = nullptr, bool is_prime[] = nullptr){
	bool flag0 = false, flag1 = false;
	if(prime == nullptr){
		flag0 = true; prime = new int[n];
	}
	if(is_prime == nullptr){
		flag1 = true; is_prime = new bool[n + 1];
	}

	int p = 0;
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2*i; j <= n; j+=i) is_prime[j] = false;
		}
	}

	if(flag0) delete prime;
	if(flag1) delete is_prime;

	return p;
}


int main(void){
	sieve(MAX_N, prime, is_prime);
	num_2017_like[3] = 1;
	for(int i = 3; i <= MAX_N; i++){
		if(is_prime[i] and is_prime[(i+1)/2]){
			num_2017_like[i] = num_2017_like[i-1] + 1;
		}else{
			num_2017_like[i] = num_2017_like[i-1];
		}
	}

	int Q; cin >> Q;
	for(int i = 0; i < Q; i++){
		int l, r; cin >> l >> r;
		printf("%d\n", num_2017_like[r] - num_2017_like[l-1]);
	}

	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i] >> u[i];
        if (u[i] == "BTC")
        {
            x[i] *= 380000.0;
        }
    }

    double ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ans += x[i];
    }
    printf("%.8f\n", ans);
}


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

using namespace std ;
                                                                                              
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	string s; 
	cin >> s; 
	int sum = 0 ; 
	for(int i = 0 ; i < s.size() ; ++i)
	{
		sum += (s[i] - '0') ; 
	}
	if(sum%9 == 0)
		cout << "Yes" ; 
	else 
		cout << "No" ; 
	
}








Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	ll n;
	cin >> n;
	ll ans = 0;
	rep1(i, n) rep1(j, n) rep1(k, n) {
		ll a = __gcd((ll)i, (ll)j);
		ans += __gcd(a, (ll)k);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632