akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int t=0,l;
string s;
void f(int x)
{
	if(x==l)
	{
		t=1;
		return;
	}
	if(x>l)
	return;
	if(s[x]=='d'&&s[x+1]=='r'&&s[x+2]=='e'&&s[x+3]=='a'&&s[x+4]=='m')
	f(x+5);
	if(s[x]=='e'&&s[x+1]=='r'&&s[x+2]=='a'&&s[x+3]=='s'&&s[x+4]=='e')
	f(x+5);
	if(s[x]=='e'&&s[x+1]=='r'&&s[x+2]=='a'&&s[x+3]=='s'&&s[x+4]=='e'&&s[x+5]=='r')
	f(x+6);
	if(s[x]=='d'&&s[x+1]=='r'&&s[x+2]=='e'&&s[x+3]=='a'&&s[x+4]=='m'&&s[x+5]=='e'&&s[x+6]=='r')
	f(x+7);
}
int main()
{
	cin>>s;
	l=s.size();
	f(0);
	if(t)
	printf("YES");
	else
	printf("NO");
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] in = s.nextLine().split(" ");
        int a = Integer.parseInt(in[0]);
        int b = Integer.parseInt(in[1]);
        if((b-a) % 2 != 0){
            System.out.println("IMPOSSIBLE");
        }else{
            System.out.println((b-a) / 2 + a);
        }
    }
}

Measured memory_bytes: 21844
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>

using namespace boost::multiprecision;
*/

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define debug(aa, a) fprintf(stderr, aa, a)

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	unordered_map<string, bool> dic;
	string s, t;
	rep(i, n) {
		cin >> s >> t;
		if (s == "insert")dic[t] = true;
		else printf("%s\n", dic[t] ? "yes" : "no");
	}

	Please AC;
}



Measured memory_bytes: 50224
N, Q = map(int, input().split())
str = input()
length = [list(map(int, input().split())) for _ in range(Q)]

ans = [0 for _ in range(N)]
for i in range(1, N):
    if (str[i-1] == "A") and (str[i] == "C"):
        ans[i] = ans[i-1] + 1
    else:
        ans[i] = ans[i-1]

for l1, l2 in length:
    # print(ans)
    print(ans[l2-1] - ans[l1-1])


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

int main(){
	string s;
	cin >> s;
	
	bool ans=true;
	
	if(s.size()<6) ans=false;
	
	int a=0, b=0, c=0;
	for(int i=0; i<s.size(); ++i){
		if('0'<=s[i] && s[i]<='9') a++;
		else if('A'<=s[i] && s[i]<='Z') b++;
		else if('a'<=s[i] && s[i]<='z') c++;
	}
	
	if(a==0 || b==0 || c==0) ans=false;
	
	if(ans) printf("VALID\n");
	else printf("INVALID\n");
}

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

int main()
{
    long long int d, n;
    cin >> d >> n;
    if(d==0)
    {
        if(n==100)
            cout << 101 << endl;
        else
            cout << n << endl;
    }
    else if(d==1)
    {
        if(n!=100)
        cout << n*100 << endl;
        else
            cout << 101*100 << endl;
    }
    else if(d==2)
    {
        if(n!=100)
        cout << n*10000 << endl;
        else
            cout << 101*10000 << endl;

    }
    return 0;
}










Measured memory_bytes: 256
"""
author : halo2halo
date : 30, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B, C = readline().decode('utf8').split()

print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 50;
int n;
int a[MAX_N];

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];

  int max_i = 0, max_v = 0;
  REP(i, n) {
    if(abs(a[i]) > max_v) {
      max_i = i;
      max_v = abs(a[i]);
    }
  }

  cout << 2 * n - 1 << endl;

  REP(i, n) {
    a[i] += a[max_i];
    cout << max_i + 1 << " " <<  i + 1 << endl;
  }

  if(a[max_i] >= 0) {
    REP(i, n - 1) {
      if(a[i] > a[i + 1]) {
        a[i + 1] += a[i];
        cout << i + 1 << " " << i + 2 << endl;
      }
      else {
        a[i + 1] += a[i + 1];
        cout << i + 2 << " " << i + 2 << endl;
      }
    }
  } else {
    REP(i, n - 1) {
      if(a[n - 2 - i] > a[n - 1 - i]) {
        a[n - 2 - i] += a[n - 1 - i];
        cout << n - i << " " << n - i - 1 << endl;
      }
      else {
        a[n - 2 - i] += a[n - 2 - i];
        cout << n - 1 - i << " " << n - 1 - i << endl;
      }
    }
  }


  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[105][20];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
        scanf("%s",s[i]);
    for(int i = 0; i < n-1; i++)
    {
        int len = strlen(s[i]);
        //int len2 = strlen(s[i+1]);
        if(s[i][len-1] != s[i+1][0])
        {
            printf("No\n");
            return 0;
        }
    }
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++)
        {
            if(strcmp(s[i],s[j]) == 0)
            {
                printf("No\n");
                return 0;
            }
        }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    long long l,r,i,j,ans=2000000000;
    cin>>l>>r;
    //for(i=1;r>=i*2019;i++)
    if(r-l>=2019)ans=0;
    else{
        for(i=l;i<r;i++)
            for(j=l+1;j<=r;j++)
                ans=min(ans,i*j%2019);
    }
    cout<<ans<<endl;
}
    


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

int main()
{
  int h[2];
  int k[2];
  int a, b, c, d;
  int kanade = 0, hayami = 0;
  
  cin >> h[0] >> h[1] >> k[0] >> k[1];
  cin >> a >> b >> c >> d;

  kanade += h[0] * a + h[1] * b;
  kanade += h[0] / 10 * c + h[1] / 20 * d;
  hayami += k[0] * a + k[1] * b;
  hayami += k[0] / 10 * c + k[1] / 20 * d;

  if (kanade > hayami) {
    cout << "hiroshi" << endl;
  } else if (kanade < hayami) {
    cout << "kenjiro" << endl;
  } else {
    cout << "even" << endl;
  }
}

Measured memory_bytes: 3124
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d%d", &n, &m)
	a := make([]int, n)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}

	sa := make([]int, n+1)
	sa[0] = 0
	for i := 0; i < len(a); i++ {
		sa[i+1] = (sa[i] + a[i]) % m
	}

	c := map[int]int{}
	for _, e := range sa {
		c[e]++
	}

	ans := 0
	for _, v := range c {
		ans += v * (v - 1) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 8576
from collections import defaultdict
import sys
sys.setrecursionlimit(10000)
N,M=list(map(int,input().split()))
links=defaultdict(list)
for i in range(M):
    a,b=list(map(int, input().split()))
    links[a].append(b)
    links[b].append(a)
ct=0
visited=[False]*N
def DFS(idx):
    global visited
    if all(visited):
        global ct
        ct+=1
        return
    for i in links[idx]:
        if visited[i-1]:
            continue
        visited[i-1]=True
        DFS(i)
        visited[i-1]=False
visited[0]=True
DFS(1)
print(ct)

Measured memory_bytes: 3316
N, X, Y = map(int, input().split())
X-=1
Y-=1
S=[0 for j in range(N)]
for i in range(N):
    for j in range(i+1,N):
        S[min(j-i,abs(i-X)+1+abs(Y-j))]+=1
for i in range(1,N):
    print(S[i])

Measured memory_bytes: 3444
from collections import Counter
n = int(input())
v_input = list(map(int,input().split()))

odd_li = []
even_li = []
for i in range(n):
    if i%2==0:
        odd_li.append(v_input[i])
    else:
        even_li.append(v_input[i])

odd_count = sorted(Counter(odd_li).items(),key=lambda x:x[1],reverse=True)
even_count = sorted(Counter(even_li).items(),key=lambda x:x[1],reverse=True)

odd_max = odd_count[0][0]
even_max = even_count[0][0]

if odd_max==even_max and len(odd_count)==1:
    ans = n//2

elif odd_max==even_max:
    odd_next = odd_count[1][1]
    even_next = even_count[1][1]
    ans = n//2-odd_count[0][1] + n//2 - max(odd_next,even_next)
else:
    ans = n//2-odd_count[0][1] + n//2 - even_count[0][1]

print(ans)



Measured memory_bytes: 21212
n, m = map(int, input().split())
parents = [-1] * n

def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    else:
        if parents[x] > parents[y]:
            x, y = y, x
        parents[x] += parents[y]
        parents[y] = x
        return True

def size(x):
    return -parents[find(x)]

for _ in range(m):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)
max = 0
for x in range(n):
    s = size(x)
    if s > max:
        max = s
print(max)

Measured memory_bytes: 75884
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll A[200001];
	int count=0;
	scan(N);
	rep(i,N){
		scan(A[i]);
		if(A[i]%2) count++;
	}
	if(count%2) prin("NO");
	else prin("YES");
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll ans;
ll n;
ll dx[3]={3,5,7};
void saiki(ll x){
  for(int i=0;i<3;i++){
    ll tmp=x*10+dx[i];
    if(tmp<=n){
      ll ok=1;
      ll o=tmp;
      for(int j=0;j<10;j++){
        if(o%10==3&&ok%3!=0) ok*=3;
        else if(o%10==5&&ok%5!=0) ok*=5;
        else if(o%10==7&&ok%7!=0) ok*=7;
        o/=10;
        if(o==0) break;
      }
      if(357<=tmp&&ok%105==0) ans++;
      //cout<<tmp<<endl;
      saiki(tmp);
    }
  }
  return;
}

int main(){
  cin>>n;

  saiki(0);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<long long> a(n), b(n);
  for(auto & i : a) cin >> i;
  for(auto & i : b) cin >> i;
  vector<long long> dt;
  for(int i = 0; i < n; i++) dt.push_back(a[i] - b[i]);
  sort(dt.rbegin(), dt.rend());
  if(dt.back() >= 0){
    cout << 0 << endl;
    return 0;
  }
  long long negative = 0;
  int negs = 0;
  for(int i = 0; i < n; i++) if(dt[i] < 0) negative += dt[i], negs++;
  long long positive = 0;
  for(int i = 0; i < n; i++) {
    if(dt[i] <= 0) break;
    positive += dt[i];
    if(positive >= -negative){
      cout << i + 1 + negs << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
  


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  vector<bool> flag(N, true);
  for (int i = 0; i < N; i++) cin >> H[i];

  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--, B--;
    if (H[A] >= H[B]) {
      flag[B] = false;
    }
    if (H[A] <= H[B]) {
      flag[A] = false;
    }
  }

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

Measured memory_bytes: 3788
# frozen_string_literal: true

l, r = gets.split.map(&:to_i)
min = 2018

l.upto([l + 2018, r].min) do |i|
  (i + 1).upto([i + 2019, r].min) do |j|
    min = [i * j % 2019, min].min
  end
end

puts min

Measured memory_bytes: 1788
#include <stdio.h>
 
int main(void)
{
 
    int x, n;
    int i, j, m, sum;
 
 
    while(1){
        scanf("%d %d", &n, &x);
 
        sum = 0;        
 
        if(n == 0 && x == 0){break;}
 
        for(i=1;i<=n-2;i++){
            for(j=i+1;j<=n-1;j++){
                for(m=j+1;m<=n;m++){
                    if(i+j+m == x && i!=j && i!=m && j!=m){
                       
                        sum += 1;
                     }
                }
            }
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define fifo ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define ll long long int
#define w(t) ll t; cin>>t; while(t--)
#define pb push_back
#define vll vector<long long int>
#define vi vector<int>
#define mp make_pair
/*
ll GCD(ll a,ll b)
{
	if(b==0)
	return a;
	else
	return GCD(b,a%b);
}


ll x,y,d;       //d is gcd x and y are coefficients
void exten_euclid(ll a,ll b)
{	ll temp;
	if(b==0)
	{
		d=a;
		x=1;
		y=0;	
	}
	else
	{
		exten_euclid(b,a%b);
		temp=x;
		x=y;
		y=temp-(a/b)*y;	
	}
return;
}

ll fastModExp(ll a,ll b)
{
	ll res=1;
	while(b>0)
	{
		if(b&1)
		res=(res*a)%m;
	a=(a*a)%m;
	b=b>>1;	
	}
return res;
}


bool isPrime(ll n) {
	if(n==1)
      return false;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            return false;               //O(root(N))
        }
    }
    return true;
}

vector<ll> factorize(ll n) {
    vector<ll> res;
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if (n != 1) {
        res.push_back(n);
    }
    return res;
}

/*************FACTORIZE IN 0(LOG(N)) PROVIDED N IS INTEGER**************

int minPrime[100000];

void modified_sieve(int n){
for (int i = 2; i * i <= n; ++i) {
    if (minPrime[i] == 0) {         //If i is prime
        for (int j = i * i; j <= n; j += i) {
            if (minPrime[j] == 0) {
                minPrime[j] = i;
            }
        }
    }
}
for (int i = 2; i <= n; ++i) {
    if (minPrime[i] == 0) {
        minPrime[i] = i;
    }
}
}

vector<int> factorize(int n) {
    vector<int> res;
    while (n != 1) {
        res.push_back(minPrime[n]);
        n /= minPrime[n];
    }
    return res;
}

/*************************************************
void sieve(int N) {
        bool isPrime[N+1];
        for(int i = 0; i <= N;++i) {
            isPrime[i] = true;
        }
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {                    
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }

ll binomialCoeff(ll n, ll k)  
{  
    ll res = 1;  
  
    // Since C(n, k) = C(n, n-k)  
    if ( k > n - k )  
        k = n - k;  
  
    // Calculate value of  
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]  
    for (ll i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
}  



*/
int main()
{
fifo;
double l;
cin>>l;
double r=l/3;
double q=r*r*r;
cout<<fixed<<setprecision(12)<<q;
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int a[105];
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	std::sort(a+1,a+n+1);
	int ans=1;
	for(int i=2;i<=n;i++)
	if(a[i]!=a[i-1]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

int main() {

        int days [13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        int m1, d1, m2, d2;
        cin >> m1 >> d1;
        cin >> m2 >> d2;

        if( days[m1] == d1 ){
                puts("1");
        }
        else puts("0");

        return 0;
}


Measured memory_bytes: 256
#[test]
fn test_solve() {
    assert_eq!(solve("5\n6 9 4 2 11\n"), "11 6\n");
    assert_eq!(solve("2\n100 0\n"), "100 0\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    let &&n = &a.iter().max().unwrap();
    let m = n as f64 / 2.0;
    let r = &a
        .iter()
        .filter(|&&x| x != n)
        .min_by(|&&a, &&b| {
            (a as f64 - m)
                .abs()
                .partial_cmp(&(b as f64 - m).abs())
                .unwrap()
        })
        .unwrap();
    format!("{} {}\n", n, r)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


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

using namespace std;;

int main() {
	int N;
	cin >> N;
	if (N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10 || N == 13  || N == 17) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

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

int main(void) {
  char c;
  vector<char> v{'a', 'e', 'i', 'o', 'u'};
  cin >> c;
  if (count(v.begin(), v.end(), c)) cout << "vowel";
  else cout << "consonant";
}

Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val graph: Array[List[(Int, Int)]] = Array.fill[List[(Int, Int)]](N+1)(Nil) // (node, cost)

  for(_ <- 1 to M) {
    val L, R, D = in.next().toInt

    graph(L) = (R, D) :: graph(L)
    graph(R) = (L, -D) :: graph(R)
  }


  val dp = Array.fill[Option[Long]](N+1)(None)

  var ans = true
  breakable {
    for(i <- 1 to N) {
      if(dp(i).isEmpty) {
        val q = new scala.collection.mutable.Queue[(Int, Long)] // (node, cost)
        dp(i) = Some(0)
        q.enqueue((i, 0))

        while(!q.isEmpty) {
          val (nowNode, nowCost) = q.dequeue

          for((nextNode, nextCost) <- graph(nowNode)) {
            val sumCost = nextCost + nowCost
            dp(nextNode) match {
              case None =>
                dp(nextNode) = Some(sumCost)
                q.enqueue((nextNode, sumCost))
              case Some(cost) =>
                if(cost != sumCost) {
                  ans = false
                  break
                }
            }
          }
        }
      }
    }
  }

  if(ans)
    println("Yes")
  else
    println("No")
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}



Measured memory_bytes: 103692
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
ll n, w;
	cin >> n >> w;
 
	ll wts[n + 1];
	ll vals[n + 1];
	ll max_val = 0;
	for (int i = 1; i <= n; i++)
	{	cin >> wts[i];
		cin >> vals[i];
		max_val += vals[i];
	}
 
 
	ll dp[n + 1][max_val + 1];
 
 
 
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j <= max_val; j++)
		{
			dp[i][j] = INT_MAX;
		}
	}
 
	for (int i = 0; i <= n; i++)
		dp[i][0] = 0;
 
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= max_val; j++)
		{
			if (j - vals[i] >= 0)
				dp[i][j] = min(dp[i - 1][j - vals[i]] + wts[i], dp[i - 1][j] );
			else
				dp[i][j] = dp[i - 1][j];
		}
	}
 
	int ans = 0;
 
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= max_val; j++)
		{
			if (dp[i][j] <= w)
				ans = max(ans, j);
		}
	}
	cout << ans << endl;
 
}
 
 

Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, z = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int c = 0;
        for (int j = 1; j <= i; j++) if (i % j == 0) c++;
        if (i % 2 && c == 8) z++;
    }
    cout << z;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<int64_t> factors(int64_t n) {
  vector<int64_t> result;
  for (int64_t d = 1; d * d <= n; d++) {
    if (n % d == 0) {
      result.push_back(d);
      if (n / d != d) {
        result.push_back(n / d);
      }
    }
  }
  return result;
}

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

  auto f1 = factors(N);
  auto f2 = factors(N - 1);

  copy(f2.begin(), f2.end(), back_inserter(f1));

  int64_t result = 0;
  for (int64_t f : f1) {
    if (f == 1) {
      continue;
    }
    int64_t x = N;
    while (x % f == 0) {
      x /= f;
    }
    if (x % f == 1) {
      result++;
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    int n, m;
    cin >> n >> m;
    do
    {
        vector<int> c(m);
        rep(i, m) cin >> c[i];
        vector<int> x(n);
        rep(i, n) cin >> x[i];

        vector<vector<ll>> dp(n + 1, vector<ll>(256, INT32_MAX));
        dp[0][128] = 0;
        rep(i, n) rep(j, m) rep(k, 256)
        {
            int p = min(255, max(0, k + c[j]));
            ll d = x[i] - p;

            chmin(dp[i + 1][p], dp[i][k] + d * d);
        }

        ll ans = min_element(dp[n].begin(), dp[n].end())[0];

        cout << ans << endl;
        cin >> n >> m;
    } while (n != 0 && m != 0);

    return 0;
}


Measured memory_bytes: 43888
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
dtmin=10**6
ans=-1
for i in range(N):
  dt=abs(A-(T-0.006*H[i]))
  if(dt<dtmin):
    ans=i+1
    dtmin=dt
    
print(ans)


Measured memory_bytes: 3060
//itp1_topic2_a
#include <bits/stdc++.h>
using namespace std;
      int main(){
      int a,b; 
      cin>>a>>b;

      if ( a < b ) cout<<"a < b"<<endl;
      if ( a > b ) cout<<"a > b"<<endl;
      if ( a == b ) cout<<"a == b"<<endl;


      return 0;
}


Measured memory_bytes: 3104
#include <cstdio>
#include <algorithm>
using namespace std;
 
#define INF 0x7fffffff
 
int n;
int dp[100001];
 
int main() {
    scanf("%d", &n);
    fill(dp, dp+n, INF);
    for (int i=0; i<n; i++) {
        int a;
 
        scanf("%d", &a);
        *lower_bound(dp, dp+n, a) = a;
    }
 
    printf("%ld\n", lower_bound(dp, dp+n, INF) - dp);
}

Measured memory_bytes: 3116
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
import sys

INF = 1145141919


def solve(N: int, S: "List[str]"):
    def list_uniq_count(l):
        return len(set(l))
    return list_uniq_count(S)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(solve(N, S))


if __name__ == '__main__':
    main()


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

typedef long long ll;

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


int main(){
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x >> y;

    cout << gcd(x,y) << endl;
}



Measured memory_bytes: 3188
from bisect import bisect,bisect_left
MAXN = 1000002
ham = [False]*MAXN
def func(n):
    if not (n>MAXN or ham[n]):
        ham[n] = True
        for m in [2,3,5]:
            func(m*n)
func(1)
H = filter(lambda i:ham[i],xrange(MAXN))
while True:
    line = raw_input()
    if line == "0":
        break
    m,n = map(int,line.split())
    print bisect(H,n)-bisect_left(H,m)

Measured memory_bytes: 27628
#include <iostream>

using namespace std;


int main(){
  int N;
  int *data;
  cin>>N;

  data=new int[N];

  int cn=0;
  for(int i=0;i<N;i++){
    cin>>data[i];
  }
  for(int i=1;i<N-1;i++){
    //if(data[0]<data[i] && data[i]<data[i+1])cn++;
    if(data[i-1]<data[i] && data[i]<data[i+1])cn++;//cout<<data[i]<<endl;
    else if(data[i-1]>data[i] && data[i]>data[i+1])cn++;
  }

  cout<<cn<<endl;
  
  return 0;

}


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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());

            string[] b = Console.ReadLine().Split(' ');

            string kota = "";
            for(int i =0; i <a; i++)
            {
                kota += b[0][i];
                kota += b[1][i];
            }
            Console.WriteLine(kota);
        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>
using namespace std;
static const long long INFTY = 10000000000;
long long a[100000];
long long dp[100000];


int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    fill(dp, dp+n, INFTY);
    for (int i = 0; i < n; i++) {
        *lower_bound(dp, dp+n, a[i]) = a[i];
    }
    printf("%ld\n", lower_bound(dp, dp+n, INFTY)-dp);

    return 0;
}



Measured memory_bytes: 4296
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const ll INF = ((1ll<<31)-1ll);
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

//https://github.com/beet-aizu/library/blob/master/segtree/basic/ushi.cpp
template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;

  SegmentTree(){}
  SegmentTree(F f,T ti):f(f),ti(ti){}

  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }

  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }

  void set_val(int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(int a,int b){ //[a,b)
    if(a>=b) return ti;
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }

  template<typename C>
  int find(int st,C &check,T &acc,int k,int l,int r){
    if(l+1==r){
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1;
    }
    int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }

  template<typename C>
  int find(int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int n,q; cin >> n >> q;
    auto f=[](int a,int b){return min(a,b);};
    SegmentTree<int> seg(f,INF);
    vi a(n,INF);
    seg.build(a);
    rep(i,q){
        int com,x,y; cin >> com >> x >> y;
        if(com==0){
            seg.set_val(x,y);
        }
        else {
            cout << seg.query(x,y+1) << endl;
        }
    }
}


Measured memory_bytes: 5748
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    S = readline().rstrip()
    e_right = S.count('E')
    w_right = S.count('W')
    e_left, w_left = 0, 0
    res = N
    for i in range(N):
        if S[i] == 'E':
            e_right -= 1
            res = min(res, e_right + w_left)
            e_left += 1
        else:
            w_right -= 1
            res = min(res, e_right + w_left)
            w_left += 1
    
    print(res)

if __name__ == '__main__':
    main()

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

using namespace std;

const int MaxN = 1001;
const int MaxM = 10001;

int N, M;

int main() {
  int count[MaxM];

  while(cin>>N>>M && !(N==0 && M==0)) {
    vector < vector< pair<int,int> > > logg(MaxM);
    int r;
    cin>>r;
    int t,n,m,s;
    for(int i=0; i<MaxM; i++) { // init
      count[i] = 0;
    }
    for(int i=0; i<r; i++) {
      cin>>t>>n>>m>>s;
      if(s == 1) { // login
	count[m]++;
	if(count[m] == 1) {
	  logg[m].push_back(make_pair(t,t));
	}
      }
      else { // logout
	count[m]--;
	if(count[m] == 0) {
	  logg[m].back().second = t;
	}
      }
    }
    int q;
    cin>>q;
    for(int i=0; i<q; i++) {
      int ts, te, m, ans = 0;
      cin>>ts>>te>>m;
      int ans1, ans2; // 4debug ans1は誤りらしい; エラーデータを弾けないから?
      for(int j=0; j<logg[m].size(); j++) {
	
	if(logg[m][j].first == logg[m][j].second) {
	  logg[m][j].second = te;
	}
	
	if(logg[m][j].first < te) {
	  ans1 = min(te, logg[m][j].second)-max(ts, logg[m][j].first);
	}
	else {
	  ans1 = 0;
	}
	ans2 = max(0, min(te,logg[m][j].second)-max(ts,logg[m][j].first));
	
	/*
        if(ans1!=ans2) {
	  cout<<"Q: "<<ts<<" "<<te<<endl;
	  cout<<"why: "<<min(te, logg[m][j].second)-max(ts, logg[m][j].first)<<endl;
	  cout<<"val: "<<logg[m][j].first<<" "<<logg[m][j].second<<endl;
	  cout<<"ans: "<<ans1<<" "<<ans2<<endl;
	}
	*/
	
        ans += ans2;
      }
      cout<<ans<<endl;
    }
  }
}

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

int main() {
	int com = 0;
	double a = 0;
	int an = 0;

	int ch = 0;
	int log = 0;

	cin >> com;

	a = com / 1.08;
	
	log = com;

	an = a;
	if (1 <= com && com <= 50000) {
		if (a > an ) {
			an += 1;
		}
		//cout << an;
		ch = an * 1.08;
		if (ch == log) {
			cout << an;
		}else{
			cout << ":(";
		}
	}else if(com < 1 || 50000<com){
		cout << ":(";
	}
	return 0;
}

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

int main(){
    //入力
    int A,B;
    cin >> A >> B;
    //出力
    if(A%3==0||B%3==0||(A+B)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



void func(long long N){

    lli sum=0;
    REP(i,1,N+1){
        sum += 800;
        if(i%15==0)sum-=200;
    }
    cout<<sum<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    func(N);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] vals = sc.nextLine().split(" ");
        long N = getLong(vals[0]);
        long K = getLong(vals[1]);
        long a = 0;
        long b = 0;
        for(long i = 1;i <= N;i++){
            if (i % K == 0) a++;
            if (K % 2 == 0 && i % K == K/2) b++;
        }
        System.out.println(a * a * a + b * b * b);
        sc.close();
    }
    static int getInt(String val) {
        return Integer.parseInt(val);
    }
    static long getLong(String val) {
        return Long.parseLong(val);
    }
}

Measured memory_bytes: 23252
// https://atcoder.jp/contests/abc133/tasks/abc133_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N;
    cin >> N;
    // ダムに溜まった量をA[i]、山に降った量をB[i]とする。
    // A[i] = (B[i] + B[i + 1]) / 2
    // B[0] = 0と仮定するとB[N] == B[0]となるはず（1周するため）
    // B[0]を1増やすとB[N]が1減るので、B[0]=(B[N]/2)を初期値にする。
    vector<int> A(N), B(N + 1);
    REP(i, N) cin >> A[i];
    B[0] = 0;
    FOR(i, 1, N + 1) { B[i] = A[i - 1] * 2 - B[i - 1]; }
    B[0] = B[N] / 2;
    FOR(i, 1, N + 1) { B[i] = A[i - 1] * 2 - B[i - 1]; }
    // 念のためB[0] == B[N]であることを確認
    assert(B[0] == B[N]);
    REP(i, N) { cout << B[i] << (i == N - 1 ? "\n" : " "); }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P, ll>;
using PP = pair<P ,P>;
constexpr ll MOD = 998244353;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()
 

template <typename Monoid>
struct SegmentTree{
private:
    using F = function<Monoid(Monoid, Monoid)>;
    int N;
    vector<Monoid> node;
    F f;
    Monoid e;  // identity element

public:
    SegmentTree(){}
    SegmentTree(F f, Monoid e):f(f), e(e){}
    void init(int sz){
        N = 1;
        while(N < sz) N <<= 1;
        node.assign(2*N-1, e);
    }
    void build(vector<Monoid>& v){
        int sz = int(v.size());
        init(sz);
        for(int i=0; i<sz; i++){
            node[i+N-1] = v[i];
        }
        for(int i=N-2; i>=0; i--){
            node[i] = f(node[i*2+1], node[i*2+2]);
        }
    }
    void update(int k, Monoid x){
        k += N-1;
        node[k] = x;
        while(k > 0){
            k = (k-1)/2;
            node[k] = f(node[2*k+1], node[2*k+2]);
        }
    }
    // [a,b)
    Monoid query(int a, int b){return query(a, b, 0, 0, N);}
    Monoid query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) return e;
        if(a <= l && r <= b) return node[k];
        Monoid vl, vr;
        vl = query(a, b, 2*k+1, l, (l+r)/2);
        vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

auto f = [=](ll a, ll b){return min(a, b);};
SegmentTree<ll> seg(f,LLINF/3);
 


int main(){
    int n, m;
    cin >> n >> m;
    vector<P3> ls(m);
    for(int i=0;i<m;i++){
        ll l, r, c;
        cin >> l >> r >> c;
        ls[i] = P3(P(l-1,r),c);
    }
    SORT(ls);
    seg.init(n);
    seg.update(0,0);
    for(int i=0;i<m;i++){
        ll l, r, c, dmin;
        l = ls[i].first.first;
        r = ls[i].first.second;
        c = ls[i].second;
        dmin = seg.query(l,r);
        seg.update(r-1, min(dmin+c, seg.query(r-1,r)));
    }
    ll ans = seg.query(n-1,n);
    if(ans < LLINF/3){
        cout << ans << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,b;
    cin>>a>>b;
    if(b==100){
        b++;
    }
    cout<<b;
    REP(i,a){
        cout<<"00";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

A = list(0 for _ in range(N))

ans = "No"

for i in range(N):
    if D[i][0] == D[i][1]:
        A[i] = 1

for i in range(N - 2):
    if A[i] == 1 and A[i+1] == 1 and A[i+2] == 1:
        ans = "Yes"


print(ans)


Measured memory_bytes: 9144
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7;
int n,s[101000],f[101000];
ll A,B,a[101000];
void upd(int &a,int b){a+=b;if(a>=mod) a-=mod;}
int main(){
	read(n);read(A);read(B);
	if(A>B) swap(A,B);
	for(int i=1;i<=n;i++){
		read(a[i]);
		if(i>2&&a[i]-a[i-2]<A){puts("0");return 0;}
		if(i>1) s[i]=s[i-1]+(a[i]-a[i-1]<A);
	}
	f[1]=1;int k=2;
	for(int i=1;i<=n;i++){
		while(k<=n&&a[k]-a[i]<B) k++;
		if(s[i]-s[i-1]==0) upd(f[i+1],f[i]);
		if(k==i+1||s[k-1]-s[i+1]==0) upd(f[k],f[i]);
	}
	cout<<f[n+1]<<'\n';
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <map>

using namespace std;

int main() {
    map<int, int> map;
    int a, max_ = 0;
    while (cin >> a) {
        if (map.find(a) != map.end()) {
            map[a] += 1;
            max_ = max(max_, map[a]);
        } else {
            map[a] = 1;
        }
    }

    for (auto a_ : map) {
        if (a_.second == max_) {
            cout << a_.first << endl;
        }
    }
}


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    vector<vector<int>> a(2, vector<int>(n));
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];

    for (int i = 1; i < n; ++i)
        a[0][i] += a[0][i - 1];

    a[1][0] += a[0][0];
    for (int i = 1; i < n; ++i) {
        a[1][i] += max(a[1][i - 1], a[0][i]);
    }

    cout << a[1][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

struct Data{
	llint T, D;
	Data(){}
	Data(llint a, llint b){
		T = a, D = b;
	}
	bool operator<(const Data& obj)const{
		if(obj.D == 0) return D != 0;
		if(D == 0) return false;
		return (double)T/D < (double)obj.T/obj.D;
	}
};

llint n;
llint h[40005], a[40005], d[40005], s[40005];
vector<Data> vec;

int main(void)
{
	cin >> n;
	for(int i = 0; i <= n; i++) cin >> h[i] >> a[i] >> d[i] >> s[i];
	
	bool pWin = true, mWin = false;
	for(int i = 1; i <= n; i++){
		if(a[0] - d[i] <= 0 && a[i] - d[0] > 0){
			pWin = false;
			break;
		}
	}
		
	if(!pWin){
		cout << -1 << endl;
		return 0;
	}
	
	for(int i = 1; i <= n; i++){
		if(a[0] - d[i] <= 0) continue;
		vec.push_back(Data( (h[i]+a[0]-d[i]-1)/(a[0]-d[i]), max(0LL, a[i] - d[0]) ) );
	}
	sort(vec.begin(), vec.end());
	
	llint ans = 0, sumT = 0;
	for(int i = 1; i <= n; i++){
		if(s[0] > s[i]) ans -= max(0LL, a[i] - d[0]);
	}
	for(int i = 0; i < vec.size(); i++){
		sumT += vec[i].T;
		ans += sumT * vec[i].D;
		if(ans >= h[0]){
			cout << -1 << endl;
			return 0;
		}
	}
	if(ans >= h[0]) ans = -1;
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 4976
class UnionFind:
    def __init__(self, n=1):
        self.parent = [i for i in range(n)]
        self.rank = [0] * n
    
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.parent[y] = x
    
    def is_same(self, x, y):
        return self.find(x) == self.find(y)


N, M, K = map(int, input().split())
uf = UnionFind(N)
count_friends = [1] * N
for i in range(M):
  a, b = map(int, input().split())
  uf.union(a-1, b-1)
  count_friends[a-1] += 1
  count_friends[b-1] += 1


parents = [uf.find(i) for i in range(N)]
par_dict = {}
for p in parents:
  if p in par_dict:
    par_dict[p] += 1
  else:
    par_dict[p] = 1

count_block = [0] * N
for i in range(K):
  c, d = map(int, input().split())
  if parents[c-1] == parents[d-1]:
    count_block[c-1] += 1
    count_block[d-1] += 1

ans = [-1]*N
for i in range(N):
  p = parents[i]
  ans[i] = par_dict[p] - count_friends[i] - count_block[i]

print(*ans)

Measured memory_bytes: 22688
N = gets.to_i
L = gets.strip.split.map(&:to_i)

L.sort!
result = 0
(0..N - 3).each do |i|
    (i + 1..N - 2).each do |j|
        t = L[i] + L[j]
        idx = L.bsearch_index{|x| x >= t}
        result += (idx ? idx : L.size) - j - 1
    end
end
puts result


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    string x,y;
    int ans = 0;
    cin >> x >> y;

    rep(i,3){
        if(x.at(i) == y.at(i)){
            ans++ ;
        }
    }

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

Measured memory_bytes: 256
from pprint import pprint

n,W = map(int,input().split())
vw = [ list(map(int,input().split())) for _ in range(n) ]

dp = [ [0]*(W+1) for _ in range(n+1) ]
for i in range(n):
    for j in range(W+1):
        v = vw[i][0]
        w = vw[i][1]
        if w<=j:
            dp[i+1][j] = max( dp[i][j-w]+v, dp[i][j] )
        else:
            dp[i+1][j] = dp[i][j]
# pprint(dp)
print( dp[n][W] )


Measured memory_bytes: 42904
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            int[][] ab = new int[N][];

            for (int i = 0; i < N; i++)
            {
                int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                ab[i] = new int[] { nbrs[0], nbrs[1] };
            }

            Array.Sort(ab, new Comparison<int[]>(
    (x, y) => { return x[1] < y[1] ? -1 : (x[1] > y[1] ? 1 : 0); }
));

            string res = "Yes";
            int time = 0;

            for (int i = 0; i < N; i++)
            {
                time += ab[i][0];

                if (ab[i][1] < time)
                {
                    res = "No";
                    break;
                }
            }

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 28196