akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64,
        e: i64,
        k: i64,
    }
    if (a - e).abs() > k {
        println!(":(");
    } else {
        println!("Yay!");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int>vec(N);
  vector<int>v(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
    v.at(vec.at(X)-1)=X+1;
  }
  for(int X=0;X<N;X++){
    if(X==N-1){
      cout<<v.at(X)<<endl;
    }
    else{
      cout<<v.at(X)<<" ";
    }
  }
}


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

namespace mondai0027
{
	class Program
	{
		static void Main(string[] args)
		{
			int[]		month_days	= { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
			string[]	week		= { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
			
			while( true ) {
				var	s	= Console.ReadLine().Split();
				var	month	= int.Parse( s[ 0 ] );
				var	day		= int.Parse( s[ 1 ] );
				if( month == 0 ) {
					break;
				}
				
				int	pass	= 0;
				for( int i = 1; i < month; i++ ) {
					pass	+= month_days[ i ];
				}
				pass	+= day - 1 + 3;
				Console.WriteLine( week[ pass % 7 ] );
			}
		}
	}
}

Measured memory_bytes: 5296
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

ll min(ll x, ll y)
{
  if(x<y) return x;
  return y;
}

int main()
{
  __;
  int n;
  cin >> n;
  vector<ll> v(n);
  ll sum1 = 0;
  for(int i=0;i<n;i++) {cin >> v[i]; sum1 += v[i];}

  ll sofar = v[0];
  ll min1 = 1e18;
  for(int i=1;i<n;i++)
  {
    ll left = sum1 - sofar;
    if(sofar <= left)
    {
      ll diff = left-sofar;
      min1 = min(min1,diff);
    }
    else
    {
      ll diff = sofar-left;
      if(left<i) continue;
      min1 = min(min1,diff);
    }
    // t(min1,i);
    sofar += v[i];
  }

  cout << min1 << endl;
  return 0;
}



Measured memory_bytes: 1792
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
from itertools import count, cycle, repeat     # count(start[,step]), cycle(iter), repeat(elm[,n])
from itertools import groupby                  # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
from itertools import starmap                  # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n = ii()
    a = lmi()
    c = 1
    ans = 0
    for i in range(n):
        if a[i] == c:
            c += 1
        else:
            ans += 1
    print(ans) if ans != n else print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 25252
n = input()
l = n.split("i")
#print(len(n))
#print(l)
i = int(len(l)-1)
#print(n)
#print(i)
#print(int(len(n)%2))
if int(len(n)%2)==0:
    if i==0:
        print("No")
    elif i==1:
        if l[0]=="h":
            print("Yes")
        else:
            print("No")
    elif i==2:
        if l[0]==l[1]=="h":
            print("Yes")
        else:
            print("No")
    elif i==3:
        if l[0]==l[1]==l[2]=="h":
             print("Yes")
        else:
            print("No")
    else:
        if l[0]==l[1]==l[2]==l[3]=="h":
            print("Yes")
        else:
            print("No")
else:
    print("No")

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

int main(){
  int N,K;
  int Max=0;
  cin >> N >> K;
  vector<int> V(0,0);
  for(int i=0;i<N;i++){
    int n;
    cin >> n;
    V.push_back(n);
  }
  vector<int> L(1,0);
  vector<int> R(1,0);
  for(int i=1;i<=N;i++){
    if(i==1){
      L.push_back(V[i-1]);
      R.push_back(V[N-1]);
    }else{
      L.push_back(L[i-1]+V[i-1]);
      R.push_back(R[i-1]+V[N-i]);
    }
  }
  for(int i=0;i<=min(N,K);i++){
    for(int j=0;j<=min(N,K)-i;j++){
      vector<int> M(0,0);
      for(int k=0;k<i;k++){
        M.push_back(V[k]);
      }
      for(int k=0;k<j;k++){
        M.push_back(V[N-1-k]);
      }
      sort(M.begin(),M.end());
      int sum = 0;
      for(int k=0;k<min(i+j,K-i-j);k++){
        if(M[k]>=0) break;
        sum += M[k];
      }
      Max = max(Max,L[i]+R[j]-sum);
    }
  }
  cout << Max << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  int amax = 0, maxn = 1, second = 0;
  for (int i = 1; i <= n; i++) {
   	int ai;
    cin >> ai;
    a.push_back(ai);
    if (ai == amax) {
      maxn++;
    }
    else if (ai > amax) {
      second = amax;
      amax = ai;
      maxn = 1;
    }
    else if (ai > second && ai < amax)
      second = ai;
  }
  
  for (int i = 1; i <= n; i++) {
    if (a[i-1] < amax)
      cout << amax << endl;
    else {
      if (maxn >= 2)
        cout << amax << endl;
      else
        cout << second << endl;
    }
  }
  
  return 0;
}


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

int main(void){
int i,n,m,a,b,count=0;
vector<int> h(N_SIZE);
vector<bool> ok(N_SIZE,true);
cin >> n >> m;
rep(i,n){
cin >> h.at(i);
}

rep(i,m){
    cin >> a >> b;
    a--;
    b--;
    if(h.at(b) <= h.at(a)){
    ok.at(b)=false;  
    }
    if(h.at(a) <= h.at(b)){
    ok.at(a)=false;  
    }
    
}
rep(i,n){
    if(ok.at(i))
    count++;
}
cout << count << endl;

}

Measured memory_bytes: 3604
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 305;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int n;
	cin >> n;
	vector<int> a(n);
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		if (i & 1 && a & 1) cnt++;
	}
	cout << cnt;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
#include <queue>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}

int N;
vector<ll> a,b,c;

ll dp[100010][3];

void func(int n)
{
	if(dp[n][0] > -1) return;
	if(dp[n][1] > -1) return;
	if(dp[n][2] > -1) return;

	if(n > N + 1) return;

	dp[n][0] = max(dp[n - 1][1] + a[n], dp[n - 1][2] + a[n]);
	dp[n][1] = max(dp[n - 1][0] + b[n], dp[n - 1][2] + b[n]);
	dp[n][2] = max(dp[n - 1][1] + c[n], dp[n - 1][0] + c[n]);
	func(n + 1);
}

int main()
{
	cin >> N;
	a.resize(N);
	b.resize(N);
	c.resize(N);
	for(int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
	for(int i = 0; i < 100010; i++) for(int j = 0; j < 3; j++) dp[i][j] = -1;
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	func(1);
	ll ans = -1;
	for(int i = 0; i < 3; i++)
	{
		ans = max(ans,dp[N - 1][i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
/* ABC156_B
    Stuartyg */

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>


int main(void){
    int n,k;
    double ans = 0;

    scanf("%d %d",&n,&k);
    
    ans = log(n)/log(k);
    printf("%d",(int)ans+1); /*型キャスト*/

    return 0;
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
        long n = sc.nextLong();
        long index = (long)Math.sqrt(n);

        while (n % index != 0) {
            index--;
        }
        System.out.println(index + (n / index) - 2);
	}
}


Measured memory_bytes: 23892
#include <stdio.h>

int main()
{
    int A,B,C,K,i;

    scanf("%d%d%d",&A,&B,&C);
    scanf("%d",&K);

    for(i=0;i<K;i++){
        if( ( A >= B ) && ( A >= C ) ){
            A = A * 2;
        }else if( B >= C ){
            B = B * 2;
        }else{
            C = C * 2;
        }
    }

    printf("%d\n",A + B + C);

    return 0;

}

Measured memory_bytes: 128
#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(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans=0;
  while(k!=0){
    ll tmp=min(a,k);
    ans+=tmp;
    k-=tmp;
    if(k==0)break;
    tmp=min(b,k);
    k-=tmp;
    if(k==0)break;
    tmp=min(c,k);
    ans-=tmp;
    k-=tmp;
  }
  cout << ans << endl;
}


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

const int MAX_N = 10005;
int N, M, used[MAX_N], deg_in[MAX_N], cmp[MAX_N];
vector<vector<int>> G(MAX_N);

int bfs(int s, int cnt){
    queue<int> q; q.push(s);
    used[s] = 1; cmp[cnt++] = s;

    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v : G[u]){
            deg_in[v]--;
            if(deg_in[v]==0){
                used[v] = 1; cmp[cnt++] = v;
                q.push(v);
            }
        }
    }
    return cnt;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int a, b; cin >> a >> b;
        G[a].push_back(b); deg_in[b]++;
    }

    int cnt = 0;
    for(int i=0;i<N;i++){
        if(used[i]==0 && deg_in[i]==0) cnt = bfs(i, cnt);
    }

    for(int i=0;i<N;i++) cout << cmp[i] << endl;
    return 0;
}


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

int main(){
	int n;
	while(cin >> n){
		int ans[10] = {};
		while(n >= 512){
			n -= 512;
			ans[9]++;
		}
		while(n >= 256){
			n -= 256;
			ans[8]++;
		}
		while(n >= 128){
			n -= 128;
			ans[7]++;
		}
		while(n >= 64){
			n -= 64;
			ans[6]++;
		}
		while(n >= 32){
			n -= 32;
			ans[5]++;
		}
		while(n >= 16){
			n -= 16;
			ans[4]++;
		}
		while(n >= 8){
			n -= 8;
			ans[3]++;
		}
		while(n >= 4){
			n -= 4;
			ans[2]++;
		}
		while(n >= 2){
			n -= 2;
			ans[1]++;
		}
		while(n >= 1){
			n -= 1;
			ans[0]++;
		}

		int cnt = 0;
		for(int i = 0; i < 10; i++){
			if(ans[i] == 0) continue;
			if(cnt == 0){
				cnt++;
				cout << pow(2, i);
				continue;
			}
			cout << " ";
			cout << pow(2, i);
		}
		cout << endl;
	}


}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int main(){
  int A,B; cin>>A>>B;
  cout<<A*B<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ans=0;
    for(int i=sqrt(n-1);i>=1;i--){
        ans+=(((n-1)/i)-(i-1))*2-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3688
h,w = map(int,input().split())
l = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]
ans = 0
for k in range(10):
    for i in range(10):
        for j in range(10):
            if l[i][j] > l[i][k]+l[k][j]:
                l[i][j] = l[i][k]+l[k][j]
num = [i[1] for i in l] + [0]
for i in a:
    for j in i:
        ans += num[j]
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int a,b;
	cin>>a>>b;
	cout<<a*b;
}

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

vector <int> adia[210];
int viz[210];
int S1, S2, D1, D2;

bool dfs(int nod)
{
    if (nod == D1 || nod == D2)
        return true;
    viz[nod] = 1;
    for (int i(0); i < adia[nod].size(); i++) {
        if (!viz[adia[nod][i]] && dfs(adia[nod][i])) {
            adia[adia[nod][i]].push_back(nod);
            swap(adia[nod][i], adia[nod].back());
            adia[nod].pop_back();
            return true;
        }
    }
    return false;
}

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

    for (int i(1); i <= n; i++) {
        for (int j(1); j <= m; j++) {
            char c;
            cin >> c;
            if (c == 'S')
                S1 = i, S2 = 100 + j;
            else if (c == 'T')
                D1 = i, D2 = 100 + j;
            else if (c == 'o') {
                adia[i].push_back(100 + j);
                adia[100 + j].push_back(i);
            }
        }
    }

    int ans(0);

    if (S1 == D1 || S2 == D2) {
        cout << -1;
        return 0;
    }

    int ok(1);

    while (ok) {
        ok = 0;
        if (dfs(S1))
            ok = 1, ans++;
        memset(viz, 0, sizeof viz);
        if (dfs(S2))
            ok = 1, ans++;
        memset(viz, 0, sizeof viz);
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
# coding: utf-8

S = list(input())
S.append("end")

def count(r, l):
    part_sum = ((r-1)*r + (l-1)*l)/2 #"<<<>>>"頂点の値以外
    part_max = max(r, l) #"<<<>>>"頂点の値
    return(part_sum + part_max)

ans = 0
r = l = 0
for i in range(len(S)-1):
    if S[i+1] != S[i] and S[i] == ">": #"<<<>>>"をセットとして足す
        r += 1
        ans += count(r, l)
        r = l = 0
    elif S[i] == "<":
        l += 1
    elif S[i] == ">":
        r += 1
ans += count(r, l) #"<"終わりの時は、その分がカウントされないので足す(ただしl = 0)
print(int(ans))

Measured memory_bytes: 7964
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    // エラトステネスのふるい
    int MAX = 100001;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for(int i = 2; i < MAX; i++) {
        if (!is_prime[i]) continue;
        for(int j = i*2; j < MAX; j+=i) is_prime[j] = 0;
    }

    // 2017likeか
    vector<int> a(MAX, 0);
    for(int i = 0; i < MAX; i++) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    // 累積和
    vector<int> s(MAX+1, 0);
    for(int i = 0; i < MAX; i++) {
        s[i+1] = s[i] + a[i];
    }

    // クエリ処理
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        r++;

        cout << s[r] - s[l] << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<memory>

template<class T>
struct node {
	T key;
	node* parent;
	std::unique_ptr<node<T>> left, right;
	bool valid_;


	bool nil()const {
		return !valid_;
	}
	bool valid()const {
		return valid_;
	}
	void validate() {
		valid_ = true;
	}
	node() :key{}
		, parent{ nullptr }
		, left{ nullptr }
		, right{ nullptr }
		, valid_{ false }
	{}

	template<class X>
	node(X&&t) :key{ t }
		, parent{ nullptr }
		, left{ nullptr }
		, right{ nullptr }
		, valid_{ false }
	{}

};



template<class T>
void inorder(const node<T>* const root) {
	if (root == nullptr)
		return;

	inorder(root->left.get());
	std::cout << " " << root->key;
	inorder(root->right.get());
}

template<class T>
void preorder(const node<T>* const root) {
	if (root == nullptr)
		return;

	std::cout << " " << root->key;
	preorder(root->left.get());
	preorder(root->right.get());
}


template<class T>
void print(const node<T>*const root) {
	inorder(root);
	std::cout <<"\n";
	preorder(root);
	std::cout << "\n";
}


template<class T>
void insert(node<T>* root, const T&value_) {
	decltype(root) parent = nullptr;
	decltype(root) here = root;

	auto z = std::make_unique<node<T>>(value_ );
	z->validate();

	//値が最も近い、有効なノード(parent)へ移動
	while (here!=nullptr && here->valid()) {
		parent = here;
//		std::cout << here->key << " ";

		if (z->key < here->key) {
			here = here->left.get();
//			std::cout << "> ";
		}
		else {
			here = here->right.get();
//			std::cout << "< ";
		}
//		std::cout << value_ << "\n";
	}
	//zはparentの left か right になる
	z->parent = parent;


	auto& up
		= z->key < parent->key ?
			parent->left
			: parent->right;

	up = std::move(z);
	
}

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

	//	std::vector<node<int>> tree;
	//	tree.emplace_back(node<int>{});
	std::unique_ptr<node<int>> root{ nullptr };


	for (int i{}; i < n; ++i) {
		std::string s;
		std::cin >> s;
		if (s == "insert") {
			int k;
			std::cin >> k;
			if (!root) {
				root = std::make_unique<node<int>>(k);
				root->validate();
			}
			else
				insert(root.get(), k);
		}
		else
			print(root.get());
	}

	return 0;
}


Measured memory_bytes: 26608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin>>N;
  if(N[N.size()-1]=='2'||N[N.size()-1]=='4'||N[N.size()-1]=='5'||N[N.size()-1]=='7'||N[N.size()-1]=='9'){
    cout<<"hon"<<endl;
  }
  else if(N[N.size()-1]=='3'){
    cout<<"bon"<<endl;
  }
  else{
    cout<<"pon"<<endl;
  }
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var s = Read();
            var k = ReadInt();

            var str = s[k - 1];
            var ans = "";
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] != str)
                {
                    ans += "*";
                }
                else
                {
                    ans += s[i];
                }
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

int N,R; cin >> N >> R ;

int ans;
if(N<10){
  R=R+100*(10-N);
}

cout << R << endl; 

return 0;

}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vll A(N); cin >> A;
	vll B(N);
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		if (i & 1) sum -= A[i];
		else sum += A[i];
	}

	B[0] = sum;
	for (int i = N-1; i > 0; i--) {
		B[i] = (A[i] - B[(i+1)%N]/2) * 2;
	}
	cout << B << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4788
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

char S[200050];

int main() {
  scanf("%s", S);
  const int N = strlen(S);

  int cnt[26] = {};
  Int res = 1;
  for (int i = 0; i < N; ++i) {
    res += i - cnt[S[i] - 'a'];
    ++cnt[S[i] - 'a'];
  }
  
  printf("%lld\n", res);

  return 0;
}


Measured memory_bytes: 384
<?php
$N = intval(trim(fgets(STDIN)));
$plus_strs = [];
for ($i=0; $i < $N; $i++) {
  $tmp_str = trim(fgets(STDIN));
  $plus_strs[] = $tmp_str;
}

$M = intval(trim(fgets(STDIN)));
$minus_strs = [];
for ($i=0; $i < $M; $i++) {
  $tmp_str = trim(fgets(STDIN));
  $minus_strs[] = $tmp_str;
}

$plus_cnts = array_count_values($plus_strs);
$minus_cnts = array_count_values($minus_strs);

$max = 0;
foreach ($plus_cnts as $key => $value) {
  if (isset($minus_cnts[$key])) {
    $value -= $minus_cnts[$key];
  }
  if ($value > $max) {
    $max = $value;
  }
}

echo $max."\n";


Measured memory_bytes: 3828
N=int(input())
ans=1000000
import math
aa=math.sqrt(N)
aa=int(aa//1)
for A in range(1,aa+1):
    B=N/A
    if B%1.0==0.0:
        ta=len(str(A))
        tb=len(str(int(B)))
        if ta<tb:
            temp=tb
        else:
            temp=ta
        if ans>temp:
            ans=temp

print(ans)


Measured memory_bytes: 9212
using System;
using static System.Console;

namespace abl
{
    class Program
    {
        static void Main()
        {
            var nm = ReadLine().Split(' ');
            var n = int.Parse(nm[0]);
            var m = int.Parse(nm[1]);
            var roads = new int[m][];
            for (var i = 0; i < m; ++i)
            {
                var ab = ReadLine().Split(' ');
                roads[i] = new int[] { int.Parse(ab[0]), int.Parse(ab[1]) };
            }
            WriteLine(CC(n, roads));
        }
        static int CC(int n, int[][] roads)
        {
            var uft = new UnionFindTree(n);
            foreach (var road in roads)
            {
                uft.Unite(road[0], road[1]);
            }
            uft.Flush();
            var set = new System.Collections.Generic.HashSet<int>();
            for (var i = 1; i < uft.rList.Length; ++i)
            {
                set.Add(uft.rList[i]);
            }
            return set.Count - 1;
        }
        class UnionFindTree
        {
            public int[] rList { get; private set; }
            public UnionFindTree(int size)
            {
                rList = new int[size + 1];
                for (var i = 0; i <= size; ++i)
                {
                    rList[i] = i;
                }
            }
            public void Flush()
            {
                for (var i = 0; i < rList.Length; ++i)
                {
                    rList[i] = GetRoot(rList[i]);
                }
            }
            public int GetRoot(int x)
            {
                if (rList[x] != x)
                {
                    rList[x] = GetRoot(rList[x]);
                }
                return rList[x];
            }
            public bool IsSameTree(int x, int y)
            {
                return GetRoot(x) == GetRoot(y);
            }
            public void Unite(int x, int y)
            {
                if (!IsSameTree(x, y))
                {
                    rList[GetRoot(x)] = y;
                }
            }
        }
    }
}


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

int main() {
  int N;
  VI place(3);
  string S;
  cin >> N;
  cin >> S;
  rep(i, N) {
    if (S.at(i) == 'R') {
      place.at(0) += 1;
    } else if (S.at(i) == 'G') {
      place.at(1) += 1;
    } else {
      place.at(2) += 1;
    }
  }

  ll minu = 0;
  for (int i = 1; i < (N + 1) / 2; i++) {
    for (int j = 0; j + 2 * i < N; j++) {
      char s1, s2, s3;
      s1 = S.at(j);
      s2 = S.at(i + j);
      s3 = S.at(i * 2 + j);
      if (s1 != s2 && s2 != s3 && s3 != s1) {
        minu += 1;
      }
    }
  }
  cout << place.at(0) * place.at(1) * place.at(2) - minu << endl;
  return 0;
}


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

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

  int mask = a[0];
  for ( int i = 1; i < n; i++ ) {
    mask ^= a[i];
  }

  for ( int i = 0; i < n; i++ ) {
    a[i] ^= mask;
    cout << a[i] << ' ';
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << x << " "
#define coutn(x) cout << x << "\n"
#define endl "\n"

template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;

void solve(){
  int a, b; cin >> a >> b;
  if(b>a) swap(a,b);
  if((a-b)%2==0) couts((a+b)/2);
  else couts("IMPOSSIBLE");
}


int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
    ll n,  m[5]; cin >> n;
    rep(i, 5) cin >> m[i];
    sort(m, m+5);

    ll res = (n+(m[0]-1))/m[0] + 4;
    cout << res << ln;
}

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

enum State {Init, Ver, Hor};

int main() {
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;
    long ans = 1;
    State prev = Init;
    for (int i = 0; i < n; i++) {
        if (s1[i] == s2[i]) {
            switch (prev) {
            case Init:
                ans = (ans * 3) % MOD;
                break;
            case Ver:
                ans = (ans * 2) % MOD;
            }
            prev = Ver;
        } else {
            i++;
            switch (prev) {
            case Init:
                ans = (ans * 6) % MOD;
                break;
            case Ver:
                ans = (ans * 2) % MOD;
                break;
            case Hor:
                ans = (ans * 3) % MOD;
            }
            prev = Hor;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
int main(){
  float t,a,m;
 int f,n,i;
  scanf("%d %f %f",&n,&t,&a);
  float h[n];
  float x[n];
  m=50000;
  for (i=0;i<n;i++){
    scanf("%f",&h[i]);
    x[i]=fabsf(t-h[i]*0.006-a);

  }
  
  for (i=0;i<n;i++){
    if(m>x[i]){
      m=x[i];
    f=i;}
    
  }
  
  printf("%d",f+1);
  
}


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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
/*  ll ans = 0;
  int k = 0;
  if (a*b > 0) k++;
  if (c*d > 0) k++;
  if (k == 0) ans = max(a*c,b*d);
  if (k == 1) ans = max(a*c,max(a*d,max(b*c,b*d)));
  if (k == 2) {
    if (a*c < 0) ans = max(a*d,b*c);
    else ans = max(a*b,c*d);
  }*/
  ll ans = max(a*c,max(a*d,max(b*c,b*d)));
  cout << ans << endl;
}

Measured memory_bytes: 3604
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import itertools

def check2(e, *ops):
    ps = []
    ps.append("((%d %s %d) %s %d) %s %d" % (e[0], ops[0], e[1], ops[1], e[2], ops[2], e[3]))
    ps.append("(%d %s %d) %s (%d %s %d)" % (e[0], ops[0], e[1], ops[1], e[2], ops[2], e[3]))
    ps.append("%d %s (%d %s (%d %s %d))" % (e[0], ops[0], e[1], ops[1], e[2], ops[2], e[3]))
    ps.append("(%d %s (%d %s %d)) %s %d" % (e[0], ops[0], e[1], ops[1], e[2], ops[2], e[3]))
    ps.append("%d %s ((%d %s %d) %s %d)" % (e[0], ops[0], e[1], ops[1], e[2], ops[2], e[3]))
    for p in ps:
        if eval(p) == 10:
            print p
            return True
    return False

def check1(e):
    for op1 in "+-*":
        for op2 in "+-*":
            for op3 in "+-*":
                if check2(e, op1, op2, op3): return True
    return False

def solve():
    a = [ int(x) for x in raw_input().split() ]
    if a[0] == 0: return False

    for e in itertools.permutations(a):
        if check1(e): break
    else:
        print 0
    return True

while solve():
    pass

Measured memory_bytes: 4456
#include<bits/stdc++.h>
using namespace std;
string s,t;
int S,p;

bool change(char ch){
  if(ch=='T')return true;
  if(ch=='F')return false;
  int a=ch-'a';
  return (S>>a&1);
}

bool calc(string &);

bool getNum(string &s){
  char ch=s[p++];
  if(ch=='('){
    return calc(s);
  }else if(ch=='-'){
    return (!getNum(s));
  }else{
    return change(ch);
  }
}

char getOp(string &s){
  char ch=s[p++];
  if(ch=='-'){
    p++;
    ch='>';
  }
  return ch;
}

bool calc(string &s){
  bool res=getNum(s);
  while(1){
    char ch=getOp(s);
    if(ch=='='||ch==')')break;
    bool num=getNum(s);
    if(ch=='*')res=(res&&num);
    else if(ch=='+')res=(res||num);
    else if(ch=='>')res=(res<=num);
  }
  return res;
}

string solve(){
  for(S=0;S<(1<<11);S++){
    p=0;
    bool a=calc(s);
    p=0;
    bool b=calc(t);
    if(a!=b)return "NO";
  }
  return "YES";
}

int main(){
  while(1){
    cin>>s;
    if(s=="#")break;
    int x=0;
    while(s[x]!='=')x++;
    t=s.substr(x+1);
    s=s.substr(0,x);
    t.push_back('=');
    s.push_back('=');
    cout<<solve()<<endl;
  }

  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll n, k; cin >> n >> k;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a.at(i) >> b.at(i);

    vector<P> q;
    for(int i=0; i<n; i++){
        P tmp = make_pair(a.at(i), b.at(i));
        q.emplace_back(tmp);
    }
    sort(q.begin(), q.end());

    ll cnt = 0;
    for(int i=0; i<n; i++){
        cnt += q.at(i).second;
        dump(cnt);
        if(cnt>=k){
            cout << q.at(i).first << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(void)
{
	int seconds;
	int hours;
	int minitues;

	cin >> seconds;
	minitues = seconds / 60;
  	hours = minitues / 60;
  	minitues = minitues % 60;
  	seconds = seconds % 60;
  
  	cout << hours << ":" << minitues << ":" << seconds;
	cout << endl;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

string s;
int main(void){
    cin >> s;
    if (s == "SUN") cout << 7 << endl;
    if (s == "MON") cout << 6 << endl;
    if (s == "TUE") cout << 5 << endl;
    if (s == "WED") cout << 4 << endl;
    if (s == "THU") cout << 3 << endl;
    if (s == "FRI") cout << 2 << endl;
    if (s == "SAT") cout << 1 << endl;
    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

ll func(ll n){
	ll i=0;
	if(n==0) return 0;
	if(n==1) return 1; 
	while(2*i+1 <= n) i=2*i+1;

	if(i==n) return 0;
	ll j=i+1;
	ll k=j;                                 
	while(j<n){
		k=k^(j+1);
		j++;
	}
	return k;
}
ll a,b;
ll solve(ll a,ll b){
	if(a%2==0 && b%2) return ((b-a+1) %4==0)? 0 : 1;
	if(a%2==0 && b%2==0){
		return solve(a,b+1) ^ (b+1);
	} 
	if(a%2 && b%2 ){
		return solve(a+1,b)^a;
	}
	if(a%2 && b%2==0){
		return solve(a+1,b)^a;
	}
}


int main(){
	startTime=clock();
	cin >> a >> b;
	//cout << func(6)<< " "<< f(6)<<"\n";

	
	cout << solve(a,b);		
	return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>

using namespace std;
using lint = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (lint i = 1; i < (n); ++i)
#define repn(i, a, b) for(lint i = (a); i < (b); ++i)
#define rep_inv(i, n) for (lint i = (n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n")

//constexpr lint mod = 998'244'353LL;
constexpr lint Mod = 1000'000'007LL;
constexpr lint Inf = 3'000'000'000'000'000'007LL; //3e18+7
constexpr double Pi = 3.141592653589793;

template<class T> using prique     = priority_queue<T>;
template<class T> using prique_inv = priority_queue<T, vector<T>, greater<T>>;
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& rhs) { return is >> rhs.first >> rhs.second; }
template<class T, class U>inline ostream& operator<<(ostream& os, const pair<T, U>& rhs) { return os << rhs.first << " " << rhs.second; }
template<class InputIterator> void arrin(InputIterator first, InputIterator last) { for (; first != last; ++first) cin >> (*first); }
template<class InputIterator> void arrout(InputIterator first, InputIterator last) {
	for (; first != last; ++first) {
		cout << (*first) << ((first + 1) != last ? " " : "\n");
	}
}

bool pri(lint x) { 
	for (lint i = 2; i * i <= x; ++i) {
		if (x % i == 0) return false;
	}
	return 1 < x; 
}

lint fact[3000000];
void fact_init(lint n, lint m = Mod) {
	if (3000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1] % m;
	}
}

lint modpow(lint x, lint n, lint m = Mod) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

lint intpow(lint x, lint n) {
	lint res = 1;
	while (n > 0) {
		if (n & 1) res *= x;
		x *= x;
		n >>= 1;
	}
	return res;
}

lint comb(lint n, lint r, lint m = Mod) {
	if (r == 0 || r == n) return 1;
	lint res = fact[n] * modpow(fact[n - r], m - 2, m) % m * modpow(fact[r], m - 2, m) % m;
	return res < 0 ? res + m : res;
}

map<lint, lint> factring(lint n) {
	map<lint, lint> res;
	for (lint i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++res[i];
		}
	}
	if (n != 1) ++res[n];
	return res;
}

lint k, cnt;
int main() {
	cin >> k;
	rep(i, k + 10) {
		cnt += modpow(10, i, k);
		cnt %= k;
		if (cnt * 7 % k == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n, d;
	cin >> n >> d;
    d = 2 * d + 1;
    if(n % d) cout << n / d + 1;
    else cout << n / d;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int u,v,w;
}a[200005];
int fa[200005];
int find(int x){
	if(x!=fa[x])
		return fa[x]=find(fa[x]);
	return fa[x];
}
int cmp(node a,node b){
	return a.w<b.w;
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int u,v,w;
	int cnt=0;
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&a[cnt].u,&a[cnt].v,&w);
		a[cnt++].w=0;
	}
	for(int i=1;i<=n;i++)
		a[cnt].u=n+1,a[cnt].v=i,a[cnt++].w=1;
	for(int i=1;i<=n;i++)
		fa[i]=i;
	sort(a,a+cnt,cmp);
	int ans=0;
	for(int i=0;i<cnt;i++){
		int fx=find(a[i].u),fy=find(a[i].v);
		if(fx!=fy){
			ans+=a[i].w;
			fa[fy]=fx;
		}
		else continue;
	}
	printf("%d\n",ans); 
}

Measured memory_bytes: 3200
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int K = scan.nextInt();
		String S = scan.next();
		
		
		int s = S.length();
		
		if(K >= s) {
			System.out.println(S);
		}else {
			System.out.println(S.substring(0,K) + "...");
		}
	}
}

Measured memory_bytes: 38492