akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

int main(void)
{
    bool check=false;
    string s,t;
    cin >> s;
    cin >> t;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            check=true;
        }
    }
    if(check)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3624
H,W = map(int,input().split())
S = []
for i in range(H+2):
    if i == 0 or i == (H+1):
        S.append(list("-"*(W+2)))
        continue
    else:
        S.append(list("-" + input() + "-"))


for h in range(1,H+1):
    for w in range(1,W+1):
        if S[h][w] == ".":
            cnt = 0
            for i in range(-1,2):
                for j in range(-1,2):
                    if S[h+i][w+j] == "#":
                        cnt += 1
            S[h][w] = str(cnt)

        else:
            continue

for i in range(1,H+1):
    print("".join(list(S[i][1:W+1])))

Measured memory_bytes: 3188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;


int main() {
    int N, K;
    string S;
    char A = '*';

    cin >> N >> S >> K;

    for (int i = 0; i < N;i++)
        if (S.at(K - 1) != S.at(i)) {
            S.at(i) = A;
        }
    cout << S << endl;
            
    }

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

int main(){
 int a,b,k;
  int cnt=0;
  scanf("%d%d%d",&k,&a,&b);
  for(int i=a;i<=b;i++){
    if(i%k==0) cnt++;
  }
  if(cnt==0) printf("NG");
  else printf("OK");
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
#define MO 1e9+7
#define LINF 1e18 + 5
#define rep(i, N) for(int i=0;i<N;i++)
#define repp(i,N) for(int i=1;i<=N;i++)
using namespace std;
using ll = long long;

int n;
double dp[3001][3001];
bool chk[3001][3001];
double coins[3000];
double solve(int y, int x){
    if(x<0) return 0.0;
    if(y==0) return dp[y][x];//이게 기저사례
    if(y<x) return 0.0;
    //y번째 동전까지 던졌을 때, x개의 헤드가 나오는 것을 반환한다?
    double& res = dp[y][x];
    if(chk[y][x]) return dp[y][x];
    
    res += solve(y-1,x-1)*coins[y];    
    res += solve(y-1,x)*(1-coins[y]);
    
    
    chk[y][x]=1;
    //printf("%lf\n", res);
    //내가 헤드가 나왔을 경우.내가 헤드가 안나왔을 경우
    return res;
}
int main(){
    cin>>n;
    //memset(dp, -1.0, sizeof(dp));
    for(int i =1;i<=n;i++){
        scanf("%lf", coins+i);
    }
    dp[0][0] = 1.0;
    double ans =0.0;
    for(int j=0;j<=n;j++){
        solve(n,j);
    }
    for(int j=0;j<=n;j++){
        if(j>n-j) ans += dp[n][j];
    }
    printf("%.15f\n",ans);

    return 0;
    // for(int i=1;i<=n;i++){
    //     for(int j=0;j<=i;j++){
    //         if(j-1>=0){
    //             dp[i][j] += dp[i-1][j-1]*coins[i];
    //         }
    //         dp[i][j] += dp[i-1][j] * (1-coins[i]);
    //     }
    // }
    // double ans = 0.0;
    // for(int i =0;i<=n;i++){
    //     if(i>n-i) ans += dp[n][i];
    // }
    // cout<<ans;
    //solve(n,n);
    //cout<<dp[3][2];
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    for(int i=1; i<=N; i++){
        int a = i*108/100;
        if(a == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
n,k,q = map(int, input().split())
a = list(map(int, input().split()))

def parse(b):
    ret = []
    tmp = []
    for ai in a:
        if ai >= b:
            tmp.append(ai)
        else:
            if len(tmp) >= k:
                tmp.sort(reverse=True)
                for i in range(k-1,len(tmp)):
                    ret.append(tmp[i])
            tmp = []
    else:
        if len(tmp) >= k:
            tmp.sort(reverse=True)
            for i in range(k-1,len(tmp)):
                ret.append(tmp[i])
    return ret

ans = 10**10

for b in set(a):
    lis = parse(b)
    if len(lis) < q:
        continue
    lis.sort()
    ans_tmp = lis[q-1] - lis[0]
    ans = min(ans, ans_tmp)

print(ans)

Measured memory_bytes: 47196
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 


#define M 100010


int main(){
	IOS;
	tihs;

	ll n;cin>>n;
	set<string>ss;
	rep(i,0,n){
		string s;cin>>s;
		ss.insert(s);
	}
	cout<<sz(ss);
	return 0;
}

Measured memory_bytes: 19196
k = int(input())
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[k-1])

Measured memory_bytes: 3060
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define pi acos(-1)
using namespace std;
int main() {
    double r;
    cin>>r;
    printf("%.6lf %.6lf\n",pi*r*r,2*pi*r);
    return 0;
}



Measured memory_bytes: 3284
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a%2 == 0 || b%2 == 0 || c%2 == 0 {
		fmt.Println(0)
	} else {
		l := []int{a, b, c}
		sort.Ints(l)

		fmt.Println(l[0] * l[1])
	}
}


Measured memory_bytes: 512
import java.io.*;

class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
                int a, b, c;

                String line = reader.readLine();
                String[] strAry = line.split(" ");

                a = Integer.parseInt(strAry[0]);
                b = Integer.parseInt(strAry[1]);
                c = Integer.parseInt(strAry[2]);

                
                if(a < b && b < c){
                    System.out.println("Yes");
                }else {
                    System.out.println("No");
                }

        } catch (IOException e) {
            //TODO: handle exception
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 24200
n = int(input())
  
def divide_count(c):
  count = 0
  while True:
    if c % 2 == 0:
      c = c / 2
      count += 1
    else:
      return count
    
answer = 1
dc = 0
before = 0
for i in range(n):
  count = i+1
  dc = divide_count(count)
  if before < dc:
    answer = count
    before = dc
print(answer)


Measured memory_bytes: 3060
#include <stdio.h>
  
int main()
{
 
  int i, j, tmp,c=0,minj;
  int number[100];
  int N;
  
  scanf("%d", &N);
 
  

  for (i=0; i<N; i++){
    scanf("%d", &number[i]);
  }
  
  for (i=0; i<N; i++) {
    minj=i;
    for (j=i; j<N; j++) {
      if (number[j] < number[minj]) {
	minj=j;
      }
    }
  if(minj!=i){
	tmp =  number[i];
        number[i] = number[minj];
        number[minj] = tmp;
	c++;
      }
  }


  
 
 
  for (i=0; i<N; i++) {
    if(N-1>i)  printf("%d ", number[i]);
    else printf("%d",number[i]);
  }
  printf("\n%d\n",c);
  return 0;
}



Measured memory_bytes: 2144
n = input()
dic = {}
for i in map(int, raw_input().split()):
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
if len(dic) > 3:
	print "No"
elif len(dic) == 3:
	vals = []
	for i in dic:
		vals.append(i)
	if vals[0]^vals[2] != vals[1] or vals[1]^vals[0] != vals[2] or vals[0] != vals[1]^vals[2]:
		print "No"
	elif max(dic.values()) - min(dic.values()) > 1:
		print "No"
	else:
		print "Yes"
elif len(dic) == 2:
	if 0 in dic and dic[0] == n/3 and n%3 == 0:
		print "Yes"
	else:
		print "No"
else:
	if 0 in dic.keys():
		print "Yes"
	else:
		print "No"

Measured memory_bytes: 11332
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  string s;
  cin>>n>>s;
  int sum[n+1];
  sum[0]=0;
  for(int i=0;i<n;i++){
    sum[i+1]=sum[i];
    if(s[i]=='R'){
      sum[i+1]++;
    }
  }
  int ans=1e6;
  for(int i=0;i<=n;i++){
    int a=sum[i];
    int b=i-sum[i];
    int c=sum[n]-sum[i];
    int d=n-i-c;
    int x=max(b,c);
    ans=min(ans,x);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4484
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    int n;cin>>n;
    vector<int> h(n);
    rep(i, n) {
        cin>>h[i];
    }
    dump(h);
    vi dp(n, INF);
    dp[0] = 0;
    rep(i, 1, n){
        chmin(dp[i], dp[i-1]+abs(h[i-1]-h[i]));
        if (i-2>=0) chmin(dp[i], dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    int a,b;
    IN a>>b;
    OUT (a*b)<<endl
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n); i>=0; i--)
#define FOR(i,m,n) for(int i=(m); i<(n); i++)

int x[100010];
int dp[100010][17];

int query(int a, int b){
    if(a > b) swap(a, b);
    int s = 0;
    rrep(i, 16) if(dp[a][i] < b) { a = dp[a][i]; s += (1 << i); }
    return s;
}

int main(){
    int N, L, Q;
    scanf("%d", &N);
    rep(i, N) scanf("%d", &x[i]);
    scanf("%d %d", &L, &Q);

    rep(i, N-1) dp[i][0] = upper_bound(x, x+N, x[i]+L) - x - 1;
    rep(i, 17) dp[N][i] = N;
    dp[N-1][0] = N;
    rrep(i, N-1) FOR(j, 1, 17) dp[i][j] = dp[dp[i][j-1]][j-1];

    rep(i, Q){
        int a, b;
        scanf("%d %d", &a, &b);
        printf("%d\n", query(--a, --b)+1);
    }

    return 0;
}


Measured memory_bytes: 7808
import java.util.*;
import java.util.Scanner;
import static java.util.Comparator.*;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        
        String In = scanner.nextLine();
        String[] input = In.split(" ");
        
        int all = Integer.parseInt(input[0]);
        Integer x_scribe = Integer.parseInt(input[1]);
        Integer y_scribe = Integer.parseInt(input[2]);

        int min = 0, max = 0;

        if(x_scribe + y_scribe > all){
            min = (x_scribe + y_scribe) - all;
        }else{
            min = 0;
        }
        if(x_scribe.compareTo(y_scribe) > -1){
            max = y_scribe;
        }else{
            max = x_scribe;
        }
        System.out.println(max + " " + min);
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  int n=s.size();
  vector<vector<ll>> dp(n+1,vector<ll>(4,0));
  dp[0][0]=1;
  rep(i,n)rep(j,4){
    if(j==3){
      if(s[i]=='?') (dp[i+1][j]+=(3*dp[i][j])%mod)%=mod;
      else (dp[i+1][j]+=dp[i][j])%=mod;
    }else{
      char now='A'+j;
      if(s[i]=='?'){
        (dp[i+1][j+1]+=dp[i][j])%=mod;
        (dp[i+1][j]+=(3*dp[i][j])%mod)%=mod;
      }else{
        (dp[i+1][j]+=dp[i][j])%=mod;
        if(s[i]==now) (dp[i+1][j+1]+=dp[i][j])%=mod;
      }
    }
  }
  cout<<dp[n][3]<<endl;
}

Measured memory_bytes: 7376
#!/usr/local/bin/ruby
num = Hash.new(0)
max = 0
#while (n=gets.to_i) != true
while(n=gets.to_i)!=0
 num[n] += 1
end
num.to_a.sort{|p,q| p[1]<=>q[1]}.reverse.each do |a,b|
 if b >= max
  max = b
  puts a
 else
  break
 end
end

Measured memory_bytes: 6088
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

for (var i = 0; i < lines.length; i++) {
	if (lines[i] == '') break;
	var vals = lines[i].split(' ').map(function(i){return +i;});
	var a = vals[0] + vals[1];
	var str = a + '';
	console.log(str.length);
}

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

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	int a[n];
	double sum = 0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum += (double)1/a[i];
	}
	// keisan
	printf("%lf",(double)1/sum);
	// syutsuryoku
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int dp[5005][5005];
// abc141 e
int main() {
  int n; string s; cin >> n >> s;
  int ans = 0;
  for (int i=n-1; i>=0; i--) {
    for (int j=i; j>=0; j--) {
      if (s[i] == s[j]) dp[i][j] = min(i-j, dp[i+1][j+1]+1); 
      else dp[i][j] = 0;
      chmax(ans, dp[i][j]);
    }
  } 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 70408
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <functional>
#include <tuple>
using namespace std;

long long N, A[1 << 18], cnt;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; A[i] += A[i - 1]; }

	map<long long, long long>Map;
	Map[0] = 1;
	for (int i = 1; i <= N; i++) {
		cnt += Map[A[i]];
		Map[A[i]]++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
using namespace std;
static const int N = 100;
 
int main(){
  int M[N][N];
  int n,u,k,v;
 
  cin >> n;
 
  for(int i = 0; i < n; i++){
    for(int j = 0; j <n; j++)M[i][j]=0;
  }
 
  for(int i = 0;i <n; i++){
    cin >> u >> k;
    u--;
    for(int j =0; j <k; j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
 
  for( int i =0;i<n;i++){
    for(int j =0;j<n;j++){
      if(j)cout << " ";
      cout << M[i][j];
    }
    cout << endl;
  }
 
  return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a==1) a+=13;
	if(b==1) b+=13;
	if(a<b) cout<<"Bob"<<endl;
	if(b<a) cout<<"Alice"<<endl;
	if(a==b) cout<<"Draw"<<endl;
}

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

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

    vector<ll> a(n);
    rep (i, n)
        cin >> a[i];

    rep (i, n - k)
        cout << (a[i + k] > a[i] ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <functional>
#define MOD 1000000007


struct edge {
    int to;
    int cost;
};

typedef long long ll;
using namespace std;
using P = pair<int, int>;

bool compare_by_b(pair<int,pair<string,int>> a, pair<int,pair<string,int>> b) {
    if(a.second.first != b.second.first){
        return a.second.first < b.second.first;
    }else{
    return a.second.second > b.second.second;
    }
}

int main(void) {
    ll i=0,j=0,k=0;
    ll n;
    string s;
    cin >> s;
    if(s[0]==s[1] && s[2]==s[3] || s[0]==s[2] && s[1]==s[3] || s[0]==s[3] && s[2]==s[1]){
        if((s[0]==s[1] && s[0]==s[2] && s[0]==s[3])){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
int main() {
  ll a, b, c;
  bool f = false;
  cin >> a >> b >> c;
  if (a == 5) {
    if (b == 5) {
      if (c == 7) {
        f = true;
      }
    } else if (b == 7) {
      if (c == 5) {
        f = true;
      }
    }
  } else if (a == 7) {
    if (b == 5) {
      if (c == 5) {
        f = true;
      }
    }
  }
  if (f) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    h1, m1, h2, m2, k = map(int, input().split())

    period = (h2-h1)*60 + (m2-m1)
    return period - k


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  string s;
  cin >> s;

  ll ans = 0;

  REP(i, 4){
    if(s[i] == '2') ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n, q;
    std::cin >> n;
    std::vector<int> v(n + 1), w(n + 1);
    for (int i = 1; i <= n; ++i)
        std::cin >> v[i] >> w[i];
    std::vector<std::vector<std::pair<int, int>>> s(n);
    std::vector<std::pair<int, int>> all;
    std::function<void(int, int, int)> dfs1 = [&](int u, int a, int b) {
        if (!u) {
            all.emplace_back(a, b);
        } else {
            dfs1(u >> 1, a, b);
            dfs1(u >> 1, a + w[u], b + v[u]);
        }
    };
    auto work = [&](int u, auto &s) {
        all.clear();
        s.clear();
        dfs1(u, 0, 0);
        std::sort(all.begin(), all.end());
        for (auto p : all)
            if (s.empty() || p.second > s.back().second)
                s.push_back(p);
    };
    for (int i = 1 << 10; i < (1 << 11) && i <= n; ++i)
        work(i, s[i]);
    int L;
    int ans;
    std::function<void(int, int, int)> dfs2 = [&](int u, int a, int b) {
        if (u < (1 << 11)) {
            if (a <= L)
                ans = std::max(ans, b + std::prev(std::lower_bound(s[u].begin(), s[u].end(), std::make_pair(L - a + 1, -1))) -> second);
        } else {
            dfs2(u >> 1, a, b);
            dfs2(u >> 1, a + w[u], b + v[u]);
        }
    };
    std::function<void(int, int, int)> dfs3 = [&](int u, int a, int b) {
        if (!u) {
            if (a <= L)
                ans = std::max(ans, b);
        } else {
            dfs3(u >> 1, a, b);
            dfs3(u >> 1, a + w[u], b + v[u]);
        }
    };
    std::cin >> q;
    for (int i = 0; i < q; ++i) {
        int u;
        std::cin >> u >> L;
        ans = 0;
        if (u >= (1 << 10)) {
            dfs2(u, 0, 0);
        } else {
            dfs3(u, 0, 0);
        }
        std::cout << ans << "\n";
    }
    return 0;
}

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

int main() {
  int N,T;
  cin >> N >> T;

  int t_prev, t_tmp;
  cin >> t_prev;
  int ans= 0;
  for(int i=1; i<N; i++){
    cin >> t_tmp;
    if(t_tmp- t_prev < T){
      ans+= t_tmp- t_prev;
      t_prev= t_tmp;
    }
    else{
      ans+= T;
      t_prev= t_tmp;
    }
  }
  ans+= T;

  cout << ans << endl;
}

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

int main(void){
    int a,b;
    
    for(int i = 0;;i++){
        cin >> a >> b;
        if(a == 0 && b == 0){
            break;
        }
        if(a > b){
            int tmp = 0;
            tmp = a;
            a = b;
            b = tmp;
            //cout << a << " " << b << endl;
        //}else{
            //cout << a << " " << b << endl;
        }
        cout << a << " " << b << endl;
        
    }
}



Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n;
ll tot;
ll a[maxn], b[maxn];
void no() { puts("NO"); exit(0);}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%lld", &a[i]);
		tot += a[i];
	}
	ll per = 1ll * n * (n + 1) / 2;
	if(tot % per) no();
	tot /= per;
	a[0] = a[n];
	for(int i = 1; i <= n; ++i) 
	{
		b[i] = tot - (a[i] - a[i - 1]);
		if(b[i] < 0 || b[i] % n) no();
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <math.h> 

using namespace std;



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

	int n, a, b, i, j, k, ct = 0, cbb = 0;
	string s;
	cin >> n >> a >> b >> s;
	for (i = 0; i < n; i++) {
		if (s[i] == 'a') {
			if (ct < a + b) {
				cout << "Yes\n";
				ct++;
			}
			else cout << "No\n";
		}
		else if (s[i] == 'b') {
			cbb++;
			if ((ct < a + b) && (cbb <= b)) {
				cout << "Yes\n";
				ct++;
			}
			else cout << "No\n";
		}
		else cout << "No\n";
	}

	return 0;
}




Measured memory_bytes: 832
#include<stdio.h>

int main()
{
  int N,X[100],i,c=1,min=0,sum;
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    scanf("%d",&X[i]);
  }
  
 
  for(i=0;i<N;i++)      
  {
    sum=sum+(X[i]-1)*(X[i]-1);
  }
  
  min=sum;
  
  while(1)
  {
    sum=0;
    
    for(i=0;i<N;i++)      
    {
      sum=sum+(X[i]-c)*(X[i]-c);
    }

    if(sum<min)
    {
      min=sum;
    }
    
    if(sum>min)
      break;
    c++;
  }
  
  
  printf("%d",min);

  return 0; 
}


Measured memory_bytes: 128
from collections import defaultdict

mod = 10**9 + 7

n, k = map(int, input().split())

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

num_dic = defaultdict(int)
num_smaller = [0 for x in range(2001)]

for num in a:
  num_dic[num] += 1
  for i in range(num + 1, 2001):
    num_smaller[i] += 1

cnt = 0
#print(num_dic)
#print(num_smaller[0:5])
# m番目以降にある数
for key, v in num_dic.items():
  # print(key, v, num_smaller[key])
  cnt += (num_smaller[key] * v * (k * (k-1)) // 2) % mod
  
# print(cnt)
# m番目にある数
for i in range(0, n - 1):
  for j in range(i + 1, n):
    if a[i] > a[j]:
      cnt += k
cnt %= mod
print(cnt)

Measured memory_bytes: 42348
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.exception, std.typecons, std.container;

  int h, w; rd(h, w);
  auto c=new char[][](h, w);
  foreach(i; 0..h) c[i]=readln.chomp.to!(char[]);

  alias pair=Tuple!(int, int);
  auto d=new int[][](h, w);
  const int inf=1_000_000_000;
  foreach(i; 0..h) fill(d[i], inf);
  auto Q=new DList!(pair);
  d[0][0]=0; Q.insertBack(pair(0, 0));
  while(Q.empty==false){
    auto cur=Q.front; Q.removeFront;
    auto i=cur[0], j=cur[1];
    foreach(dd; [[1, 0], [-1, 0], [0, 1], [0, -1]]){
      auto ni=i+dd[0], nj=j+dd[1];
      if(ni<0 || ni>=h || nj<0 || nj>=w) continue;
      if(c[ni][nj]=='#') continue;
      if(d[i][j]+1<d[ni][nj]){
        d[ni][nj]=d[i][j]+1;
        Q.insertBack(pair(ni, nj));
      }
    }
  }

  if(d[h-1][w-1]==inf){writeln(-1); return;}
  int bk=0;
  foreach(i; 0..h) bk+=count(c[i], '#');
  auto res=h*w-bk-(d[h-1][w-1]+1);
  writeln(res);
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
vector<ll> h;
ll dp[100005],n,k;
ll solve(int i)
{
    if(i==n-1) return 0;
    if(~dp[i]) return dp[i];
    ll ans = INT_MAX;
    for(int j=1; j<=k && i+j<n; j++)
        ans = min(ans, abs(h[i]-h[i+j])+solve(i+j));
    return dp[i]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    ll x;
    cin>>n>>k;
    while(n--)
    {
        cin>>x;
        h.push_back(x);
    }
    memset(dp, -1, sizeof dp);
    n=(int)h.size();
    cout<<solve(0)<<endl;
} 


Measured memory_bytes: 9716
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
#define INF 1145141919810893
signed main(){
    int Q,H,S,D;
    int  N;
    cin >> Q >> H >> S >> D;
    cin >> N;
    H=min(H,2*Q);
    S=min(S,2*H);
    D=min(D,2*S);
    if(N%2==0){
        cout << N*D/2 << endl;
    }else{
        cout << (N/2)*D+S << endl;
    }
    
	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong x = ulong.Parse(Console.ReadLine());
            ulong d = 100;
            int y;

            for (y = 1; d < x; ++y)
            {
                d = d + d / 100;
                if (d >= x)
                {
                    Console.WriteLine(y);
                }
            }

        }
    }
}


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

void solve(){
    int n;
    string s;
    cin >> n >> s;
    int right = 0;
    int left = 0;

    for(int i = 0; i < n; ++i){
        if(s[i] == '(') right++;
        else{
            if(right == 0) left++;
            else right--;
        }
    }

    string ans = string(left,'(') + s + string(right,')');

    cout << ans << endl;

    return ;
}

int main(){
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,m;
  ll a[100000],b[100000];
  ll ans=0,asum=0,bsum=0;
  cin>>n>>m;
  rep(i,n){
    cin>>a[i];
    asum+=a[i];
  }
  rep(i,m){
    cin>>b[i];
    bsum+=b[i];
  }
  cout<<asum*bsum<<endl;
  return 0;
}





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

int main(){
  long long int   N, D;
  cin >> N >> D;	
  vector<long long int> X(N), Y(N);
  for(long long int i = 0; i < N; i++) cin >> X[i] >> Y[i];
  
  long long int ans = 0;
  for(long long int i = 0; i < N; i++){
    if(X[i] * X[i] + Y[i] * Y[i] <= D * D) ans++;
  }

  cout << ans << endl;
}


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

static const int NMAX = 100005;
vector<pair<int, int> > adj[NMAX];
int ans[NMAX];

void dfs(int r, int c) {
  stack<int> s, dist;
  s.push(r);
  dist.push(0);
  ans[r] = c;
  while (!s.empty()) {
    int u = s.top();
    s.pop();
    int dist_now = dist.top();
    dist.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i].first;
      int w = adj[u][i].second;
      if (ans[v] == -1) {
        if ((dist_now + w) % 2 == 0) ans[v] = 0;
        else ans[v] = 1;
        s.push(v);
        dist.push(dist_now+w);
      }
    }
  }
}


int main() {
  int n, u, v, w;

  cin >> n;

  for (int i = 1; i < n; i++) {
    scanf("%d%d%d", &u, &v, &w);
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
  }
  for (int i = 1; i <= n; i++) ans[i] = -1;

  for (int i = 1; i <= n; i++) {
    if (ans[i] == -1) dfs(i, 0);
  }

  for (int i = 1; i <= n; i++) cout << ans[i] << endl;


  return 0;

}

Measured memory_bytes: 6784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

int main() {
    string s;
    cin >> s;
    const string k = "keyence";
    if (s.size() < k.size()) {
        cout << "NO" << endl;
        return 0;
    }
    bool f = false;
    rep(i,0,k.size() + 1) {
        bool fg = true;
        rep(j,0,i) {
            if (s[j] != k[j]) {
                fg = false;
            }
        }
        rep(j,0,k.size() - i) {
            if (s[s.size() - 1 - j] != k[k.size() - 1 - j]) {
                fg = false;
            }
        }
        if (fg) {
            f = true;
            break;
        }
    }
    if (f) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define all(c) begin(c),end(c)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//最大公約数
ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}
//最小公倍数
ll lcm(ll x, ll y) {
  return x/gcd(x, y)*y;
}
//素因数分解
vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}
 
 
 ll mod=998244353;
 
int main() {
  int n;
  cin>>n;
  if(n>=30){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

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

        //int A[] = new int[M];
        int count = 0;
        int a;
        for(int i = 0;i<M;i++) {
            a = sc.nextInt();
            count += a;
        }
/*        if(N%2 != 0){
        for(int i = 1; i <= N; i++){
            for(int j = i; j <= N; j++){
                c = i*j;
                if(c == N){
                    d = i+j-2;
                    if(min == 0 || min > d) min = d;
            }
        }
    }
}*/
//double R = (double)r * Math.PI * 2;
count = N - count;
if(count < 0) System.out.println(-1);
else System.out.println(count);

    }
}

Measured memory_bytes: 46220
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int N;
  cin>>N;
  int a[N];
  double ave=0;
  int ans;
  REP(i, N) {
    cin>>a[i];
    ave += a[i];
  }
  ave /= N;
  ans = 0;
  REP(i, N-1){
    if(abs(ave-a[i+1])<abs(ave-a[ans])) ans = i+1;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input!{
        n: usize,
        m: usize,
        a: [usize; n],
        b: [usize; m]
    }
    let d = 1000000007;
    let mut sa = a;
    sa.sort_by(|x, y| y.cmp(&x));
    let mut sb = b;
    sb.sort_by(|x, y| y.cmp(&x));
    if sa[0] != n * m || sb[0] != n * m {
        println!("0");
        return;
    }
    for i in 0..n - 1 {
        if sa[i] == sa[i + 1] {
            println!("0");
            return;
        }
    }
    for i in 0..m - 1 {
        if sb[i] == sb[i + 1] {
            println!("0");
            return;
        }
    }
    let mut ans: usize = 1;
    let mut ida = 0;
    let mut idb = 0;
    for i in (1..n * m).rev() {
        let mut tr = ida + 1;
        let mut tc = idb + 1;
        if (ida < n - 1 && i == sa[ida + 1]) || (idb < m - 1 && i == sb[idb + 1]) {
            if ida < n - 1 && i == sa[ida + 1] {
                tr = 1;
                ida += 1;
            }
            if idb < m - 1 && i == sb[idb + 1] {
                tc = 1;
                idb += 1;
            }
            ans = ans * (tr * tc) % d;
        } else {
            ans = ans * (tr * tc - (n * m - i)) % d;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

//型宣言
typedef long long ll;
typedef unsigned long long ull;
typedef std::string string;
typedef ull answerType;

//変数宣言
ll N;
ll M;
std::vector<string> Ai;
std::vector<string> Bi;
answerType answer;

//関数のプロトタイプ宣言
//入力の取得
void getInput();
//答えを求める
answerType calcAnswer();

//メイン関数
int main() {
	//入力の取得
	getInput();

	//答え
	answerType answer = calcAnswer();

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}

//入力の取得
void getInput() {
	std::cin >> N >> M;
}

//答えを求める
answerType calcAnswer() {
	ull temp = 0;
	ull N2 = N << 1;
	if(N2 > M) {
		return M >> 1;
	}

	temp = N;
	M -= N2;

	temp += M >> 2;
	return temp;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;
 
signed main() {
  int N;
  cin >> N;
  
  map<int, int> num;
  for( int i = 0; i < N; i++ ){
    int A;
    cin >> A;
    if( num.count(A) ) num.at(A)++;
    else num[A] = 1;
  }
  
  bool fg = true;
  if( num.size() > 3 ) fg = false;
  else if( num.size() == 3 ){
    vector<int> suzi(6);
    int cnt = 0;
    for( auto p : num ){
      suzi.at(cnt) = p.first;
      suzi.at(cnt+3) = p.second;
      cnt++;
    }
    int y = suzi.at(0)^suzi.at(1)^suzi.at(2);
    if( y != 0 || suzi.at(3) != suzi.at(4) || suzi.at(4) != suzi.at(5) ){
      fg = false;
    }
  }else if( num.size() == 2 ){
    if( !num.count(0) ) fg = false;
    else if( num.at(0) != N/3 ) fg = false;
  }else if( num.size() == 1 ){
    if( !num.count(0) ) fg = false;
  }
  if( fg ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 5120
def main
  s = ARGF.gets.chomp

  # + を入れられる場所の数
  n = s.length - 1

  sum = 0
  # 2^n     = 1 << n
  0.upto((1 << n) - 1) do |mask|
    # puts "mask = #{mask}"
    last_idx = 0
    0.upto(n-1) do |i|
      if mask[i] == 1
        # '+'を i番目 と i+1番目の間に入れる
        part = s.slice(last_idx, i - last_idx + 1)
        # puts part
        sum += part.to_i
        last_idx = i+1
      end
    end
    last_part = s.slice(last_idx..-1)
    # puts last_part
    sum += last_part.to_i
  end

  puts sum
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 3836
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<cassert>
#include<cstring>
#include<bitset>
#include<iterator>
#include<queue>
typedef long long ll;
using namespace std;

int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;
int const inf = 1000 * 1000 * 1000;

int n, m, k;
int a[3*N];

int main()
{
	cin.tie(0);
	cin.sync_with_stdio(0);

	cin >> n;
	copy_n(istream_iterator<int>(cin), 3 * n, a);
	sort(a, a + 3 * n);
	ll sum = 0;
	int cnt = 0;
	for(int i = 3 * n - 2; cnt < n; cnt++, i -= 2)
	  sum += a[i]; 
	cout << sum << endl;
}

Measured memory_bytes: 1408
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end
def min(a,b)
  return a>b ? b : a
end
class SD
  attr_accessor:data,:bucket,:add,:n,:n_sqrt
  def initialize(n)
    @n_sqrt=(n**0.5).to_i
    @n=(n+@n_sqrt-1)/@n_sqrt
    @data=array(@n*@n_sqrt,1,0)
    @add=array(@n,1,0)
    @bucket=array(@n,1,0)
  end

  def add(s,t,x)
    @n.times do|i|
      l=i*@n_sqrt
      r=l+@n_sqrt
      next if r<=s or t<=l
      if s<=l and r<=t
        @add[i]+=x
      else
        for j in max(s,l)..min(t,r)-1
          @data[j]+=x
          @bucket[i]+=x
        end
      end
    end
  end

  def getSum(s,t)
    sum=0
    @n.times do|i|
      l=@n_sqrt*i
      r=l+@n_sqrt
      next if r<=s or t<=l
      if s<=l and r<=t
        sum+=@add[i]*@n_sqrt+@bucket[i]
      else
        for j in max(s,l)..min(t,r)-1
          sum+=@data[j]+@add[i]
        end
      end
    end 
    return sum
  end
end

n,q=get_i
sd=SD.new(n)
q.times do
  que=get_i
  case que[0]
  when 0 then
    s=que[1]-1
    t=que[2]-1
    x=que[3]
    sd.add(s,t+1,x)
  when 1 then
    s=que[1]-1
    puts sd.getSum(s,s+1)
  end
end


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
  cout << max(0, a - b) << endl;
    return 0;
}


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

#define MAX 100
int main() {
	int n = 0;
	scanf("%d", &n);
	int M[MAX][MAX] = { 0 };
	for (int i = 0; i < n; i++) {
		int u, k;
		scanf("%d%d", &u, &k);
		u--;
		for (int j = 0; j < k; j++) {
			int v = 0;
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j) printf(" ");
			printf("%d",M[i][j]);
		}
		printf("\n");
	}
	return 0;

}

Measured memory_bytes: 2768
#include<bits/stdc++.h>
#define ll long long
#define F(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define i64 int64_t
#define fi first
#define se second
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n,r;
	cin>>n>>r;
	if(n>=10)
		cout<<r;
	else
		cout<<(r+100*(10-n));
}

Measured memory_bytes: 256