akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x[105],y[105],h[105];
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(c!=0)
        {
            x[cnt]=a;
            y[cnt]=b;
            h[cnt]=c;
            cnt++;
        }
    }
    int mhd;
    int d;
    if(cnt==1)
    {
        cout<<x[0]<<" "<<y[0]<<" "<<h[0]<<endl;
    }
    else
    for(int i=0;i<=100;i++)
    {
        for(int j=0;j<=100;j++)
        {
            mhd=h[0]+abs(x[0]-i)+abs(y[0]-j);
            int f=0;
            for(int k=1;k<cnt;k++)
            {
                //cout<<h[k]+abs(x[k]-i)+abs(y[k]-j)<<endl;
                if(h[k]+abs(x[k]-i)+abs(y[k]-j)!=mhd)
                {
                    f=1;
                    break;
                }
            }
            if(!f)
            {
                cout<<i<<" "<<j<<" "<<mhd;
                goto end;
            }
        }
    }
    end:
    return 0;
}


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

using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

int m;
int p[5][5];
bool ok(int y1,int x1,int y2,int x2) {
    for(int y=y1;y<=y2;y++) {
        for(int x=x1;x<=x2;x++) {
            if(p[y][x]==0) return 0;
        }
    }
    return 1;
}
int solve() {
    int res = 0;
    rep(y1,5) rep(x1,5) {
        rep(y2,5) rep(x2,5) {
            if(!(y1<=y2 && x1<=x2)) continue;
            if(ok(y1,x1,y2,x2)) {
                //printf("debug: %d %d %d %d\n",y1,x1,y2,x2);
                res = max(res, (y2-y1+1)*(x2-x1+1));
            }
        }
    }
    return res;
}
int main() {
    cin>>m;
    rep(_,m) {
        rep(i,5) rep(j,5) cin>>p[i][j];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 3044
import sys
input = sys.stdin.readline
N,Q = map(int,input().split())
S = input()
lr = [[int(i) for i in input().split()] for i in range(Q)]
C = [0]*(N+1)
terget = "AC"
index = -1
for i in range(N):
    C[i+1] = C[i] + (S[i:i+2] == "AC")
for l,r in lr:
    print(C[r-1] - C[l-1])

Measured memory_bytes: 26000
c = []
for i in range(3):
    c.append(list(map(int, input().split())))
tmp = [[] for i in range(4)]
for i in range(3):
    for j in range(2):
        tmp[j].append(c[j+1][i] - c[0][i])
        tmp[j+2].append(c[i][j+1] - c[i][0])
if set([len(set(i)) for i in tmp]) == {1}:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

template<class X> X gcd(X a, X b) {return b ? gcd(b,a%b):a;}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int>A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; ; i++){
        if((K - 1) * i + 1 >= N){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 1024
using System;

class Program {
    static void Main (string[] args) {
        long input = long.Parse (Console.ReadLine ());
        long all = input * (input + 1) / 2;
        long three = input - (input % 3);
        long threesum = three * (three + 3) / 6;
        long five = input - (input % 5);
        long fivesum = five * (five + 5) / 10;
        long fifteen = input - (input % 15);
        long fifteensum = fifteen * (fifteen + 15) / 30;
        long minus = threesum + fivesum - fifteensum;
        long ans = all - minus;
        Console.WriteLine (ans);
    }
}

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

int MargeElem(int elem[], int start, int mid, int end)
{
    int i, j, k, l;
    int num = 0;
    int A[250001], B[250001];
    i = mid - start;
    j = end - mid;
    l = (i > j) ? i : j;
    for (k = 0; k < l; k++) {
        A[k] = elem[start+k];
        B[k] = elem[mid+k];
    }
    A[i] = 0x7FFFFFFF;
    B[j] = 0x7FFFFFFF;

    i = 0;
    j = 0;
    for (k = start; k < end; k++) {
        ++num;
        if (A[i] <= B[j]) {
            elem[k] = A[i];
            ++i;
        }
        else {
            elem[k] = B[j];
            ++j;
        }
    }

    return num;
}

int MargeSort(int elem[], int start, int end)
{
    int mid;
    int cnt = 0;

    if ((start + 1) >= end) {
        return 0;
    }

    mid = (start + end) / 2;
    cnt += MargeSort(elem, start, mid);
    cnt += MargeSort(elem, mid, end);
    cnt += MargeElem(elem, start, mid, end);

    return cnt;
}

int main(void)
{
    int i;
    int num;
    int cnt;
    int elem[500002];

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

    cnt = MargeSort(elem,0, num);

    printf("%d", elem[0]);
    for (i = 1; i < num; i++) {
        printf(" %d", elem[i]);
    }
    printf("\n%d\n", cnt);

    return 0;
}

Measured memory_bytes: 5092
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
    string w, result = "Yes";
    cin >> w;

    int array['z' - 'a'];
    for(int i = 0; i < 'z' - 'a'; i++)
    {
        array[i] = 0;
    }

    for(int i = 0; i < w.size(); i++)
    {
        array[w[i] - 'a'] = (array[w[i] - 'a'] + 1) % 2;
    }

    for(int i = 0; i < 'z' - 'a'; i++)
    {
        if(array[i] != 0)
        {
            result = "No";
            break;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let v: Vec<usize> = (0..n).map(|_| read()).collect();
    let mut c = v.clone();
    c.sort();
    c.pop();
    let mx = *v.iter().max().unwrap();
    for i in v {
        if i == mx {
            println!("{}", c.last().unwrap());
        } else {
            println!("{}", mx);
        }
    }
}

Measured memory_bytes: 5680
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<30;
//const ll INF = (ll)1e18 + 1;

int main(){
  string S; cin >> S;
  int N = S.length();
  vector<int> direct(4, 0);
  rep(i, N){
    if (S[i] == 'W') direct[0]++;
    if (S[i] == 'E') direct[1]++;
    if (S[i] == 'N') direct[2]++;
    if (S[i] == 'S') direct[3]++;
  }
  bool flag = true;
  if (direct[0] != 0) {
    if (direct[1] != 0 && direct[2] == direct[3]) flag = true;
    else flag = false;
  }
  if (direct[1] != 0) {
    if (direct[0] != 0 && direct[2] == direct[3]) flag = true;
    else flag = false;
  }
  if (direct[2] != 0) {
    if (direct[3] != 0 && direct[0] == direct[1]) flag = true;
    else flag = false;
  }
  if (direct[3] != 0) {
    if (direct[2] != 0 && direct[0] == direct[1]) flag = true;
    else flag = false;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a, b;
    cin >> a >> b;

    if(a + b == 15) {
        cout << "+";
    } else if(a * b == 15) {
        cout << "*";
    } else {
        cout << "x";
    }

    return 0;
}

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

import bisect
import math

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    n = II()
    a = LII()

    a.sort()
    n = a.pop(-1)
    mn = 10**9
    for ai in a:
        if abs(n//2 - ai) <= abs(n//2 - mn):
            mn = ai
    

    print(n, mn)

if __name__ == '__main__':
    main()


Measured memory_bytes: 20020
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct point {int x, y, z;};

pair<point, point> rot(int axis, int dir, point s, point g, int N){
    point rs = s, rg = g;
    if (axis == 0) {
        if (dir == 0) {
            rs.y = N - 1 - s.z;
            rs.z = s.y;
            if (s.x == g.x) {
                rg.y = N - 1 - g.z;
                rg.z = g.y;
            }
        }
        if (dir == 1) {
            rs.y = s.z;
            rs.z = N - 1 - s.y;
            if (s.x == g.x) {
                rg.y = g.z;
                rg.z = N - 1 - g.y;
            }
        }
    }
    if (axis == 1) {
        if (dir == 0) {
            rs.z = N - 1 - s.x;
            rs.x = s.z;
            if (s.y == g.y) {
                rg.z = N - 1 - g.x;
                rg.x = g.z;
            }
        }
        if (dir == 1) {
            rs.z = s.x;
            rs.x = N - 1 - s.z;
            if (s.y == g.y) {
                rg.z = g.x;
                rg.x = N - 1 - g.z;
            }
        }
    }
    if (axis == 2) {
        if (dir == 0) {
            rs.x = N - 1 - s.y;
            rs.y = s.x;
            if (s.z == g.z) {
                rg.x = N - 1 - g.y;
                rg.y = g.x;
            }
        }
        if (dir == 1) {
            rs.x = s.y;
            rs.y = N - 1 - s.x;
            if (s.z == g.z) {
                rg.x = g.y;
                rg.y = N - 1 - g.x;
            }
        }
    }
    
    return mp(rs, rg);
}

int d(point s, point g){
    return abs(s.x - g.x) + abs(s.y - g.y) + abs(s.z - g.z);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    point s,g;
    cin >> s.x >> s.y >> s.z;
    cin >> g.x >> g.y >> g.z;
    
    vector<pair<pair<point, point>, int>> dist, tmp;
    rep(i, 3){
        rep(j, 3){
            rep(k, 3){
                dist.pb(mp(mp(point{s.x + dx[i] , s.y + dx[j], s.z + dx[k]}, g), abs(dx[i]) + abs(dx[j]) + abs(dx[k])));
            }
        }
    }
    
    
    rep(a, 3){
        rep(i, dist.size()){
            rep(j, 3){
                rep(k, 2){
                    tmp.pb(mp(rot(j, k, dist[i].first.first, dist[i].first.second, N), dist[i].second + 1));
                }
            }
            tmp.pb(dist[i]);
        }
        dist = tmp;
        tmp.resize(0);
    }
    
    int ret = inf;
    rep(i, dist.size()){
        ret = min(ret, dist[i].second + d(dist[i].first.first, dist[i].first.second));
    }
    output(ret, 0);
    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-
 
def _rotx(c,x):
    if 'A' <= c and c <= 'Z':
        # 13 文字分ずらす
        return chr((ord(c) - ord('A') + x) % 26 + ord('A'))
    return c

def rotx(s,x):
    # ジェネレータ内包表記で文字列に ROT13 を適用する
    g = (_rotx(c,x) for c in s)
    # 文字列に直す
    return ''.join(g)

n = int(input())
s = str(input())
print(rotx(s,n))


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

int main(){
    int n;
    scanf("%d",&n);
    char str[n][20];
    for(int a = 0;a < n;a++){
        scanf("%s",str[a]);
    }
    int a = 1;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < i;j++){
            if(strcmp(str[i],str[j]) == 0) {
                a = 0;
                break;
            }
        }
    }
    if(a){
        for(int i = 1;i < n;i++){
            int l = strlen(str[i - 1]);
            if(str[i][0] != str[i - 1][l - 1]){
                a = 0;
                break;
            }
        }
    }
    if(a) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[5],b[5];
	scanf("%s",a);
	scanf("%s",b);
	int cnt=0;
	for(int i=0;i<=2;i++){
		if(a[i]-'A'==b[i]-'A')
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

s = input()
a = int(s[0])
b = [int(s[1]), -int(s[1])]
c = [int(s[2]), -int(s[2])]
d = [int(s[3]), -int(s[3])]

def sign(n):
    if n >= 0:
        return '+' 
    else:
        return '-' 

for i in b:
    for j in c:
        for k in d:
            if 7 == a + i + j + k:
                print('{}{}{}{}{}{}{}=7'.format(a, sign(i), abs(i), sign(j), abs(j), sign(k), abs(k)))
                exit(0)


Measured memory_bytes: 9192
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N, pos_of_Alice, pos_of_Borys;
    scanf("%d%d%d", &N, &pos_of_Alice, &pos_of_Borys);
    
    if (N < 2 || 100 < N){
        fprintf(stderr, "Error: 2 <= N <= 100)\n");
        exit(1);
    }
    if (pos_of_Alice < 1 || N < pos_of_Borys || pos_of_Alice >= pos_of_Borys){
        fprintf(stderr, "Error: 1 <= A < B <= N\n");
        exit(2);
    }
    
    if ((pos_of_Alice - pos_of_Borys) % 2 == 0){
        printf("Alice\n");
    }else {
        printf("Borys\n");
    }
    return 0;
}


Measured memory_bytes: 128
def check(board_data)
  if board_data[0]**2 + board_data[1]**2 == board_data[2]**2
    return 1
  elsif board_data[0] == board_data[1]
    return 2
  end
  return 0
end

count_rect = 0
count_loze = 0
while input = gets do
  input_data = (input.chomp).split(",")
  board_data = []
  input_data.each do |datum|
    board_data << datum.to_i
  end

  flag = check(board_data)
  if flag == 1
    count_rect += 1
  elsif flag == 2
    count_loze += 1
  end
end

puts count_rect
puts count_loze

Measured memory_bytes: 6108
def is_acgt(str):
    return all(c in ['A', 'C', 'G', 'T'] for c in list(str))


s = input()
rslt = 0

for i in range(len(s)):
    for j in range(i, len(s)):
        str = s[i:j + 1]
        if is_acgt(str) and rslt < len(str):
            rslt = len(str)

print(rslt)


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

#define ll long long
#define mx  505
#define mod 1000000009
#define lim 10000000
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;
vector<int>vx,vy;

int main()
{
    ios_base::sync_with_stdio(false);
    int n,m,x,y;cin>>n>>m;
    cin>>x>>y;
    vx.push_back(x);
    vy.push_back(y);

    for(int i=0;i<n;i++)
    {
        cin>>x;vx.push_back(x);
    }

    for(int i=0;i<m;i++)
    {
        cin>>y;vy.push_back(y);
    }

    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());

    int z=vx.back()+1;

    if(z<=vy[0])
    cout<<"No War\n";
    else
    cout<<"War\n";
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  int count = 0;
  for(int i=0; i<n-2; i++) {
    if(a[i] < a[i+1] && a[i+1] < a[i+2]) count++;
    else if(a[i] > a[i+1] && a[i+1] > a[i+2]) count++;
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;

#define int long long
#define reg register
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)

inline int Read() {
	int res=0,f=1;
	char c;
	while(c=getchar(),c<48||c>57)if(c=='-')f=0;
	do res=(res<<3)+(res<<1)+(c^48);
	while(c=getchar(),c>=48&&c<=57);
	return f?res:-res;
}

template<class T>inline bool Min(T &a,T const&b) {
	return a>b?a=b,1:0;
}
template<class T>inline bool Max(T &a,T const&b) {
	return a<b?a=b,1:0;
}

const int N=1e5+5;

int n,A[N],B[N],Sum,tot;

signed main() {
	n=Read();
	rep(i,1,n) {
		A[i]=Read(),Sum+=A[i];
		if(i%2==0)tot+=A[i]*2;
	}
	B[1]=Sum-tot;
	rep(i,2,n)B[i]=2*A[i-1]-B[i-1];
	rep(i,1,n)printf("%lld ",B[i]);
	return 0;
}

Measured memory_bytes: 2816
use strict;
use warnings;

my ($a, $b, $c) = split /\s/, <>;

my $ans;
if ($a > $b) {
	if ($a > $c) {
		$ans  = $b + $c;
	} else {
		$ans = $a + $b;
	}
} else {
	if ($b > $c) {
		$ans = $a + $c;
	} else {
		$ans = $a + $b;
	}
}

print $ans, "\n";



Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::pair<int,double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;


void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(b <=a){
        b*=2;
        k--;
    }
    while(c <= b){
        c *= 2;
        k--;
    }
    if (k >= 0) cout << "Yes";
    else cout << "No";
}


int main(){
    int T;
    T = 1;
    //cin >> T;
    while(T--){
        solve();
        cout << endl;
    }
}





































Measured memory_bytes: 3632
#include <iostream>

int main()
{
  int x,y;
  std::cin>>x>>y;
  
  bool ok=false;
  for(int t=0;t<=x;t++)
  {
    if(2*t+4*(x-t)==y)
    {
      ok=true;
      break;
    }
  }
  
  if(ok)
    std::cout<<"Yes"<<std::endl;
  else
    std::cout<<"No"<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e18;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
vector<int>vc[200001];
map<pair<int,int>,int>mpp;
int cl[200001],ans,vst[200001];
int dfs(int x,int ccl)
{
	vst[x]=1;
	int st=1;
	for(auto i:vc[x])
	{
		if(vst[i]==0)
		{
			while(st==ccl)
				st++;
			int aa=mpp[mp(x,i)];
			//cout<<x<<" "<<i<<" "<<st<<endl;
			cl[aa]=st;
			dfs(i,st);
			st++;
		}
	}
}
int32_t main() 
{
	fastio();
	int n;
	cin>>n;
	f(i,0,n-1)
	{
		int a,b;
		cin>>a>>b;
		vc[a].pb(b);
		vc[b].pb(a);
		mpp[mp(a,b)]=i;
		mpp[mp(b,a)]=i;
	}
	f(i,1,n+1)
	{
		int tt=vc[i].size();
		ans=max(ans,tt);
	}
	cout<<ans<<endl;
	dfs(1,0);
	f(i,0,n-1)
	cout<<cl[i]<<endl;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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

  int count = 0;
  for (int i = 0; i < n - 2; i++) {
    if (v[i + 1] < max(v[i], v[i + 2]) && v[i + 1] > min(v[i], v[i + 2])) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void PANA2020A()
{
	int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;
	cout << a[K-1];
}
int main()
{
	PANA2020A();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

int p[20],c;

int getphi(int x){
	int res=1;
	rep(i,1,c) if(x%p[i]==0){
		res*=p[i]-1,x/=p[i];
		while(x%p[i]==0) x/=p[i],res*=p[i];
	}
	return res;
}

int power(int x,ll p,int m){
	int res=1;
	for(;p;p>>=1,x=(ll)x*x%m)
		if(p&1)res=(ll)res*x%m;
	return res;
}

int gcd(int a,int b,int &x,int &y){
//	cerr<<"@"<<a<<" "<<b<<endl;
	if(!b) return x=1,y=0,a;
	int r=gcd(b,a%b,y,x);
	return y-=a/b*x,r;
}

ll solve(int a,int m){
	if(m==1) return 1;
	int n=getphi(m),g=__gcd(m,n);
	int u=solve(a,g),v=power(a,u+n,m);
//	cerr<<"#"<<u<<" "<<v<<endl;
	int x,y,c=v-u,t=gcd(n,m,x,y);
//	cerr<<a<<" "<<n<<" "<<m<<" "<<c<<" "<<t<<endl;
	assert(c%t==0);
	ll X=(ll)x*c/t%m,mod=(ll)m*n;
	return (ll)(n*X+u+mod)%mod+mod;
}

void rmain(){
	int a,m,t;
	read(a),read(m),a%=m;
	int g=__gcd(a,m);
	t=m,c=0;
	for(int i=2;i*i<=t;i++)
		if(t%i==0){
			p[++c]=i;
			while(t%i==0) t/=i;
		}
	if(t>=2) p[++c]=t;
	ll res=solve(a,m);
//	cerr<<a<<" "<<m<<" "<<res<<endl;
	assert(power(a,res,m)==res%m);
	cout<<res<<endl;
}

signed main(){
	int T; read(T);
	while(T--) rmain();
	return 0;
}


Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int a, b, t;
	while(cin >> a >> b >> t) {
		int ans = 0;
		int d = a;
		FOR(i, 1, t+1) {
			if(i%a == 0) {
				ans += b;
				a += d;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(std::string S){
    rep(i, 3) cout << S[i];
    cout << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main(void){
  int n;
  int total=0;
  int nzcnt=0;
  vector<int> nzvec;
  
  cin >> n;
  for (int i=0; i<n; i++){
    int s; cin >> s;
    total += s;
    if (s%10){
      nzcnt++;
      nzvec.push_back(s);
    }
  }
  sort(nzvec.begin(), nzvec.end());
//  cout << total << " " << nzcnt << " " << nzvec[0] << endl;
  if (total%10){
    cout << total << endl;
  } else {
    if (nzcnt) cout << total-nzvec[0] << endl;
    else cout << 0 << endl;
  }
  return 0;
}

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

using namespace std;

void solve()
{
	int N;
	cin >> N;
	float as[N], sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> as[i];
		sum += as[i];
	}
	sum /= N;
	int ans = 0;
	float diff = FLT_MAX;
	for (int i = 0; i < N; i++)
	{
		if (diff > abs(sum-as[i]))
		{
			diff = abs(sum-as[i]);
			ans = i;
		}
	}
	cout << ans << endl;
}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N],b[N];
int main(){
	int A,B,m,ans,mi=1e9,x,y,c;scanf("%d%d%d",&A,&B,&m);
	for(int i=1;i<=A;i++)scanf("%d",a+i),mi=min(mi,a[i]);ans=mi,mi=1e9;
	for(int i=1;i<=B;i++)scanf("%d",b+i),mi=min(mi,b[i]);ans+=mi;
	for(int i=0;i<m;i++){
		scanf("%d%d%d",&x,&y,&c);
		ans=min(ans,a[x]+b[y]-c);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  int n,t[105]={},m,p,x,sum=0,ans=0;
  cin>>n;
  rep(i,0,n){
     cin>>t[i];
     sum+=t[i];
  }
  cin>>m;
  rep(i,0,m){
    cin>>p>>x;
    ans=sum-t[p-1];
    ans+=x;
    cout<<ans<<endl;
    ans=0;
  }
}


Measured memory_bytes: 256
N, K = map(int,input().split())
p = list(map(int,input().split()))

#累積和を前計算
sum_list = [0 for _ in range(300000)]
sum = 0

for i in range(len(p)):
    sum += p[i]
    sum_list[i] = sum

#答えを計算
mev = 0
idx = 0
for i in range(N-K+1):
    ev = sum_list[i+K]-sum_list[i]
    if ev > mev:
        idx = i
        mev = ev

mev = 0.0
if N != K:
    for i in range(idx+1,idx+1+K):
        mev += (p[i] + 1.0) / 2.0

else:
    for i in range(len(p)):
        mev += (p[i] + 1.0) / 2.0

print(mev)

Measured memory_bytes: 84744
// 2011/04/04 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int sum = 0;

	while(true){
		char c;
		cin.get(c);
		if(cin.eof())
			break;

		if(c>='0'&&c<='9'){
			int num = c-'0';
			while(true){
				cin.get(c);
				if(!(c>='0'&&c<='9'))
					break;
				num = num*10+(c-'0');
			}
			sum += num;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <array>
#include <algorithm>

using namespace std;

using ll = long long int;

int main(){
    
    ll N;
    array<ll, 100> A;
    
    cin >> N;
    for(ll i = 0; i < N; ++i){
        cin >> A[i];
    }
    std::sort(A.begin(), A.begin() + N);
    
    cout << A[N - 1] - A[0] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

int getDepth(int );
int getSibling(int );
void print(int );


struct Node
{
  int p, l, r;
};

struct Node T[MAX];
int n;
int D[MAX], H[MAX];

int getDepth(int u)
{
  int d=0;
  while(1)
    {
      u=T[u].p;
      if(u==NIL) break;
      d++;
    }
  return d;
}

int getSibling(int u)
{
  if(T[u].p==NIL) return NIL;
  if(T[T[u].p].l!=u && T[T[u].p].l!=NIL) return T[T[u].p].l;
  if(T[T[u].p].r!=u && T[T[u].p].r!=NIL) return T[T[u].p].r;
  return NIL;
}

void print(int u)
{
  printf("node %d: ", u);
  
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", getSibling(u));
  int deg=0;
  if (T[u].l!=NIL) deg++;
  if (T[u].r!=NIL) deg++;
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if(T[u].p==NIL)
    {
      printf("root\n");
    }
  else if(T[u].l==NIL && T[u].r==NIL)
    {
      printf("leaf\n");
    }
  else
    {
      printf("internal node\n");
    }
}

int main()
{
  int i, v, l, r;
  scanf("%d", &n);
  
  for(i=0;i<n;i++)
    {
      T[i].p=NIL;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d %d %d", &v, &l, &r);
      T[v].l=l;
      T[v].r=r;
      if(l!=NIL) T[l].p=v;
      if(r!=NIL) T[r].p=v;
    }

  for(i=0;i<n;i++ )
    {
      D[i]=getDepth(i);
      H[i]=0;
    }

  for(i=0;i<n;i++)
    {
      if (T[i].l==NIL && T[i].r==NIL )
	{ 
	  H[i]=0;
	  int p=T[i].p;
	  int c=1;
	  while(1)
	    {
	      if(p==NIL) break;
	      if(H[p]<c) H[p]=c;
	      c++;
	      p=T[p].p;
	    }
	}
    }
  
  for(i=0;i<n;i++)print(i);
  return 0;
}



Measured memory_bytes: 2048
import sys
n = int(input())
l = list(map(int,input().split()))
if 0 in l:
  print(0)
  sys.exit()
flag = True
anz = 1
for i in l:
  anz *= i
  if anz > 1000000000000000000:
    flag = False 
    break
print (anz if flag else -1)


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    string s;cin>>s;

    if(s[2]==s[3] && s[4]==s[5])cout<<"Yes\n";
    else cout<<"No\n";

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define    nl     "\n"
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

int main()
{
    char ch;
    cin>>ch;
    if(ch>='A'&&ch<='Z'){
        cout<<'A';
    }else cout<<'a';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<vector<i64>> cnt(10, vector<i64>(10));

  rep(x,1,N + 1) {
    i64 b = x % 10;
    i64 a;
    {
      i64 now = x;
      while(now >= 10) {
        now /= 10;
      }
      a = now;
    }
    cnt[a][b]++;
  }
  i64 ans = 0;
  rep(i,0,10) {
    rep(j,0,10) {
      ans += cnt[i][j] * cnt[j][i];
    }
  }
  cout << ans << endl;
}


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

void solve(){
    int d,t,s;
    cin>>d>>t>>s;
    float dis=s*t;
    if(dis>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

int main()
{
    int t;
    solve();
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

vector<ll> makedivprimes(ll n) {
    // エラトステネスの篩
    vector<ll> divprimes(n + 1, -1);
    vector<bool> isprime(n + 1, true);
    isprime[0] = false;
    isprime[1] = false;
    for (ll i = 2; i <= n; i++) {
        if (isprime[i]) {
            divprimes[i] = i;
            for (ll j = 2 * i; j <= n; j += i) {
                divprimes[j] = i;  // その数をふるい落とした素数を記録
                isprime[j] = false;
            }
        }
    }
    return divprimes;
}
map<ll, ll> prime_factor_fast0(ll n, vector<ll> &divprimes) {
    // n < divprimes.size() であること.
    map<ll, ll> result;
    ll ni = n;
    while (ni >= 2) {
        ll p = divprimes[ni];
        if (!result.count(p)) {
            result[p] = 0;
        }
        result[p]++;
        ni = ni / p;
    }
    return result;
}
vector<pair<ll, ll>> prime_factor_fast(ll n, vector<ll> &divprimes) {
    // n < divprimes.size() であること.
    vector<pair<ll, ll>> result;
    ll ni = n;
    while (ni >= 2) {
        ll p = divprimes[ni];
        auto pa = make_pair(p, 0);
        while (ni % p == 0) {
            pa.second++;
            ni = ni / p;
        }
        result.push_back(pa);
    }
    return result;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll maxval = 1000000;
    auto divprimes = makedivprimes(maxval);
    vector<ll> usecount(maxval + 1, 0);
    for (ll i = 0; i < N; i++) {
        for (auto pf : prime_factor_fast(A[i], divprimes)) {
            usecount[pf.first]++;
        }
    }
    ll maxusecount = 0;
    for (auto u : usecount) {
        maxusecount = max(maxusecount, u);
    }
    if (maxusecount == N) {
        print("not coprime");
    } else if (maxusecount >= 2) {
        print("setwise coprime");
    } else {
        print("pairwise coprime");
    }
}


Measured memory_bytes: 26720
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void a_candy_and_two_children(void) {
	int a, b, c;
	cin >> a >> b >> c;
	string msg = "Yes";

	if (a + b == c) msg = "Yes";
	else if (a + c == b) msg = "Yes";
	else if (b + c == a) msg = "Yes";
	else                msg = "No";


	cout << msg << endl;
}

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

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import java.math.*;
     
public class Main{
	public static void main(String[] args) throws Exception {
	IO io = new IO();
	PrintWriter out = new PrintWriter(System.out);
	Solver sr = new Solver();
	sr.solve(io,out);
	out.flush();
	out.close();
    	}

	static class Solver
	{
	    void solve(IO io, PrintWriter out)
	    {
           int i, j;
           char s = io.next().charAt(0);
          	i = s;
          out.print((char)(s+1));
	    }
    	
	}
	//Special thanks to Petr (on codeforces) who inspired me to implement IO class!
	static class IO
	{
    	BufferedReader reader;
        StringTokenizer tokenizer;
    	public IO() {
                reader = new BufferedReader(new InputStreamReader(System.in));
                tokenizer = null;
            }
     
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public String nextLine() {
            String s="";
            try {
                    s=reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            return s;
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
    
        public long nextLong() {
            return Long.parseLong(next());
        }
    	double nextDouble()
    	{
    		return Double.parseDouble(next());
    	}
	}
}

Measured memory_bytes: 19156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  cout<<setprecision(14)<<a*2*M_PI<<endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> L(n);
    for(int i=0; i<n; i++){
        cin >> L[i];
    }

    sort(L.begin(), L.end());
    int wa = 0;
    for(int i=n-1; i >= n-k; i--){
        wa += L[i];
    }

    cout << wa << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;

void main()
{
    string s = readln().chomp;
    int n = s.to!(int);
    if (s[$ - 1] == '0' ||
        s[$ - 1] == '2' || 
        s[$ - 1] == '4' ||
        s[$ - 1] == '6' ||
        s[$ - 1] == '8' ) {
        writeln(s);
    } else {
        writeln(n*2);
    }
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
 
string S;
int main() {
    cin >> S;
    if (S.substr(2, 1) == S.substr(3, 1) && S.substr(4, 1) == S.substr(5, 1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
# 入力
A,B=map(int,input().split())

c=0
for i in range(A,B+1):
  i=str(i)

  # 1桁目と5桁目が一致する
  # かつ2桁目と4桁目が一致する場合
  if i[0]==i[4] and i[1]==i[3]:
    c+=1

# 出力
print(c)

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll N;
VL P;
map<ll, ll> memo;
set<ll> st;

signed main() {
    LCIN(N);
    VL A(N), B(N), C(N - 1);
    VECCIN(A);
    REP(i, N) A[i]--;
    VECCIN(B);
    VECCIN(C);
    ll pre = -LINF, ans = 0;
    REP(i, N) {
        ans += B[A[i]];
        if(pre == A[i] - 1) ans += C[A[i] - 1];
        pre = A[i];
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }

  val map = mutableMapOf<Int, Int>()
  for (ai in a) {
    val tmp = map.getOrElse(ai) { 0 }
    map.put(ai, tmp+1)
  }

  var count = 0L
  for (mi in map) {
    val key = mi.key
    val value = mi.value
    if (key > value) {
      count += value
      continue
    }
    count += value - key
  }

  println(count)
}

Measured memory_bytes: 62416
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let mut input = read_vec::<i64>();
    let mut count = 0;
    loop {
        let &max =input.iter().max().unwrap();
        let &min = input.iter().min().unwrap();
        let maxs = input.iter().filter(|&x| x == &max).count();
        if maxs == 2 {
            for n in 0..3 {
                if input[n] == min{
                    input[n] += 2;   
                }
            }
            count += 1;
        } else if maxs == 1 {
            for n in 0..3 {
                if input[n] != max{
                    input[n] +=1;
                }
            }
            count +=1;
        } else {
            break;
        }
    }
    println!("{}",count);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
int main()
{
	int m,n;
	char a[55][55];
	while(~scanf("%d%d",&m,&n))
	{
		int flag=1;
		memset(a,'.',sizeof(a));
		for(int i=1;i<=m;i++)
	    {
			getchar();
			for(int j=1;j<=n;j++)
			scanf("%c",&a[i][j]);
		}
		for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)
		if(a[i][j]=='#')
		{
			if(a[i-1][j]=='.'&&a[i+1][j]=='.'&&a[i][j-1]=='.'&&a[i][j+1]=='.')
			{
				flag=0;
				break;
			}
		}
		if(flag==0)
		printf("No\n");
		else
		printf("Yes\n");
	}
}

Measured memory_bytes: 256
let () =
    let main () =
        let n = Scanf.scanf "%d" (fun n -> n) in
        let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun k -> k)) in
        let rec loop i cur =
            if i = n then cur else
                let cur = if a.(i) = cur then cur + 1 else cur in
                loop (i + 1) cur
        in
        let c = loop 0 1 in
        let r = if c = 1 then (-1) else n - c + 1 in
        Printf.printf "%d\n" r
    in
    main ()

Measured memory_bytes: 6144
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; 
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(min(b,d)-max(a,c)>=0){
    	cout<<min(b,d)-max(a,c)<<endl;
	}else cout<<"0"<<endl;
	return 0;
}

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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();

            int[] m = new int[input[0]];
            for (int i = 0; i < input[0]; i++)
            {
                m[i] = int.Parse(Console.ReadLine());
                
            }

            var sum = m.Sum();
            var min = m.Min();
            
            var answer = (input[1] - sum) / min+ input[0];



            Console.WriteLine(answer);

        }
    }
}


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

int main(void)
{
    int n;
    vector< pair<char, int> > a, b;
    
    cin >> n;
    for (int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        a.push_back(make_pair(tmp[0], tmp[1]-'0'));
    }
    b = a;
    
    // bubble sort
    for (int i = 0; i < n; i++)
        for (int j = n-1; j > i; j--)
            if (a.at(j).second < a.at(j-1).second) swap(a.at(j), a.at(j-1));
    
    // selection sort
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i+1; j < n; j++)
            if (b.at(j).second < b.at(minj).second) minj = j;
        if (i != minj) swap(b.at(i), b.at(minj));
    }
    
    for (int i = 0; i < n-1; i++)
        cout << (char)a.at(i).first << a.at(i).second << " ";
    cout << (char)a.at(n-1).first << a.at(n-1).second << endl;
    cout << "Stable" << endl;
    
    for (int i = 0; i < n-1; i++)
        cout << (char)b.at(i).first << b.at(i).second << " ";
    cout << (char)b.at(n-1).first << b.at(n-1).second << endl;
    if (a == b) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;

}



Measured memory_bytes: 3152
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N,M; cin >> N >> M;
    priority_queue<int> q;
    vector<vector<int>> P(100100);
    REP(i,N){
        int a,b; cin >> a >> b;
        P[a].push_back(b);
    }

    ll ans = 0;

    FOR(i,1,M+1){
        //cout << i << " " << P[i].size() << endl;
        for(auto a: P[i]){
            q.push(a);
        }

        if(!q.empty()){
            //cout << q.top() << endl;
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8408
ABCD = input()
a = int(ABCD[0])
b = int(ABCD[1])
c = int(ABCD[2])
d = int(ABCD[3])


if a + b + c + d == 7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a - b + c + d == 7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a + b - c - d == 7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a + b - c + d == 7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a + b + c - d == 7:
    print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a - b + c - d == 7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a - b - c - d == 7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))


Measured memory_bytes: 3064