akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

LL dp[5005][5005] = {};
int main() {
  int N; cin >> N;
  string S; cin >> S;

  LL vmax = 0;
  for (int i = N - 2; i >= 0; --i) {
    for (int j = N - 1; j > i; --j) {
      if (S[i] == S[j]) {
        dp[i][j] = min(dp[i + 1][j + 1] + 1LL, (LL)(j - i));
        vmax = max(vmax, dp[i][j]);
      }
    }
  }
  cout << vmax << endl;
}


Measured memory_bytes: 120072
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()
ans = [0] * (len(s) + 1)
ret = 0
for j in range(len(s) - 1, -1, -1):
    if s[j] == '>':
        ret += 1
        ans[j] = ret
    else:
        ret = 0


ret = 0
for i in range(len(s)):
    if s[i] == '<':
        ret += 1
        if ans[i + 1] < ret:
            ans[i + 1] = ret
    else:
        ret = 0



print(sum(ans))




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

int main(){
  long long  n,k,h[1000000],s=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h,h+n);
  for(int i=0;i<n-k;i++){
    s+=h[i];
  }
  cout<<s<<endl;
}

  


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>

using namespace std;

typedef long long ll;

int main() {
  int N, Y, tmp;
  cin >> N >> Y;
  tmp = Y / 1000 - N;
  rep(i, N + 1) {
    rep(j, N - i + 1) {
      if (tmp == 9 * i + 4 * j) {
        cout << i << ' ' << j << ' ' << N - i - j << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << ' ' << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    while (true) {
        val (midTermExamScore, finalTermExamScore, retestScore)
                = readLine()?.split(" ")?.map { it.toInt() } ?: return
        if (midTermExamScore < 0 && finalTermExamScore < 0 && retestScore < 0) return
        val totalScore = midTermExamScore + finalTermExamScore
        val record = when {
            midTermExamScore < 0 || finalTermExamScore < 0 -> 'F'
            totalScore >= 80 -> 'A'
            totalScore in 65..79 -> 'B'
            totalScore in 50..64 || totalScore in 30..49 && retestScore >= 50 -> 'C'
            totalScore in 30..49 -> 'D'
            else -> 'F'
        }
        println(record)
    }
}


Measured memory_bytes: 31968
import sys
m=166666;a=[[1]*m for _ in[0]*2]
for i in range(m):
 if a[0][i]:
  k=6*i+5
  a[0][i+k::k]=[0]*len(a[0][i+k::k])
  a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k])
 if a[1][i]:
  k=6*i+7
  a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k])
  a[1][i+k::k]=[0]*len(a[1][i+k::k])
for e in map(int,sys.stdin):
 print([e-1,sum(a[0][:(e+1)//6])+sum(a[1][:(e-1)//6])+2][e>3])


Measured memory_bytes: 9888
import math
from decimal import *
import random

s1 = str(input())
s2 = str(input())
ans = int(1e9)+7
for i in range(len(s1)-len(s2)+1):
    tmp = 0
    for j in range(len(s2)):
        if(s2[j]!= s1[i+j]):
            tmp+=1
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 83492
def gcd(A, B, C, D):
	l, L = A-C, B-D
	if l<0:
		l = l*(-1)
	if L<0:
		L = L*(-1)
	return l+L
	
N, M = map(int, input().split())
x = []
y = []
n = 0
m = 0
ans = 1
for i in range(N):
	x1, y1 = map(int, input().split())
	x.append(x1)
	y.append(y1)
X = []
Y = []
for l in range(M):
	x2, y2 = map(int, input().split())
	X.append(x2)
	Y.append(y2)
for a in range(N):
	m = gcd(x[a], y[a], X[0], Y[0])
	for b in range(M):
		n = gcd(x[a], y[a], X[b], Y[b])
		if n < m:
			m = n
			ans = b+1
	print(ans)
	ans = 1

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dice1
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            Dice dice = new Dice(
                int.Parse(strs[0]),
                int.Parse(strs[1]),
                int.Parse(strs[2]),
                int.Parse(strs[3]),
                int.Parse(strs[4]),
                int.Parse(strs[5]));

            string directions = Console.ReadLine();
            foreach (char dir in directions)
            {
                if (dir.Equals('E')) dice.GoEast();
                if (dir.Equals('N')) dice.GoNorth();
                if (dir.Equals('S')) dice.GoSouth();
                if (dir.Equals('W')) dice.GoWest();
            }
            Console.WriteLine(dice.GetNumber(1));
        }
    }

    public class Dice
    {
        private Dictionary<int, int> dice;
        
        public Dice(
            int face1,
            int face2,
            int face3,
            int face4,
            int face5,
            int face6)
        {
            dice = new Dictionary<int, int>();
            dice.Add(1, face1);
            dice.Add(2, face2);
            dice.Add(3, face3);
            dice.Add(4, face4);
            dice.Add(5, face5);
            dice.Add(6, face6);
        }

        public void GoEast()
        {
            Dictionary<int, int> temp = new Dictionary<int, int>();
            temp = new Dictionary<int, int>(dice);

            dice[3] = temp[1];
            dice[2] = temp[2];
            dice[6] = temp[3];
            dice[1] = temp[4];
            dice[5] = temp[5];
            dice[4] = temp[6];
        }

        public void GoNorth()
        {
            Dictionary<int, int> temp = new Dictionary<int, int>();
            temp = new Dictionary<int, int>(dice);

            dice[5] = temp[1];
            dice[1] = temp[2];
            dice[3] = temp[3];
            dice[4] = temp[4];
            dice[6] = temp[5];
            dice[2] = temp[6];
        }

        public void GoSouth()
        {
            Dictionary<int, int> temp = new Dictionary<int, int>();
            temp = new Dictionary<int, int>(dice);

            dice[2] = temp[1];
            dice[6] = temp[2];
            dice[3] = temp[3];
            dice[4] = temp[4];
            dice[1] = temp[5];
            dice[5] = temp[6];
        }

        public void GoWest()
        {
            Dictionary<int, int> temp = new Dictionary<int, int>();
            temp = new Dictionary<int, int>(dice);

            dice[4] = temp[1];
            dice[2] = temp[2];
            dice[1] = temp[3];
            dice[6] = temp[4];
            dice[5] = temp[5];
            dice[3] = temp[6];
        }

        public int GetNumber(int face)
        {
            return dice[face];
        }
    }
}

Measured memory_bytes: 6184
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <math.h>
using namespace std;

int main() {
    int n,x;
    cin>>n>>x;
    int m[101]={0};
    for(int i=0;i<n;++i) cin>>m[i];
    int s=0;
    for(int i=0;i<101;++i) s+=m[i];
    x-=s;
    sort(m,m+101);
    int a=0;
    for(int i=0;i<101;++i){
        if(m[i]!=0){
            a=x/m[i];
            cout<<a+n<<endl;
            return 0;
        }
    }
    return 0;
}

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

#define f first
#define s second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(v) cout << #v << ":\t" << v << endl
#define _ << ", " <<

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 1e3 + 3;
const ll INF = 1e9 + 37;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b);
	
	return 0;
}


Measured memory_bytes: 256
s = input()
a = s[2:]
a = a[::-1]
a = a.replace(a[0],'',1)
a = a[::-1]
cnt = 0
for i in list(s):
  if i.isupper() == True:
    cnt += 1
if s[0] !='A' or a.count('C') != 1 or cnt != 2:
  print('WA')
else:
    print('AC')

Measured memory_bytes: 3064
H, W, K = map(int, input().split())
m = []
for h in range(H):
    m.append(list(map(int, list(input()))))

ans = float('inf')
for hb in range(2**(H-1)):
    hl = []
    for i in range(H-1):
        if hb & (1 << i) > 0:
            hl.append(i+1)
    t = len(hl)
    hl = [0]+hl+[H]

    w, pw = 0, 0
    wl = [0]*len(hl)
    while w < W:
        ok = True
        for i in range(len(hl)-1):
            sh, eh = hl[i], hl[i+1]
            for h in range(sh, eh):
                wl[i] += m[h][w]
                if wl[i] > K:
                    ok = False
                    break
            if not ok:
                break

        if not ok:
            if pw == w:
                t = float('inf')
                break
            pw, w = w, w
            t += 1
            wl = [0]*len(hl)
        else:
            w += 1

    ans = min(t, ans)

print(ans)


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


int main(){
    int n;
    cin >> n;
    vector<ll> A(n);
    bool odd = 0;
    rep(i, n){
        cin >> A.at(i);
        if (A.at(i)%2 == 1) odd = 1;
    }
    // odd case
    if (odd == 1) cout << 0 << endl;
    else{
        ll cnt = 0;
        while (true){
            cnt ++;
            rep(i, n){
                A.at(i) = A.at(i)/2;
                if (A.at(i) % 2 == 1){
                    cout << cnt << endl;
                    return 0;
                } 
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main()
{
	bool dp[100000];
	bool dp2[100000];
	int a[10000];
	int N,K;
	int b[10000];

	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>a[i];
	}
	cin>>K;
	for(int i=1;i<=K;i++){
		cin>>b[i];
	}

	for(int h=1;h<=K;h++){
	memset(dp,false,sizeof(dp));
	dp[0]=true;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=b[h];j++){
			if(dp[j]==true){
				dp2[j+a[i]]=true;
			}
		}
		for(int j=0;j<=b[h];j++){
			if(dp2[j]==true){
				dp[j]=true;
			}
		}
		memset(dp2,false,sizeof(dp2));
	}

	cout<<(dp[b[h]]?"yes":"no")<<endl;

	}

	return 0;
}

Measured memory_bytes: 1368
#include <cstdio>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
int readint() {
	char ch = getchar_unlocked();
	int res = 0;
	while('0' <= ch && ch <= '9') {
		res = res * 10 + (ch - '0');
		ch = getchar_unlocked();
	}
	return res;
}
alignas(1024) char buf[1024];
void writeint(int x, char endch) {
	int ptr = 0, g;
	while(x > 0) {
		g = x / 10;
		buf[ptr++] = x - g * 10;
		x = g;
	}
	if(ptr == 0) {
		buf[ptr++] = 0;
	}
	while(ptr--) {
		putchar_unlocked(buf[ptr] + '0');
	}
	putchar_unlocked(endch);
}
int g[] = { 1, 8, 23, 77, 281, 1073, 4193, 16577, 65921, 262913 };
int N, A[1024000];
int main() {
	int N = readint();
	for(int i = 0; i < N; ++i) {
		A[i] = readint();
	}
	// https://oeis.org/A036562
	int sz = sizeof(g) / sizeof(int), lim = 1;
	while(lim < sz && g[lim] < N) ++lim;
	int cnt = 0;
	for(int i = lim - 1; i >= 0; --i) {
		for(int j = g[i]; j < N; ++j) {
			int pos = j, x = A[j];
			while(pos >= g[i] && A[pos - g[i]] > x) {
				A[pos] = A[pos - g[i]];
				pos -= g[i];
				++cnt;
			}
			A[pos] = x;
		}
	}
	writeint(lim, '\n');
	for(int i = lim - 1; i >= 0; --i) {
		writeint(g[i], (i != 0 ? ' ' : '\n'));
	}
	writeint(cnt, '\n');
	for(int i = 0; i < N; ++i) {
		writeint(A[i], '\n');
	}
	return 0;
}



Measured memory_bytes: 6476
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


ll n, k[300005], l[300005], mon = 0;
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k[i];
		l[i] = k[i];
	}

	sort(l, l + n);

	for (int i = 0; i < n; ++i) {
		if (k[i] == l[i]) { ++mon; }
	}

	if (mon == n) {
		cout << 0 << endl;
		return 0;
	}

	ll q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		ll a, b;
		cin >> a >> b;

		if (k[a - 1] == l[a - 1]) { --mon; }
		if (k[b - 1] == l[b - 1]) { --mon; }
		if (k[a - 1] == l[b - 1]) { ++mon; }
		if (k[b - 1] == l[a - 1]) { ++mon; }
		swap(k[a - 1], k[b - 1]);
		if (mon == n) { cout << i + 1 << endl; return 0; }
	}

	cout << -1 << endl;
}


Measured memory_bytes: 7832
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const uint64_t MOD = 1000000000 + 7;

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

	vector<int> l(n);
	for (int i = 0; i < n; i++)
	{
		cin >> l.at(i);
	}

	sort(l.begin(), l.end());

	int s = accumulate(l.begin(), l.end() - 1, 0);
	
	cout << (s > l.back() ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
int n , k , h , cnt;
int32_t main()
{
		cin >> n >> k;
		while(n --)
		{
				cin >> h;
				if(h >= k)
						cnt ++;
		}
		return cout << cnt << endl , 0;
}


Measured memory_bytes: 384
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)

	/* 1st line */
	stdin.Scan()
	text := stdin.Text()
	n, _ := strconv.Atoi(text)

	/* 2st line */
	stdin.Scan()
	text = stdin.Text()
	strs := strings.Split(text, " ")

	h, _ := strconv.Atoi(strs[0])
	ret := 1
	for i := 1; i < n; i++ {
		h2, _ := strconv.Atoi(strs[i])
		if h <= h2 {
			ret++
			h = h2
		}
	}
	fmt.Println(ret)
}


Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#define INF 1000000000
using namespace std;

int ned[5010],dis[5010],ans[5010];
set<int> ary[5010];
bool kaku[5010]={};

//????¢??????????????????¨???????????????
void ssm(int a,set<int> &s){
	stack<int> st,st2,*sti,*sto;
	set<int>::iterator it;
	set<int> ss;
	int tmp,l;
	l=dis[a];
	s.clear();
	st2.push(a);
	//cout<<"in ssm "<<a<<" "<<l<<endl;//
	for(int cnt=0;cnt<l;cnt++){
		if(cnt%2){
			sti=&st;
			sto=&st2;
		}
		else{
			sti=&st2;
			sto=&st;
		}
		while(!(*sto).empty())(*sto).pop();
		while(!(*sti).empty()){
			tmp=(*sti).top();
			(*sti).pop();
			it=ary[tmp].begin();
			while(it!=ary[tmp].end()){
				if(ss.find(*it)==ss.end()){
					(*sto).push(*it);
					ss.insert(*it);
					if(!kaku[*it])  s.insert(*it);
				}
				it++;
			}
		}
		/*//
		cout<<" "<<cnt<<":";
		it=s.begin();
		while(it!=s.end()){
			cout<<*it<<" ";
			it++;
		}
		cout<<endl;
		
		*///
	}
}

int main(){
	int N,K,hog,bak;
	pair<int,int> tm;
	set<int>::iterator it;
	set<int> tmp;
	priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > pq;//first?????¢second???
	cin>>N>>K;
	fill(ans,ans+N+1,INF);
	for(int i=1;i<=N;i++){
		cin>>ned[i]>>dis[i];
	}
	for(int i=0;i<K;i++){
		cin>>hog>>bak;
		ary[hog].insert(bak);
		ary[bak].insert(hog);
	}
	ans[1]=0;
	kaku[1]=true;
	pq.push(make_pair(ned[1],1));
	while(!pq.empty()){
		tm=pq.top();
		pq.pop();
		//cout<<tm.second<<"??????"<<endl;//
		ssm(tm.second,tmp);
		for(it=tmp.begin();it!=tmp.end();it++){
			ans[*it]=tm.first;
			pq.push(make_pair(ans[*it]+ned[*it],*it));
			kaku[*it]=true;
			//cout<<*it<<"?¢???? ?????¢???"<<ans[*it]<<" ";//
		}
		//cout<<endl;//
		
	}
	cout<<ans[N]<<endl;
	return 0;
}

Measured memory_bytes: 2852
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,h,ans=0;cin>>n>>h;
  lvector va(n,0),vb(n,0);rep(i,n) cin>>va[i]>>vb[i];
  sort(va.begin(),va.end()); sort(vb.begin(),vb.end());
  ll a=va[n-1],b=0,bpos=n-1;
  while(h>0) {
    b=vb[max(bpos,0ll)];
    if(a<b && bpos>-1) { h-=b; bpos--; ans++; }
    else { ans+=(h+a-1)/a; h=0; }
  }
  print(ans);
  return 0;
}

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

const string MARCH { "MARCH" };

int main() {
  int N; cin >> N;
  vector<int> c(5);
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    for (int j = 0; j < 5; j++) {
      if (MARCH[j] == s[0]) c[j]++;
    }
  }
  ll ans {};
  for (int i = 0; i < (1 << 5); i++) {
    ll sum {}, p { 1 };
    for (int j = 0; j < 5; j++) {
      if (i >> j & 1) {
        p *= c[j];
        sum++;
      }
    }
    ans += p * (sum == 3);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    ll x;
    cin >> x;
    ll a=100;
    ll ans;
    rep(i,inf){
        if (a>=x) {ans=i;break;}
        a+=a/100;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
sx,sy,tx,ty = map(int,input().split())
U,D,L,R = 'U','D','L','R'
dx,dy = tx-sx,ty-sy
ans = R*dx+U*dy + L*dx+D*(dy+1) + R*(dx+1)+U*(dy+1)+L +U+L*(dx+1)+D*(dy+1)+R
print(ans)

Measured memory_bytes: 9180
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1<<29;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m = MOD){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
inline int modinv(int a){return powerexp(a,MOD-2,MOD);}
inline int lcm(int a,int b){int g=__gcd(a,b);return a/g*b;}

//-------------------< start here >-------------------------// 
double calc(double n,double m,double d){
  double ret;
  if ( d == 0){
	   ret = 1.0000;
	   ret /= n;
	   ret *= (m - 1); 
	 }
  else{
	  ret = 2.000 * ( n - d);
	  ret /= (n*n); 
	  ret *= (m-1);
	 }
  return ret;
}

void solve(){
    double d, n, m;
    cout << fixed;
    cout << setprecision(10);
    cin >> n >> m >> d;
    double val = calc(n,m,d);
    cout << val << endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
   #endif
}


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

int main() {
	int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for(int i = 0; i < m; i++){
  	cin >> a.at(i);
  }
  for(int i = 0; i < m; i++){
  	//cout << a.at(i) << endl;
  }
  for(int i = 0; i < m; i++){
  	n -= a.at(i);
    //cout << n << endl;
  }
  if(n < 0){
  	cout << "-1" << endl;
  }
  else{ cout << n << endl;
}
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        for (int i = 1; ; i++) {
            int sum = (y + z) * i + z;
            if(x < sum) {
                System.out.println(i - 1);
                return;
            }
        }
    }
}

Measured memory_bytes: 35828
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

//===
template<class SemiGroup, class OP = function<SemiGroup(SemiGroup, SemiGroup)> >
struct SlidingWindow {
    using Stack = stack<SemiGroup>;
    const OP merge;
    Stack front_st, back_st;
    Stack front_sum, back_sum;
    size_t sz;

    SlidingWindow(const OP &f):merge(f) {
        sz = 0;
    };

    SemiGroup fold() {
        assert(sz > 0);
        
        if (front_sum.empty()) return back_sum.top();
        else if (back_sum.empty()) return front_sum.top();
        else return merge(front_sum.top(), back_sum.top());
    };

    void push(SemiGroup d) {
        sz++;
        back_st.push(d);
        if (back_sum.empty()) back_sum.push(d);
        else back_sum.push(merge(back_sum.top(), d));
    };

    void pop() {
        assert(sz > 0);

        sz--;
        if (front_st.empty()) {
            front_st.push(back_st.top());
            front_sum.push(back_st.top());
            back_st.pop();
            back_sum.pop();
            
            while (!back_st.empty()) {
                front_st.push(back_st.top());
                front_sum.push(merge(front_sum.top(), back_st.top()));
                back_st.pop();
                back_sum.pop();
            }
        }
        
        front_st.pop();
        front_sum.pop();
    };
    
    bool empty() {
        return sz == 0;
    };

    size_t size() {
        return sz;
    };
};
//===

llong n, s;
llong a[100005];
SlidingWindow<llong> sum([](auto l, auto r){return l + r;});

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

    llong ans = 1ll << 60ll;
    for (int i = 0; i < n; i++) {
        sum.push(a[i]);
        while (!sum.empty() && sum.fold() >= s) {
            ans = min<llong>(ans, sum.size());
            sum.pop();
        }
    }

    if (ans == (1ll << 60ll)) cout << 0 << endl;
    else cout << ans << endl;

    return 0;
}



Measured memory_bytes: 5204
#include <stdio.h>
int main(){
    int i,j,ch[1000000];

    for(i=0;i<1000000;i+=2){ch[i]=0;ch[i+1]=1;}

    ch[1]=0;
    ch[2]=1;

    for(i=3;i<1000;i+=2) if(ch[i]) for(j=i+i;j<1000000;j+=i) ch[j]=0;

    for(i=3;i<1000000;i++) ch[i]+=ch[i-1];

    while(scanf("%d",&i)!=EOF) printf("%d\n",ch[i]);

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    vector<LL> v(n);
    LL sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];

    }

    vector<LL> sdiv = Div(sum);
    vector<LL> p;
    LL res = 1;
    for(int i = 0; i < sdiv.size(); ++i) {
        p.clear();
        for(int j = 0; j < n; ++j) {
            p.pb(v[j] % sdiv[i]);

        }
        sort(all(p));

        for(int j = 0; j <= n; ++j) {
            LL a, b;
            a = b = 0;
            for(int l = 0; l < j; ++l) {
                a += p[l];

            }
            for(int l = j; l < n; ++l) {
                b += sdiv[i] - p[l];

            }
            if(a == b && a <= k) {
                res = max(res, sdiv[i]);

            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input);
    let mut nums = input.split_whitespace().map(|e| e.parse::<i32>().unwrap());
    let a = nums.next().unwrap();
    let b = nums.next().unwrap();

    let ans = match (a, b) {
        (a, b) if a < b => "a < b",
        (a, b) if a > b => "a > b",
        _ => "a == b",
    };
    println!("{}", ans);
}



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

int main() {
  long long W, H, x, y; cin >> W >> H >> x >> y;
  int pattern;
  if(x * 2 == W && y * 2 == H) pattern = 1;
  else pattern = 0;
  double ans = (double)(W*H) / 2.0;
  printf("%9lf %d\n", ans, pattern);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x{};
    int y{};
    int z{};
    int res{};
    cin >> x >> y >> z;
    for (int i=x;i<=y;i++)
    {
        if (z%i==0)
            res += 1;
    }
    cout << res << endl;
}


Measured memory_bytes: 3088
N=int(input())
d={}
for i in range(N):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
ds=sorted(d.items(),key=lambda x:-x[1])
buf=[]
f=0
for sn in ds:
    s=sn[0]
    n=sn[1]
    if f==0:
        buf.append(s)
        nb=n
        f=1
    else:
        if n!=nb:
            break
        buf.append(s)
buf.sort()
for i in buf:
    print(i)


Measured memory_bytes: 45788
//ûjÆµÄÍ_Pª¢ABCÌàÉ êÎ¢ABCÌÊÏÆ¢PAB,¢PBC,¢PCAÌÊÏÌaª¯¶ÉÈéÍ¸
#include<stdio.h>

int main(void){
	float x1,y1,x2,y2,x3,y3,xp,yp;
	//A(x1,y1) B(x2,y2) C(x3,y3) P(xp,yp)
	float s,s1,s2,s3;
	float data;
	
	while(scanf("%f %f %f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)==8){
		
		//¢ABCÌÊÏ
		data=(x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
		if(data<0)
			data=data*(-1);
		if(data==0){
			printf("NO\n");
			continue;
		}
		s=data/2;
		
		//¢PABÌÊÏ
		data=(x1-xp)*(y2-yp)-(x2-xp)*(y1-yp);
		if(data<0)
			data=data*(-1);
		if(data==0){
			printf("NO\n");
			continue;
		}
		s1=data/2;
		
		//¢PBCÌÊÏ
		data=(x2-xp)*(y3-yp)-(x3-xp)*(y2-yp);
		if(data<0)
			data=data*(-1);
		if(data==0){
			printf("NO\n");
			continue;
		}
		s2=data/2;
		
		//¢PCAÌÊÏ
		data=(x3-xp)*(y1-yp)-(x1-xp)*(y3-yp);
		if(data<0)
			data=data*(-1);
		if(data==0){
			printf("NO\n");
			continue;
		}
		s3=data/2;
		
		if(s==s1+s2+s3)
			printf("YES\n");
		else
			printf("NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}


#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int x;

int main(int argc, char **argv) {
    std::cin >> x;
    if (x < 1200) {
        std::cout << "ABC" << std::endl;
    } else {
        std::cout << "ARC" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
 
using vd=vector<double>;
using vvd=vector<vd>;
 
 
int main(){
    int h,w;
    cin>>h>>w;
    vvi f(h+2,vi(w+2,1));
    vvi walk(h+2,vi(w+2,0));
    int gy,gx,y=0,x=0,v=0;
    range(i,1,h+1)range(j,1,w+1){
        char c;
        cin>>c;
        switch(c){
            case 'G': gy=i,gx=j,f[i][j]=0; break;
            case '.': f[i][j]=0;break;
            case '#': break;
            case '^': y=i,x=j,v=0,f[i][j]=0; break;
            case '>': y=i,x=j,v=1,f[i][j]=0; break;
            case 'v': y=i,x=j,v=2,f[i][j]=0; break;
            case '<': y=i,x=j,v=3,f[i][j]=0; break;
        }
    }
    walk[y][x]=1;
    rep(loop,(2650+2700)/2){
        vvi vec={{-1,0},{0,1},{1,0},{0,-1}};
        if(f[y+vec[(v+1)%4][0]][x+vec[(v+1)%4][1]]==0){ //右手が道なら右に曲がって前に進む
            //cout<<"hoge";
            v=(v+1)%4;
            y+=vec[v][0], x+=vec[v][1];
            walk[y][x]=1;
        }else if(f[y+vec[v][0]][x+vec[v][1]]==1){ //（右が壁で、）正面が壁なら左に回る
            //cout<<"fuga";
            v=(v+3)%4;
        }else{ //そうでないならまえに進む
            //cout<<"zako";
            y+=vec[v][0],x+=vec[v][1];
            walk[y][x]=1;
        }
        if(y==gy&&x==gx){
            break;
        }
        // cout<<y<<","<<x<<","<<v<<endl;
        // rep(i,h+2){
        //     rep(j,w+2){
        //         if(i==y&&j==x){
        //             cout<<"^>v<"[v];
        //         }else{
        //             cout<<".#"[f[i][j]];
        //         }
        //     }
        //     cout<<endl;
        // }
    }
    if(y==gy&&x==gx){
        int ans=0;
        rep(i,h+2)rep(j,w+2)ans+=walk[i][j];
        cout<<ans<<endl;
    }else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    vector<bool> dp(X+200,false);
    vector<int> a = {100,101,102,103,104,105};

    dp[0] = true;

    rep(i,0,X+1) {
        if (!dp[i]) {
            continue;
        }
        rep(j,0,a.size()) {
            dp[i+a[j]] = true;
        }
    }

    cout << dp[X] << endl;

}





Measured memory_bytes: 384
// Date: 2020-03-22

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define D(x) cout<<#x<<" = "<<x<<endl;
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

bool isp(string s) {
    int n = SZ(s);
    rep(i, 0, n-1) if(s[i] != s[n-i-1]) return false;
    return true;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if(isp(s) && isp(s.substr(0, (n-1)/2)) && isp(s.substr((n+1)/2, n-(n+1)/2))) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//二項係数の計算
int nCr(int A, int B) {
    ll ans = 1;
    for (int i = 0; i < B; i++) {
        ans*= A - i;
    }
    for (int i = 0; i < B; i++) {
        ans /= i + 1;
    }
    return ans;
}
int main(){
    ld N,K;
    cin>>N>>K;
    vector<ld>P(N);
    rep(i,N){
        cin>>P[i];
        P[i]=(1+P[i])/2;
    }
    ld ans=0;
    ld a=0;
    rep(i,N-K+1){
        if(i==0){
            rep(i,K){
                a+=P[i];
            }
        }
        else{
            a=a-P[i-1]+P[i+K-1];
        }
        if(ans<a){
            ans=a;;
        }
    }
    cout<<setprecision(10)<<fixed<<ans<<endl;
}


Measured memory_bytes: 6468
#include <bits/stdc++.h>
using namespace std;
int main(){
	pair<int,int> box1[3],box2[3],box3[3];
	for (int i=0;i<3;i++) cin>>box1[i].first>>box2[i].first>>box3[i].first;
	int n;
	cin>>n;
	int box[11];
	for (int i=0;i<n;i++){
		cin>>box[i];
		for (int j=0;j<3;j++){
			if (box1[j].first==box[i]) box1[j].second=1;
			if (box2[j].first==box[i]) box2[j].second=1;
			if (box3[j].first==box[i]) box3[j].second=1;
		}
	}
	if (box1[0].second&&box1[1].second&&box1[2].second||
		box2[0].second&&box2[1].second&&box2[2].second||
		box3[0].second&&box3[1].second&&box3[2].second||
		box1[0].second&&box2[0].second&&box3[0].second||
		box1[1].second&&box2[1].second&&box3[1].second||
		box1[2].second&&box2[2].second&&box3[2].second||
		box1[0].second&&box2[1].second&&box3[2].second||
		box1[2].second&&box2[1].second&&box3[0].second){
			cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R cin>>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long unsigned int ll;
int main(){
    int n;
    scanf("%d", &n);
    ll a, b, pr;
    ll ans;
    rep(i, n){
        scanf("%d", &a);
        scanf("%d", &b);
        pr = a * b;
        ll t = sqrt(pr);
        if(t * (t+1) < pr){
            ans = t * 2 - 1;
        }
        else if(t * t == pr){
            if(a == b) ans = (t-1) * 2;
            else ans = (t-1) * 2 - 1;
        } else {
            ans = (t-1) * 2;
        }
        printf("%d\n", ans);
    }
    return 0;
}


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

#define lli long long int
#define pb push_back
#define in insert
#define pi pair<int, int>
#define pii pair<int, pi>
#define mp make_pair
#define fir first
#define sec second
#define MAXN 100001

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

  lli n;
  cin >> n;

  lli ans = 0;
  ans += (n / 500) * 1000;
  n = n % 500;
  ans += (n / 5) * 5;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

struct union_find {
    vector<ll> par;
    vector<ll> rank;
    vector<ll> count;

    union_find(ll n) : par(n, 0), rank(n, 0), count(n, 1) {
        for(ll i = 0; i < n; ++i){ par.at(i) = i; }
    }

    ll find(ll x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = find(par.at(x));
        }
    }

    void unite(ll x, ll y){
        x = find(x);
        y = find(y);
        if(x == y){ return; }
        if(rank.at(x) < rank.at(y)){
            par.at(x) = y;
        }else{
            par.at(y) = x;
            if(rank.at(x) == rank.at(y)){
                rank.at(x)++;
            }
        }

        ll new_count = count.at(x) + count.at(y);
        count.at(find(x)) = new_count;
    }

    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    ll get_count(ll x){
        return count.at(find(x));
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> links(m);
    for(int i = 0; i < m; ++i){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        links.at(i) = make_pair(a, b);
    }

    union_find uf(n);
    vector<ll> inconvs;
    inconvs.push_back(n * (n - 1) / 2);
    for(int i = m - 1; i > 0; --i){
        ll a = links.at(i).first;
        ll b = links.at(i).second;
        if(!uf.same(a, b)){
            ll c1 = uf.get_count(a);
            ll c2 = uf.get_count(b);
            inconvs.push_back(inconvs.back() - c1 * c2);
            uf.unite(a, b);
        }else{
            inconvs.push_back(inconvs.back());
        }
    }

    for(auto it = inconvs.rbegin(); it != inconvs.rend(); ++it){
        cout << *it << endl;
    }
    return 0;
}


Measured memory_bytes: 6132
// abc.73.C - Write and Erase

#include <bits/stdc++.h>
using namespace std;

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

    vector<int> a( n );
    for( int i = 0; i < n; i++ ) cin >> a.at( i );

	//昇順にソート
    sort( a.begin(), a.end() );

    int ptr=0;
    int ans;
    while( ptr < n ) {
        int num = a.at( ptr ), f = 0;
		//各数字ごとに数を数える
		while( ptr < n && a.at( ptr ) == num ){
            f++;		//同じ数字の個数
            ptr++;		//配列の添え字
		}
            ans += f % 2;	//奇数だったらインクリメント
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int a[22];
int b[22];
int c[22];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++){
        scanf("%d", a + i);
    }
    for (int i = 1; i <= n; i++){
        scanf("%d", b + i);
    }
    for (int i = 1; i <= n - 1; i++){
        scanf("%d", c + i);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        ans += b[a[i]];
        if (a[i - 1] + 1 == a[i])
            ans += c[a[i - 1]];
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
def solve(positions)
  ct, cx, cy = [0, 0, 0]
  positions.each do |position|
    t, x, y = position
    diff = (cx - x).abs + (cy - y).abs
    diff_t = t - ct
    if diff > diff_t
      return "No"
    elsif diff - diff_t == 0 || (diff - diff_t) % 2 == 0
      ct, cx, cy = position
    else
      return "No"
    end
  end
  return "Yes"
end

n = gets.strip.to_i
positions = []
n.times do
  positions.push(gets.strip.split.map(&:to_i))
end

puts solve(positions)


Measured memory_bytes: 9468
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	if (y >= 2 * x && y <= 4 * x && y % 2 == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int h, w;
        cin >> h >> w;
        vector<vector<int> > a(h, vector<int>(w));
        rep(i,h){
                rep(j,w) {
                        cin >> a[i][j];
                }
        }



        int res = 0;

        vector<vector<int> > ans;
        int i=0, j=0;


        while (true) {
                if (((h%2==1) && (i==h-1) && (j==w-1)) || ((h%2==0) && (i==h-1) && (j==0))) break;
                else if (((j==0) && (i%2==1)) || ((j==w-1) && (i%2==0))) {
                        if (a[i][j]%2==1) {
                                res++;
                                a[i+1][j]++;
                                ans.push_back({i+1,j+1,i+2,j+1});
                        }
                        i++;
                }else if (i%2==0) {
                        if (a[i][j]%2==1) {
                                res++;
                                a[i][j+1]++;
                                ans.push_back({i+1,j+1,i+1,j+2});
                        }
                        j++;
                }else if (i%2==1) {
                        if (a[i][j]%2==1) {
                                res++;
                                a[i][j-1]++;
                                ans.push_back({i+1,j+1,i+1,j});
                        }
                        j--;
                }
        }


        cout << res << endl;
        rep(k,res) {
                cout << ans[k][0] << ' ' << ans[k][1] << ' ' << ans[k][2] << ' ' << ans[k][3] << endl;
        }
}


Measured memory_bytes: 10032
#include <iostream>
#include <stdio.h>

using namespace std;

char mmap[105][105];
int dire[4][2] = {0,1,0,-1,1,0,-1,0};
int x,y;
int count;
char sign;

void dfs(int h,int l){
    mmap[h][l] = '.';

    for(int i = 0; i < 4; i++){
        int xx = h + dire[i][0];
        int yy = l + dire[i][1];

        if(mmap[xx][yy] == sign && xx >= 1 && yy >= 1 && xx <= x && yy <= y){
            dfs(xx,yy);
        }
    }
}

void solve(){
    for(int i = 1; i <= x; i++){
        for(int j = 1; j <= y; j++){
            if(mmap[i][j] != '.'){
                sign = mmap[i][j];
                dfs(i,j);
                count++;
            }
        }
    }

    cout << count << endl; 
}

int main(void){
    while(~scanf("%d %d",&x,&y)){
        if(x == 0 && y == 0){
            break;
        }

        count = 0;

        for(int i = 1; i <= x; i++){
            getchar();
            for(int j = 1; j<= y; j++){
                scanf("%c",&mmap[i][j]);
            }
        }

        solve();
    }
}


Measured memory_bytes: 3464
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

ll a[60];

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

    ll l = 0, r = LONG_LONG_MAX;
    while(r - l > 1){
        ll m = (l + r) / 2;
        ll x = 0;
        for(int i = 0; i < N; i++){
            x += (a[i] + m + 1) / (N + 1);
        }
        if(x < m){
            r = m;
        }
        else{
            l = m;
        }
    }

    ll res = 0;
    for(ll x = max(0LL, l-2500); x <= l; x++){
        ll y = 0;
        for(int i = 0; i < N; i++){
            y += (a[i] + x + 1) / (N + 1);
        }
        if(y <= x){
            res = x;
            break;
        }
    }

    cout << res << endl;


    return 0;
}



Measured memory_bytes: 256
<?php
  
fscanf(STDIN,"%d",$n);

$before_x = 0;
$before_y = 0;
$before_t = 0;
for($i=0;$i<$n;$i++){
  fscanf(STDIN,"%d%d%d",$t,$x,$y);
  $dis = abs($x-$before_x)+abs($y-$before_y);
  $count = $t-$before_t;
  if($dis>$count || abs($dis-$count)%2==1){
    echo "No\n";
    exit;
  }
  $before_x = $x;
  $before_y = $y;
  $before_t = $t;
}

echo "Yes\n";


Measured memory_bytes: 4604