akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> S(N+1, 0);
    REP(i, N) S[i+1] = S[i] + A[i];

    ll mi = (1ll << 60);
    for(int i=2;i<N-1;i++){
    	//dump(i)
    	vector<ll> X(4);
    	ll l = 1;
    	ll u = i;
    	while(u-l > 1){
    		ll m = (l+u)/2;
    		ll maewa1 = S[m] - S[0];
    		ll ushirowa1 = S[i] - S[m];
    		ll maewa2 = S[m-1] - S[0];
    		ll ushirowa2 = S[i] - S[m-1];
    		if(abs(maewa1-ushirowa1) < abs(maewa2 - ushirowa2)){
    			l = m;
    		}else{
    			u = m;
    		}
    	}
    	//dump(l)
    	X[0] = S[l] - S[0];
    	X[1] = S[i] - S[l];

    	l = i+1;
    	u = N;
    	while(u-l > 1){
    		ll m = (l+u)/2;
    		ll maewa1 = S[m] - S[i];
    		ll ushirowa1 = S[N] - S[m];
    		ll maewa2 = S[m-1] - S[i];
    		ll ushirowa2 = S[N] - S[m-1];
    		if(abs(maewa1-ushirowa1) < abs(maewa2 - ushirowa2)){
    			l = m;
    		}else{
    			u = m;
    		}
    	}
    	X[2] = S[l] - S[i];
    	X[3] = S[N] - S[l];
    	//dump(l)
    	//cout << X << endl;
    	sort(X.begin(), X.end());
    	mi = min(mi, X[3] - X[0]);
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3456
package main

import "fmt"

func main() {
	var (
		n, q, sum int
		s         []int
	)
	fmt.Scan(&n)
	s = make([]int, n)
	for i := range s {
		fmt.Scan(&s[i])
	}

	fmt.Scan(&q)
	var tmp int
	for i := 0; i < q; i++ {
		fmt.Scan(&tmp)
		for _, v := range s {
			if tmp == v {
				sum++
				break
			}
		}
	}
	fmt.Println(sum)

}



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

int main(){
    int n; cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);
    for(int i=0; i<n+1; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];

    ll ans=0;
    for(int i=0; i<n; i++){
        if(a[i]>=b[i]){
            ans += b[i];
        }else{
            ans += a[i]; b[i] -= a[i];
            if(b[i] > a[i+1]){
                ans += a[i+1]; a[i+1]=0;
            }else{
                ans += b[i]; a[i+1] -= b[i];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4824
import bisect,sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

aa = sorted(a)
bb = sorted(b)

for i in range(n):
    if aa[i] > bb[i]:
        print('No')
        exit()
    
for i in range(1,n):
    if aa[i] <= bb[i-1]:
        print('Yes')
        exit()

dg = 10**10

ab = []
for i in range(n):
    ab.append(b[i]*dg+a[i])
ab.sort()

a = []
for e in ab:
    a.append(e%dg)


idx = {}
for i in range(n):
    k = bisect.bisect_left(aa,a[i])
    idx[k] = i


for i in range(n-1):
    if a[i] == aa[i]:
        print('Yes')
        exit()
    a[idx[i]] = a[i]
    k = bisect.bisect_left(aa,a[i])
    idx[k] = idx[i]

print('No')










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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int i = 0; i <= 100; ++i)
    {
        for (int k = 0; k <= 100; ++k)
        {
            int ans = -1;
            for (int m = 0; m < n; ++m)
            {
                if (h[m] > 0)
                {
                    int tmp = h[m] + abs(x[m] - i) + abs(y[m] - k);
                    if (ans == -1)
                    {
                        ans = tmp;
                    }
                    else
                    {
                        if (ans != tmp)
                        {
                            ans = -1;
                            break;
                        }
                    }
                }
            }
            for (int m = 0; m < n; ++m)
            {
                if (h[m] == 0 && ans > abs(x[m] - i) + abs(y[m] - k))
                {
                    ans = -1;
                    break;
                }
            }
            if (ans > 0)
            {
                cout << i << ' ' << k << ' ' << ans << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

#define MOD 1000000007

int main(){
    lld n;
    scanf("%lld", &n);
    lld a[1001];
    rep(i, 0, 1001){
        a[i] = 0;
    }
    lld ans = 1;
    for(lld i=2; i<=n; i++){
        lld x = i;
        while(x%2 == 0){
            a[2]++;
            x = x/2;
        }
        for(lld j=3; j*j<=x; j++){
            while(x % j == 0){
                a[j]++;
                x = x/j;
            }
        }
        if(x != 1){
            a[x]++;
        }
    }
    rep(i, 2, n+1){
        if(a[i] > 0){
            ans *= (a[i] + 1);
            ans = ans%MOD;
        }
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int n,i;

  scanf("%d%d",&n,&i);
  if(1>n){
    return 1;
  }else if(n>100){
    return 1;
  }else if(1>i){
    return 1;
  }else if(i>n){
    return 1;
  }

  printf("%d\n",n-i+1);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
#define INF 1000000000000
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<lli,lli> P;

struct edge{ int u, v; lli cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
	vector< vector<lli> > distance_matrix;
};

template <typename T>
vector<int> argsort(const vector<T> &v) {

  // initialize original index locations
  vector<int> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](int i1, int i2) {return v[i1] < v[i2];});

  return idx;
}

template<typename T>
void displayVector(vector<T> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}


int main(){
	int N; cin >> N; 
	vector<lli> a(N), b(N);
	REP(i,N){ cin >> a[i]; }
	b = a;
	sort(a.begin(), a.end() );

	REP(i, N){
		if(b[i] != a[N-1]){ cout << a[N-1] << endl; }
		else{ cout <<  a[N-2] << endl; }
	}
	return 0;
}

Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
  cin>>n;
  string s,t;
  cin>>s;
  cin>>t;
  for(int i=0;i<n;i++)
  {
	cout<<s[i]<<t[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
route=''
route+='U'*(ty-sy)
route+='R'*(tx-sx)
route+='D'*(ty-sy)
route+='L'*(tx-sx)
route+='L'
route+='U'*(ty-sy+1)
route+='R'*(tx-sx+1)
route+='DR'
route+='D'*(ty-sy+1)
route+='L'*(tx-sx+1)
route+='U'
print(route)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

//Main
public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n=sc.nextInt();
		int a[]=sc.readArray(n);
		int prev=a[0];
		long ans=0;
		for (int i = 1; i < a.length; i++) {
			
			prev=Math.max(prev, a[i]);
			
			ans+=prev-a[i];
			
		}
		System.out.println(ans);

	}

	static final Random random = new Random();

	static void ruffleSort(int[] a) {
		int n = a.length;//shuffle, then sort 
		for (int i = 0; i < n; i++) {
			int oi = random.nextInt(n), temp = a[oi];
			a[oi] = a[i];
			a[i] = temp;
		}
		Arrays.sort(a);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  ll res = 0, cnt = 0;
  for (int i = 0; i < (int)S.size() - 1; i++) {
    if (S[i] == 'A') {
      cnt++;
    } else if (S[i] == 'B' && S[i + 1] == 'C') {
      res += cnt;
      i++;
    } else {
      cnt = 0;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
int main(){
    int H,W;
    while(1){
        scanf("%d%d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(int h=0;h<H;h++){
            for(int w=0;w<W;w++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
  int A, B, C;
  int pos = 0;
  cin >> A >> B >> C;
  
  while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
    int a, b, c;
    a = A / 2;  b = B / 2;  c = C / 2;
    A = b + c;  B = c + a;  C = a + b;
    if (A == B && A == C) {
      pos = -1;
      break;
    }
    pos += 1;
  }
  
  cout << pos << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)
S=0
for i in range(1,N+2):
  S+=abs(A[i]-A[i-1])

for i in range(1,N+1):
  print(S+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1]))


Measured memory_bytes: 20632
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long 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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}

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

  ll n, a, t;
  cin >> n >> t >> a;
  vector<ll> h(n);
  for(ll i = 0; i < n; i++) cin >> h[i];

  double mintem = 1e9;
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    double tem = t - h[i]*0.006;
    if(abs(a-tem) < abs(a-mintem)){
      mintem = tem;
      ans = i+1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
    	Scanner sc = new Scanner(System.in);   		
    	long x = sc.nextLong();
    	int b = sc.nextInt();
    	long counter = 0;
    	while (x >0) {
    		counter++;
    		x = x/b;
    	}
    	System.out.println(counter);
    	
    		}
    }

class Pair
{
	long x;
	long y;
	
	public Pair(long x,long y) {
		this.x=x;
		this.y=y;
		
	}
}

class Scanner 
{
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

	public String next() throws IOException 
	{
		while (st == null || !st.hasMoreTokens()) 
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {return Integer.parseInt(next());}
	
	public long nextLong() throws IOException {return Long.parseLong(next());}

	public String nextLine() throws IOException {return br.readLine();}
	
	public double nextDouble() throws IOException
	{
		String x = next();
		StringBuilder sb = new StringBuilder("0");
		double res = 0, f = 1;
		boolean dec = false, neg = false;
		int start = 0;
		if(x.charAt(0) == '-')
		{
			neg = true;
			start++;
		}
		for(int i = start; i < x.length(); i++)
			if(x.charAt(i) == '.')
			{
				res = Long.parseLong(sb.toString());
				sb = new StringBuilder("0");
				dec = true;
			}
			else
			{
				sb.append(x.charAt(i));
				if(dec)
					f *= 10;
			}
		res += Long.parseLong(sb.toString()) / f;
		return res * (neg?-1:1);
	}
	
	public boolean ready() throws IOException {return br.ready();}
}


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

void fnBubbleSort(vector<int> &rvnSort, int &rnSortCnt)
{
  int nSorting = 0;
  bool bSorting = true;

  while (bSorting)
  {
    bSorting = false;
    for (int i = rvnSort.size() - 1; i > nSorting; i--)
    {
      if (rvnSort[i] < rvnSort[i - 1])
      {
        bSorting = true;
        swap(rvnSort[i], rvnSort[i - 1]);
        rnSortCnt++;
      }
    }
    nSorting++;
  }
}

void fnOutput(const vector<int> &cnrvnSort, int nSortCnt)
{
  for (int i = 0; i < cnrvnSort.size(); i++)
  {
    if (i) cout << " ";
    cout << cnrvnSort[i];
  }
  cout << endl;
  cout << nSortCnt << endl;
}
    
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int nSortCnt = 0;
  vector<int> vnSort;
  int nMaxSiz;
  
  cin >> nMaxSiz;
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nNum;
    cin >> nNum;
    vnSort.push_back(nNum);
  }

  fnBubbleSort(vnSort, nSortCnt);
  fnOutput(vnSort, nSortCnt);

  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

int main(void)
{
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);
   if(a<b){
   if(b<c){
   	 printf("Yes\n");
   }
   }
    if(a>b){
     printf("No\n");
    }
    else if(b>c){
     printf("No\n");
    }
    else if(a==b){
   	 printf("No\n");
   
   
   }
	return 0;
}

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

ll x,y;

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

    cin>>x>>y;

    if(abs(x-y)<=1)
        cout<<"Brown"<<endl;
    else
        cout<<"Alice"<<endl;


    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c;
	c=abs(c-b);
	for(int s=1;s<a;s++)
	{
		cin>>d;
		c=__gcd(c,abs(d-b));
	}
	cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int i,j,k,v,n,a[100];

    cin >> n;

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

    for(i = 1;i <= n-1;i++){
        for(k = 0;k < n - 1;k++){
            cout << a[k] << ' ';
        }
        cout << a[k] << endl;
        
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
    }

    for(i = 0;i < n - 1;i++){
        cout << a[i] << ' ';
    }
    cout << a[i] << endl;

    return 0;
}

Measured memory_bytes: 1160
INF = 10 ** 18
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n):
    b[i + 1] = b[i] + a[i]
dp = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(2, n + 1):
    for j in range(n - i + 1):
        t = INF
        for k in range(j + 1, j + i):
            t = min(t, dp[j][k] + dp[k][j + i])
        dp[j][j + i] = b[j + i] - b[j] + t
print(dp[0][n])


Measured memory_bytes: 42732
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

memo = [{} for i in range(N + 1)]


def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i - 1], t[i] = t[i], t[i - 1]
        if ''.join(t).count('AGC') >= 1:
            return False
    return True


def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in 'AGCT':
        if ok(last3 + c):
            ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret


print(dfs(0, 'TCT'))


Measured memory_bytes: 4584
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline


    s=readline().strip()
    q=int(readline().strip())
    hed=""
    btm=""
    rev=0
    for i in range(q):
        x=list(map(str, readline().strip().split()))
        if x[0]=="1": #rev
            if rev==0:
                rev=1
            else:
                rev=0
        elif x[0]=="2":
            if x[1]=="1": #head
                if rev==0:
                    hed = x[2] + hed
                else:
                    btm = btm + x[2]
            else: #bottom
                if rev==0:
                    btm = btm + x[2]
                else:
                    hed = x[2] + hed
    if rev==0:
        print(hed,end="")
        print(s,end="")
        print(btm)
    else:
        print(''.join(list(reversed(btm))),end="")
        print(''.join(list(reversed(s))),end="")
        print(''.join(list(reversed(hed))))
    return

if doTest==0:
    resolve()
    sys.exit()

Measured memory_bytes: 7032
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static List<long> Divisor(long input)
        {
            List<long> result = new List<long>();

            for (long i = 1; i * i <= input; i++)
            {
                if (0 == input % i)
                {
                    result.Add(i);
                    if (i * i != input)
                    {
                        result.Add(input / i);
                    }
                }
            }

            return result;
        }

        static long gcd(long a, long b)
        {
            if (a < b)
            {
                return gcd(b, a);
            }

            while (b != 0)
            {
                long rem = a % b;
                a = b;
                b = rem;
            }

            return a;
        }

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            long a = long.Parse(s[0]);
            long b = long.Parse(s[1]);

            List<long> div0 = Divisor(a);
            List<long> div1 = Divisor(b);

            List<long> divC = new List<long>();

            foreach(long d0 in div0)
            {
                foreach(long d1 in div1)
                {
                    if(d0 == d1)
                    {
                        divC.Add(d0);
                    }
                }
            }

            divC.Sort();
            List<long> ans = new List<long>();

            foreach(long v in divC)
            {
                List<long> div = Divisor(v);

                if (v == 1 || div.Count == 2)
                {
                    ans.Add(v);
                    continue;
                }

                bool f = false;
                foreach(long h in div)
                {
                    if (h == 1)
                    {
                        continue;
                    }

                    int t = ans.BinarySearch(h);
                    if (t >= 0)
                    {
                        f = true;
                        break;
                    }
                }

                if(!f)
                {
                    ans.Add(v);
                }
            }

            Console.WriteLine(ans.Count);
        }
    }
}



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

int main ()
{
    string S;
    cin >> S;
    string subS;
    int ans=753;
    for(int i=0;i<S.size()-2;i++){
        subS=S.substr(i,3);
        ans=min(ans,abs(atoi(subS.c_str())-753));
    }
    cout << ans<<endl;
}












Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
 ll dp[200000];

int po(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}

ll nck(ll n, ll k) {
	ll ans=1;
	for(int i=1; i<=k; ++i)
		ans=ans*(n-i+1)%mod*dp[i]%mod;
	return ans;
}
int main()
{
	int h,n;
	cin>>h>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	int dp[h+1];
	for(int i=1;i<=h;i++)
	{
		int rs=mod;
		for(int j=0;j<n;j++)
		{
			if(a[j]>=i)
				rs=min(rs,b[j]);
			else
				rs=min(rs,dp[i-a[j]]+b[j]);
		}
		dp[i]=rs;
	}
    cout<<dp[h]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,count;
  count=0;
 char a;
  for(i=0;i<4;i++){
    cin>>a;
    if(a=='+'){count++;}
    else{count--;}
  }
  cout<<count<<endl;
}


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

typedef long long LL;

const int N=2000;

int n;
char s[N+9];
bitset<N+9>a[N+9];

void into(){
  scanf("%d",&n);
  for (int i=2;i<=n;++i){
	scanf("%s",s+1);
	for (int j=1;j<i;++j) a[j][i]=(a[i][j]=s[j]-'0')^1;
  }
}

bitset<N+9>dp[2][N+9];

void Get_dp(){
  for (int i=1;i<=n;++i) dp[0][i][i]=dp[1][i][i]=1;
  for (int len=2;len<=n;++len)
	for (int l=1;l+len-1<=n;++l){
	  int r=l+len-1;
	  if ((a[l]&dp[1][l+1]&dp[0][r]).count()) dp[0][r][l]=1;
	  if ((a[r]&dp[1][l]&dp[0][r-1]).count()) dp[1][l][r]=1;
	}
}

void work(){
  Get_dp();
}

void outo(){
  printf("%d\n",(dp[0][n]&dp[1][1]).count());
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 5272
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
string s;
int n;
int dfs(vi &dp, vi &pos, vi &bit, int i) {
	if (i == n)return 0;
	if (dp[i] != -1)return dp[i];
	//cout << i << endl;
	int ret = INF;
	int b = bit[n] ^ bit[i];
	int popcount = 0;

	b = bit[i];
	ret = min(ret, 1+pos[b]);

	REP(k, 26) {
		int c = b ^ (1 << k);
		ret = min(ret, 1+pos[c]);

	}
	//ret = min(ret, 1 + dfs(dp, pos, bit, i + 1));
	pos[b] = min(pos[b], ret);
	return dp[i] = ret;

}

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

	cin >> s;
	n = s.size();
	vi bit(n + 1);

	vi pos(1 << 26, INF);
	bit[0] = 0;
	REP(i, n) {
		bit[i + 1] = bit[i] ^ (1 << (s[i] - 'a'));

	}
	pos[bit[n]] = 0;
	vi dp(n, -1);
	RREP(i, n)dfs(dp, pos, bit, i);
	cout << dp[0] << endl;
}


Measured memory_bytes: 264340
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//i番目までみたときのj枚選んだときのカードの合計がkである組合せの総数。
LL dp[51][51][3000];

//基本
//平均＝合計/枚数
//合計＝平均×枚数
int main() {

	int n, a; cin >> n >> a;

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

	//dp初期化式。
	dp[0][0][0]=1;


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < 3000; k++) {
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}

	LL ans = 0;
	for (int i = 1; i < n + 1; i++) {
		ans += dp[n][i][i*a];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 60032
n,l = gets.chomp.split(" ").map(&:to_i)

taste = []
n.times do |i|
  taste[i] = l + i
end

min = taste[0].abs
index = 0

taste.each_with_index do |t,i|
  if min > t.abs
    min = t.abs
    index = i
  end
end

taste.delete_at(index)
puts taste.inject(:+)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  string s;
  cin >> s;
  ll n = s.size();

  ll ans = 0;
  ll cnt = 0;
  rep(i, n) {
    if (s[i] == 'A') {
      cnt++;
    } else if (i+1 < n and s[i] == 'B' and s[i+1] == 'C') {
      ans += cnt;
      i++;
    } else {
      cnt = 0;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 720
n, a, b = list(map(int, input().split()))
res = 0
for i in range(1, n+1):
  sum = int(i/10000) + int(i%10000/1000) + int(i%1000/100) + int(i%100/10) + int(i%10)
  if a <= sum and sum <= b:
    res += i

print(res)


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

using namespace std;

using ll = long long;

const int N = 2e5 + 5;
const int M = 1e6 + 5;
int n;
int a[N], d[M];

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


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

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

    int n, k;
    cin >> n >> k;

    int ans = k;
    for(int i = 0; i < n - 1; i++){
        ans *= (k - 1);
    }

    cout << ans << endl;

    return 0;
}

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

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr iterator

typedef pair<ll,ll> pii;

const ll MAX=2e5+9;
const ll INF=1e8;

int N,M,X,cur,res,cnt[400],front[400],mark[400],arr[400][400];

signed main()
{
	ios_base::sync_with_stdio(false);

	res=INF;
	cin>>N>>M;
	for(int A=1;A<=N;A++)
	{
		for(int B=1;B<=M;B++)
			cin>>arr[A][B];
		front[A]=arr[A][1];
	}
	for(int it=1;it<=M;it++)
	{
		cur=0;
		for(int A=1;A<=M;A++)
			cnt[A]=0;
		for(int A=1;A<=N;A++)
		{
			for(int B=1;B<=M;B++)
			{
				front[A]=arr[A][B];
				if(!mark[arr[A][B]])
					break;
			}
			cnt[front[A]]++;
			cur=max(cur,cnt[front[A]]);
		}
		res=min(res,cur);
		for(int A=1;A<=M;A++)
		{
			if(cnt[A]==cur)
			{
				mark[A]=1;
				break;
			}
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 768
N, K = map(int, input().split())
D = set(map(str, input().split()))

for i in range(N, 10*N+1):
    sn = str(i)
    flg = True
    for c in sn:
        if c in D:
            flg = False
            break
    if flg:
        print(i)
        break

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end

template<unsigned mod>struct mint {
   static int get_mod(){return mod;}
   int val;
   int inv() const{
      int tmp,a=val,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0)x+=mod; return x;
   }
   mint():val(0){}
   mint(ll x):val(x>=0?x%mod:mod+(x%mod)){}
   mint pow(ll t){mint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
   mint& operator+=(const mint& x){if((val+=x.val)>=mod)val-=mod;return *this;}
   mint& operator-=(const mint& x){if((val+=mod-x.val)>=mod)val-=mod; return *this;}
   mint& operator*=(const mint& x){val=(ll)val*x.val%mod; return *this;}
   mint& operator/=(const mint& x){val=(ll)val*x.inv()%mod; return *this;}
   mint operator+(const mint& x)const{return mint(*this)+=x;}
   mint operator-(const mint& x)const{return mint(*this)-=x;}
   mint operator*(const mint& x)const{return mint(*this)*=x;}
   mint operator/(const mint& x)const{return mint(*this)/=x;}
   bool operator==(const mint& x)const{return val==x.val;}
   bool operator!=(const mint& x)const{return val!=x.val;}
};
using Mint=mint<1000000007>;
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx){
      Fact.resize(maxx+1),Finv.resize(maxx+1); Fact[0]=Mint(1); rep(i,0,maxx)Fact[i+1]=Fact[i]*(i+1);
      Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*i;
   }
   Mint fact(int n,bool inv=0){if(inv)return Finv[n];else return Fact[n];}
   Mint nPr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[n-r];}
   Mint nCr(int n,int r){if(n<0||n<r||r<0)return Mint(0);else return Fact[n]*Finv[r]*Finv[n-r];}
};

factorial fac(101000);

int main(){
   int n; scanf("%d",&n);
   vector<int> a(n); rep(i,0,n)scanf("%d",&a[i]);
   Mint ans=1; int cnt=0;
   rep(i,0,n){
      if(a[i]<cnt*2+1)ans*=(cnt+1);
      else cnt++;
   }
   ans*=fac.fact(cnt); printf("%d\n",ans.val);
   return 0;
}

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

class Program
{
    public static void Main()
    {
        var val = Console.ReadLine().Split(' ');
        int n = int.Parse(val[0]);
        KeyValuePair<string, KeyValuePair<int,int>>[] Shops = new KeyValuePair<string, KeyValuePair<int, int>>[n];
        for(int i = 0; i < n; i++)
        {
            var dat = Console.ReadLine().Split(' ');
            var s = dat[0];
            int p = int.Parse(dat[1]);
            Shops[i] = new KeyValuePair<string, KeyValuePair<int, int>>(s, new KeyValuePair<int, int>(p,i));
        }
        var Sorted = Shops.OrderBy(d => d.Key).ThenByDescending(x => x.Value.Key).ToArray();
        foreach(var v in Sorted)
        {
            Console.WriteLine(v.Value.Value+1);
        }
    }
}


Measured memory_bytes: 13536
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	string n;
	cin>>n;
	if( (n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3]) ){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

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

//オーバーフロー
//コーナーケース

typedef long long ll;

void yes() {
    cout << "Yay!" << endl;
}
void no() {
    cout << ":(" << endl;
}

int main() {
    int m;
    cin >> m;
    ll ans = 0;
    ll sum = 0;
    for (int i = 0; i < m; i++) {
        ll d,c;
        cin >> d >> c;
        ans += c;
        sum += d * c;
        ans += sum / 9;
        sum %= 9;
    }
    if (sum == 0) ans--;
    cout << ans - 1 << endl;
    return 0;
}


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

#define int long long
#define double long double 

using namespace std;

const int INF = 1e+18;
const int MAXN = 100000;
const int LOGN = 20;
const int mod = 1e9+7;



signed main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i-2]), dp[i - 1] + abs(h[i] - h[i-1]));
    }
    cout << dp[n - 1];
}

Measured memory_bytes: 1792
#include <iostream>
int main(){
        int R=0,B=0,N;
        std::string s;
        std::cin>>N>>s;
        for(int i=0; i<N; i++) {
                if(s[i]=='R') R++;
                else B++;
        }
        if(R>B) std::cout<<"Yes";
        else std::cout<<"No";
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    l, r, c = 0, 0, 0
    for a in s:
        if a == '(':
            c += 1
        elif c:
            c -= 1
        else:
            l += 1
    r = c
    print("("*l + s + ")"*r)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9156
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 10000 * 2;

int main(void){
    string S, T;
    ll answer;
    ll s2t[26];
    ll t2s[26];
    rep(i, 26){s2t[i] = -1; t2s[i] = -1;}
    ll N;
    cin >> S >> T;
    N = S.length();
    /*
    {a, b, c,...,z} - 1 = 96, 97, 98, ..., 121
    any i and j s.t. si == sj 
    some i and j s.t. ti != tj exist then false
    */

    rep(i, N){
        ll s_idx = S[i] - 97;
        ll t_idx = T[i] - 97;
        if (s2t[s_idx] == -1) s2t[s_idx] = t_idx;
        else if (s2t[s_idx] != t_idx) {cout << "No" << endl; return 0;}
        if (t2s[t_idx] == -1) t2s[t_idx] = s_idx;
        else if (t2s[t_idx] != s_idx) {cout << "No" << endl; return 0;}
    }


    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 776
import java.util.Scanner;

public class Main {
	
	Scanner sc = new Scanner(System.in);
	public void run() {
		int n = sc.nextInt();
		if(n != 0) calc(n);
		while(n != 0 && sc.hasNext()){
			n = sc.nextInt();
			if(n == 0) break;
			System.out.println();
			calc(n);
		}
	}
	
	public void calc(int n){
		int ten = sc.nextInt();
		int ten5 = sc.nextInt();
		int hund = sc.nextInt();
		int hund5 = sc.nextInt();
		
		int sumMon = ten * 10 + ten5 * 50 + hund * 100 + hund5 * 500;
		int returnMon = sumMon - n;
		
		int retTen = 0;
		int retTen5= 0;
		int retHund = 0;
		int retHund5 = 0;
		
		while(returnMon >= 500){
			returnMon = returnMon - 500;
			retHund5++;
		}
		while(returnMon >= 100){
			returnMon = returnMon - 100;
			retHund++;
		}
		while(returnMon >= 50){
			returnMon = returnMon - 50;
			retTen5++;
		}
		while(returnMon >= 10){
			returnMon = returnMon - 10;
			retTen++;
		}
		
		if(retTen < ten) {
			System.out.print("10 ");
			System.out.println(ten-retTen);
		}
		if(retTen5 < ten5) {
			System.out.print("50 ");
			System.out.println(ten5-retTen5);
		}
		if(retHund < hund) {
			System.out.print("100 ");
			System.out.println(hund-retHund);
		}
		if(retHund5 < hund5) {
			System.out.print("500 ");
			System.out.println(hund5-retHund5);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

ans = sum(a)
mini = []
for i in range(n):
    mini.append(a[i])


for k in range(1,n+1): #魔法をかける回数
    total = 0
    for i in range(n):
        if mini[i] > a[(i-k+n)%n]:
            mini[i] = a[(i-k+n)%n]
        total += mini[i]
    total += k*x
    if total < ans:
        ans = total

print(ans)    

Measured memory_bytes: 3188
fn solve(n: usize) -> Option<usize> {
    let n: f64 = n as f64;

    let ans = (n / 1.08).ceil();

    if n as usize != (ans * 1.08) as usize {
        None
    } else {
        Some(ans as usize)
    }
}

#[test]
fn solve_test() {
    assert_eq!(solve(10), Some(10));
    assert_eq!(solve(432), Some(400));
    assert_eq!(solve(1079), None);
    assert_eq!(solve(1001), Some(927));
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let n = parse_line!(usize);

    let ans = solve(n);
    println!(
        "{}",
        if let Some(ans) = ans {
            format!("{}", ans)
        } else {
            ":(".to_owned()
        }
    );
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
int main(void){
    char s[20];
    scanf("%s",s);
    int count=0;
    for (int i=0; i<strlen(s); i++){
        if (s[i]=='o'){
            count++;
        }
    }
    if (count+15-strlen(s)>=8){
        printf("YES\n");
    } else {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
a,b,c=map(int,input().split())

A=[a,b,c]
A.sort()

ans=0
for i in range(3):
    if A[i%3]%2==A[(i+1)%3]%2 and A[(i+1)%3]%2!=A[(i+2)%3]%2 :
        A[i%3]+=1
        A[(i+1)%3]+=1
        ans+=1

A.sort
ans+=(A[2]-A[1])//2+(A[2]-A[0])//2
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
#define DBL(a) ((a) * (a))

int
main()
{
        int n;
        double co[6];
        double a, b, c, d, e, f, delta;
        double cc_x, cc_y, r;

        for (scanf("%d", &n); n > 0; n--) {
                scanf("%lf%lf%lf%lf%lf%lf", co, co + 1, co + 2, co + 3, co + 4, co + 5);
                a = -2.0 * (co[0] - co[2]);
                b = -2.0 * (co[1] - co[3]);
                c = -2.0 * (co[2] - co[4]);
                d = -2.0 * (co[3] - co[5]);
                e = -(DBL(co[0]) + DBL(co[1])) + (DBL(co[2]) + DBL(co[3]));
                f = -(DBL(co[2]) + DBL(co[3])) + (DBL(co[4]) + DBL(co[5]));
                delta = a * d - b * c;
                cc_x = 1 / delta * (d * e + -b * f);
                cc_y = 1 / delta * (-c * e + a * f);
                r = sqrt(DBL(cc_x - co[0]) + DBL(cc_y - co[1]));
                printf("%.3lf %.3lf %.3lf\n", cc_x, cc_y, r);
        }
        return 0;
}

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

int n;
int h;
vector<int> a(100000);
vector<int> b(100000);
vector< pair<int,int> > sord(100000,pair<int,int>(0,0));
int max_sord=0;
int max_sordb=0;
int max_num=0;

int main(){
  cin >> n;
  cin >> h;
  for(int i=0;i<n;i++){
    cin >> sord.at(i).second;
    cin >> sord.at(i).first;
  }
  sort(sord.begin(),sord.begin()+n);
  reverse(sord.begin(),sord.begin()+n);
  for(int i=0;i<n;i++){
    if(sord.at(i).second>max_sord){
      max_sord=sord.at(i).second;
      max_sordb=sord.at(i).first;
      max_num=i;
    }
    else if(sord.at(i).second==max_sord){
      if(sord.at(i).first<max_sordb){
        max_sordb=sord.at(i).first;
        max_num=i;
      }
    }
  }
  int count=0;
  if(h<=max_sordb){
    count +=1;
    cout << count << endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    if(i!=max_num){
      if(sord.at(i).first>max_sord){
        count += 1;
        h -= sord.at(i).first;
        if(h<=0){
          cout << count << endl;
          return 0;
        }
        if(h<=max_sordb){
          count += 1;
          cout << count << endl;
          return 0;
        }
      }
    }
  }
  while(h>max_sordb){
    count+=1;
    h-=max_sord;
  }
  if(h<=0){
    cout << count << endl;
    return 0;
  }
  else{
    count += 1;
    cout << count << endl;
    return 0;
  }
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n; cin>>n;
    vector<ll> v(n),c(n);
    rep(i,n) cin>>v[i];
    rep(i,n) cin>>c[i];
    ll ans=0;
    rep(i,n){
        ll tmp=v[i]-c[i];
        if(tmp>0)ans+=tmp;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    string S;
    getline(cin,S);
    for(int i=0;i<S.size();i++){
        cin>>S[i];
        if(S[i]>='a' &&S[i]<='z'){
            S[i]+='A'-'a';
        }
        else if(S[i]>='A'&&S[i]<='Z'){          
            S[i]+='a'-'A';
        }
    }
    cout<<S<<endl;
    
}


Measured memory_bytes: 3164
#include <iostream>
using namespace std;
const int N=60;

int n;
int a[N];
int sum;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	
	for(int i=1;i<=n-1;i++)
		for(int j=i+1;j<=n;j++){
			sum+=a[i]*a[j];	
		}
		
	cout<<sum;
	return 0;
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,D;

ll i, j, k;

int main(){
    scanf("%lld%lld", &N,&D);
    D *= D;
    j = 0;
    rep(i,0,N){
        ll x, y;
        scanf("%lld%lld", &x, &y);
        if(x*x+y*y<=D)
            ++j;
    }
    printf("%lld\n", j);
    return 0;
}

Measured memory_bytes: 3824
local S = io.read("l")

local R = string.byte("R")

local max = 0
local count = 0
for i = 1, 3 do
	if S:byte(i) == R then
		count = count + 1
		max = (max < count) and count or max
	else
		count = 0
	end
end

print(max)

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

using namespace std;

int main() {
    string S;
    cin >> S;
    for (int i = 1; i < 4; ++i) {
        if (S[i - 1] == S[i]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
n = int(input())
l = [[0] * 10 for i in range(10)]
ans = 0

for i in range(1, n+1):
  top = int(str(i)[0])
  btm = int(str(i)[-1])
  if btm == 0:
    continue
  l[top][btm] += 1
    
for i in range(1, 10):
  for j in range(1, 10):
    ans += l[i][j] * l[j][i]
    
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
 
int main() {
    int n, x, i, j, k, count;
    while (scanf("%d%d", &n, &x) == 2 && (n || x)) {
        count = 0;
        for (i = 1; i < n - 1; i++) {
            for (j = i + 1; j < n; j++) {
                k = x - i -j;
                if (k > j && k <= n) {
                    count++;
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 600
S = input()
mod = 2019
len_S = len(S)
# 10の乗数のmodを格納
# オーバーフローを防ぐ
power = [0] * len_S
power[len_S - 1] = 1

for i in range(1,len_S):
    power[len_S-i-1] = (power[len_S-i] * 10) % mod

a = []
S_a = [0] * len_S
for i in range(len_S):
    a.append((power[i] * int(S[i])) % mod)
    if i > 0:
        S_a[i] = S_a[i-1] + int(a[i])
    else:
        S_a[i] = int(a[i])

# S_a の 2019の余りをカウント
cnt = [0] * 2020
ans = 0
for i in range(len_S):
    cnt[S_a[i]%mod] += 1

# 累積和のあまりがすでに0のやつはそれを選べば割り切れるので足す
ans += cnt[0]
for i in range(2020):
    ans += cnt[i] * (cnt[i] - 1) // 2
print(ans)

Measured memory_bytes: 31600