akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long s = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (a[i] > i) {
            cout << -1;
            return 0;
        }
        if (i < n - 1 && a[i] == a[i + 1] - 1) {
            continue;
        } else if (i < n - 1 && a[i] < a[i + 1] - 1) {
            cout << -1;
            return 0;
        } else {
            s += a[i];
        }
    }
    cout << s;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node{
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur=nil->next;
  while(cur!=nil && cur->key!=key){
    cur=cur->next;
  }
  return cur;
}

void init() {
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}

void printfList(){
  Node *cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void deleteNode(Node* t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deletekey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main() {
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){
      insert(key);
      np++;
      size++;
    }else if (com[0]=='d'){
      if(strlen(com)>6){
	if(com[6]=='F')deleteFirst();
	else if(com[6]=='L')deleteLast();
      }else{
	deletekey(key);
	nd++;
      }
      size--;
    }
  }
  printfList();
  return 0;
}



Measured memory_bytes: 33828
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

bc = []
idx = 0
for i in range(n):
    while True:
        if b[i] >= c[-1]:
            bc.append(0)
            break
        elif c[idx] <= b[i]:
            idx += 1
        else:
            bc.append(n-idx)
            break

bc2 = bc[::-1]
ab2 = []
absum = 0
for i in range(n):
    absum += bc2[i]
    ab2.append(absum)
ab = ab2[::-1]

res = 0
idx = 0
for i in range(n):
    while True:
        if a[i] >= b[-1]:
            break
        elif b[idx] <= a[i]:
            idx += 1
        else:
            res += ab[idx]
            break
print(res)


Measured memory_bytes: 25416
from collections import deque
count = 0

def merge(A,left,mid,right):
    L = deque(A[left:mid])
    R = deque(A[mid:right])
    L.append(10**9)
    R.append(10**9)
    
    global count
    
    for k in range(left,right):
        count +=1
        if L[0] <= R[0]:
            A[k] = L.popleft()
 
        else:
            A[k] = R.popleft()

            
def mergeSort(A,left,right):
    if left + 1 < right:
        middle = (left + right) //2
        mergeSort(A,left,middle)
        mergeSort(A,middle,right)
        merge(A,left,middle,right)
        
input()
l = list(map(int,input().split()))
mergeSort(l,0,len(l))
print(*l)
print(count)            
        

Measured memory_bytes: 64332
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int time = m * 1900 + (n - m) * 100;
	int ret  = time * pow(2, m);
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, m = map(int, input().split())
d = [tuple(map(int, input().split())) for i in range(m)]
ans = [-1] * n
if (n > 1 and (1, 0) in d):
    print(-1)
    exit()
    
if n == 1 and d == []:
    print(0)
    exit()

for i in d:
    s, c = i
    if ans[s - 1] == -1:
        ans[s - 1] = c
    elif ans[s - 1] == c:
        pass
    else:
        print(-1)
        exit(0)

for i, j in enumerate(ans):
    if i == 0:
        if j == -1:
            ans[i] = 1
        else:
            pass
    else:
        if j == -1:
            ans[i] = 0
        else:
            pass

print(int(''.join(map(str, ans))))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define FOR(i,n) for(long long i=0;i<n;i++)
#define SFOR(i,a,b) for(long long i=a;i<b;i++)
#define RFOR(i,a,b) for(long long i=b;i>a;i--)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  int cnt=1,ans=0;
  while(cnt<b){
    cnt+=a-1;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
while True:
	n,m = raw_input().split(" ")
	n = int(n)
	m = int(m)
	if n*m==0:
		break
	a_all = 0
	b_all = 0
	A = []
	B = []
	for i in xrange(0,n):
		x = input()
		x = int(x)
		A.append(x)
		a_all += x
	for j in xrange(0,m):
		y = input()
		y = int(y)
		B.append(y)
		b_all += y
	A.sort()
	B.sort()
	sa = abs(a_all - b_all)
	if sa%2==1:
		print -1
	else:
		sa = sa / 2
		if(a_all < b_all):
			sa = sa * -1
		flag = False
		for i in xrange(0,n):
			for j in xrange(0,m):
				if (A[i]-B[j])==sa:
					print A[i],
					print B[j]
					flag = True
					break
			if flag==True:
				break
		if flag==False:
			print -1

Measured memory_bytes: 6372
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
n k
a1 b1
...
an bn
 */
typedef pair<int,int> P;
int n;
ll k;
P p[100000];

int main(){
  cin >> n>>k;
  REP(i,n){
    int a,b;
    cin>>a>>b;
    p[i] = make_pair(a,b);
  }
  sort(p,p+n);

  int ans=0;
  ll j = 0;
  REP(i,n){
    j+=p[i].second;
    if(j>=k){
      ans = p[i].first;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
from collections import deque

def main():
  N,K=map(int,input().split())
  mod = 10**9+7
  G=[[] for _ in range(N)]
  for i in range(N-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

  def bfs(s):
      seen = [0]*N
      color = [0]*N
      todo = deque()
      seen[s]=1
      todo.append(s)
      color[s]=K
      while todo:
        a = todo.popleft()
        if a == s: count = K-1
        else: count = K-2
        for b in G[a]:
          if seen[b] == 0:
            seen[b] = 1
            todo.append(b)
            color[b] = count %mod
            count -= 1
      return color

  MAX,start = 0,-1
  for i in range(N):
    if len(G[i])>MAX:
      MAX=len(G[i])
      start = i
  
  color = bfs(start)
  ans = 1
  for i in range(N):
    ans *= color[i]
    ans %= mod

  print(ans)
  
if __name__=="__main__":
  main()

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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n, t[50];
    string s[50], x;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> s[i] >> t[i];
    cin >> x;
    bool flag = false;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == x) {
            flag = true;
            continue;
        }
        if (flag)
            sum += t[i];
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n,i,k=1,flag=0;
    int a[200001];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==k)
            {
                k++;
                flag=1;
            }
    }
    if(flag==1)
        printf("%d\n",n-k+1);
    else
        printf("-1\n");
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>>s(h + 2, vector<int>(w + 2, -1));
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			char x;
			cin >> x;
			if (x == '#')s.at(i).at(j) = -1;
			else s.at(i).at(j) = 0;
		}
	}
	vector<vector<int>>yoko = s;
	vector<vector<int>>tate = s;
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			if (yoko.at(i).at(j) == -1)continue;
			else {
				if (yoko.at(i).at(j - 1) != -1)yoko.at(i).at(j) = yoko.at(i).at(j - 1) + 1;
				else yoko.at(i).at(j) = 1;
			}
		}
		for (int j = w + 1; j >= 0; j--) {
			if (yoko.at(i).at(j) == -1)continue;
			else {
				if (yoko.at(i).at(j + 1) == -1)continue;
				else yoko.at(i).at(j) = yoko.at(i).at(j + 1);
			}
		}
	}
	for (int i = 0; i < w + 2; i++) {
		for (int j = 0; j < h + 2; j++) {
			if (tate.at(j).at(i) == -1)continue;
			else {
				if (tate.at(j - 1).at(i) != -1)tate.at(j).at(i) = tate.at(j - 1).at(i) + 1;
				else tate.at(j).at(i) = 1;
			}
		}
		for (int j = h + 1; j >= 0; j--) {
			if (tate.at(j).at(i) == -1)continue;
			else {
				if (tate.at(j + 1).at(i) == -1)continue;
				else tate.at(j).at(i) = tate.at(j + 1).at(i);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h + 2; i++) {
		for (int j = 0; j < w + 2; j++) {
			ans = max(ans, yoko.at(i).at(j) + tate.at(i).at(j));
		}
	}
	cout << ans - 1<< endl;
}

Measured memory_bytes: 47360
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;


namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int H, W;
        private string[] A;
        private const int Mod = (int)1e9 + 7;
        void Scan()
        {
            var sc = new Scanner();
            H = sc.NextInt();
            W = sc.NextInt();
            A = new string[H];
            for (int i = 0; i < H; i++)
            {
                A[i] = sc.Next();
            }
        }

        public void Solve()
        {
            Scan();
            var ans = new int[H, W];
            ans[0, 0] = 1;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (A[i][j] == '#') continue;
                    if (i + 1 < H)
                    {
                        ans[i + 1, j] += ans[i, j];
                        ans[i + 1, j] %= Mod;
                    }
                    if (j + 1 < W)
                    {
                        ans[i, j + 1] += ans[i, j];
                        ans[i, j + 1] %= Mod;
                    }
                }
            }
            Console.WriteLine(ans[H - 1, W - 1]);
        }




        static void Main() => new Program().Solve();
    }


}

Measured memory_bytes: 25176
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>

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

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

    if ( (a == b && b == c) || (a != b && b != c && c != a))
    {
        cout << "No" << endl;
        return 0;
    }   
    
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
d = deque()
for i in range(n):
    x = input().split()

    if x[0] == "insert":
        d.appendleft(x[1])
    elif x[0] == "delete":
        if x[1] in d:
            d.remove(x[1])
    elif x[0] == "deleteFirst":
        d.popleft()
    elif x[0] == "deleteLast":
        d.pop()

print(*d)



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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int N;cin>>N;vector<int> v(N);cin>>v;
    sort(ALL(v));
    cout<<v.back()-v.front()<<endl;
    return 0;
}


Measured memory_bytes: 256
/*                    */
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
lint gcd(lint a, lint b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
lint lcm(lint a, lint b) { return a * b / my::gcd(a, b); }
}  // namespace my
/*                    */

int main() {
  const lint hoge = 10e8 + 7;
  lint n, k;
  cin >> n >> k;
  lint ans = 0;
  for (lint i = k; i <= n + 1LL; i++) {
    ans += i * n - i * (i - 1LL) + 1LL;
    ans %= hoge;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
import itertools

import numpy as np


N  = int(input())
XY = []

for n in range(N):
    x, y = map(int, input().split())
    XY.append([x, y])

XY = np.array(XY)
D  = []

for iter in itertools.permutations(list(range(N))):
    XY_tmp = XY[np.array(iter)]
    D.append((((XY_tmp[:-1] - XY_tmp[1:]) ** 2).sum(axis=1) ** 0.5).sum())

print(sum(D)/len(D))


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

int checkGroup(int n);

int main() {
	int x = 0;
	int y = 0;
	cin >> x >> y;
	if (checkGroup(x) == checkGroup(y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

int checkGroup(int n) {
	switch (n)
	{
	case 2: 
		return 0;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		return 1;
		break;
	default:
		return 2;
		break;
	}
	return -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
   string s1,s2,s3;
   cin>>s1>>s2>>s3;
   cout<<char(toupper(s1[0]))<<char(toupper(s2[0]))<<char(toupper(s3[0]))<<endl;

}

Measured memory_bytes: 256
def main():
    N = int(input())
    AList = list(map(int, input().split()))
    AList.sort()
    AMax = AList[-1] + 1

    dp = [True] * AMax
    answer = 0

    ACheckSet = set()
    ACheckSetCheckSet = set()

    for A in AList:

        if dp[A]:
            answer = answer + 1
            ACheckSet.add(A)

            for x in range(A, AMax, A):
                dp[x] = False

        elif A in ACheckSet:

            if A in ACheckSetCheckSet:
                pass
            else:
                answer = answer - 1
                ACheckSetCheckSet.add(A)

    print(answer)


if __name__ == "__main__":
    main()

Measured memory_bytes: 39448
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

struct IoSetup {
	IoSetup() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N, A, B;
int X[100005];

void solve() {
	ll ans = 0;
	int now = X[0];
	rep2 (i, 1, N) {
		if ((ll)(X[i] - now) * A <= B) ans += (ll)(X[i] - now) * A;
		else ans += B;
		now = X[i];
	}
	cout << ans << endl;
}

int main() {
	cin >> N >> A >> B;
	rep (i, N) cin >> X[i];
	solve();
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int r; cin>>r;
    cout << r*r << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,d;
	cin >> n >> d;
	int cnt = 0;
	for(int i=0;i<n;i++){
		ll a,b;
		cin >> a >> b;
		if((a*a)+(b*b) <= (d*d)){
			cnt++;
		}
	}
	cout << cnt << '\n';
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>

using namespace std;

#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main() {
    int n;
    cin >> n;
    int mx = 0;
    map<string, int> m;
    for(int i=0; i<n; i++) {
        string s;
        cin >> s;
        m[s]+=1;
        mx = max(mx, m[s]);
    }
    vector<string> v;
    for(auto i : m) {
        if(i.second == mx) {
            v.push_back(i.first);
        }
    }
    sort(all(v));
    for(auto i : v) {
        cout << i << "\n";
    }
}


Measured memory_bytes: 26868
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e5 + 10 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n , c1[maxn] , c2[maxn] , mx1 , mx2 , q1 , q2 , b1 , b2;
int a[maxn];

int32_t main() {
    FAST
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if(i & 1) {
            c2[a[i]]++;
            if(c2[a[i]] > c2[mx2]) {
                mx2 = a[i];
            }
            q2++;
        }
        else {
            c1[a[i]]++;
            if(c1[a[i]] > c1[mx1]) {
                mx1 = a[i];
            }
            q1++;
        }
    }

    if(mx1 != mx2) {
        // cout << "hey" << endl;
        cout << q1 - c1[mx1] + q2 - c2[mx2] << '\n';
    }
    else {
        for (int i = 0; i < maxn; ++i) {
            if(a[i] != mx1 && c1[a[i]] > c1[b1]) {
                b1 = a[i];
            }
            if(a[i] != mx2 && c2[a[i]] > c2[b2]) {
                b2 = a[i];
            }
        }
        if(b1 == 0 && b2 == 0) {
            if(q1 < q2) {
                cout << q1 + q2 - c2[mx2] << '\n';
            }
            else {
                cout << q2 + q1 - c1[mx1] << '\n';
            }
        }
        else {
            if(c1[b1] > c2[b2]) {
                cout << q1 - c1[b1] + q2 - c2[mx2] << '\n';
            }
            else {
                cout << q2 - c2[b2] + q1 - c1[mx1] << '\n';
            }
        }
    }
 }


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

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

    int color[9] = {0};
    int a;
    for (int i = 0; i < N; ++i) {
        std::cin >> a;
        if      (a <= 399)  { ++color[0]; }
        else if (a <= 799)  { ++color[1]; }
        else if (a <= 1199) { ++color[2]; }
        else if (a <= 1599) { ++color[3]; }
        else if (a <= 1999) { ++color[4]; }
        else if (a <= 2399) { ++color[5]; }
        else if (a <= 2799) { ++color[6]; }
        else if (a <= 3199) { ++color[7]; }
        else                { ++color[8]; }
    }

    int type = 0;
    for (int i = 0; i < 8; ++i) {
        if (color[i] != 0) {
            ++type;
        }
    }

    const int min = std::max(1, type);
    int max = type;
    if (color[8] != 0) {
        max = type + color[8];
    }

    std::cout << min << " " << max << std::endl;
        
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, M;
  cin >> N >> M;
  cout << (N-1)*(M-1) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

int main() {
   int H, W, N;
   cin >> H >> W >> N;
   int a[N];
   vector<int> log;
   for (int i = 0; i < N; i++) {
      cin >> a[i];
      for (int j = 0; j < a[i]; j++) {
         log.push_back(i + 1);
      }
   }

   for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
         if (h % 2 == 0) {
            cout << log[h * W + w] << " ";
         } else {
            cout << log[(h + 1) * W  - w  - 1] << " ";
         }
      }
      cout << endl;
   }
   return 0;
}


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

int main()
{
ll n , a , b ;
cin >> n >> a >> b ;
if(a+b-1>n){
  cout << -1 << endl;
  return 0;
}
vector<ll> ans;
ll cb=0;
vector<ll> te;
rep(i,n){
  te.push_back(n-i);
  if(te.size()==a||i==n-1){
    ll t=te.size();
    rep(j,t){
      ans.push_back(te.back());
      te.pop_back();
    }
    cb++;
    if(cb>b){
      cout << -1 << endl;
      return 0;
    }
  }
}
ll nok=b-cb;
ll it=0;
rep(i,nok){
  if(ans[n-1-it]>ans[n-2-it])it++;
  else it+=2;
}
sort(ans.begin()+n-it-1, ans.end(), greater<ll>());
for(auto rr:ans)cout << rr << " ";
cout << endl;
return 0;
}

Measured memory_bytes: 9708
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)


//C++で提出



// string s="AAA";    s.size() =3    (sのサイズ) ...1
// vector <int> a;    配列a(サイズは0) ...2
// a.push_back(10);   配列のサイズが一つ増えて一番後ろに10を代入 ...2
// A.pop_back();   最後の要素が消去される
// sort(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)より前までを小さい順に並び替えてa[0]から代入していく...3
// reverse(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)までを逆の順にしてa[0]から代入していく
// s.substr(3,2)   配列s[3]から2個の文字を抜き出した文字列 (s[3]とs[4]) ...4
// strcmp(s1,s2)  文字列が等しければ0を出力　s1>s2なら1 s1<s2なら-1を出力　C言語用なので配列は、s1[100]にする...5




/*
const int MAX = 100;
int main() {
	int N, M;
	string s, t;
	map<string, int> m;
	m["apple"] = 10;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> s;
		m[s]++;
	}
	cin >> M;
	for (int i = 0; i < M; ++i) {
		cin >> t;
		m[t]--;
	}
	
	int max=0;

	for (map<string, int>::iterator i = m.begin(); i != m.end(); ++i) {
		if (max < (i->second)) max = i->second;
	}

	if (max < 0) cout << "0";
	else cout << max;

	return 0;
}

*/

int main() {

	int N;
	int i;
	
	string s;
	map<string, int> m;
	// m["apple"] = 10;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> s;
		m[s]++;
		
	}
	
	
	int max = 0;
	string t;

	for (map<string, int>::iterator i = m.begin(); i != m.end(); ++i) {
		if (max < (i->second)) { max = i->second;}
		
	}

	vector<string> mm;

	for (map<string, int>::iterator i = m.begin(); i != m.end(); ++i) {
		if (max == (i->second)) {  mm.push_back( i->first); }
	}
	
	sort(mm.begin(), mm.end());

	for (i = 0; i < mm.size(); i++) cout << mm[i]<<endl;

	return 0;
}

Measured memory_bytes: 26996
N, M = map(int, input().split())
A_array = sorted(map(int, input().split()))
BC_array = [list(map(int, input().split())) for _ in range(M)]
BC_array = sorted(BC_array, key=lambda x: x[1])

plus_count = 0
ans = 0
a_index = N - 1
bc_index = M - 1

while plus_count != N:
    if A_array[a_index] <= BC_array[bc_index][1]:
        add_count = min(BC_array[bc_index][0], N - plus_count)
        plus_count += add_count
        ans += (add_count * BC_array[bc_index][1])
        bc_index -= 1
        if bc_index < 0:
            a_rest = N - plus_count
            ans += sum(A_array[a_index - a_rest + 1:a_index + 1])
            break
    else:
        plus_count += 1
        ans += A_array[a_index]
        a_index -= 1
print(ans)

Measured memory_bytes: 82200
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] x = sc.next().toCharArray();
        int pc = 0;
        for (int i = 0; i < n; i++) {
            if(x[i] == '1') pc++;
        }
        StringBuilder sb = new StringBuilder();
        if(pc == 0){
            for (int i = 0; i < n; i++) {
                sb.append(1 + "\n");
            }
        }else{
            int ppc = pc+1, mpc = pc-1;
            int[] ppcm = new int[n];
            int[] mpcm = new int[n];
            ppcm[n-1] = 1%ppc;
            if(mpc != 0) mpcm[n-1] = 1%mpc;
            int pm = 0, mm = 0;
            for (int i = 0; i < n; i++) {
                if(0 < i){
                    ppcm[n-1-i] = (ppcm[n-i] * 2) % ppc;
                    if(mpc != 0) mpcm[n-1-i] = (mpcm[n-i] * 2) % mpc;
                }
                if(x[n-1-i] == '1'){
                    pm = (pm + ppcm[n-1-i]) % ppc;
                    if(mpc != 0) mm = (mm + mpcm[n-1-i]) % mpc;
                }
            }
            int[] dp = new int[n+1];
            dp[0] = 1;
            for (int i = 1; i <= n; i++) {
                dp[i] = dp[i % Integer.bitCount(i)] + 1;
            }
            for (int i = 0; i < n; i++) {
                if(x[i] == '1'){
                    if(mpc == 0){
                        sb.append(0 + "\n");
                    }else{
                        int d = (mm + mpc - mpcm[i]) % mpc;
                        sb.append(dp[d] + "\n");
                    }
                }else{
                    int d = (pm + ppcm[i]) % ppc;
                    sb.append(dp[d] + "\n");
                }
            }
        }
        System.out.print(sb.toString());
        sc.close();

    }

}



Measured memory_bytes: 60220
#include<iostream>
#include<cstdio>
#define N 200009
using namespace std;
double ans;
int head[N],tot,sg[N],n;
inline int rd(){
	int x=0;char c=getchar();bool f=0;
	while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
	while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return f?-x:x;
}
struct edge{int n,to;}e[N<<1];
inline void add(int u,int v){e[++tot].n=head[u];e[tot].to=v;head[u]=tot;}
void dfs(int u,int fa){
	for(int i=head[u];i;i=e[i].n)if(e[i].to!=fa){
		int v=e[i].to;dfs(v,u);
		sg[u]^=(sg[v]+1);
	}
}
int main(){
    n=rd();int u,v;
	for(int i=1;i<n;++i){
		u=rd();v=rd();
		add(u,v);add(v,u);
	}
	dfs(1,0);
	if(sg[1])puts("Alice");
	else puts("Bob");
	return 0;
} 

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); cout.tie(NULL);
	ll n,min=10e5,ans;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
		cin>>a[i];
	for(ll i=*max_element(a,a+n);i>=1;i--)
	{
		ans = 0;
		for(ll j=0;j<n;j++)
			ans += ((a[j]-i)*(a[j]-i));
		if(ans < min)
			min = ans;
	}
	cout<<min<<"\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input())

l = [0]*(n+1)
l[0] = 2
l[1] = 1

def luca (x:int):
    if l[x] > 0:
        return l[x]
    else:
        l[x] = luca(x-1) + luca(x-2)
        return l[x]

print (luca(n))


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int N; cin >> N;
    int max_a = INT_MIN;
    int min_a = INT_MAX;

    for (int i = 0;i < N;i++){
        int a; cin >> a;
        max_a = max(a,max_a);
        min_a = min(a,min_a);
    }

    cout << max_a-min_a << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<variant>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<climits>
#include<set>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (*(s.end() - 1) == 's') {
		s += "es";
	}
	else {
		s += 's';
	}
	cout << s;
	return 0;
}

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

using namespace std;


int main()
{
    const int INF = 1e9 + 5;
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector<int> heights(n);
    for (int& x: heights){
        cin >> x;
    }
    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(heights[i] - heights[j]));
            }
        }
    }
    cout << dp[n-1] << "\n";
}





Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <vector>

int main (){
    int N;
    scanf("%d",&N);
    std::vector<int> difficulty(N);
    for (int i = 0; i < N; i++){
        scanf("%d",&difficulty[i]);
    }
    std::sort(difficulty.begin(), difficulty.end());
    int K;
        K=difficulty[N/2]-difficulty[N/2-1];
        if(K<=0) K=0;
    printf("%d",K);
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <time.h>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(ll i = a; i < b; i++)
#define repj(a,b)for(ll j = a; j < b; j++)
#define pii pair<int,int>
#define print_time()cout<<clock()/CLOCKS_PER_SEC<<" s"<<endl;

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


int main() {
	ll l, r; cin >> l >> r;
	repi(l, r + 1) {
		if (i % 2019 == 0) {
			cout << "0\n";
			return 0;
		}
	}
	l %= 2019; r %= 2019;
	if (r < l)r += 2019;
	ll ans = LLINF;
	repi(l, r + 1) {
		repj(i + 1, r + 1) {
			ans = min(ans, i * j % 2019);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[110];
int check(int l,int r){
	for(int i=l;i<=r;i++){
		int j=l+r-i;
		if(s[i]!=s[j]){
			return 0;
		}
	}
	return 1;
}
int main(){
	int len;
	scanf("%s",s);
	len=strlen(s);
	if(check(0,len-1)&&check(0,(len-1)/2-1)&&((len+3)/2-1,len-1)){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
    
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        String s = "";

        if (x > y) {
            s = ">";
        }
        else if (x < y) {
            s = "<";
        }
        else {
            s = "==";
        }
        System.out.print("a");
        System.out.print(" ");
        System.out.print(s);
        System.out.print(" ");
        System.out.println("b");
    }
}


Measured memory_bytes: 26228
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
i=0
count=1
frag=-1
for j in range(n):
  if a[i]==2:
    frag=count
    break
  else:
    i=a[i]-1
    count+=1
print(frag)  

Measured memory_bytes: 49240
from math  import gcd
n, m = map(int, input().split())
s = input()
t = input()

g = gcd(n, m)
ans = n*m//g

"""
最小公倍数の長さで収まらない場合は、何をやってもダメ
"""
for i in range(g):
    if not s[i*n//g] == t[i*m//g]:
        print(-1)
        exit(0)
print(ans)




Measured memory_bytes: 9324
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>

#define MAX_SIZE 100000000
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int n,k; cin>>n>>k;
  vector<int> x(n);
  for(auto& v : x) {
    cin >> v;
  }

  int sum = 0;
  for(int i = 0; i < n; i++) {
    int a_move = x[i];
    int b_move = k - x[i];
    if(a_move < b_move) {
      sum += a_move * 2;
    } else {
      sum += b_move * 2;
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
"""
Writer: SPD_9X2
https://atcoder.jp/contests/dp/tasks/dp_q
いわゆるインラインdpなのは分かった
→どこが？

dpを決めると、更新式がセグ木などで更新可能？
dp[i][h] = i番目まで見て、最大の高さがhの時の美しさの総和の最大値

dp[i][h] = max( dp[i-1][0] , dp[i-1][1] , … , dp[i-1][h-1] ) + a[i]
なので,RMQで処理できる
→これがインラインdpなのか？？

"""

def make_ST(n,first): #firstで初期化された、葉がn要素を超えるように2のべき乗個用意されたリストを返す

    i = 0
    ret = []
    while 2 ** (i-1) < n:

        for j in range(2 ** i):
            ret.append(first)

        i += 1

    return ret

def RMQ_update_point(num,point,tree): #葉のindex(0-origin)がpointの要素をnumにする/treeはセグ木

    i = (len(tree) - 1) // 2 + point
    tree[i] = num
    while i > 0:
        i = (i - 1) // 2
        tree[i] = max(tree[i * 2 + 2] , tree[i * 2 + 1])

    return

def RMQ_query(a,b,k,l,r,tree): #query区間左,右,注目ノード番号,担当範囲左,担当範囲右,木

    if r <= a or b <= l: #区間が完全にかぶらない場合inf
        return 0
    
    if a <= l and r <= b: #区間が完全に含まれる場合自分
        return tree[k]

    c1 = RMQ_query(a,b,2*k+1,l,(l+r)//2,tree)
    c2 = RMQ_query(a,b,2*k+2,(l+r)//2,r,tree)   

    return max(c1,c2)


N = int(input())
h = list(map(int,input().split()))
a = list(map(int,input().split()))

tree = make_ST(N+1,0)

for i in range(N):

    maxi_sc = RMQ_query(0,h[i],0,0,(len(tree)+1)//2,tree)
    RMQ_update_point(maxi_sc+a[i] , h[i] ,tree)

print (RMQ_query(0,N+1,0,0,(len(tree)+1)//2,tree))



Measured memory_bytes: 121424
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)

int c[20];
int a[20][20];

int main(){
	int n,m,x;
	scanf("%d%d%d",&n,&m,&x);
	for(int i=0;i<n;i++){
		scanf("%d",c+i);
		for(int j=0;j<m;j++)scanf("%d",&a[i][j]);
	}
	
	int ans=1e9;
	for(int b=0;b<1<<n;b++){
		int temp[20]={};
		int cost=0;
		for(int i=0;i<n;i++)if(bit(b,i)){
			cost+=c[i];
			for(int j=0;j<m;j++)temp[j]+=a[i][j];
		}
		int flag=1;
		for(int j=0;j<m;j++)flag&=temp[j]>=x;
		if(flag)ans=min(ans,cost);
	}
	
	if(ans==1e9)puts("-1");
	else printf("%d",ans);
}

Measured memory_bytes: 1728
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = do
  n <- readLn
  print $ solve n

solve :: Int -> Int
solve n = length $ takeWhile (<= n) n753s

n753s :: [Int]
n753s = filter is753 n753s'

is753 :: Int -> Bool
is753 x = find 3 x && find 5 x && find 7 x

find :: Int -> Int -> Bool
find n x
  | a == n = True
  | b == 0 = False
  | otherwise = find n b
  where
    a = x `mod` 10
    b = x `div` 10

n753s' :: [Int]
n753s' = go [3, 5, 7]
  where
    go xs = xs ++ go ys
      where
        ys = do
          x <- xs
          [append x 3, append x 5, append x 7]

append :: Int -> Int -> Int
append x y = x * 10 + y


Measured memory_bytes: 2684
eval'N,X,M='+`tr ' ' ,`
s,*v=t=0
(v[X]=t
t+=1
$*[X]=s
s+=X
v[X=X*X%M]&&(b=t-v[X]
s+=N/b*(s-$*[X])
N%=b))until 0>N-=1
p s

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

int main(){

  	int k,x;
  	cin>>k>>x;
  	int ans;
  	int flag=0;
  	for(int i=-(k-1);i<=k-1;i++){
    	if(x+i<-1000000 && flag==0){
        	ans=-1000000;
          	flag=1;
        }else if(flag==1){
          ans++;
        }else{
        ans=x+i;
        }
      
      cout<<ans<<" ";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b, lli mod = MOD){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%mod;
		a = (a*a)%mod;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7


int main(){_
	lli n,x=7,y=1;cin>>n;
	while(x%n and y<n+1)x=(x+7*powm(10,y++,n))%n;
	cout<<(y<n+1?y:-1)<<ENDL;

}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int m[200010];

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int n, p;
    cin >> n >> p;
    string s;
    cin >> s;

    if (p == 2 || p == 5){
        ll res = 0;
        for (int i = n-1; i >= 0; --i){
            if ((s[i] - '0') % p == 0){
                res += i+1;
            }
        }
        cout << res << endl; 
    } else{
        for (int i = n-1; i >= 0; --i){
            m[i] = (((s[i] - '0') % p) * modpow(10, n-1-i, p) + m[i+1]) % p;
        }

        map<int, int> mp;
        for (int i = 0; i <= n; ++i) {
            mp[m[i]]++;
        }
        ll res = 0;
        for (auto &x : mp){
            res += (ll)x.second * (ll)(x.second - 1) / 2;
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 4764
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    string s;
    cin >> s;
    if(s == "ARC"){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    //--------------
    return 0;
}

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

int main() {
    int n,ans=0,b=0;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    rep(i,n) {
        if (i%2==0) ans+=a[i];
        else b+=a[i];
    }
    cout<<ans-b<<endl;
} 


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    int H, W;
    cin >> H >> W;
    int ch, cw;
    cin >> ch >> cw;
    ch--;
    cw--;
    int dh, dw;
    cin >> dh >> dw;
    dh--;
    dw--;
    vector<string> S(H);
    rep(i,H) cin >> S[i];

    ll INF = 100100100100LL;

    vector<vector<ll>> c(H, vector<ll>(W, INF));
    auto cmp = [](auto a, auto b) {
        return get<2>(a) > get<2>(b);
    };

    priority_queue<tuple<int, int, ll> , vector<tuple<int,int,ll>> , decltype(cmp)> q(cmp);
    q.push(make_tuple(ch, cw, 0));

    int mh[] = { 0, -1, 0, 1, -2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
    int mw[] = { 1, 0, -1, 0, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2 };
    int cost[] = { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1,1,1,1,1,1,1,1,1};


    while (!q.empty()) {
        auto t = q.top();
        q.pop();

        int h = get<0>(t);
        int w = get<1>(t);
        int x = get<2>(t);

        if (c[h][w] < x) continue;

        c[h][w] = x;
        if (h == dh && w == dw) break;

        rep(i,24){
            int nh = h + mh[i];
            int nw = w + mw[i];
            int nx = x + cost[i];

            if(nh >= 0 && nh < H && nw >= 0 && nw < W && S[nh][nw] == '.' && c[nh][nw] > nx){
                q.push(make_tuple(nh, nw, nx));
            }
        }
    }

    ll ans = c[dh][dw];
    if (ans == INF) ans = -1;

    cout << ans << endl;
}


Measured memory_bytes: 17256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 1000000007
typedef long long ll;



int main(){
  int A,B;
  cin>>A>>B;
  int ans;
  ans=max(A+B,A-B);
  ans=max(ans,A*B);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,c,d; IN(a >> b >> c >> d);
    if(a+b > c+d) OUT("Left");
    else if(a+b == c+d) OUT("Balanced");
    else OUT("Right");
    
    return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	a := getNextInt(scanner)
	b := getNextInt(scanner)

	if a >= 10 {
		fmt.Println(-1)
		return
	}
	if b >= 10 {
		fmt.Println(-1)
		return
	}

	fmt.Fprintln(writer, a*b)
	writer.Flush()
}


Measured memory_bytes: 640