akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, D: "List[List[int]]"):
    cnt = 0
    for i in range(len(D)):
        d1, d2 = [int(t) for t in D[i]]
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            return YES
    return NO


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  # type: "List[List[int]]"
    print(solve(N, D))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
ID = [LIST() for _ in range(M)]
ID_t = [list(x) for x in zip(*ID)]

tmp = min(ID_t[1]) - max(ID_t[0])

print(tmp + 1 if tmp >= 0 else 0)

Measured memory_bytes: 87256
#include<iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main(){

	int i,j,n;
	int a[3];

	cin >> n;
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			cin >> a[j];
		}
		sort(a,a+3);
		if(a[0]*a[0]+a[1]*a[1] == a[2]*a[2]){
			cout << "YES";
		}else{
			cout << "NO";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
def search(graph, n):
  result = [[] for _ in range(n)]
  if(1 in graph):
    result[0] = [1]
    for nxt in graph[1]:
      if(nxt in graph):
        result[1].append([1, nxt])
        if(2 == n):
          continue
        for nxt2 in graph[nxt]:
          if(nxt2 in graph):
            result[2].append([1, nxt, nxt2])
            if(3 == n):
              continue
            for nxt3 in graph[nxt2]:
              if(nxt3 in graph):
                result[3].append([1, nxt, nxt2, nxt3])
                if(4 == n):
                  continue
                for nxt4 in graph[nxt3]:
                  if(nxt4 in graph):
                    result[4].append([1, nxt, nxt2, nxt3,nxt4])
                    if(5 == n):
                      continue
                    for nxt5 in graph[nxt4]:
                      if(nxt5 in graph):
                        result[5].append([1, nxt, nxt2, nxt3,nxt4,nxt5])
                        if(6 == n):
                          continue
                        for nxt6 in graph[nxt5]:
                          if(nxt6 in graph):
                            result[6].append([1, nxt, nxt2, nxt3,nxt4,nxt5,nxt6])
                            if(7 == n):
                              continue
                            for nxt7 in graph[nxt6]:
                              if(nxt7 in graph):
                                result[7].append([1, nxt, nxt2, nxt3,nxt4,nxt5,nxt6,nxt7])
  return result

n, m = list(map(int, input().split()))
route = [False for _ in range(n)]
gh = {}
for i in range(m):
  start,end = list(map(int, input().split()))
  if(start in gh):
    gh[start].add(end)
  else:
    gh[start] = {end}
  if(end in gh):
    gh[end].add(start)
  else:
    gh[end] = {start}
    
ans = search(gh,n) 
cnt = 0
for arr in ans[n-1]:
  if(set(arr) == {i for i in range(1, n+1)}):
    cnt +=1
print(cnt)

Measured memory_bytes: 177196
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Control.Monad.State
import Data.Array.Unboxed

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve n <$> getLine >>= putStrLn
    main

solve :: Int -> String -> String
solve n xs = f $ execState (game xs (cycle [1..n])) (listArray (1,n) (repeat 0), 0)
  where
    f (a,f) = (unwords . map show . sort . elems) a ++ " " ++ show f

game :: String -> [Int] -> State (UArray Int Int, Int) ()
game [] _ = return ()
game (b:bs) (i:is) = do
  (a,f) <- get
  case b of
   'M' -> put (accum (+) a [(i,1)], f)
   'L' -> put (accum (+) a [(i,1 + f)], 0)
   'S' -> put (a // [(i,0)],f + a ! i + 1)
  game bs is

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4128
n = int(input())
T = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
p = 10 ** 9 + 7

B = [10**9] * n

if max(T) != max(A):
    print(0)
    exit()

h = 0

for i, t in enumerate(T):
    if h < t:
        B[i] = 1
        h = t
    else:
        B[i] = h

h = 0

for i, a in zip(range(n-1, -1, -1), A[::-1]):
    if h < a:
        B[i] = 1
        h = a
    elif B[i] == 1 and T[i] > A[i]:
        print(0)
        exit(0)
    elif B[i] > h:
        B[i] = h

ans = 1

for b in B:
    ans *= b
    ans %= p

print(ans)

Measured memory_bytes: 19648
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

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

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

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;

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

void solve(){
	string s;
	cin>>s;
	sort(all(s));
	if(s[0]!=s[1]||s[2]!=s[3]||s[0]==s[2]){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}
	


}
	
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;	
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int t,n;
int __a[333333],*a=__a+155555,__b[333333],*b=__b+155555,*exc;
inline int top()
{
	register int i,ii;
	if(b[0]==b[1]||b[0]==b[-1])return b[0];
	for(i=1,ii=-1;i<t;i++,ii--)
	{
		if(b[i+1]==b[i])goto T;
		if(b[ii-1]==b[ii])goto S;
	}return(t&1)^b[0];
	T:return b[i];
	S:return b[ii];
}
inline int valid(int mid)
{
	register int i;
	for(i=-t;i<=t;i++)
		b[i]=(a[i]>=mid);
	return top();
}
int main()
{
	scanf("%d",&n);
	register int i,ii;
	t=n-1;
	for(i=-t;i<=t;i++)
		scanf("%d",&a[i]);
	int l=1,r=2e9;
	while(l+1<r)
	{
		int mid=(l+r)>>1;
		if(valid(mid))l=mid;
		else r=mid;
	}printf("%d\n",l);
}

Measured memory_bytes: 1792
#include<string.h>
#include<stdio.h>
int main()
{
    char s[15],a[15];
    gets(s);
    int len =strlen(s);
    int l=0;
    for(int i=0;i<len ;i++)
    {
        if(s[i]=='0'||s[i]=='1')
        a[l++]=s[i];
        if(s[i]=='B'&&l>=1)
            l--;
    }
    for(int i=0;i<l;i++)
    printf("%c",a[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env ruby

word = [];numbers = []
i = 0
sharp = "#";dot = "."
loop do 
    word = gets.split.map(&:to_i)
    if word[0] == 0 and word[1] == 0 then; break; end
    word.each do |key|
        numbers << key
    end
end

((numbers.count + 1) / 2).times do
    numbers[i].times do |index|
        if index == 0 or index == numbers[i] - 1 then
            puts sharp * numbers[i + 1]
        else
            print sharp,dot * (numbers[i + 1] - 2),sharp,"\n"
        end
    end
    puts ""
    i += 2 
end


Measured memory_bytes: 6900
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <bitset>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

ll gcd(ll a, ll b)
{
    if (a > b)
        std::swap(a, b);

    while (true)
    {
        auto m = b % a;
        if (m == 0)
            return a;
        b = a;
        a = m;
    }
}

int win(ll x, ll k)
{
    if (x >= k)
        return 0;
    int i = 1;
    while (x * (1ll << i) < k)
        ++i;

    return i;
}

int main()
{
    using namespace std;

    ll n, k;
    cin >> n >> k;

    long double p{};

    for (int i = 1; i <= n; ++i)
    {
        if (i < k)
        {
            auto x = win(i, k);
            p += powl(0.5l, x) / n;
        }
        else
        {
            p += 1.0l / n;
        }
    
    }

    cout << fixed << setprecision(15) << p << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int n,m,x,y,f[210000],cnt[210000];
int find(int k)
{
    if(f[k]==k)return k;
    return f[k]=find(f[k]);
}
int main(void)
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)f[i]=i;
    for(int i=1;i<=m;i++)
    {
        cin>>x>>y;
        f[find(x)]=find(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int fi=find(i);
        cnt[fi]++;
        ans=max(cnt[fi],ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7116
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<ll> a(n);
    for (ll &x : a) {
        cin >> x;
    }
    ll res = (ll) 1e18;
    auto check = [&](ll x) {
        ll ret = 0;
        for (ll y : a) {
            ret += (x - y) * (x - y);
        }
        return ret;
    };
    for (ll i = -1000; i < 1000; i++) {
        res = min(res, check(i));
    }
    cout << res;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    string s1;
    for(auto el : s) {
        if (el == 'B' and !s1.empty()) {
            s1.pop_back();
        } else if (el != 'B') {
            s1.push_back(el);
        }
    }
    cout << s1 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

int main() {
  int D; cin >> D;
  vector<LL> c(26); cin >> c;
  vector<vector<LL>> s(D, vector<LL>(26, 0));
  for (int i = 0; i < D; ++i) cin >> s[i];

  for (int d = 0; d < D; ++d) cout << (rand() % 26) + 1 << endl;
}


Measured memory_bytes: 3716
N = int(input())
#N,A,B = map(int,input().split())
V_list = list(map(int,input().split()))
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]
V_list = sorted(V_list)
result = (V_list[0] + V_list[1]) /2
for i in range(2,N):
    tmp = (result + V_list[i] )/2
    result = ((result + V_list[i]) /2)
print(result)


Measured memory_bytes: 3064
# input
N, M = map(int, input().split())
X = list(map(int, input().split()))

X.sort()
K = sorted(
    [
        abs(X[i] - X[i - 1])
        for i in range(1, M)
    ],
    reverse=True
)

print(sum(K[N - 1:]))

Measured memory_bytes: 13968
# frozen_string_literal: true

antena = []
5.times { antena << gets.chomp.to_i }
k = gets.chomp.to_i

flag = false
5.times do |i|
  5.times do |j|
    next if i == j

    flag = true if (antena[i] - antena[j]).abs > k
  end
end

puts flag ? ':(' : 'Yay!'


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 1000000007;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a;
  cin >> a;
  cout << a + a*a + a*a*a ;

}


Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  int m,f,r,i;
  int count=0;
  int S[50];
  while(1){
    int sum=0;
    scanf("%d%d%d", &m, &f, &r);
    if( m == -1 && f == -1 && r == -1) break;
    sum = m +f;
    if( m == -1 || f == -1)
      S[count] = 5;
    else if( sum >= 80)
       S[count] = 1;
    else if( sum >= 65)
       S[count] = 2;
    else if( sum >= 50)
       S[count] = 3;
    else if( sum >= 30){
      if( r >= 50)
	 S[count] = 3;
      else
	 S[count] = 4;
    }
    else
       S[count] = 5;
    count++;
  }
  for( i = 0; i < count; i++){
    if( S[i] == 1)
      printf("A\n");
    else if( S[i] == 2)
      printf("B\n");
    else if( S[i] == 3)
      printf("C\n");
    else if( S[i] == 4)
      printf("D\n");
    else
      printf("F\n");
  }

  return 0;
}




Measured memory_bytes: 2036
#include<cstdio>
#include<algorithm>
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
int a[2005];
int main()
{
	int n;
	scanf("%d",&n);
	int minn=0x7f,maxn=-1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		minn=min(minn,a[i]);
		maxn=max(maxn,a[i]);
	}
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(a[j]-a[i]>maxn){
				break;
			}
			for(int k=j+1;k<=n;k++){
				if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]){
					ans++;
				}else{
					break;
				}
			}
		}
	}
	printf("%d",ans);
	return 0;
}

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

int main()
{
	//ifstream in("test.txt");
	//cin.rdbuf(in.rdbuf());
	int n;
	cin >> n;
	vector<ll> a(n),b(n);
	for(int i = 0 ;i<n;i++)cin >> a[i];
	for(int i = 0 ;i<n-1;i++)
	{
		if(a[i]>a[i+1])
		{
			b[i]=a[i];
		}
	}
	b.back()=a.back();
	reverse(b.begin(),b.end());

	for(int i = 0;i<n-1;i++)
	{
		b[i+1] =max<ll>({0, b[i]-1,b[i+1]});
	}
	reverse(b.begin(),b.end());
	ll ans = 0;


	for(int i = 0;i<n;++i)
	{
		if(a[i]<b[i]||a[i]>i)
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	a.push_back(0);
	n++;
	ans = 0;
	reverse(a.begin(),a.end());
	for(int i = 0;i<n-1;i++)
	{
		if(a[i]!=a[i+1]+1)
		{
			ans += a[i+1];
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 6528
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        
        String str1 = N.substring(N.length()-1,N.length());
        
        if(str1.equals("s")){
            N = N+"es";
        }else{
            N =N+"s";
        }
        
        System.out.println(N);
    }
}


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

int main() {
  int a,b,i,M;
  cin >> a >> b;
  vector<int> vec(a);
  for(i=0;i<a;i++)vec[i]=b+i;
  M = 1000;
  int t=0;
  for(i=0;i<a;i++)if (M > abs(vec[i])) t = vec[i],M=abs(vec[i]);
  int S = accumulate(vec.begin(),vec.end(),0);

  cout << S - t << endl;
  
  
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] list = new int[n];

        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
        }

        int sum = 0;
        for (int i = 0; i < n; i++) {
            int value = list[i];
            for (int index = i + 1; index < n; index++) {
                sum += value * list[index];
            }
        }

        // 出力
        System.out.println(sum);
    }
}

Measured memory_bytes: 25172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Random;
import java.util.StringTokenizer;
public class Main{
       public static void main(String[] args){
            FastScanner scanner = new FastScanner(System.in);
            int a = scanner.nextInt();
            int b=scanner.nextInt();
            if(a>=b)for(int i=0;i<a;++i)System.out.print(b);
         	else for(int i=0;i<b;++i)System.out.print(a);
       }
       static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
 
        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
 
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int main()
{int n;
double d;
cin>>n>>d;
double x ,y;
int ans = 0;
for(int i = 0;i<n;i++)
{
    cin>>x>>y;
    if(x*x+y*y<=d*d)
    ans++;
}
cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int maxn=100005;

int n,q;
vector<int>G[maxn];
int fa[maxn],dep[maxn],size[maxn],son[maxn],top[maxn];

void dfs1(int u,int p) {
    size[u]=1;
    for (int v:G[u]) {
        if (v==p) continue;
        fa[v]=u;
        dep[v]=dep[u]+1;
        dfs1(v,u);
        size[u]+=size[v];
        if (size[son[u]]<size[v]) son[u]=v;
    }
}

void dfs2(int u,int t) {
    top[u]=t;
    if (son[u]) dfs2(son[u],t);
    for (int v:G[u])
        if (v!=fa[u] && v!=son[u])
            dfs2(v,v);
}

int lca(int u,int v) {
    while (top[u]!=top[v]) {
        if (dep[top[v]]<dep[top[u]]) swap(u,v);
        v=fa[top[v]];
    }
    return dep[u]<dep[v]?u:v;
}

int main() {
    cin>>n;
    for (int i=1;i<=n;i++) {
        int m; cin>>m;
        for (int j=0;j<m;j++) {
            int v; cin>>v; ++v;
            G[i].pb(v);
            G[v].pb(i);
        }
    }
    dfs1(1,0);
    dfs2(1,1);
    cin>>q;
    while (q--) {
        int u,v; cin>>u>>v; ++u; ++v;
        cout<<lca(u,v)-1<<'\n';
    }
}


Measured memory_bytes: 18384
#include <stdio.h>
#include <string.h>

int main(void){
	char text[1024];
	int i,n;
	fgets(text,1024,stdin);
	n=strlen(text);
	for(i=0;i<n-5;i++){
		if(strncmp(&text[i],"apple",5)==0){memcpy(&text[i],"peach",5);}
		else if(strncmp(&text[i],"peach",5)==0){memcpy(&text[i],"apple",5);}
	}
	printf("%s",text);
	return 0;
}

Measured memory_bytes: 524
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int s      = sc.nextInt();
        String str = sc.next();

        boolean[] way = new boolean[s];
        int e_num = 0;
        for(int i=0; i<s; i++){
            if(str.charAt(i) == 'E'){ way[i] = true; e_num++;}
            else                    { way[i] = false;        }
        }
        int count = 0;
        int min = e_num;
        for(int i=0; i<s; i++){
            if(way[i] == true){ count--; }
            else              { count++; }
            if(count + e_num < min)   { min = count + e_num; }
        }
        System.out.println(min);
    }
}

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

int main() {
	long long n, d;
	cin >> n >> d;
	long long d2 = d * d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		long long x, y;
		cin >> x >> y;
		if (x*x + y*y <= d2) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3176
import sys

numbers=input().rstrip().split(" ")
A=int(numbers[0])
B=int(numbers[1])
M=int(numbers[2])

ref=input().rstrip().split(" ")
mic=input().rstrip().split(" ")

koopons=[]
for line in sys.stdin.readlines():
    koopons.append(line.rstrip().split(" "))

'''print(A)
print(B)
print(M)
print(ref)
print(mic)
print(koopons)'''

prices=[]
for koopon in koopons:
    price=int(ref[int(koopon[0])-1])+int(mic[int(koopon[1])-1])-int(koopon[2])
    prices.append(price)
#print(prices)
lowest2=sorted(prices)[0]
refs=sorted(ref)
mics=sorted(mic)
lowest1=int(refs[0])+int(mics[0])
#print(lowest1)
#print(lowest2)
if lowest1>=lowest2:
    print(lowest2)
else:
    print(lowest1)

Measured memory_bytes: 58232
#include <iostream>

int main() {
  int N;
  std::cin >> N;
  long n, sum = 0;
  for (int i = 0; i < N; ++i) {
    std::cin >> n;
    sum += n;
  }
  std::cout << (sum % 2 == 0 ? "YES" : "NO") << std::endl;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    for (int i = 1; i < 10; i++)
    {
        int k = N;
        if(k / i <= 9 && k % i == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
### subroutines

def parse_num(str)
  num = 0
  while str[$pos] >= '0' && str[$pos] <= '9'
    num = num * 10 + str[$pos].to_i
    $pos += 1
  end
  num
end

def parse(str)
  return 'N/A' if str[$pos] != '['
  $pos += 1

  if str[$pos] >= '0' && str[$pos] <= '9'
    num = parse_num(str)
    $pos += 1
    return (num + 1) / 2
  end

  ds = []
  nds = 0
  while str[$pos] == '['
    ds << parse(str)
    nds += 1
  end
  $pos += 1
  
  ds.sort[0..(nds / 2)].inject(:+)
end

### main

n = gets.to_i

n.times do
  str = gets.strip
  $pos = 0
  
  puts parse(str)
end

Measured memory_bytes: 6160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> edge[1005],p,ans;
int vis[1005],now=0,len=1e9;
void dfs(int u,int root,int tag){
    if(tag&&root==u){
        if(len>p.size()){
            len=p.size();
            ans=p;return;
        }
    }
    if(vis[u]==now) return;
    vis[u]=now;
    p.push_back(u);
    for(int i=0;i<edge[u].size();i++){
        dfs(edge[u][i],root,1);
    }
    p.pop_back();
}
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        int u,v;
        cin>>u>>v;
        edge[u].push_back(v);
    }
    for(int i=1;i<=n;i++){
        ++now;
        dfs(i,i,0);
    }
    if(len==1e9){
        cout<<-1<<endl;
        return 0;
    }
    else{
        cout<<len<<endl;
        for(int i=0;i<ans.size();i++){
            cout<<ans[i]<<endl;
        }
    }
}  

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=b-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main(){
	fast_io();
	int n;
	cin >> n;
	vector<int> c(n);
	cu(i,0,n)cin >> c[i];
	vector<int> dp(n);
	dp[0] = 0;
	dp[1] = abs(c[1] - c[0]);
	cu(i,2,n){
		dp[i] = min(abs(c[i] - c[i-2]) + dp[i-2], abs(c[i] - c[i-1]) + dp[i-1]);
	}
	cout << dp[n-1] << '\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

ll d(ll src,ll to,ll x,ll y){
    ll ret=abs(to-src);
    chmin(ret,abs(to-x)+abs(y-src)+1);
    chmin(ret,abs(src-x)+abs(y-to)+1);
    return ret;
}
void solve(long long N, long long X, long long Y){
    vl ans(N);
    fore(i,1,N)fore(j,i+1,N){
        ans[d(i,j,X,Y)]++;
    }
    fore(i,1,N-1){
        cout<<ans[i]<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){
	int a, b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
t = list(map(int, input().split()))
difft = [t[i+1] - t[i] for i in range(N-1)]
total = 0
if N == 1:
    print(T)
    exit()
for d in difft:
    total += min(T, d)
print(total+T)


Measured memory_bytes: 26836
#include<stdio.h>
int main(void)
{
    int x,y,result;
    scanf(" %d %d",&x,&y);
    if(x>0 && y>0 && x<101 &&y<101 && y%2==0)
    {
        result=x+y/2;
        printf("%d",result);
    }
    return 0;
}

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

int main() {
  double Ans = 0;  // 回答：
  int R; cin >> R;  // 半径

  cout << Ans << setprecision(7);	// 計算前に桁数指定
  Ans = R * 2 * 3.141592653589;

  cout << Ans << endl;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007
//#define MOD 7

using namespace std;

int main(void){
    // Your code here!
    long long n, copied_n, sum_n = 0;
    
    cin >> n;
    copied_n = n;
    while(copied_n > 0){
        sum_n += copied_n % 10;
        copied_n /= 10;
    }
        
    if(n % sum_n == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,t;
	cin>>n>>t;
	int a[n+1];
	int check=1;
	int x[n+1];
	int m=5267246;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i]>>x[i];
		if(x[i]<=t)
		{
			check=0;
			if(a[i]<m)
			{
				m=a[i];
			}
		}
	}
	if(check)
	{
		cout<<"TLE";
		return 0;
	}
	cout<<m;
	return 0;
}

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

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

// 無限大の値
const long long INF = 1LL << 60;

int main(){
    int N, K;
    long long h[100000];
    long long dp[100000]; // i番目の石場にいくための最短のコスト

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

    dp[0] = 0;
    for(int i = 1; i < N; i++){
        dp[i] = INF;
    }
    
    long long res;
    long long minres = INF;
    for(int i=1; i<N; i++){
        for(int k=1; k<K+1; k++){
            if(i > k-1) res = dp[i-k] + abs(h[i] - h[i-k]);
            minres = min(minres, res);
        }
        dp[i] = minres;
        minres = INF;
    }

    cout << dp[N-1] << endl;
    
    return 0;
}

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

int main(){
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
  return 0;
}


Measured memory_bytes: 256
n, k = gets.split(' ').map(&:to_i)
r, s, p = gets.split(' ').map(&:to_i)
t = gets.chomp
points = 0
hands = []
0.upto(n - 1) do |i|
  if t[i]=='r'
    if i - k < 0
      points += p
      hands << 'p'
    elsif hands[i-k] != 'p'
      points += p
      hands << 'p'
    else
      hands << ''
    end
  elsif t[i]=='s'
    if i - k < 0
      points += r
      hands << 'r'
    elsif hands[i-k] != 'r'
      points += r
      hands << 'r'
    else
      hands << ''
    end
  else
    if i - k < 0
      points += s
      hands << 's'
    elsif hands[i-k] != 's'
      points += s
      hands << 's'
    else
      hands << ''
    end
  end
end
puts points

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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 2e5 + 10, inf = 1e18 + 21, LG = 20;

int n, k;
double p[MAXN], res;
double ans;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        double a;
        cin >> a;
        p[i] = (a + 1) / 2;
    }

    for (int i = 0; i < k; i++) {
        ans += p[i];
        res += p[i];
    }
    
    for (int i = k; i < n; i++) {
        res -= p[i - k];
        res += p[i];
        ans = max(res, ans);
    }

    cout << fixed << setprecision(10) << ans << '\n';
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;

void Pyramid() {
	int N;
	cin >> N;
	int x[101];
	int y[101];
	int h[101];
	for (size_t i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i] >> h[i];
	}
	for (int i = 0; i <= 100; i++)
	{
		for (int j = 0; j <= 100; j++)
		{
			int tmp = 0;
			for (int k = 0; k < N; k++)
			{
				if (h[k] == 0) continue;
				tmp = h[k] + abs(x[k] - i) + abs(y[k] - j);
				break;
			}
			bool ok = true;
			for (int k = 0; k < N; k++)
			{
				if (max((tmp - abs(x[k] - i) - abs(y[k] - j)),0) != h[k]) ok = false;
			}
			if (ok) {
				cout << i << " " << j << " " << tmp << "\n";
				return;
			}
		}
	}

}
 int main() {
	 Pyramid();
	 return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ST = [tuple(map(int,input().split())) for i in range(M)]

es = [[] for _ in range(N)]
for s,t in ST:
    s,t = s-1,t-1
    es[s].append(t)

dp = [0] * N
for i in range(N-2,-1,-1):
    s = 0
    for to in es[i]:
        s += dp[to]
    dp[i] = 1 + s / len(es[i])

pp = [0] * N
pp[0] = 1.0
for i in range(N-1):
    l = len(es[i])
    for to in es[i]:
        pp[to] += pp[i] / l

ans = dp[0]
for i in range(N-1):
    l = len(es[i])
    if l < 2: continue
    before = 0
    after_whole = 0
    for to in es[i]:
        before += dp[to] / l
        after_whole += dp[to] / (l-1)
    for to in es[i]:
        after = after_whole - dp[to] / (l-1)
        diff = (before - after) * pp[i]
        ans = min(ans, dp[0] - diff)
print(ans)

Measured memory_bytes: 34528
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
ll hell=pow(10,9)+7;
ll exp(ll x,ll y){
    ll res=1;
    x%=hell;
    while(y>0){
        if(y&1)
        res=(res*x)%hell;
        y>>=1;
        x=(x*x)%hell;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin>>n>>a>>b;
    ll res=exp(2,n)-1;
    ll sum=1;
    for(ll i=1;i<=a;i++){
        sum*=((n-i+1)*exp(i,hell-2))%hell;
        sum%=hell;
    }
    res-=sum;
    res%=hell;
    sum=1;
    for(ll i=1;i<=b;i++){
        sum*=((n-i+1)*exp(i,hell-2))%hell;
        sum%=hell;
    }
    res-=sum;
    res%=hell;
    if(res<0)
    res+=hell;
    cout<<res;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a,b,s,l;
	cin >> a >> b;
	if( a<1 || b>100 ){
		cout << "error." << endl;
		return 0;
	}
	s=a*b;
	l=(a+b)*2;
	cout << s << ' ' << l << endl;
	return 0;
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n;vi vec;
    cin>>n;
    int sum=0;
    vec.pb(0);
    for(int i=0; i<n; ++i)
    {
    	int x;
    	cin>>x;
    	vec.pb(x);
    	sum+=x;
    }
    int mini=INT_MAX;
    for(int i=1; i<n; ++i)
    {
    	int sumx=0;
    	for(int j=1; j<=i; ++j)
    	{
    		sumx+=vec[j];
    	}
    	if(mini>abs(sum-2*sumx))
    		mini=abs(sum-2*sumx);
    }
    cout<<mini<<"\n";

}

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

int main() {
       int A, B, C;
       cin >> A >> B >> C;
       if(B == C && B != A) cout << A << endl;
       if(A == C && A != B) cout << B << endl; 
       if(A == B && A != C) cout << C << endl;
       return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    ll K; cin >> K;
    ll x = 7%K;
    VI n(K,0);

    int ans = 1;
    while(!(x==0 || n[x]==1)){
        n[x] = 1;
        x = (x*10+7)%K;
        ans++;
    }
    cout << (x==0 ? ans : -1) << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 7148
#include<stdio.h>

int main()
{
  int i, j, n, temp, flag, A[100];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  flag = 1;
  j = 0;
  while(flag){
    flag = 0;
    for(i = n-1; i >= 1; i--){
      if(A[i] < A[i-1]){
	temp = A[i-1];
	A[i-1] = A[i];
	A[i] = temp;
	flag = 1;
	j++;
      }
    }
  }
  
  for(i = 0; i < n-1; i++){
    printf("%d ", A[i]);
  }
  printf("%d\n", A[n-1]);

  printf("%d\n", j);
  
  return 0;
}

Measured memory_bytes: 600
n, m = map(int, input().split())
st = [list(map(int, input().split())) for _ in range(m)]

e = [[] for _ in range(n)]
for s, t in st:
    e[s-1].append(t-1)

ans = float('inf')
for i in range(n-2, -1, -1):
    if len(e[i]) <= 1:
        continue
    dp = [0.0 for _ in range(n)]
    for j in range(n-2, i, -1):
        temp = 0.0
        for x in e[j]:
            temp += dp[x]
        dp[j] = temp / len(e[j]) + 1.0
    temp = 0.0
    mx = 0.0
    for x in e[i]:
        temp += dp[x]
        mx = max(mx, dp[x])
    dp[i] = (temp - mx) / (len(e[i]) - 1) + 1.0
    for j in range(i-1, -1, -1):
        temp = 0.0
        for x in e[j]:
            temp += dp[x]
        dp[j] = temp / len(e[j]) + 1.0
    ans = min(ans, dp[0])

if ans == float('inf'):
    dp = [0.0 for _ in range(n)]
    for j in range(n-2, -1, -1):
        temp = 0.0
        for x in e[j]:
            temp += dp[x]
        dp[j] = temp / len(e[j]) + 1.0
    print(dp[0])
else:
    print(ans)

Measured memory_bytes: 81624
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val k = sc.nextLong()
    val q = sc.nextInt()
    val a = (0 until q).map { sc.next().toInt() }
    problem141c(n, q, k, a)
}

fun problem141c(n: Int, q: Int, k: Long, a: List<Int>): String {
    val dp = (0 until n).map { 0 }.toMutableList()
    for (i in 0 until q) {
        val winner = a[i]
        dp[winner - 1] = dp[winner - 1] + 1
    }
    val out = PrintWriter(System.out)
    for (element in dp) {
        out.println(if (q - k >= element) "No" else "Yes")
    }
    out.flush()
    return ""
}

Measured memory_bytes: 46188
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		long w = long.Parse(input[1]);
    long[,] vertexes = new long[n,2];//ここに受け取る
    for(long i = 0; i < n; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);//１行ごとに受け取る
      vertexes[i,0] = nums[0];
      vertexes[i,1] = nums[1];
    }
    long[,] dp = new long[n+1, n*1000+1];//x個見て価値がyの時の重さの最小値

    for(int i = 0; i <= n; i++)
    {
      for(int j = 0; j <= n*1000; j++)
      {
        dp[i,j] = long.MaxValue/3;
      }
    }
    dp[0,0] = 0;

    for(int i = 1; i <= n; i++)
    {
      for(int j = 0; j <= n*1000; j++)
      {
        dp[i,j] = Math.Min(dp[i,j], dp[i-1,j]);//取らない場合

        if(j-vertexes[i-1,1] >= 0)
          dp[i,j] = Math.Min(dp[i,j], dp[i-1,j-vertexes[i-1,1]] + vertexes[i-1,0]);//取る場合
      }
    }

    long answer = 0;
    for(int i = 0; i <= n*1000; i++)
    {
      if(dp[n,i] <= w) answer = i;
    }

		Console.WriteLine(answer);
	}
}

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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    rep(i,n) sort(s[i].begin(),s[i].end());
    sort(s.begin(),s.end());
    s.push_back("#");
    ll ans = 0;
    ll cnt = 1;
    rep(i,n){
        if(s[i]==s[i+1]) cnt++;
        else{
            ans += cnt*(cnt-1)/2;
            cnt = 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9604
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define MAX_BUF 11
#define YEAR_BUF 5
#define MONTH_BUF 3
#define DAY_BUF 3

int main()
{
	char buf[MAX_BUF];
	char year[YEAR_BUF];
	char month[MONTH_BUF];
	char day[DAY_BUF]; 
	int i, j, flag = 0;
	int Year, Month, Day;
	int sum = 0;

	scanf("%s", buf);

	for (i = 0, j = 0; i < MAX_BUF; i++) {
		if (i <= 3) {
			year[j] = buf[i];
			j++;
		} else if (i == 4) {
			j = 0;
		} else if (i >= 5 && i <= 6) {
			month[j] = buf[i];
			j++;
		} else if (i == 7) {
			j = 0;
		} else if (i >= 8 && i <= 9) {
			day[j] = buf[i];
			j++;
		}
	}

	year[YEAR_BUF - 1] = '\0';
	month[MONTH_BUF - 1] = '\0';
	day[DAY_BUF - 1] = '\0';

	Year = atoi(year);
	Month = atoi(month);
	Day = atoi(day);

	sum += Year * 10000;
	sum += Month * 100;
	sum += Day;
	
	if (sum <= 20190430) {
		printf("Heisei\n");
	} else {
		printf("TBD\n");
	}

	return 0;
}


Measured memory_bytes: 128
import sys

line1 = sys.stdin.readline().rstrip()
line2 = sys.stdin.readline().rstrip()

len2 = len(line2)

res = True

for i in range(0, len(line1)):
    if line2[len2-1 - i] != line1[i]:
        res = False
        print("NO")
        break

if res == True:
    print("YES")


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

int main(){
  while(1){
  char c,ans[1001];
  int n,m,q,cnt=0,f[37][1001],s[37]={},b[1001];
  cin>>n>>m>>q;
  if(n+m+q==0) break;
  
     for(int i=0;i<n;i++)
       for(int j=0;j<m;j++)f[i][j]=1;
   
  while(cnt<q){
    cnt++;
    for(int i=0;i<n;i++)cin>>c,s[i]=(s[i]+(c-'0'))%2;
    for(int i=0;i<m;i++)cin>>c,b[i]=c-'0';
    
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++){
	if(f[i][j]==2) continue;
	else if(s[i]==b[j])f[i][j]=1;
	else f[i][j]=2;
      }
    }

  for(int j=0;j<m;j++){
    int flag=0;
    for(int i=0;i<n;i++){
      if(f[i][j]==1 && flag==0){
	flag=1;
	if(i>=0 && i<=9) ans[j]=i+'0';
	else ans[j]=i-10+'A';
      }else if(flag==1 && f[i][j]==1)ans[j]='?';
    }
   }
  
  for(int i=0;i<m;i++)cout<<ans[i];
  cout<<endl;
  }
  return 0;
}

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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  
  int x,ans=0;
  for (int i = 0; i< N-1; i++) {
    x = A.at(i+1) - A.at(i);
    ans = max(ans,x);
  }
  x = A.at(0) + K - A.at(N-1);
  ans = max(ans,x);
  
  ans = K - ans;
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys

n = int(input())

h_list = list(map(int, input().split()))

max_ = 1

for i in range(n-1):
  max_ = max(h_list[i], max_)
  d = h_list[i+1] - h_list[i]
  if d < -1:
    print('No')
    sys.exit()
  elif i > 0:
    if max_ - h_list[i+1] > 1:
      print('No')
      sys.exit()

print('Yes')


Measured memory_bytes: 14252
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

vector<vector<int> > graph(100001);
vector<int> result(100001, -1);

int solve(int n)
{
	if(result[n] >= 0) return result[n];
	result[n] = 0;
	for(int i = 0; i < graph[n].size(); i++){
		result[n] = max(result[n], solve(graph[n][i]) + 1);
	}
	return result[n];
}

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

Measured memory_bytes: 8192
#include <iostream>
#include <sstream>
#include <cstring>
#include <string>
using namespace std;

int main()
{
    char arr[105];
    char res[105];
    //gets(arr);
    cin>>arr;
    int j=0;
    int cnt=0;
    for(int i=0;i<strlen(arr);i++)
    {
        if(i>=1&&i<=strlen(arr)-2)
            cnt++;
        else
        {
            res[j]=arr[i];
            j++;
        }
    }
    cout<<res[0];
    cout<<cnt;
    cout<<res[1];
}


Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


ll count_pair_less(vl A, ll X) {
  int N = A.size();
  ll cnt = 0;
  REP(i,N) {
    if (A[i] < 0) {
      int l = -1, r = N; // (l, r]
      while (l+1 < r) {
        int m = (l+r)/2;
        if (A[m]*A[i] < X) r = m;
        else l = m;
      }      
      cnt += N-r;
    } else {
      int l = -1, r = N; // (l, r]
      while (l+1 < r) {
        int m = (l+r)/2;
        if (A[m]*A[i] < X) l = m;
        else r = m;
      }
      cnt += r;
    }
    if (A[i]*A[i] < X) cnt--;
  }
  return cnt/2;
}


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


  ll N,K; cin>>N>>K;
  vl A(N); REP(i,N) cin>>A[i];
  
  sort(A.begin(), A.end());

  ll PMAX = ll(1e18); // 積の値の最大値
  ll l = -PMAX, r = PMAX+1;
  // ooo...oo|xxx...xx [l,r)
  while (l < r-1) {
    ll m = (l+r)/2;
    // 積 m より小さいペアが K 個未満なら l を増やす
    if (count_pair_less(A, m) < K) l = m;
    else r = m;
  }

  ll ans = l;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3428
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [None for _ in range(n)]
for _ in range(m):
  i,j = map(int,input().split())
  if a[i-1] == None:
    a[i-1] = j
  elif a[i-1] != j:
    a = -1
    break
else:
  if n == 1:
    if a[0] == None:
      a = 0
    else:
      a = a[0]
  else:
    for j in range(n):
      if j == 0:
        if a[j] == None:
          a[j] = 1
        elif a[j] == 0:
          a = [-1]
          break
      elif a[j] == None:
        a[j] = 0
    a = "".join(map(str,a))
print(a)

Measured memory_bytes: 3188