akhauriyash/Code-Regression huggingface dataset:
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    a = list(map(int, input().split()))

    cumulative = 0
    count1 = 0
    for i in range(len(a)):
        cumulative += a[i]
        if i % 2 == 0: # positive
            if cumulative <= 0:
                count1 += abs(cumulative) + 1
                cumulative += (abs(cumulative) + 1)
        else:  # negative
            if cumulative >= 0:
                count1 += abs(cumulative) + 1
                cumulative -= (abs(cumulative) + 1)
        # print('count = {} c = {}'.format(count, cumulative))

    cumulative = 0
    count2 = 0
    for i in range(len(a)):
        cumulative += a[i]
        if i % 2 == 0: # negative
            if cumulative >= 0:
                count2 += abs(cumulative) + 1
                cumulative -= (abs(cumulative) + 1)
        else:  # positive
            if cumulative <= 0:
                count2 += abs(cumulative) + 1
                cumulative += (abs(cumulative) + 1)
        # print('count = {} c = {}'.format(count, cumulative))

    print(min(count1, count2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63216
n=int(input())
S=input()
ans=0
for i in range(10):
    if str(i) in S:
        T=S[S.index(str(i))+1:]
        for j in range(10):
            if str(j) in T:
                U=T[T.index(str(j))+1:]
                for k in range(10):
                    if str(k) in U:
                        ans+=1
print(ans)

Measured memory_bytes: 3188
#include<iostream>

//using namespace std;

int main(){
  int a,b;
  std::cin >> a >> b;
  if (a == b){
    std::cout << 2*a << std::endl;
  }else{
    int maxval;
    if (a > b){
     maxval = a;
    }else{
     maxval = b;
    }
    std::cout << 2*maxval - 1 << std::endl; 
  }
  return 0;
}

Measured memory_bytes: 256
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc171_b.cpp"

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

  int n, k;
  cin >> n >> k;
  vi a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));

  int ans = 0;
  REP(i, k) { ans += a[i]; }
  cout << ans << endl;
}


Measured memory_bytes: 3660
import java.util.Scanner;
class Main{
    public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.nextLine();
    String T = scan.nextLine();

    int ans = 0;
    for(int i = 0; i < S.length(); i++){
      if(S.charAt(i) == T.charAt(i)){
        ans++;
      }
    }
    System.out.println(ans);
  }
}

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

 bool cards[4][13];

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

  string suit = "SHCD";
  for(int i=0; i<n; i++){
    char M; cin >> M;
    int R; cin >> R;
    cards[suit.find(M)][R-1] = 1;
  }
  for(int i=0; i<4; i++){
    for(int j=0; j<13; j++){
      if(cards[i][j] == 0){
        cout << suit[i] << " " << j+1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset> 
using namespace std;
typedef long long ll;
ll s[200005];
ll a[200005];
ll mo1[200005]={0};
ll mo2[200005]={0};
ll m1=0,m2=0;
ll n;
ll ff(ll n)
{
	ll cnt=0;
	while(n>0)
	{
		if(n%2==1) cnt++;
		n/=2;
	}
	return cnt;
}
int main(void)
{
	scanf("%lld",&n);
	for(ll i=0;i<n;i++)
	{
		char ch;
		scanf(" %c",&ch);
		if(ch=='1') s[n-i-1]=1,m1++;
		else s[n-i-1]=0;
	}
	if(m1<=1)
	{
		if(m1==1)
		{
			for(ll i=n-1;i>=0;i--)
			{
				if(s[i]==1)
				{
					printf("0\n");
				}
				else
				{
					if(i==0)
					{
						printf("%lld\n",2);
					}
					else
					{
						printf("%lld\n",1);
					}
				}
			}
		}
		else
		{
			for(ll i=0;i<n;i++)
			{
				printf("1\n");
			}
		}
		return 0;
	}
	m1--;
	m2=m1+2;
	a[0]=0;
	for(ll i=1;i<=200000;i++)
	{
		a[i]=i%ff(i);
	}
	for(ll i=1;i<=200000;i++)
	{
		a[i]=a[a[i]]+1;
	}
	mo1[0]=mo2[0]=1;
	for(ll i=1;i<=200000;i++)
	{
		mo1[i]=mo1[i-1]*2%m1;
		mo2[i]=mo2[i-1]*2%m2;
	}
	ll go1=0,go2=0;
	for(ll i=0;i<n;i++)
	{
		go1+=mo1[i]*s[i]%m1;
		go2+=mo2[i]*s[i]%m2;
	}
	go1%=m1;
	go2%=m2;
	for(ll i=n-1;i>=0;i--)
	{
		ll ans;
		if(s[i]==1)
		{
			ans=(go1-mo1[i]+m1*1000)%m1;
		}
		else
		{
			ans=(go2+mo2[i]+m2*1000)%m2;
		}
		printf("%lld\n",a[ans]+1);
	}
}

Measured memory_bytes: 10016
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <map>

using namespace std;
typedef long long int lint;

lint solve(priority_queue<lint, vector<lint>, greater<lint> > &q)
{
	lint ret, sum;

	ret = 0; sum = 0;
	while (q.size() != 1){
		sum += q.top();
		ret += sum;
		q.pop();
	}
	return ret;
}

int main()
{
	
	lint n;
	while (true){
		cin >> n;
		if (n == 0) break;
		priority_queue<lint, vector<lint>, greater<lint> > q;
		int buf;
		for (lint i = 0; i < n; i++){
			cin >> buf;
			q.push(buf);
		}

		cout << solve(q) << endl;
	}

	return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcd(long long a,long long b){return a*b / gcd(a,b) / gcd(a,b);}
int main()
{
	int N;
	cin>>N;
	while(N!=0)
	{
		if(N%10==7)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		N/=10;
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
 
    
    
int main(){
     
  long int n,a,b,s,t;
  cin>>n>>a>>b;

  if ((a-b)%2==0)
  {
    cout<<(b-a)/2<<endl;
  }
  
  else
  {
    s=a-1+(b-a+1)/2;
    t=n-b+(b-a+1)/2;
    cout<<min(s,t)<<endl;
  }
  
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextIntArray()

	c := 1
	for i := 0; i < N; i++ {
		if c == A[i] {
			c++
		}
	}
	if c == 1 {
		fmt.Println(-1)
	} else {
		fmt.Println(N - c + 1)
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	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) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

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: 10752
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

static const unordered_map<std::string, std::string> weather = {
  { "Sunny", "Cloudy" },
  { "Cloudy", "Rainy" },
  { "Rainy", "Sunny" }
};

auto main() -> int {

  string input;
  cin >> input;
  
  cout << weather.at(input);
  
  return 0;
}


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

string s;
int main()
{
	cin>>s;
	int len=s.size();
	char opt;
	bool flag=1;
	for (int i=0;i<len;i++)
	{
		if ((i+1)&1) opt='R';
		else opt='L';
		if (s[i]!=opt&&s[i]!='U'&&s[i]!='D')
		{
			flag=0;
			break;
		}
	}
	if (!flag) printf("No\n");
	else printf("Yes\n");
	return 0;
}

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

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= s * t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int a[55] = {};
    rep(i,m){
        int ta,tb;
        cin >> ta >> tb;
        a[ta]++;
        a[tb]++;
    }
    REP(i,1,n+1) cout << a[i] << endl;

    return 0;
}


Measured memory_bytes: 256
# A
from collections import Counter
S = list(input())
count = Counter(S)
flag = True

if count['N'] > 0:
  if count['S'] == 0:
    flag = False
if count['S'] > 0:
  if count['N'] == 0:
    flag = False
if count['E'] > 0:
  if count['W'] == 0:
    flag = False
if count['W'] > 0:
  if count['E'] == 0:
    flag = False
print("Yes") if flag == True else print("No")

Measured memory_bytes: 9332
n = input().split()
N,K = int(n[0]),int(n[1])
S = list(input())

count = 0
count_s1 = 0
count_sn = 0
s_1 = S[0]
if s_1 == "L":
    count_s1 += 1
s_N = S[-1]
if s_N == "R":
    count_sn += 1

for i in range(len(S)-1):
    if S[i] == "R" and S[i+1] == "L":
        count += 1

if K <= count:
    print(N - ((count-K)*2 + count_s1 + count_sn))
else:
    print(N-1) 



Measured memory_bytes: 4084
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
using namespace std;

#define Getsign(n) ((n > 0) - (n < 0))

typedef vector<int> Ivec;
typedef pair<int, int> Pos;

int main() {
	int n,m,p;
	
	while (scanf("%d %d %d", &n, &m, &p)) {
		if (!n)
			return 0;

		int hitter = 0, sum = 0;
		for (int i = 0; n > i; i++) {
			int a;
			scanf("%d", &a);
			if (i + 1 == m) hitter = a;
			sum += 100 * a;
		}
		if (!hitter)printf("0\n");
		else printf("%d\n", (int)(sum/100*(100-p) / hitter));
	}




	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int dp[2][200001] = {};

int main() {
	string s;
	cin>>s;
	int n = s.size();
	char c = '\n';
	for(int i = 0; i < n; i++) {
		if(c!=s[i]) {
			dp[0][i+1] = max(dp[0][i],dp[1][i])+1;
		}
		else dp[0][i+1] = dp[1][i]+1;
		if(i>0) {
			dp[1][i+1] = max(dp[1][i+1],max(dp[0][i-1],dp[1][i-1])+1);
		}
		c = s[i];
		//cout << dp[0][i+1] << "," << dp[1][i+1] << endl;
	}
	cout << max(dp[0][n],dp[1][n]) << endl;
}


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;


int main(void){
    int n;
    cin >> n;
    int mon = 100000;
    rep(unused, n){
        mon += mon/20;
        if(mon % 1000) mon -= (mon % 1000) - 1000;
    }
    cout << mon << endl;
    return 0;
}

Measured memory_bytes: 1160
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")


count = 0

for i in range(n):
	for j in range(i+1,n):
		k = j*2-i
		if 0 <= k < n:
			if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
				count += 1
print(r*g*b - count)




Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

//a

int main() {
    int N,X,T;
    cin>>N>>X>>T;
    int ans=0;
    while(N>0){
        ans+=T;
        N-=X;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	int r,g,b,n;
	cin >> r >> g >> b >>n;
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			int x=n-i*r-j*g;
			if(x>=0&&x%b==0) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
    int N, T;
    std::cin >> N >> T;
    int c[N], t[N];
    for(int i = 0; i < N; ++i){
        int c_buf, t_buf;
        std::cin >> c_buf >> t_buf;
        c[i] = c_buf;
        t[i] = t_buf;
    }

    int t_pref[N];
    int count = 0;
    for(int i = 0; i < N; ++i){
        if(t[i] <= T){
            t_pref[count] = i;
            ++count;
        }
    }

    int min_cost = 1001;
    for(int i = 0; i < count; ++i){
        int t_number = t_pref[i];
        if(min_cost > c[t_number])
        min_cost = c[t_number];
    }

    if(min_cost == 1001){
        std::cout << "TLE" << std::endl;
        return 0;
    }

    std::cout << min_cost << std::endl;
    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;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) "FUCK YOU"
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);
template<typename A> ostream& operator<<(ostream&,vector<A>&);

const int N=500006;

void solve(){
	int n,k;
	cin>>n>>k;
	if(k>1)
	cout<<(n-(k));
	else cout<<0;
}
	
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}


}

int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}

int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


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

int main(){
	int n;
	cin >> n;
	for(; n--; ){
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double d = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));

		if(d+rb < ra) cout << 2 << endl;
		else if(d+rb == ra) cout << 1 << endl;
		else if(d+ra < rb) cout << -2 << endl;
		else if(d+ra == rb) cout << 1 << endl;
		else if(d <= ra+rb) cout << 1 << endl;
		else cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int a = n % 10;
		
		if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
			System.out.println("hon");
		}else if(a == 0 || a == 1 || a == 6 || a == 8) {
			System.out.println("pon");
		}else {
			System.out.println("bon");
		}
		
		
	}

}


Measured memory_bytes: 35792
#include <cmath>
#include <cassert>
#include <vector>
#include <iostream>
using namespace std;

vector<long long> factor(long long n) {
    vector<long long> fs;
    for (long long p = 2; p * p <= n; p++) {
        if (n % p == 0) {
            long long q = 1;
            while (n % p == 0) { n /= p; q *= p; }
            fs.emplace_back(q);
        }
    }
    if (n > 1) fs.emplace_back(n);
    return fs;
}

long long extgcd(long long a, long long b, long long& x, long long& y) {
    if (b == 0) { x = 1; y = 0; return a; }
    else {
        long long g = extgcd(b, a%b, y, x);
        y -= a / b * x;
        return g;
    }
}

int main() {
    long long n; cin >> n;
    vector<long long> fs = factor(2*n);
    const int m = fs.size();
    long long ans = 2*n - 1;
    for (int s = 1; s < (1<<m) - 1; s++) {
        long long a = 1, b = 1;
        for (int i = 0; i < m; i++) {
            if ((s >> i) & 1) a *= fs[i];
            else b *= fs[i];
        }
        long long x, y;
        assert(extgcd(a, b, x, y) == 1);
        ans = min(ans, min(abs(a * x), abs(b * y)));
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> p(N);
  for (int i = 0; i < N; i++) {
    string s;
    int r;
    cin >> s >> r;
    p.at(i) = make_tuple(s, -r, i+1);
  }
  
  sort(p.begin(), p.end());
  
  for (tuple<string, int, int> t : p) {
    string s;
    int u, v;
    tie(s, u, v) = t;
    cout << v << endl;
  }
}

Measured memory_bytes: 3588
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;


class Main {

	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Integer> x = new ArrayList<Integer>();
        ArrayList<Integer> y = new ArrayList<Integer>();
         
        int H,W;
         
        while(true){
            H = sc.nextInt();
            W = sc.nextInt();
             
            if(H == 0 && W == 0)
                break;
             
            x.add(H);
            y.add(W);
             
        }
        
        int countH = 0;
        int countW = 0;

        for(countH = 0; countH < x.size(); countH++){
        	
        	for(int i = 0; i < x.get(countH); i++)
            {
            	for(int t = 0; t < y.get(countW); t++)
            	{
            		if(t < y.get(countW) -1)
            		{
            			System.out.print("#");
            		}
            		else if(t == y.get(countW) -1)
            		{
            			System.out.println("#");
            		}
            	}
            }
        	
        	System.out.println("");
        	countW++;
        }

		
		
		
	}

}

Measured memory_bytes: 33312
using System;
using System.Collections.Generic;

namespace abc169_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var A = CIn.ReadLong();
      var B = CIn.ReadDecimal();

      Console.WriteLine(Math.Floor(A * B));
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static decimal ReadDecimal() => decimal.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 27928
#include <stdio.h>

int main(){
	int money = 100000;
	int n;

	scanf("%d", &n);
	for(int i=0 ; i<n ; i++){
		money *= 1.05;
		if(money%1000 != 0){
			money += 1000 - (money%1000);
		}
	}
	printf("%d\n", money);

	return 0;
} 

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	pair<long long,long long>ar[a];
	for(int i=0;i<a;i++){
		cin>>ar[i].first>>ar[i].second;
	}
	sort(ar,ar+a);
	long long sum=0;
	for(int i=0;b>0;i++){
		if(b>=ar[i].second){
			sum+=ar[i].second*ar[i].first;
			b-=ar[i].second;
		}
		else{
			sum+=b*ar[i].first;
			b-=b;
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,ans;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s>>a;
    rep(i,Size(s)){
        if(i%a==0)ans+=s[i];
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, sum, ans, a[3][3];
struct Edge { Pll to; LL cost; };
bool f=1;
vector<Edge>vec[100][100];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	rep(i, 3)rep(j, 3)cin >> a[i][j];
	LL A[2];
	rep(i, 3) {
		rep(j, 2) {
			if (i >= 1)
				if (A[j] != a[i][j] - a[i][j + 1])
					f = 0;
			A[j] = a[i][j] - a[i][j + 1];
		}
	}
	rep(i, 3) {
		rep(j, 2) {
			if (i >= 1)
				if (A[j] != a[j][i] - a[j + 1][i])
					f = 0;
			A[j] = a[j][i] - a[j + 1][i];
		}
	}
	yn(f);
	return 0;
}

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

typedef long long ll;

// a = 5 k = 3 -> a = 2 k = 0
// a = 5 b = 1 k = 8 -> a = 0 k = 3

int main() {

    ll a, b, k;
    cin >> a >> b >> k;

    ll tmp = min(a, k);
    a -= tmp;
    k -= tmp;

    b -= k;
    b = max(0LL, b);

    cout << a << " " << b;


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
struct node
{
	int to;
	node *next;
}edge[MAXN*2+5];
node *ncnt=&edge[0],*Adj[MAXN+5];
int d[MAXN+5],root=MAXN+5,dp[MAXN+5];
bool vis[MAXN+5];
int n;
void AddEdge(int u,int v)
{
	node *p=++ncnt;
	p->to=v;
	p->next=Adj[u];
	Adj[u]=p;
	
	node *q=++ncnt;
	q->to=u;
	q->next=Adj[v];
	Adj[v]=q;
}
void dfs(int u)
{
	vis[u]=true;
	int chnum=0,nothave=0;
	for(node *p=Adj[u];p!=NULL;p=p->next)
	{
		int v=p->to;
		if(vis[v]==false)
		{
			chnum++;
			dfs(v);
			dp[u]+=dp[v];
			if(dp[v]==0)
				nothave++;
		}
	}
	if(nothave>=2)
		dp[u]+=nothave-1;
}
int main()
{
	scanf("%d",&n);
	int x,y;
	for(int i=1;i<n;i++)
	{
		scanf("%d %d",&x,&y);
		AddEdge(x,y);
		d[x]++,d[y]++;
	}
	for(int i=0;i<n;i++)
	{
		if(d[i]>=3)
		{
			root=i;
			break;
		}
	}
	if(root>MAXN)
	{
		printf("1\n");
		return 0;
	}
	dfs(root);
	printf("%d\n",dp[root]);
}

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

struct Point {
    int t;
    int x;
    int y;
};

int main() {
    uint N;
    cin >> N;

    vector<Point> v(N+1);
    v[0].t = v[0].x = v[0].y = 0;
    for (size_t i=1; i<v.size(); ++i) {
        cin >> v[i].t >> v[i].x >> v[i].y;
    }

    for (size_t i=1; i<v.size(); ++i) {

        int dx = abs(v[i].x - v[i-1].x);
        int dy = abs(v[i].y - v[i-1].y);
        int dt = v[i].t - v[i-1].t;
        int dtMin = dx + dy;
        if (dtMin > dt) {
            // 最短でもdtMinかかる. これ以上短くできないからNG
            cout << "No" << endl;
            return 0;
        }
        else if (dtMin == dt) {
            continue;  // ok
        }
        else {
            if((dt - dtMin) % 2 == 0) {
                continue;
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

int main(){

	int n,m;
	string str;
	while(cin >> n && n != 0){
		cin >> m;
		cin >> str;

		// 2:ツづ慊つソツづ按つオ,1:Iツづ慊つソ,0:oツづ慊つソ
		int state = 0;
		int cnt = 0;
		int sum = 0;
		for(int i = 0; i < str.size(); i++){
			if(state == 2 && str[i] == 'I'){
				state = 0;
			}
			else if(state == 1 && str[i] == 'I'){
				state = 0;
				if(cnt == n){
					sum++;
					cnt--;
				}
			}
			else if(state == 0 && str[i] == 'O'){
				cnt++;
				state = 1;
			}
			else{
				if(str[i] == 'I'){
					cnt = 0;
					state = 0;
				}
				else{
					state = 2;
					cnt = 0;
				}
			}
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1952
N = int(input())
ans = 0

def dfs(i):
    global ans
    if int(i) > N:
        return
    if all(i.count(c) for c in '753'):
        ans += 1
    dfs(i + '3')
    dfs(i + '5')
    dfs(i + '7')
    
dfs('0')

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define mod 1000000007
int main() 
{
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll cnt1,cnt2;
   if(c%b!=0)
    cnt1 = c/b +1;
   else
    cnt1 = c/b;
   if(a%d!=0)
      cnt2 = a/d +1;
   else
    cnt2 = a/d;
  if(cnt1<=cnt2)
    cout<<"Yes";
else
    cout<<"No";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REPi(n) for(int i=0;i<n;i++)
#define REPj(n) for(int j=0;j<n;j++)

using namespace std;

int main(){
    string n,ans;
    cin >> n ;
    ans="Yes";
    if(n=="AAA"||n=="BBB"){
        ans="No";
    }

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

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

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int Q; cin >> Q;
  priority_queue<long long, vector<long long>, less<long long>> lows;
  priority_queue<long long, vector<long long>, greater<long long>> highs;
  long long curValue = 0;
  for (int q = 0; q < Q; q++) {
    int t; cin >> t;
    if (t == 1) {
      long long a, b; cin >> a >> b;
      curValue += b;
      assert(lows.size() == highs.size() || lows.size() == highs.size() + 1);
      if (lows.empty()) {
        lows.push(a);
      } else {
        curValue += abs(lows.top() - a);
        if (a >= lows.top()) {
          highs.push(a);
          if (highs.size() == lows.size() + 1) {
            curValue -= highs.top() - lows.top();
            lows.push(highs.top());
            highs.pop();
          }
        } else {
          lows.push(a);
          if (lows.size() == highs.size() + 2) {
            highs.push(lows.top());
            lows.pop();
          }
        }
      }
    } else if (t == 2) {
      cout << lows.top() << ' ' << curValue << '\n';
    } else assert(false);
  }
}

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

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

  if(n == 1){
    cout << "Hello World" <<endl;
  }
  if(n == 2){
    int a, b;
    cin >> a >> b;
    cout << a + b <<endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        StringBuffer sb = new StringBuffer(sc.next());
        sc.nextLine();
        
        int n = sc.nextInt();
        sc.nextLine();
        
        for(int i=0;i<n;i++){
            String op = sc.next();
            int a = sc.nextInt();
            int b = sc.nextInt();
            switch (op){
                case "replace":
                    String p = sc.next();
                    sb.replace(a, b+1, p);
                    break;
                    
                case "print":
                    System.out.println(sb.substring(a, b+1));
                    break;
                    
                case "reverse":
                    StringBuffer r = new StringBuffer(sb.substring(a, b+1));
                    r.reverse();
                    sb.replace(a, b+1, r.toString());
                    break;
            }
            sc.nextLine();
        }
    }
}


Measured memory_bytes: 29060
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>
#include <memory>
#include <climits>
#include <iomanip>

constexpr long long MOD = 1000000007;

int main()
{
  int N, M;
  std::cin >> N >> M;
  std::vector<long long> A(N);
  for (auto& a: A)
    std::cin >> a;
  std::sort(A.begin(), A.end());
  std::vector<std::pair<long long, long long>> CB(M);
  for (auto& cb: CB)
    std::cin >> cb.second >> cb.first;
  std::sort(CB.begin(), CB.end(), std::greater<std::pair<long long, long long>>{});
  long long ans = 0;
  int i = 0;
  for (auto& cb: CB)
  {
    auto C = cb.first;
    auto B = cb.second;
    while (i < A.size() && A[i] < C && B)
    {
      ans += C;
      --B;
      ++i;
    }
    if (A.size() <= i)
      break;
  }
  while (i < A.size())
    ans += A[i++];
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    int x, y,ans;
    cin >> x >> y;

    if(x < y){
        if(x>=0&&y>0) ans = y - x;
        else if(x<0&&y>0){
            if(abs(x) <= abs(y)) ans = 1 + y + x;
            else ans = -1 * y - x + 1;
        }else {
            ans = y - x;
        }
    }else{
        if(x>0&&y>0) ans = 2 + -1*y + x;
        else if(x==0){
            ans = 1 + -1 * y;
        }else if(y==0) {
            ans = 1 + x;
        }else if(x>0&&y<0){
                if(abs(x) >= abs(y)) ans = 1 + y + x;
                else ans = -1 * y - x + 1;
        }else {
            ans = -1 * y + x + 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
/*int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];*/
using namespace std;
int main() {
	string a; cin >> a;
	a[0] = '2';
	a[1] = '0';
	a[2] = '1';
	a[3] = '8';
	cout << a << endl;
	return 0;
}


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

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

    std::cin >> n;
    std::vector<int> a(n, 0);
    for (int i = 0; i < n; i++)
        std::cin >> a[i];
    std::sort(a.begin(), a.end());
    int i;
    for (i = 0; i < n - 1; i++)
        if (a[i] == a[i + 1])
            break;
    std::cout << (i == n - 1 ? "YES" : "NO") << std::endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main (void){
    double R;
    cin >> R;
    cout << M_PI * 2 * R << endl;
}


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

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

	int counte = 0;
	int counto = 0;
	for (int i = 0;i < n;i++) {
		if (a[i] % 2 == 0) {
			counte++;
		}
		else {
			counto++;
		}
	}
	if (counto % 2 != 0 && (counte + counto / 2) % 2 != 0) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}

	return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

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

    var(int, N);
    vector<string> a(N);
    read(a);

    set<string> st;
    st.insert(a.front());
    bool ok = true;
    rep(i, 1, N) {
        ok &= (!st.count(a[i]) && a[i].front() == a[i-1].back());
        st.insert(a[i]);
    }

    print((ok) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
// 23:40

#include <iostream>

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

struct Node {
  int value;
  Node *prev;
  Node *next;
};

Node *root;

void insertNode(int key) {
  Node *node = new Node{key, root, root->next};
  root->next->prev = node;
  root->next = node;
}

Node *searchNode(int key, Node *node) {
  Node *t = node->next;
  if (t == root)
    return nullptr;

  if (t->value == key)
    return t;

  return searchNode(key, t);
}

void deleteNode(int key) {
  Node *node = searchNode(key, root);
  if (node == nullptr)
    return;

  node->prev->next = node->next;
  node->next->prev = node->prev;

  delete node;
}

void deleteFirst() {
  Node *t = root->next;
  t->next->prev = root;
  root->next = t->next;

  delete t;
}

void deleteLast() {
  Node *t = root->prev;
  t->prev->next = root;
  t->next->prev = t->prev;

  delete t;
}

void printList(Node *node) {
  Node *t = node->next;

  if (t == root) {
    return;
  }

  std::cout << t->value;
  if (t->next == root) {
    std::cout << '\n';
  } else {
    std::cout << ' ';
    printList(t);
  }
}

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

  root = new Node();
  root->value = 0;
  root->prev = root;
  root->next = root;

  std::string com;
  int key;

  rep(i, n) {
    std::cin >> com;
    if (com == "insert") {
      std::cin >> key;
      insertNode(key);
    } else if (com == "delete") {
      std::cin >> key;
      deleteNode(key);
    } else if (com == "deleteFirst") {
      deleteFirst();
    } else if (com == "deleteLast") {
      deleteLast();
    }
  }

  printList(root);

  return 0;
}


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

using namespace std;

int main()
{
        string s,t;
        int k=0,i;
        cin>>s>>t;
        for(i=0;i<3;i++)
        {
                if(s[i]==t[i])
                        k++;
        }
        cout<<k<<endl;
        return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int n,maxn=0;
string s;
map<string,int>mp;
vector<string>v;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		mp[s]++;
		if(mp[s]>maxn)maxn=mp[s],v.clear(),v.push_back(s);
		else if(mp[s]==maxn)v.push_back(s);
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++)cout<<v[i]<<endl;
	return 0;
}


Measured memory_bytes: 26736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
int mod = 1e9 + 7;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	unordered_map<char, int> cur, prev, ans;
	string s;
	cin >> s;
	for (int j = 0; j < (int) s.size(); j++) {
		prev[s[j]]++;
	}
	for (int i = 1; i < n; i++) {
		cin >> s;
		for (int j = 0; j < (int) s.size(); j++) {
			cur[s[j]]++;
		}
		for (int j = 0; j < (int) s.size(); j++) {
			if (prev[s[j]] != 0){
				ans[s[j]] = min (prev[s[j]] , cur[s[j]]);
			}
		}
		prev = ans;
		cur.clear();
		ans.clear();
	}
	string sans;
	for (auto i : prev) {
		if (i.second != 0) {
			for (int j = 0 ; j < i.second ; j++) sans += i.first;
		}
	}
	sort(sans .begin() , sans.end());
	cout << sans << endl;
}



Measured memory_bytes: 3660
#include<stdio.h>
int main(){

    long long int n,r,a,b,x,y,m;
   while( scanf("%lld%lld",&x,&y)==2){
    a=x;
    b=y;
    while(b!=0){
        r=a%b;
        a=b;
        b=r;
    }
    n=a;
    m=((x*y)/n);
    printf("%lld\n",m);}
    return 0;

}


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

int timeSerialDiff (vector<int> &v){
    int size = v.size();
    if(size < 2){
        return 0;
    }
    int i, max, min, cnt = 0;
    min = v[0];
    max = v[1] - v[0];
    for(i = 1; i < size; i++){
        int diff = v[i] - min;
        max = max < diff ? diff : max;
        min = min > v[i] ? v[i] : min;
    }
    return max;
}
int main(){
    int n, i, x, min, max;
    vector<int> v;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> x;
        v.push_back(x);
    }
    cout << timeSerialDiff(v) << endl;
    return 0;
}

Measured memory_bytes: 2064
import java.util.Scanner;
             
            public class Main { //クラス名はMain
                public static void main(String[] args) {
                    //コード
                  Scanner sc = new Scanner(System.in);
                  int n1 = sc.nextInt();
                  int kane = 0;
                  
                  loop: for(int i=1;i<=n1;i++) {
                  kane = (int)(i * 1.08);
                    //等価判定
       				if (n1 == kane) {
              				System.out.println(i);
                      return;
                    }
                }
                  System.out.println(":(");
            }
            }

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
using namespace std;
typedef long long ll;

int na,nb,nc,n;
ll r;
pair<ll,pair<ll,ll> > x[100005];
ll w0[100005],w1[100005];
priority_queue<ll> q;

int main(){
	scanf("%d%d%d",&na,&nb,&nc);n=na+nb+nc;
	fore(i,0,n){
		ll a,b,c;
		scanf("%lld%lld%lld",&a,&b,&c);
		a-=c;b-=c;r+=c;
		x[i]=mp(a-b,mp(a,b));
	}
	sort(x,x+n);
	ll s=0;
	fore(i,0,nb)s+=x[i].snd.snd,q.push(-x[i].snd.snd),w0[i]=-(1LL<<61);
	w0[nb]=s;
	fore(i,nb,n){
		s+=x[i].snd.snd;
		q.push(-x[i].snd.snd);
		s+=q.top();q.pop();
		w0[i+1]=s;
	}
	while(!q.empty())q.pop();
	s=0;
	for(int i=n-1;i>=n-na;--i)s+=x[i].snd.fst,q.push(-x[i].snd.fst),w1[i+1]=-(1LL<<61);
	w1[n-na]=s;
	for(int i=n-na-1;i>=0;--i){
		s+=x[i].snd.fst;
		q.push(-x[i].snd.fst);
		s+=q.top();q.pop();
		w1[i]=s;
	}
	ll rr=-(1LL<<62);
	fore(i,0,n+1)rr=max(rr,w0[i]+w1[i]);
	printf("%lld\n",r+rr);
	return 0;
}

Measured memory_bytes: 4984
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  vector<int>a(9);
  
  for(int i=0;i<9;i++){
    cin >> a[i];
  }
  
  int n;
  cin >> n;
  
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<9;j++){
      if(b[i] == a[j]) a[j] = 0;
    }
  }
  
  bool bingo = false;
  
  if(a[0] == a[1] && a[1] == a[2]) bingo = true;
  if(a[3] == a[4] && a[4] == a[5]) bingo = true;
  if(a[6] == a[7] && a[7] == a[8]) bingo = true;
  if(a[0] == a[3] && a[3] == a[6]) bingo = true;
  if(a[1] == a[4] && a[4] == a[7]) bingo = true;
  if(a[2] == a[5] && a[5] == a[8]) bingo = true;
  if(a[0] == a[4] && a[4] == a[8]) bingo = true;
  if(a[2] == a[4] && a[4] == a[6]) bingo = true;
  
  if(bingo) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

int main(int argc, char* argv[])
{
  ll K, S;
  std::cin >> K >> S;

  ll ans = 0;
  for (ll x = 0; x <= K; x++) {
    for (ll y = 0; y <= K; y++) {
      if (S - x - y <= K && S - x - y >= 0) {
	ans++;
      }
    }
  }

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


Measured memory_bytes: 256