akhauriyash/Code-Regression huggingface dataset:
n = int(input())
hoge_list = list(map(int,input().split()))
h_list = hoge_list[::-1]
mae = h_list[0]
s = 0
for h in h_list:
  if h <= mae:
    mae = h
  elif h-1 == mae:
    mae = h-1
  else:
    print('No')
    s += 1
    break
if s == 0:
  print('Yes')

Measured memory_bytes: 14396
import math

a, b, h, m = map(int, input().split())

h_d = 30*h + 30 * (m/60)
m_d = 360 * (m/60)

diff = abs(h_d-m_d)
c_2 = (a**2) + (b**2) - 2*a*b*math.cos(math.radians(diff))

print(math.sqrt(c_2))

Measured memory_bytes: 9504
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n; cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	for(int i=0;i<n;i++){
		cin >> x[i] >> u[i];
	}
	double ans = 0.0;
	for(int i=0;i<n;i++){
		if(u[i]=="JPY"){
			ans += x[i];
		}else{
			ans += 380000.0*x[i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    string S, T;
    cin >> S;
    cin >> T;
    int count = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == T[i]) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]
sushi.sort(key=lambda x: x[1], reverse=True)

score = 0

remains = []
kinds = set()
for t, d in sushi[:K]:
    if t in kinds:
        remains.append(d)
    kinds.add(t)
    score += d
score += len(kinds)**2

test = score
for t, d in sushi[K:]:
    if not remains:
        break
    if t in kinds:
        continue
    kinds.add(t)
    rm = remains.pop()
    test = test + (d - rm) + (len(kinds)*2 - 1)
    score = max(score, test)

print(score)

Measured memory_bytes: 30784
const main = (input) => {
    input = input.split("\n");
    const X = Number(input[0].split(" ")[1]);
    const Ls = input[1].split(" ").map((L) => Number(L));
    var distance = 0;
    var boundSum = 1;

    for (var i = 0; i < Ls.length; i++) {
        distance += Ls[i];
        if (distance <= X) {
            boundSum += 1;
        } else {
            break;
        }
    }
    console.log(boundSum);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

import math

Listp = []
for i in range(1,N):
    countp = 0
    for j in range(0,i):
        if P[j] <= P[i]:
            countp = countp + 1
        else:
            countp = countp
    Listp.append(countp)

Listq = []
for i in range(1,N):
    countq = 0
    for j in range(0,i):
        if Q[j] <= Q[i]:
            countq = countq + 1
    Listq.append(countq)


ansp = (P[0]-1)*math.factorial(N-1)
for i in range(1,N):
    ansp = ansp + (P[i]-Listp[i-1]-1)*math.factorial(N-i-1)
    
ansq = (Q[0]-1)*math.factorial(N-1)
for i in range(1,N):
    ansq = ansq + (Q[i]-Listq[i-1]-1)*math.factorial(N-i-1)
    
print(abs(ansp-ansq))

Measured memory_bytes: 3064
package main

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

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e13
var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	ans := n
	maxn := 0
	for i := 1; i <= n; i++ {
		j := i
		cnt := 0
		for {
			if j%2 != 0 || j == 1 {
				break
			}
			j /= 2
			cnt++
		}
		if cnt > maxn {
			ans = i
			maxn = cnt
		}

	}

	fmt.Println(ans)
}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
string s;
int a[10];
int main()
{
	cin>>s;
	for(int i=1;i<=s.size();i++)  a[i]=s[i-1]-'0';
	if(a[1]+a[2]+a[3]+a[4]==7)
	 cout<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"+"<<a[4]<<"="<<"7";
	else if(a[1]+a[2]+a[3]-a[4]==7)
	 cout<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"-"<<a[4]<<"="<<"7";
	else if(a[1]+a[2]-a[3]+a[4]==7)
	 cout<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"+"<<a[4]<<"="<<"7";
	else if(a[1]+a[2]-a[3]-a[4]==7)
	  cout<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"-"<<a[4]<<"="<<"7";
	else if(a[1]-a[2]+a[3]+a[4]==7)
	  cout<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"+"<<a[4]<<"="<<"7";
	else if(a[1]-a[2]+a[3]-a[4]==7)
	  cout<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"-"<<a[4]<<"="<<"7";
	else if(a[1]-a[2]-a[3]+a[4]==7)
	  cout<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"+"<<a[4]<<"="<<"7";
	else if(a[1]-a[2]-a[3]-a[4]==7)
      cout<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"+"<<a[4]<<"="<<"7";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

constexpr unsigned int InputSize = 3e6;
unsigned char Input[InputSize];
unsigned char* pointer = Input;

inline unsigned int getInt(void){
    unsigned int res = 0; while(*pointer < '0') ++pointer;
    do{
        res = 10 * res + ((*pointer) - '0');
    } while(*(++pointer) >= '0');
    return res;
}

unsigned int n;
unsigned int N;
constexpr unsigned int SIZE = (1U << 19) + 1;
unsigned int data[2 * SIZE];

inline void set(void){
    N = 1; while(N < n) N <<= 1;
    while(*pointer < 'a') ++pointer;
    unsigned int i, j;
    for(i = 0, j = N; i < n; ++i, ++j){ 
        unsigned char idx = *(pointer++) - 'a'; data[j] = 1U << idx;
    }
    for(; i < N; ++i, ++j) data[j] = 0;
    for(i = N - 1; i ; --i) data[i] = data[i << 1] | data[(i << 1) | 1U];
}

inline void query(void){
    while(*pointer < '0') ++pointer;
    if(*(pointer++) == '1'){
        unsigned int index = getInt() - 1;
        while(*pointer < 'a') ++pointer;
        unsigned char idx = *(pointer++) - 'a';
        data[index += N] = 1U << idx;
        while(index >>= 1) data[index] = data[index << 1] | data[(index << 1) | 1U];
    }
    else{
        unsigned int l = getInt() + N - 1, r = getInt() + N;
        unsigned int res = 0;
        while(l < r){
            if(l & 1) res |= data[l++]; l >>= 1;
            if(r & 1) res |= data[--r]; r >>= 1;
        }
        printf("%u\n", __builtin_popcount(res));
    }
}

int main(void){
    fread(Input, sizeof(unsigned char), InputSize, stdin);
    n = getInt(); set(); 
    unsigned int q = getInt();
    while(q--) query();
    return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

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

}


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

using namespace std;

void Main() {
    string s;
    cin >> s;
    int N = s.size();

    // pattern "aa"
    for (int i = 1; i < N; ++i) {
        if (s[i - 1] == s[i]) {
            cout << i << " " << i + 1 << endl;
            return;
        }
    }
    for (int i = 2; i < N; ++i) {
        if (s[i - 2] == s[i]) {
            cout << i - 1 << " " << i + 1 << endl;
            return;
        }
    }
    cout << "-1 -1" << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3708
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
int main() 
{
    FAST
    FO
    FI
    int n;
    IN n;
    int flag=0;
    loop(i,1,10)
    {
        loop(j,1,10)
        {
            if((i*j)==n)
            {
                flag=1;
                break;
            }
        }
    }
    if(flag)
    {
        OUT "Yes";
    }
    else
    {
        OUT "No";
    }
    return 0;
}

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

int main(void){
        int a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        if(a<b){
            if(b<c) cout<<"Yes";
            else    cout<<"No";
        }
        else    cout<<"No";
        cout<<endl;
}


Measured memory_bytes: 3108
import itertools as iters
N = int(input())
P = [int(i) for i in input().rstrip().split()]
Q = [int(i) for i in input().rstrip().split()]

for i,p in enumerate(iters.permutations(range(1,N+1))):
    if list(p) == P:
        P = i
    if list(p) == Q:
        Q = i

print(abs(P-Q))

Measured memory_bytes: 3060
n = int(input())
l = [int(input()) for i in range(n)]
l2 = sorted(l)
c2 = l.index(l2[-2])
c = l.index(max(l))
d = max(l)
for i in range(n):
  if i != c:
    print(d)
  else:
    print(l2[-2])

Measured memory_bytes: 14152
#include<stdio.h>

int main()
{

  int debt = 100000;
  int n=0;
  int sen=0;

  scanf("%d",&n);

  while(n!=0)
  {
    n--;
    debt+=debt/20;
    sen=debt%1000;
    if(sen!=0)debt+=1000-sen;
  }
  printf("%d\n",debt);
  return 0;
}

Measured memory_bytes: 592
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, A[222222];

long long acc[222222];


std::pair<long long, long long> compute(int a, int b, int c)
{
  return std::make_pair(acc[b] - acc[a], acc[c] - acc[b]);
}


std::pair<long long, long long> searchm(int a, int b)
{
  if (b - a == 2)
    return compute(a, a + 1, b);
    
  long long l = a + 1, u = b;

  while (u - l > 1) {
    long long m = (l + u) / 2;

    auto pair1 = compute(a, m - 1, b);
    auto pair2 = compute(a, m,     b);

    (std::min(pair1.first, pair1.second) < std::min(pair2.first, pair2.second) ? l : u) = m;
  }

  return compute(a, l, b);
}


std::pair<long long, long long> searchp(int a, int b)
{
  if (b - a == 2)
    return compute(a, a + 1, b);
    
  long long l = a + 1, u = b;

  while (u - l > 1) {
    long long m = (l + u) / 2;

    auto pair1 = compute(a, m - 1, b);
    auto pair2 = compute(a, m,     b);

    (std::max(pair1.first, pair1.second) < std::max(pair2.first, pair2.second) ? u : l) = m;
  }

  return compute(a, l, b);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N;

  acc[0] = 0;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    acc[i + 1] = A[i] + acc[i];
  }

  long long dm = INF;

  for (int i = 2; i < N - 1; i ++) {
    auto pair1 = searchm(0, i);
    auto pair2 = searchp(i, N);

    long long dmp =
      std::max(std::max(pair1.first, pair1.second),
               std::max(pair2.first, pair2.second)) -
      std::min(std::min(pair1.first, pair1.second),
               std::min(pair2.first, pair2.second));

    pair1 = searchp(0, i);
    pair2 = searchm(i, N);

    long long dpm =
      std::max(std::max(pair1.first, pair1.second),
               std::max(pair2.first, pair2.second)) -
      std::min(std::min(pair1.first, pair1.second),
               std::min(pair2.first, pair2.second));

    dm = std::min({dmp, dpm, dm});
  }

  std::cout << dm << std::endl;

  return 0;
}


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

int main(){
    string s;
    cin>>s;
    if(s[0]=='A'){
        int f=0;
        for(int i=2;i<s.length()-1;i++){
            if(s[i]=='C'){
                f++;
            }
        }
        if(f==1){
            int count=0;
            for(int i=1;i<s.length();i++){
                if(isupper(s[i]))count++;
                
            }
            if(count==1)cout<<"AC";
            else cout<<"WA";
        }else cout<<"WA";
    }else cout<<"WA";
}



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


long long a[100010];
int n;

long long c(long long x){
	long long ans = 0;
	for(int i = 0;i < n;i++){
		ans += x ^ a[i];
	}
	return ans;
}


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

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

	for(long long i = 0;i < 63;i++){
		if(k & (1ll << i)) fin = i;
	}

	long long tmp = 0;
	for(long long i = fin; i >= 0;i--){
		if(c((1ll << i)) > c(0)){
			tmp |= (1ll << i);
		}
	}

	long long t2 = 0;
	if(fin != -1 && tmp & (1ll << fin)){
		t2 = (1ll << fin);
		for(long long i = fin-1;i >= 0;i--){
			if(k >= (t2 | (tmp & (1ll << i)))){
				t2 |= (tmp & (1ll << i));
			}
		}
		cout << max(c(t2), c(tmp & (~(1ll << fin)))) << endl;
	}else{
		cout << c(tmp) << endl;
	}

	return 0;
}







Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define N 505

int n;
int a[N][N];

int main()
{
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	for(int i=1;i<n;i++,cout<<'\n')
	for(int j=i+1;j<=n;j++)
	{
		int c=0;
		while(!((i^j)&(1<<c))) c++;
		cout<<c+1<<' ';
	}
	
	return 0;
}

Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))

MOD = 10**9+7

sum_num = 0
for i in range(60):
    o = 0
    for a in A:
        o += (a>>i)%2
    z = N - o
    sum_num = (sum_num + (o*z)*(1<<i)) % MOD

print(sum_num)

Measured memory_bytes: 122936
#include <stdio.h>
 
int main(void) {
	int i;
char ans[10];
while(scanf("%d",&i),i){
sprintf(ans,"%o",i);
for(i=0;i<10;i++){
if(ans[i]=='\0') break;
 
if(ans[i]>='4') ans[i]++;
if(ans[i]>='6') ans[i]++;
 
}
printf("%s\n",ans);
}
	return 0;
}

Measured memory_bytes: 1048
a,b,c,d,e,f=[int(i) for i in input().split()]

max_a=f//(100*a)
max_b=f//(100*b)
max_c=f//c
max_d=f//d

#水リスト
x_list=[]
for i in range(max_a+1):
   for j in range(max_b+1):
        #水
       x=100*a*i+100*b*j
       if 0<x<=f and x not in x_list:
           x_list.append(x)
#print(x_list)
       
#砂糖リスト
y_list=[]
for i in range(max_c+1):
   for j in range(max_d+1):
        #砂糖
       y=c*i+d*j
       if 0<=y<f and y not in y_list:
           y_list.append(y)
#print(y_list)

concentration_list=[]
sugar_water_list=[]
sugar_list=[]

for i in x_list:
   for j in y_list:
       if i+j<=f and j/i<=e/100:
           concentration=100*j/(i+j)
           concentration_list.append(concentration)
           sugar_water_list.append(i+j)
           sugar_list.append(j)
                   
sugar_index=concentration_list.index(max(concentration_list))
print(sugar_water_list[sugar_index],sugar_list[sugar_index])        

Measured memory_bytes: 9496
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(int a, int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main(void) {
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;


	if (s == u) {
		cout << a - 1 << " " << b << endl;
	}
	else if (t == u) {
		cout << a << " " << b - 1 << endl;
	}
	else {
		cout << a << " " << b << endl;
	}
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

    ll ans = min(1LL+a+b, c) + b;
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque

N = int(input())
match_order = [deque(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]


q = deque(range(N))
finish_by = [0] * N
next_opponent = [None] * N

while q:
    a = q.popleft()
    # aの残りの順で一番初めに戦う対戦相手を取り出す
    b = match_order[a].popleft()
    # 互いの初めに戦うべき相手がお互いであれば、そのペアで試合を行う
    if next_opponent[b] == a:
        # a,bが今までに試合した回数の多いほう+1（同じ人が日に二度試合を行えないので）
        finish_by[a] = finish_by[b] = max(finish_by[a], finish_by[b]) + 1
        # a,bについて、まだ対戦相手が残っているならキューに積む
        if match_order[a]:
            q.append(a)
        if match_order[b]:
            q.append(b)
    # bの残りの順で戦う相手がaではないなら、順番が来るまで待つ
    else:
        next_opponent[a] = b

# 対戦相手が残っている人がいる場合、条件通りに終わることができない
if any(match_order):
    print(-1)
else:
    print(max(finish_by))

Measured memory_bytes: 83804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
int main() {
    int n;
    cin >> n;
    vi a(n+1),b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll count = 0;
    rep(i, n) {
        if(a[i]>b[i]) {
            count+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
        else if(a[i]<=b[i]) {
            count+=a[i];
            b[i]-=a[i];
            a[i]=0;
        }
        if(a[i+1]>b[i]) {
            count+=b[i];
            a[i+1]-=b[i];
            b[i]=0;
        }
        else if(a[i+1]<=b[i]) {
            count+=a[i+1];
            b[i]-=a[i+1];
            a[i+1]=0;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#define SZ 666666
int n; typedef pair<int,int> pii;
pii ps[SZ],gs[SZ];
#define fi first
#define se second
typedef long long ll;
const ll MOD=1e9+7;
ll tag[SZ]; //mul
int ls[SZ],rs[SZ];
const int M=262144;
bool by_2(pii x,pii y)
{
	swap(x.fi,x.se);
	swap(y.fi,y.se);
	return x<y;
}
void init()
{
	for(int i=1;i<=M;i++) ls[i+M]=rs[i+M]=i-1;
	for(int i=M-1;i>=1;--i)
		ls[i]=ls[i+i],rs[i]=rs[i+i+1];
	for(int i=1;i<=M+M;++i) tag[i]=1;
}
ll sum[SZ];
void pd(int x)
{
	if(tag[x]!=1)
	{
		sum[x]=sum[x]*tag[x]%MOD;
		if(x<=M)
			tag[x+x]=tag[x+x]*tag[x]%MOD,
			tag[x+x+1]=tag[x+x+1]*tag[x]%MOD;
		tag[x]=1;
	}
}
void upd(int x)
{
	pd(x+x); pd(x+x+1);
	sum[x]=(sum[x+x]+sum[x+x+1])%MOD;
}
ll qsum(int x,int l,int r)
{
	if(rs[x]<l||r<ls[x]||l>r) return 0;
	pd(x); if(l<=ls[x]&&rs[x]<=r) return sum[x];
	ll ans=(qsum(x+x,l,r)+qsum(x+x+1,l,r))%MOD;
	upd(x); return ans;
}
void addt(int x,int l,int r,ll t)
{
	if(rs[x]<l||r<ls[x]||l>r) return;
	pd(x); if(l<=ls[x]&&rs[x]<=r)
	{tag[x]=tag[x]*t%MOD; return;}
	addt(x+x,l,r,t); addt(x+x+1,l,r,t); upd(x);
}
void adds(int x,int l,ll g)
{
	if(rs[x]<l||l<ls[x]) return;
	pd(x); if(ls[x]==rs[x]&&ls[x]==l)
	{sum[x]=(sum[x]+g)%MOD; return;}
	adds(x+x,l,g); adds(x+x+1,l,g); upd(x);
}
#define tm tmd
int r[SZ],l[SZ],tm[SZ],t[SZ];
int bs[SZ];
int qmax(int x)
{
	int ans=-1e9;
	for(;x>=1;x-=x&-x) ans=max(ans,bs[x]);
	return ans;
}
void edt(int x,int y)
{
	for(;x<=n;x+=x&-x) bs[x]=max(bs[x],y);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&ps[i].fi,&ps[i].se),tm[i]=ps[i].fi;
	sort(ps+1,ps+1+n,by_2); sort(tm+1,tm+1+n);
	for(int i=1;i<=n;i++) t[i]=lower_bound(tm+1,tm+1+n,ps[i].fi)-tm;
	memset(bs,-127/3,sizeof bs);
	for(int i=1;i<=n;i++)
		edt(n+1-t[i],-i), l[i]=-qmax(n+1-t[i]);
	memset(bs,-127/3,sizeof bs);
	for(int i=n;i>=1;--i)
		edt(t[i],i), r[i]=qmax(t[i]);
	for(int i=1;i<=n;i++) gs[i]=pii(l[i],r[i]);
	sort(gs+1,gs+1+n); init(); adds(1,0,1);
	for(int i=1;i<=n;i++)
	{
		int l=gs[i].fi,r=gs[i].se;
		ll tmp=qsum(1,l-1,r); adds(1,r,tmp); addt(1,r+1,n,2);
	}
	ll aa=qsum(1,n,n);
	aa=(aa%MOD+MOD)%MOD;
	printf("%d\n",int(aa));
}

Measured memory_bytes: 35072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
 
        //System.out.println(str);
        scan.close();
        
		int[] dataArr = new int[] {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		
		System.out.println(dataArr[Integer.parseInt(str,10)-1]);
	}

}


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

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

    int total = n;
    for (int i = 1; i < n; i++) {
        if (s.at(i - 1) == s.at(i)) {
            total--;
        }
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
  vector<int >perm(n,0);
  for(int i=0;i<n;i++)cin>>perm[i];
	int total=1;
  int mini = perm[0];
  for(int i=1;i<n;i++){
  	if(perm[i]<=mini){
    	mini = perm[i];
      total++;
    }
  }
  cout<<total;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, Q;

struct HeapNode {
	int d, u;
	bool operator < (const HeapNode& rhs) const {
		return d > rhs.d;
	}
};

struct Edge {
	int from, to, dist;
	Edge(int u, int v, int d) :from(u), to(v), dist(d) {}
};

struct Dijkstra {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];

	int cnt, res;
	int dep[NUM], p[NUM], siz[NUM], son[NUM], top[NUM], id[NUM], sumv[NUM << 2], addv[NUM << 2];

	void init(int n) {
		this->n = n;
		cnt = 0;
		dfs1(0, -1, 0);
		dfs2(0, 0);
	}

	void AddEdge(int from, int to, int dist) {
		edges.push_back(Edge(from, to, dist));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	void query(int o, int L, int R, int ql, int qr) {
		if (ql <= L && qr >= R) {
			res += sumv[o];
		}
		else {
			int M = L + (R - L) / 2;
			if (ql <= M)
				query(o * 2, L, M, ql, qr);
			if (qr > M)
				query(o * 2 + 1, M + 1, R, ql, qr);
		}
	}

	void update(int o, int L, int R, int v, int w) {
		int M = L + (R - L) / 2;
		if (L == R)
			sumv[o] += w;
		else {
			if (id[v] <= M)
				update(o * 2, L, M, v, w);
			else
				update(o * 2 + 1, M + 1, R, v, w);
			sumv[o] = sumv[o * 2] + sumv[o * 2 + 1];
		}
	}

	void dfs1(int u, int fa, int depth) {
		dep[u] = depth;
		p[u] = fa;
		siz[u] = 1;
		int maxson = -1;
		for (int i = 0; i < G[u].size(); i++) {
			Edge& e = edges[G[u][i]];
			int v = e.to;
			if (v == fa)
				continue;
			dfs1(v, u, depth + 1);
			siz[u] += siz[v];
			if (siz[v] > maxson) {
				son[u] = v;
				maxson = siz[v];
			}
		}
	}

	void dfs2(int u, int topf) {
		id[u] = ++cnt;
		top[u] = topf;
		if (!son[u])
			return;
		dfs2(son[u], topf);
		for (int i = 0; i < G[u].size(); i++) {
			Edge& e = edges[G[u][i]];
			int v = e.to;
			if (v == p[u] || v == son[u])
				continue;
			dfs2(v, v);
		}
	}

	int qRange(int u) {
		int ans = 0;
		while (top[u] != top[0]) {
			res = 0;
			query(1, 1, n, id[top[u]], id[u]);
			ans += res;
			u = p[top[u]];
		}
		res = 0;
		query(1, 1, n, id[0], id[u]);
		ans += res;
		return ans;
	}
};

Dijkstra solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int k, c, cmd, v, w, u;
	cin >> V;
	for (int i = 0; i < V; i++) {
		scanf("%d", &k);
		for (int j = 0; j < k; j++) {
			scanf("%d", &c);
			solve.AddEdge(i, c, 1);
			solve.AddEdge(c, i, 1);
		}
	}
	solve.init(V);
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		scanf("%d", &cmd);
		if (cmd) {
			scanf("%d", &u);
			printf("%d\n", solve.qRange(u));
		}
		else {
			scanf("%d%d", &v, &w);
			solve.update(1, 1, V, v, w);
		}
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 26160
# Problem B - Lucas Number

# input
N = int(input())

# initialization
lucas = [0]*100

# count
for i in range(N+1):
    if i==0:
        lucas[i] = 2
    elif i==1:
        lucas[i] = 1
    else:
        lucas[i] = lucas[i-1] + lucas[i-2]

# output
print(lucas[N])


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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int>           PI;
typedef pair<ll,ll>             PL;
typedef vector<PI>               vip; 
typedef vector<int>             vi;
typedef vector<vi>              vvi;

const ll INF = 1e9;
struct edge{
    int to;
    int cost;
};





int main (){
    int v,e,r;
    cin >> v >> e >> r;
    vector<vector<edge> > grap(v, vector<edge>());
    vector<ll> dist(v,INF);

    REP(i,e){
        int a,b,c;
        cin >> a >> b >> c;
        grap.at(a).push_back({b,c});
    }
    dist.at(r) = 0;
    priority_queue<PI, vector<PI>, greater<PI> > que;
    que.push(PI(0,r));
    while(!que.empty()){
        PI p = que.top();
        que.pop();
        int m = p.second;
        if(dist.at(m) < p.first) continue;

        for(int i = 0; i < grap.at(m).size(); i++){

            edge e = grap.at(m).at(i);

            if(dist.at(e.to) > dist.at(m) + e.cost){

                dist.at(e.to) = dist.at(m) + e.cost;
                que.push(PI(dist.at(e.to), e.to));
            }
        }
    }

    for(int i = 0; i < v; i++){
        if(dist.at(i) == INF) cout << "INF" << endl;
        else cout << dist.at(i) << endl;
    }





    return 0;
}


Measured memory_bytes: 13320
#include "iostream"
#include <algorithm>
#include <stdlib.h>
#include <cstring>
using namespace std;
#define NUM 999999999

int main(int argc, char const *argv[]) {
  int n,m,min,cnt;
  int ans[50];
  std::cin >> n >> m;
  long long sx[50],sy[50],cx[50],cy[50];

  for(int i=1; i<=n; i++) std::cin >> sx[i] >> sy[i];
  for(int i=1; i<=m; i++) std::cin >> cx[i] >> cy[i];

  for(int i=1; i<=n; i++){
    min=NUM;
    for(int j=1; j<=m; j++){
      int dist=abs(sx[i]-cx[j]) + abs(sy[i]-cy[j]);
      if(dist < min ){ 
        cnt=j;
        min=dist;
       }
    }
    ans[i]=cnt;
  }

  for(int i=1; i<=n; i++){
    if(i>1) std::cout << '\n';
    std::cout << ans[i];
  }
  std::cout  << endl;
  
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

template<typename T>
struct SegmentTree {
  using F = function<T(T, T)>;
  vector<T> v;
  F f;
  T e;
  int n = 1;
  SegmentTree(int size, F f, T e) : f(f), e(e) {
    while (n < size) n <<= 1;
    v.resize(n * 2, e);
  }
  void set(int k, T x) {
    v[k += n] = x;
  }
  void build() {
    rrep(i, n) v[i] = f(v[i * 2 + 0], v[i * 2 + 1]);
  }
  void update(int k, T x) {
    v[k += n] = x;
    while (k >>= 1) v[k] = f(v[k * 2 + 0], v[k * 2 + 1]);
  }
  T query(int a, int b, int k = 1, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (b <= l || r <= a) return e;
    if (a <= l && r <= b) return v[k];
    T ret = e;
    ret = f(ret, query(a, b, k * 2 + 0, l, (l + r) / 2));
    ret = f(ret, query(a, b, k * 2 + 1, (l + r) / 2, r));
    return ret;
  }
};

void solve() {
  int N; cin >> N;
  auto se = SegmentTree<i64>(N, [](i64 a, i64 b) { return a + b; }, 0ll);
  rep(i, N) {
    int a; cin >> a;
    se.set(i, a);
  }
  se.build();
  i64 ans = 1e18;
  reps(i, N - 1) {
    amin(ans, (i64) labs(se.query(0, i) - se.query(i, N)));
  }
  cout << ans << '\n';
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

enum { DOWN, UP };

int main() {
	int n;
	char f[3];
	int i;
	int left, right;
	int prev;
	int ans;

	while(1) {
		scanf("%d", &n);

		if(n == 0) break;

		ans = 0;
		prev = DOWN;
		left = DOWN;
		right = DOWN;

		for(i = 0; i < n; ++i) {
			scanf("%s", f);

			int *p = (f[0] == 'l' ? &left : &right);
			*p = (f[1] == 'u' ? UP : DOWN);

			if(left == right && left != prev) {
				++ans;
				prev = left;
			}
		}

		printf("%d\n", ans);
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXH 101
#define MAXW 101
#define INF 1000
#define MAXN 100001
#define MOD 1000000007

int N, L;
string S[101];
bool compare(const string &A,const string &B){
    int l = A.length();
    for(int i = 0;i < l;i++){
        if(A[i] < B[i]) return true;
        else if(A[i] > B[i]) return false;
    }
    return false;
}

int main(){
    cin >> N >> L;
    for(int i = 0;i < N;i++){
        cin >> S[i];
    }

    sort(S,S + N, compare);
    
    string res = "";

    for(int i = 0;i < N;i++){
        res += S[i];
    }

    cout << res << endl;

    return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<double> v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double ans = v[0];
    for(int i=1; i<n; i++){
        ans=(ans+v[i])/2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define MOD 1000000007
#define inf 1e18
#define deb(x) cout << #x << " -> " << x << "\n";

#ifdef LOCAL_DEFINE
	mt19937 rng(228);
#else 
	mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	cout.precision(10);
	cout << fixed;
	int n, a = 0, w = 0, t = 0, r = 0;
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		if (s == "AC") a++;
		else if (s == "WA") w++;
		else if (s == "TLE") t++;
		else r++;
	}	
	cout << "AC x " << a << "\n";
	cout << "WA x " << w << "\n";
	cout << "TLE x " << t << "\n";
	cout << "RE x " << r << "\n";
	return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> t(n);
    vector<int> x(n);
    vector<int> y(n);
    int act=0,dis=0,nowt=0,nowx=0,nowy=0;
    for(int i=0;i<n;i++){
        cin>>t[i]>>x[i]>>y[i];
    }
    for(int i=0;i<n;i++){
        act=t[i]-nowt;
        dis=abs(x[i]-nowx)+abs(y[i]-nowy);
        if(act<dis||dis%2!=act%2){
            cout<<"No"<<endl;
            return 0;
        }
        nowt=t[i];
        nowx=x[i];
        nowy=y[i];
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
#include <stdio.h>

#define LENGTH 100000

static int stack[LENGTH]; // X^bN
static int stackNum; // X^bNÌvf

//----------------------------------------
// Ö
void stackinit(void);
void push(int d);
int pop(void);

//********************************************************************************
// C
int main(void)
{
	int n;

	stackinit();

	while(scanf("%d", &n) != EOF) {
		if(n == 0) {
			printf("%d\n", pop());
		} else {
			push(n);
		}
	}

	return 0;
}

// X^bNðú»
void stackinit(void)
{
	stackNum = 0;
	return;
}
// X^bNÉÏÞ
void push(int d)
{
	stack[stackNum++] = d;
	return;
}
// X^bN©çæèo·
int pop(void)
{
	return stack[--stackNum];
}

Measured memory_bytes: 0
N = input()
charlist = list(N)
hoge = 0
maxscore = 0
def onon(char, hogehoge):
    nowscore = 0
    while char[hogehoge] == "A" or char[hogehoge] == "T" or char[hogehoge] == "G" or char[hogehoge] == "C" :
        hogehoge = hogehoge + 1
        nowscore += 1
        if hogehoge  >= len(char):
            break
    return nowscore 
for i in charlist:
    score = 0
    if i == "A" or i == "T" or i == "G" or i == "C"  :
        score = onon(charlist,hoge)
    if maxscore <= score:
        maxscore = score
    hoge = hoge + 1
print(maxscore)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int digits(int n);

int main()
{
    int n;
    int m = 0;

    cin >> n;

    for(int i = 0; i <= n; i++){
        if(digits(i) % 2 == 1){
            m++;
        }
    }

    cout << m << endl;

    return 0;
}

int digits(int n)
{
    int m = 0;

    while (n > 0){
       n /= 10;
       m++;
    }

    return m;
}

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

int main() {
  int A,B,X,c=0;
  cin >> A >> B;
  X = A;
  
  rep(i,B-A+1){
    if(X/10000 == X%10 && (X%10000)/1000 == (X%100)/10){
      c += 1;
    }
    
    X += 1;
  }
  cout << c << endl;
}


Measured memory_bytes: 3596
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  long long a[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      sum++;
    }
  }
  std::cout << sum << "\n";
  return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    lint x;
    cin >> n >> x;

    vector<lint> l(n);
    rep(i, n){
        cin >> l[i];
    }

    lint d = 0;
    lint ans = 1;
    rep(i, n){
        d += l[i];
        if(d <= x){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int a;
    
    std::cin >> a;
    
    if (a == 1 || a == 2) {
        std::cout << "4" << std::endl;
        return 0;
    }
    
    for (int i = 1; ; i++) {
        if (a == 4) {
            std::cout << i + 3 << std::endl;
            return 0;
        } else if (a % 2 == 0) {
            a /= 2;
        } else {
            a = 3 * a + 1;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      String s = next();
      for(int i = 0; i < 10; i++){
        String check = String.valueOf(i) + String.valueOf(i) + String.valueOf(i);
        if(s.contains(check)){
          myout("Yes");
          return;
        }
      }
      myout("No");
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 37300
N, M = map(int, input().split(' '))
ac_set = set()
wa_cnt, wa_cnt_ls = 0, [0] * N
for i in range(M):
    p, s = input().split(' ')
    idx = int(p) - 1
    if not idx in ac_set:
        if s == 'AC':
            ac_set.add(idx)
            wa_cnt += wa_cnt_ls[idx]
        else:
            wa_cnt_ls[idx] += 1
print(len(ac_set), wa_cnt)

Measured memory_bytes: 18048
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int mod = 998244353;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 1e6 + 10;
int n;
int d[105][2];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 2; j++) cin >> d[i][j];
    }
    for (int i = 1; i + 2 <= n; i++) {
        if (d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long A=0;
  int i=0;
  while(i<N){
    i=i+1;
    if((i%3)!=0 && (i%5)!=0)
    A=A+i;
  }
  cout<<A<<endl;
}
  


Measured memory_bytes: 3636
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sum = 0;
            var num = int.Parse(Console.ReadLine());
            for(int i = 1; i < num+1; i++)
            {
                for (int j = 1; j < num+1; j++)
                {
                    for (int k = 1; k < num+1; k++)
                    {
                        sum += Gcd(i, Gcd(j,k));
                    }
                }
            }
            Console.WriteLine(sum);
        }

        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }

    }
}


Measured memory_bytes: 27532
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int X = scan.nextInt();
        int Y = scan.nextInt();
        if((2*X-Y)%3 != 0 || (2*X-Y)/3 < 0){
            os.println(0);
            return;
        }

        int B = (2*X-Y)/3;
        int A = X-2*B;
        int C = A+B;

        if(A < 0) {
            os.println(0);
            return;
        }

        long mother = 1000000007;

        long invA = 1;
        for(long i = A; i > 0; i--) {
            BigInteger inv = new BigInteger(String.valueOf(i)).modInverse(BigInteger.valueOf(mother));
            long invOf2 = inv.longValue();
            invA *= invOf2;
            invA %= mother;
        }

        long invB = 1;
        for(long i = B; i > 0; i--) {
            BigInteger inv = new BigInteger(String.valueOf(i)).modInverse(BigInteger.valueOf(mother));
            long invOf2 = inv.longValue();
            invB *= invOf2;
            invB %= mother;
        }

        long facC = 1;
        for(long i = C; i > 0; i--) {
            facC *= i;
            facC %= mother;
        }

        long answer = (((invA * invB) % mother) * facC) % mother;
        os.println(answer);
    }
}

Measured memory_bytes: 100736
#include <iostream>
#include <string>
using namespace std;
int main() {
    int count=0;

    int n ;
    cin>>n;
    for (int i = 1; i <= n; i++)
    {
        int k ;
        cin>>k;
        if(i%2==1 && k%2==1)
        {
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3536