akhauriyash/Code-Regression huggingface dataset:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def is_ok(S):
    N = len(S)
    for i in range(N):
        if S[i]!=S[-i-1]:
            return False
    return True
def main():
    S=ST()
    N=len(S)
    a = is_ok(S[:(N-1)//2])
    b = is_ok(S[(N+3)//2-1:])
    c = is_ok(S)
    # print(S[:(N-1)//2],S[(N+3)//2-1:])
    if(a and b and c):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Measured memory_bytes: 66028
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll N; cin>>N;
  map<string, ll> s;
  ll ans=0;
  for(int i=0; i<N; i++){
    string S; cin>>S;
    sort(S.begin(), S.end());
    s[S] += 1;
  }
  for(auto itr=s.begin(); itr!=s.end(); itr++){
    ll a =itr->second;
    if(a>1){
      for(int i=1; i<a; i++){
        ans+=i;
      }
    }
  }
  cout<<ans<<endl;  
}

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

namespace Sample1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char[] cha = new char[3];
            for(int i=0; i<str.Length; i++)
            {
                if(str[i] == '1')
                {
                    cha[i] = '9';
                }
                else if(str[i] == '9')
                {
                    cha[i] = '1';
                }
                else
                {
                    cha[i] = str[i];
                }
            }
            Console.WriteLine(cha);
        }
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int x, y;
    cin >> x >> y;
    bool flg = false;
    rep(i, x+1) {
        rep(j, x+1) {
            if(i + j != x) continue;
            if(i*2 + j*4 == y) flg = true;
        }
    }
    Yn(flg);

    return 0;
}


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

namespace Atcoder
{

    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] Ass = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            
            int ans = 0;
            bool flug = true;
            while (flug == true)
            {
                for (int i = 0; i < N; i++)
                {
                    if (Ass[i] % 2 != 0)
                    {
                        flug = false;
                        break;
                    }else{
                        Ass[i] = Ass[i]/2;
                    }
                }
                if(flug==true){
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

namespace lean
{
    class Program
    {
        static void Main()
        {
            string S= Console.ReadLine();
            string A = S.Substring(2, 1);
            string B = S.Substring(3, 1);
            string C = S.Substring(4, 1);
            string D = S.Substring(5, 1);
            if (A == B && C == D)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<string>
using namespace std;
int main(){
  string w;
  string t;
  cin >> w;
  int i;
  for(i=0;i<w.size();i++) {
    if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
  }
  int o=0;
  cin >> t;
  while(t!="END_OF_TEXT"){
  
    for(i=0;i<t.size();i++) {
      if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
    }
    if(w==t) o++;
    cin >> t;
  }
  cout << o << endl;
}



Measured memory_bytes: 3188
N = int(input())
c = list(input())
ans = 0
r = False
w = False
for i in c:
    if i == 'W':
        w = True
    else:
        r = True
    if r == True and w == True and i == 'R':
        ans += 1
c.reverse()
r = False
w = False
ans2 = 0
for i in c:
    if i == 'W':
        w = True
    else:
        r = True
    if r == True and w == True and i == 'W':
        ans2 += 1
cnt = c.count('W')
ans3 = 0
for i in range(N):
    if c[i] == 'R' and cnt > 0:
        ans3 += 1
        cnt -= 1
    if c[i] == 'W':
        cnt -= 1
    #print(ans3,cnt)
print(min(ans,ans2,ans3))


Measured memory_bytes: 77612
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		try (Scanner sc = new Scanner(System.in);) {

			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());

			if (n + m == 15) {
				System.out.println("+");
			} else if (n * m == 15) {
				System.out.println("*");
			} else {
				System.out.println("x");
			}

		}
	}
}


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

using namespace std;

using ll = long long;

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

    int n, m, c;
    cin >> n >> m >> c;

    vector<int> b(m);
    for (int i = 0; i < m; ++i) cin >> b[i];

    int num = 0;
    for (int i = 0; i < n; ++i) {
        int sum = c;
        for (int j = 0, a; j < m; ++j) {
            cin >> a;
            sum += a * b[j];
        }
        if (sum > 0) ++num;
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef pair<ll,P> PP;
int main() {
	string s; cin >> s;
	cout << "ABC" << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <limits>
#include <string>
#include <bitset>

using namespace std;
using lint = long long;
using P = pair<int, int>;
using V = vector<int>;
constexpr int MOD = 1e9 + 7;
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define repr(i, n) for (lint i = (n); i > 0; i--)
#define rep1(i, n) for (lint i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define mp(x, y) make_pair((x), (y))

// int A, B, C, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
lint A, B, F, H, I, J, K, L, M, N, S, T, U, W, X, Y;
// string A, B;
lint ans = 1;
// string ans;

lint gcd(lint a, lint b) {
    if (a == 0) {
        return b;
    } else {
        return gcd(b % a, a);
    }
}

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

	cin >> A >> B;
    lint g = gcd(A, B);

    for (lint i = 2; i * i <= g; i++) {
        if (g % i == 0) {
            ans++;
            while (g % i == 0) g/= i;
        }
    }
    if (g > 1) ans++;

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

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//gcdをユークリッド互除法で求める。O(log n)
int euclid(int x, int y){
    if(min(x, y) ==  0) return max(x, y);
    else return euclid(max(x, y)% min(x, y) , min(x, y));
}
//

int main() {
	ll ans = 0;
	int tmp;
	int n, x;
	cin >> n >> x;
	vector<int> c(n);
	REP(i, n) cin >> c[i];
	REP(i, n) c[i] = abs(c[i] - x);
	REP(i, n) ans = euclid(ans, c[i]);
	cout << ans << endl;
}

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

int main(){
    long long X;
    cin >> X;
    long long count = 0LL;
    long long deposit = 100LL;
    while(true){
        deposit =  deposit + deposit * 0.01;
        count++;
        if(deposit >= X){
            break;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

ll INF = 1;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    rep(i, n){
        a[i] = -a[i];
    }

    ll dp[n];
    fill(dp, dp+n, INF);

    rep(i, n){
        *upper_bound(dp, dp+n, a[i]) = a[i];
    }

    cout << (lower_bound(dp, dp+n, INF) - dp) << endl;



    return 0;
}

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

int g(int x, int y, int z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main(void){
    int n;
    cin >> n;
    vector<int> ans(n+10);
    for(int x = 1; x*x <= n; x++){
        for(int y = 1; x*x + y*y + x*y <= n; y++){
            for(int z = 1; g(x,y,z) <= n; z++){
                ans[g(x,y,z)]++;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int D, N;
	int d = 1;
	cin >> D >> N;

	if (N == 100)
		N = 101;

	for (int i = 0; i < D; i++)
	{
		d *= 100;
	}

	cout << d * N << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;

void solve(){
    char ch;
    cin>>ch;
    ch += 1;
    cout<<ch<<endl;
}

int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int n;
int saiki(int ima)
{
	if(ima == n)
		return 1;
	if(ima > n)
		return 0;

	int res = 0;
	res += saiki(ima + 1) + saiki(ima + 2) + saiki(ima + 3);
	return res;
}

int main() {
	while (true){
		cin >> n;
		if (n == 0)
			break;
		
		int ans,a;
		ans = saiki(0);
		a = ans;
		ans /= 3650;
		a %= 3650;
		if( a == 0 )
		{
			cout << ans << endl;
		}
		else if( a != 0 )
		{
			ans++;
			cout << ans << endl;
			
		}
	}
}

Measured memory_bytes: 2984
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N - 1];
    ll par[N];
    fill(par, par + N, 0);
    REP(i, 0, N - 1) {
        cin >> A[i];
        par[A[i] - 1]++;
    }
    REP(i, 0, N) {
        cout << par[i] << endl;
    }
}


Measured memory_bytes: 6740
package main

import "fmt"

func main() {
	var n, k int
	var h []int
	var hi int
	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		fmt.Scan(&hi)
		h = append(h, hi)
	}
	result := 0
	for _, height := range h {
		if height >= k {
			result++
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,h;
  cin >> n >>k;
  int ans=0;
  for(int i=1;i<=n;i++){
    cin >> h;
    ans+=(h>=k);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

// Nまでの約数取得 (指定なしの場合昇順)
vector<lint> Divisor(lint N, bool ascending = true)
{
	vector<lint> divisor;
	for (lint i = 1; i <= sqrt(N); i++)
	{
		if (N % i == 0)
		{
			divisor.push_back(i);
			if (i * i != N)
				divisor.push_back(N / i);
		}
	}

	if (ascending)
		sort(all(divisor));
	else
		sort(all(divisor), greater<lint>());

	return divisor;
}

void execute()
{
	lint N, M;
	cin >> N >> M;

	vector<lint> divisor = Divisor(M, false);

	for (auto out : divisor)
	{

		if (out * N <= M)
		{
			cout << out << endl;
			return;
		}
	}

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

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

int dp[100100], n, m, x, y, ans;
vector<int> graph[100100];

int dfs(int u) {
	int &ret = dp[u];
	if(ret != -1) return ret;
	ret = 0;
	for(int v : graph[u]) {
		ret = max(ret, dfs(v));
	}
	ret++;
	return ret;
}

int main() {
	memset(dp, -1, sizeof(dp));
	cin>>n>>m;
	for(int i = 0; i < m; i++) {
		cin>>x>>y;
		graph[x].push_back(y);
	}
	for(int i = 1; i <= n; i++) {
		ans = max(ans, dfs(i));
	}
	cout<<ans-1<<endl;
	return 0;
}


Measured memory_bytes: 7424
import sys
n=int(input())
k=2
l=list(map(int,input().split()))
ans=[0,abs(l[1]-l[0])]
for i in range(2,n):
    m=sys.maxsize
    c=1
    while c<min(k+1,i+1):
        
        m=min(abs(l[i]-l[i-c])+ans[-c],m)
        c+=1
    ans.append(m)
# print(ans)
print(ans[-1])
    

Measured memory_bytes: 13980
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main{

    static class sushi{
        long x,v;
        sushi(long x,long v){
            this.x=x;
            this.v=v;
        }

    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N  =scan.nextInt();
        long C = scan.nextLong();
        List<sushi> sushis = new ArrayList<>();
        for(int i=0;i<N;++i){
            long x = scan.nextLong();
            long v = scan.nextLong();
            sushis.add(new sushi(x,v));
        }
        Collections.sort(sushis,(a,b)-> a.x<b.x ? -1:1);
        long lmax[] = new long[N];
        long retlmax[] = new long[N];
        long rmax[] = new long[N];
        long retrmax[] = new long[N];

        long tmp=0;
        for(int i=0;i<N;++i){
            tmp += sushis.get(i).v;
            retlmax[i] = Math.max(i>0 ? retlmax[i-1]:0, tmp-sushis.get(i).x*2);
            lmax[i] = Math.max(i>0 ? lmax[i-1]:0, tmp-sushis.get(i).x);
        }
        tmp = 0;
        for(int i=N-1;i>=0;--i){
            tmp += sushis.get(i).v;
            retrmax[i] = Math.max(i<N-1 ? retrmax[i+1]:0, tmp-(C-sushis.get(i).x)*2);
            rmax[i] = Math.max(i<N-1 ? rmax[i+1]:0, tmp-(C-sushis.get(i).x));
        }
        long ans = Math.max(lmax[N-1], rmax[0]);
        for(int i=0;i<N-1;++i)ans = Math.max(ans,retlmax[i]+rmax[i+1]);
        for(int i=1;i<N;++i)ans = Math.max(ans, retrmax[i]+lmax[i-1]);
        System.out.println(ans);

    }
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1000000007;

int mod(int x){
	return x % MOD;
}

int main(void)
{
    IOS
    string s;
    cin >> s;
    REP(i,s.size()-1) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;

    return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

string s;

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

  cin >> s;

  bool flag = false;
  ll ans = 0ll;
  ll tmp = 0ll;
  REP(i, s.size()) {
    tmp += s[i] - '0';
  }
  if (s[0] == '9') {
    ans += 9;
  } else {
    ans += s[0] - '0';
    ans--;
    flag = true;
  }
  FOR(i, 1, s.size()) {
    if (flag) {
      ans += 9;
      continue;
    }
    if (s[i] == '9') {
      ans += 9;
    } else {
      ans += 9;
      ans--;
      flag = true;
    }
  }

  ans = max(ans, tmp);

  cout << ans << endl;

  return 0;
}



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

int ck(int v1[], int v2[], int n){
    int a=1;;
    for (int i=0; i<n; i++){
        if (v1[i]!=v2[i]){
            a=0;
            break;
        }
    }
    return a;
}
long long a=1,b=1,n,c,d;
string ss,l[100][100];
int main(){
    cin>>a>>b;
    if (a!=1 and b!=1){
        cout<<1<<endl;
    }
    else if (a!=2 and b!=2){
        cout<<2<<endl;
    }
    else if (a!=3 and b!=3){
        cout<<3<<endl;
    }
}


Measured memory_bytes: 384
N = int(input())
S = input()
K = int(input())

S_list = list(S)

for i in range(N):
    if S_list[i] != S_list[K-1]:
        S_list[i] ="*"
    else:
        continue

S_new = ""
for i in S_list:
    S_new += i

print(S_new)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fi first 
#define se second
using namespace std;
#define ll long long 
ll n;
void solve()
{   cin>>n;
  ll a[n];     map<ll,ll>m;
    for(ll i=0;i<n;i++)
    { cin>>a[i];  
      m[a[i]]++;
    }   
    ll sum=0,ans;
    for(auto i:m)
    {
        sum+=i.se*(i.se-1)/2;
    }  //cout<<sum;
       for(ll i=0;i<n;i++)
       {
           ans=sum-m[a[i]]+1;
           cout<<ans<<"\n";
       } 
    m.clear();   
}
int main()
{   
   solve();
    return 0;
}


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

#define Need_For_Speed ios_base::sync_with_stdio;cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define mp make_pair

#define bg begin
#define en end

#define sz size()

#define fe first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e6 + 17, maxN = 4 * N, darr = 1e3 + 17, mod = 1e9 + 7;

int mn = mod;
string s, r;

bool f (int n) {
    for(int i = 0; i < n - 1; ++i) {
        if(r[i] != r[i + 1]) {
        	return 0;
        }
    }
    return 1; 
}

int main () {
	Need_For_Speed;
	cin >> s;
	for(int i = 0; i < s.sz; ++i) {
	    r = s;
	    char a = s[i];
	    int n = s.sz;
	    int ct = 0;
	    while(!f(n)) {
	    	n--;
	        ct++;
	        for(int i = 0; i < n; i++) {
	            if(r[i + 1] == a) {
	            	r[i] = a;
	            }
	        }
	    }
	    mn = min(mn, ct);
	}
	cout << mn;
	return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <fstream>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long n, k;
	cin >> n >> k;
	vector<pair<long long, long long>> a;
	REP(i, n) {
		int c, b;
		cin >> c >> b;
		a.push_back(make_pair(c, b));
	}
	sort(a.begin(), a.end());
	long long hoge = 0;
	for (int i = 0;i < a.size();++i) {
		hoge += a[i].second;
		if (hoge >= k) {
			cout << a[i].first << endl;
			return 0;
		}
	}
	cout << a[a.size() - 1].first << endl;
	return 0;
}

Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();

        String convertStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";

        String ans = "";
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < convertStr.length(); j++) {
                if (s.charAt(i) == convertStr.charAt(j)) {
                    ans += String.valueOf(convertStr.charAt(j + n));
                    break;
                }

            }
        }
        System.out.println(ans);

        sc.close();
    }

}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<LL> a;
  vector<vector<LL>> dp;
  Solver(LL n) : n(n), a(n), dp(n + 1, vector<LL>(n + 1, LINF)){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for (int i = 1; i < n; ++i) {
      a[i] += a[i - 1];
    }
    for (int i = 0; i < n; ++i) {
      dp[i][i + 1] = 0;
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j + i <= n; ++j) {
        int r = j + i;
        for (int k = j + 1; k < i + j; ++k) {
          dp[j][r] = min(dp[j][r], dp[j][k] + dp[k][r] + (a[r - 1] - (j == 0 ? 0 : a[j - 1])));
        }
      }
    }
    DBG(dp)
    cout << dp[0][n] << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define rei(n) for(int i=0;i<(int)n;i++)
#define rel(n) for(int l=0;l<(int)n;l++)
#define all(s) s.begin(),s.end()
#define INT_MAX 2147483647
#define debug(x) cout<<#x<<": "<<x<<endl;
#define PI 2*acos(0,0)
#define inin(x) int x; cin>>x;
#define ll long long

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<int> a, b(n+1,0);
	for (int i = 0; i < m; i++)
	{
		inin(x);
		a.push_back(x);
	}

	for (int i = 0; i < m; i++)
	{
		int miss=0;
		for (int l = 1; l <= n; l++)
		{
			inin(x);
			if (x == a[i])b[l]++;
			else miss++;
		}
		b[a[i]] += miss;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << b[i] << endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    string s;
    int i=0;
    cin>>s;
    string days[7]={"SUN","MON", "TUE", "WED", "THU", "FRI", "SAT"};
    for(i=0;i<7;i++){
        if(s==days[i]){
            break;
        }
    }
    cout<<7-i;   
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
s=[];
n.times do
  s << gets.chomp
end

m=gets.to_i
t=[];
m.times do
  t << gets.chomp
end

ans=0
cnt=0
s.each do |str1|
  s.each do |str2|
    if str1==str2
      cnt+=1
    end
  end
  t.each do |str3|
    if str1==str3
      cnt-=1
    end
  end
  ans = cnt if cnt>ans
  cnt = 0
end

puts ans

Measured memory_bytes: 1788
import java.util.*;

public class Main {
public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int a[]=new int[n];
		for(int s=0;s<n;s++){
			a[s]=sc.nextInt();
		}
		double total=0;

		for(int s=0;s<n;s++){
			total+=(double)1/a[s];
		}

		
		System.out.println((double)1/total);

	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int kai(int n){
    if(n == 0){
        return 1;
    }
    return kai(n-1) * n;
}

int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n), cp(n), cq(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
  	for(int i = 0; i < n; i++){
        cin >> q[i];
    }

    cp[0] = 0;
    cq[0] = 0;
    for(int i = 1; i < n; i++){
        cp[i] = 0;
        cq[i] = 0;
        for(int j = 0; j < i; j++){
            if(p[j] < p[i]){
                cp[i]++;
            }
            if(q[j] < q[i]){
                cq[i]++;
            }
        }
    }

    int tmp1 = 0, tmp2 = 0;
    for(int i = 1; i < n; i++){
        tmp1 += kai(n - i) * (p[i - 1] - 1 - cp[i - 1]) + 1;
        tmp2 += kai(n - i) * (q[i - 1] - 1 - cq[i - 1]) + 1;
    }

    if(tmp1 > tmp2){
        cout << tmp1 - tmp2 << endl;
    }else{
        cout << tmp2 - tmp1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    vector<int> v;
    rep(i,3){
        int t;cin>>t;
        v.push_back(t);
    }
    sort(all(v));
    cout<<v[0]+v[1]<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int[] alphabets = new int[26];
			while(sc.hasNext()) {
				String str = sc.nextLine();
				for(int i = 0;i<str.length();i++) {
					char ch = str.charAt(i);
					if(64<ch&&ch<91) {
						alphabets[ch-65]++;
					}
					else if(96<ch&&ch<123) {
						alphabets[ch-97]++;
					}
				}
			}
			for(int i = 0;i<26;i++) {
				System.out.println(String.format("%c : %d", (char)i+97, alphabets[i]));
			}
		}
	}
}


Measured memory_bytes: 26356
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        
        for(int i = 0; i < n; i++){
          x[i] = sc.nextInt();
          y[i] = sc.nextInt();
          a[i] = sc.nextInt();
        }
      
        
        int minX = 0;
        int maxX = w;
        int minY = 0;
        int maxY = h;
        for(int i = 0; i < n; i++){
          if(a[i] == 1){
            minX = Math.max(minX,x[i]);
          }else if(a[i] == 2){
            maxX = Math.min(maxX,x[i]);
          }else if(a[i] == 3){
            minY = Math.max(minY,y[i]);
          }else if(a[i] == 4){
            maxY = Math.min(maxY,y[i]);
          }
        }
       
        
        int ans = (maxX - minX)*(maxY - minY);
        if(minX < maxX && minY < maxY){
          System.out.println(ans);
        }else{
          System.out.println(0);
        }
      
	}
}

Measured memory_bytes: 36340
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    a=sorted([-1*random.randint(1,5) for _ in range(n)])[::-1]
    return n,a

show_flg=False
show_flg=True

n=I()
a=[int(input()) for i in range(n)]
dp=[1]+[0]*n
p=[-1]*(1+2*10**5)
for i in range(1,n+1):
    dp[i]+=dp[i-1]
    c=a[i-1]
    if p[c]!=-1 and p[c]!=i-1:
        dp[i]+=dp[p[c]]
    p[c]=i
    dp[i]%=mo

print(dp[-1]%mo)



Measured memory_bytes: 57432
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int N,M;
vector<vector<int>> G;
int ans = 0;

void dfs(int u,vector<int> used){
  used[u] = 1;
  for(auto v:G[u]){
    if(used[v] == -1){
      dfs(v,used);
    }
  }
  bool ok = true;
  rep(i,N){
    if(used[i] == -1) ok = false;
  }
  if(ok) ans++;
}

int main(){
  cin >> N >> M;
  G.resize(N);
  rep(i,M){
    int a,b; cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> used(N,-1);
  dfs(0,used);
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using longlong=long long;

[[maybe_unused]]auto cmn=[](auto&& a,auto b){if(a>b){a=b;return true;}return false;};
[[maybe_unused]]auto cmx=[](auto&& a,auto b){if(a<b){a=b;return true;}return false;};
int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n;std::cin>>n;
    std::string s;std::cin>>s;
    std::vector<int>mul(26);
    for(char c:s)mul.at(c-'a')++;
    std::vector<int>left(26);
    int ans=0,now=0;
    for(char c:s){
        cmx(ans,now);
        if(left.at(c-'a')==0)now++;
        left.at(c-'a')++;
        if(left.at(c-'a')==mul.at(c-'a'))now--;
    }
    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

#define N 100
ll n;
dd x[N],y[N];
dd ans=inf;

struct kouho{
    dd x,y,r;
};
dd dis(dd sx,dd sy,dd tx,dd ty){
    return sqrt(powl((sx-tx),2.0)+powl((sy-ty),2.0));
}
bool check(kouho k){
    rep(i,0,n-1){
        dd dit=dis(x[i],y[i],k.x,k.y);
        if(dit>k.r+EPS)return false;
    }
    return true;
}

kouho cal1(ll i,ll j){
    kouho res;
    res.x=(x[i]+x[j])/2.0;
    res.y=(y[i]+y[j])/2.0;
    res.r=dis(res.x,res.y,x[i],y[i]);
    return res;
}
kouho cal2(ll i,ll j, ll k){
    kouho res;
    dd a=x[i],b=y[i],c=x[j],d=y[j],e=x[k],f=y[k];
    res.y=((e-a)*(powl(a,2)+powl(b,2)-powl(c,2)-powl(d,2))-(c-a)*(powl(a,2)+powl(b,2)-powl(e,2)-powl(f,2)))/(2*(e-a)*(b-d)-2*(c-a)*(b-f));
    if(abs(c-a)<EPS){
        res.x=(2*(b-f)*res.y-a*a-b*b+e*e+f*f)/(2*(e-a));
    }else{
        res.x=(2*(b-d)*res.y-a*a-b*b+c*c+d*d)/(2*(c-a));
    }
    res.r=dis(res.x,res.y,x[i],y[i]);
    return res;
}

int main(){fastio
    cin>>n;
    rep(i,0,n-1)cin>>x[i]>>y[i];
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            kouho k=cal1(i,j);
            if(check(k)){
                ans=min(ans,k.r);
            }
        }
    }
    rep(i,0,n-1){
        rep(j,i+1,n-1){
            rep(k,j+1,n-1){
                kouho z=cal2(i,j,k);
                if(check(z)){
                    ans=min(ans,z.r);
                }
            }
        }
    }
    cout<<setprecision(20)<<ans<<endl;
    
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int left, right;
    bool find1 = false, find2 = false;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'A' && !find1) {
            left = i;
            find1 = true;
        }
        if(s[s.size()-1-i] == 'Z' && !find2) {
            right = s.size()-1-i;
            find2 = true;
        }
        if(find1 && find2) {
            break;
        }
    }
    cout << right - left + 1<< endl;
     return 0;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
#define ls (p << 1)
#define rs (p << 1 | 1)
#define mid (l + r) / 2
#define rep(i, l, r) for(int i = l; i <= r; ++i)
typedef long long ll;
const int N = 8000000 + 5;
struct tree{
    int min, tag;
}t[N];
int n, m, a, b, fir;
int read(){
    char c; int x = 0, f = 1;
    c = getchar();
    while(c > '9' || c < '0'){ if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}
void lazy(int p, int k){
    t[p].min = t[p].tag = k;
}
void down(int p, int l, int r){
    if(!t[p].tag) return;
    lazy(ls, t[p].tag), lazy(rs, t[p].tag + mid - l + 1);
    t[p].tag = 0;
}
void update(int p, int l, int r, int x, int y, int k){
    down(p, l, r);
    if(l >= x && r <= y){ lazy(p, k); return;}
    if(mid >= x) update(ls, l, mid, x, y, k);
    if(mid < y) update(rs, mid + 1, r, x, y, k + max(0, mid - max(l, x) + 1));
    t[p].min = min(t[ls].min, t[rs].min);
}
int query(int p, int l, int r, int x, int y){
    if(l >= x && r <= y) return t[p].min;
    down(p, l, r);
    if(mid >= x) return query(ls, l, mid, x, y);
    else return query(rs, mid + 1, r, x, y);
}
int main(){
    n = read(), m = read();
    rep(i, 1, n){
        a = read(), b = read(); 
        fir = (a == 1 ? m + 1 : query(1, 1, m, a - 1, a - 1) + 1);
        update(1, 1, m, a, b, fir);
        printf("%d\n", t[1].min >= m + 1 ? -1 : t[1].min + i);
    }
    return 0;
}

Measured memory_bytes: 11884
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
import heapq
# import math
INF = 10**11

def main():
    n, m= getList()
    begin = [[] for i in range(n)]
    cost = [-1 for i in range(n)]
    for i in range(m):
        st, en, cos = getList()
        begin[st-1].append((cos, en-1))

    h = []
    for warp in begin[0]:
        heapq.heappush(h, warp)
    cur_mas = 0

    while(h):
        cand = heapq.heappop(h)
        if cand[1] > cur_mas:
            # 歩を1つ進め、その場所を更新
            cur_mas += 1
            cost[cur_mas] = cand[0]
            for warp in begin[cur_mas]:
                # そこまでの距離とコストを足す
                tcos, ten = warp[0] + cost[cur_mas], warp[1]
                heapq.heappush(h, (tcos, ten))
            heapq.heappush(h, cand)



    print(cost[n-1])
if __name__ == "__main__":
    main()

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

int main()
{
    ios_base::sync_with_stdio(0);

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

    for(int i = 0; i <= n; i++)
    for(int j = 0; j <= m; j++)
    if(i * j + (n - i) * (m - j) == k)
    {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
class Dice:

    def __init__(self):
        # 初期値がない場合
        # 上, 南、東、西、北、下にそれぞれ1, 2, 3, 4, 5, 6がくる想定
        self.t = 1
        self.s = 2
        self.e = 3
        self.w = 4
        self.n = 5
        self.b = 6
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def __init__(self, t, s, e, w, n, b):
        # 初期値が指定される場合
        self.t = t
        self.s = s
        self.e = e
        self.w = w
        self.n = n
        self.b = b
        self.rotway = {"S": 0, "N": 1, "E": 2, "W": 3}

    def rot(self, way):
        if way == 0:
            self.t, self.s, self.e, self.w, self.n, self.b = self.n, self.t, self.e, self.w, self.b, self.s
        elif way == 1:
            self.t, self.s, self.e, self.w, self.n, self.b = self.s, self.b, self.e, self.w, self.t, self.n
        elif way == 2:
            self.t, self.s, self.e, self.w, self.n, self.b = self.w, self.s, self.t, self.b, self.n, self.e
        elif way == 3:
            self.t, self.s, self.e, self.w, self.n, self.b = self.e, self.s, self.b, self.t, self.n, self.w
        

def main():
    import random

    n = int(input())
    diceList = [[0 for _ in range(6)] for _ in range(n)]
    for i in range(n):
        diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5] = map(int, input().split())

    flag = 0

    # 2つ目以降のさいころが、以前のさいころと一致しているか確認していく。
    for i in range(1, n):
        if flag == 1:
            break
        else:
            dice_a = Dice(diceList[i][0],diceList[i][1],diceList[i][2],diceList[i][3],diceList[i][4],diceList[i][5])
            for j in range(i):
                dice_b = Dice(diceList[j][0],diceList[j][1],diceList[j][2],diceList[j][3],diceList[j][4],diceList[j][5])

                for _ in range(200):
                    if (dice_a.t, dice_a.s, dice_a.e, dice_a.w, dice_a.n, dice_a.b) == (dice_b.t, dice_b.s, dice_b.e, dice_b.w, dice_b.n, dice_b.b):
                        flag = 1
                        break
                    else:
                        seed = random.randint(0, 3)
                        dice_a.rot(seed)

    if flag == 0:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()



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

using namespace std;

using i64 = long long;

const i64 INF = 1e18 + 7;
const i64 MOD = 1e9 + 7;


signed main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    vector<int> v(n, k - q);
    for(auto& x : a){
        cin >> x;
        --x;
        ++v[x];
    }
    for(auto& x : v)
        cout << (x > 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1408
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tup(t=int):return tuple(pin(t))
#%%code
def resolve():
    N=int(input())
    if N%2==0:
        print(0.5)
    else:
        t=(N+1)//2
        print(t/N)
#%%submit!
resolve()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    private static char[]   cells = new char[9];
    private static int [][] cond  = {{0,1,2},{3,4,5},{6,7,8},
    	                             {0,3,6},{1,4,7},{2,5,8},
    	                             {0,4,8},{2,4,6}        };

	public static void main(String[] args) {

        //input
        Scanner sc = new Scanner(System.in);

        char ret;
        while(sc.hasNext()){
        	cells = sc.next().toCharArray();
        	ret = check();
        	System.out.println(ret);
        }
	}

	private static char check(){

		char t   = 'n',
		     ret = 'n';

		loop:for(int i=0;i<2;i++){

			ret = 'd';

			if      (i == 0){ t = 'o';}
			else if (i == 1){ t = 'x';}

			for(int j=0;j<8;j++){
				if ( cells[cond[j][0]] == t &&
					 cells[cond[j][1]] == t &&
					 cells[cond[j][2]] == t    ){
					ret = t;
					break loop;
				}
			}
		}
		return ret;
	}
}

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

int main(){
    string s;
    int k;
    cin>>s;
    cin>>k;
    rep(i,k){
        if(s[i]!='1'){
            cout<<s[i]<<"\n";
            return 0;
        }
    }
    cout<<1<<"\n";
    return 0;
}

Measured memory_bytes: 3600
/*
 * atcoder/abc148/e.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

void solve() {
  ll n;
  cin >> n;
  if (n%2==1) {
    cout << 0 << endl;
    return;
  }

  n /= 2;
  ll ans = 0;
  while (n) {
    ans += n / 5;
    n /= 5;
  }
  cout << ans << endl;
}


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

const bool DEBUG = false;

long long N;
vector<long long> A;

void input() {
  cin >> N;
  A = vector<long long>(N);
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
  }
}

int main(int argc, char const *argv[]) {
  input();
  map<long long, long long> counts;
  for (auto &&a : A) counts[a]++;

  long long total = 0;
  map<long long, long long> subtracts;
  for (auto &&elem : counts) {
    long long a = elem.first;
    long long c = elem.second;
    long long num_patterns = max((c * (c - 1)) / 2, 0ll);
    subtracts[a] = num_patterns - max(((c - 1) * (c - 2)) / 2, 0ll);
    total += num_patterns;
  }

  for (size_t i = 0; i < N; i++) {
    cout << total - subtracts[A[i]] << endl;
  }

  return 0;
}

Measured memory_bytes: 19968
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.println(s.substring(0, 1) 
				+ new Integer(s.length()-2) 
				+ s.substring(s.length()-1, s.length()));
	}
}

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

int main(){
    int k;
    cin >> k;
    int c[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    cout << c[k - 1] << endl;
}

Measured memory_bytes: 256