akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	N, C, K := getInt(), getInt(), getInt()
	t := make([]int, N)
	for i := 0; i < N; i++ {
		t[i] = getInt()
	}

	sort.Ints(t)
	// out(t)
	ans := 1
	cnt := 1
	end := t[0] + K
	for i := 1; i < N; i++ {
		if cnt < C && t[i] <= end {
			cnt++
			// out(t[i])
		} else {
			// out("----")
			// out(t[i])
			cnt = 1
			end = t[i] + K
			ans++
		}
	}
	out(ans)
}


Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int main(void){
    int c1, c5, c10, c50, c100, c500;
    //c1は１円玉を表す、他同様

    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

    int sum = (1 * c1) + (5 * c5) + (10 * c10) + (50 * c50) + (100 * c100) + (500 * c500);
    if(sum >= 1000)
        cout << "1" << endl;
    else
        cout << "0" << endl;
}


Measured memory_bytes: 3096
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())
    S = readline().strip()

    ans = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            ans += 1

    ans += 2 * K
    if ans > N - 1:
        ans = N - 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
def solve(string):
    n, *p = map(int, string.split())
    ans = 0
    for i, j, k in zip(p, p[1:], p[2:]):
        ans += 1 if i <= j <= k or i >= j >= k else 0
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = Integer.parseInt(sc.next());
    	List<String> S = new ArrayList<String>();
    	for (int i=0; i<N; i++){
    		S.add(sc.next());
    	}
    	List<String> T = new ArrayList<String>();
    	int M = Integer.parseInt(sc.next());
    	for (int i=0; i<M; i++){
    		T.add(sc.next());
    	}
    	
    	int ans = 0;
    	for(String s: S){
    		int ans_tmp = 0;
    		for(String s1: S){
    			if (s.equals(s1)){
    				ans_tmp++;
    			}
    		}
    		for(String t:T){
    			if (s.equals(t)){
    				ans_tmp--;
    			}
    		}
    		if (ans < ans_tmp){
    			ans = ans_tmp;
    		}
    	}
    	System.out.println(ans);
    }
}


Measured memory_bytes: 22868
void main()
{
    long n, a, b;
    rdVals(n, a, b);
    long[] h = n.rdCol;

    long diff = a - b;
    bool check(long x)
    {
        long cnt;
        foreach (y; h)
        {
            long rem = y - b * x;
            if (rem > 0)
            {
                cnt += (rem + diff - 1) / diff;
            }
        }
        return cnt <= x;
    }

    long l = 2 * 10 ^^ 9, r = -1;
    while (abs(r - l) > 1)
    {
        long m = (l + r) / 2;
        if (check(m)) l = m;
        else r = m;
    }

    l.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 3836
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>
#include <cmath>
#include <map>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
namespace mp = boost::multiprecision;
typedef long long ll;
const ll M = 1000000007;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> v(m);
	vector<int> p(m);
	int num = pow(2,n);

	for (int i = 0; i<m; i++) {
		int k, x;
		cin >> k;
		x = 0;
		for (int j = 0; j < k; j++) {
			int s;
			cin >> s;
			x |= 1 << (s - 1);
		}
		v[i] = x;
	}

	for (int i = 0; i < m; ++i) {
		cin >> p[i];
	}

	int count = 0;
	for (int i = 0; i < num; ++i) {
		for (int j = 0; j < m; ++j) {
			if (__builtin_popcount(i & v[j]) % 2 != p[j]) {
				break;
			}
			if (j == m - 1) {
				count++;
			}
		}
	}

	cout << count;

	return 0;
}


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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
	string s;
	cin >> s;
	li n = sz(s);
	li g = 0, p = 0;
	li res = 0;
	rep(i, (n + 1) / 2) {
		if (s[i] == 'p') {
			res--;
		}
	}
	repp(i, (n + 1) / 2, n) {
		if (s[i] == 'g') {
			res++;
		}
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 512
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
Long f(Long x) {
  return x * (x + 1) / 2;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long n;
  cin >> n;
  Long ans = f(n);
  ans -= 3 * f(n / 3);
  ans -= 5 * f(n / 5);
  ans += 15 * f(n / 15);
  cout << ans << endl;

  return 0;
}

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

int main(){
	int n, ans = -1000000000;
	cin >> n;
	vector<int> R(n);
	cin >> R[0];
	int minv = R[0];
	for(int i = 1; i < n; i++) {
		cin >> R[i];
		ans = max(ans, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3560
#include<stdio.h>
#include<string.h>
long long int max(long long int a, long long int b)
{
	if (a > b) return a;
	else return b;
}
int main()
{
	char s[500005];
	scanf("%s", s);
	long long int a[500005];
	int n = strlen(s) + 1;
	int i;
	a[0] = 0;
	for (i = 0; i < n - 1; i++)
	{
		if (s[i] == '<')
			a[i + 1] = a[i] + 1;
		else
			a[i + 1] = a[i] - 1;
	}
	long long int min = 0;
	for (i = 0; i < n; i++)
		if (a[i] < min)
			min = a[i];
	for (i = 0; i < n; i++)
		a[i] -= min;
	if (a[0] < a[1])
		a[0] = 0;
	for (i = 1; i < n - 1; i++)
		if (a[i - 1] > a[i] && a[i] < a[i + 1])
			a[i] = 0;
	if (a[n - 2] > a[n - 1])
		a[n - 1] = 0;
	for (i = 1; i < n - 1; i++)
	{
		if (a[i - 1] < a[i] && a[i] < a[i + 1])
			a[i] = a[i - 1] + 1;
		else if (a[i - 1]<a[i] && a[i]>a[i + 1])
			a[i] = max(a[i - 1], a[i + 1]) + 1;
	}
	if (a[n - 2] < a[n - 1])
		a[n - 1] = a[n - 2] + 1;
	for (i = n - 2; i > 0; i--)
	{
		if (a[i - 1] > a[i] && a[i] > a[i + 1])
			a[i] = a[i + 1] + 1;
		else if (a[i - 1]<a[i] && a[i]>a[i + 1])
			a[i] = max(a[i - 1], a[i + 1]) + 1;
	}
	if (a[0] > a[1])
		a[0] = a[1] + 1;
	for (i = 1; i < n - 1; i++)
	{
		if (a[i - 1] < a[i] && a[i] < a[i + 1])
			a[i] = a[i - 1] + 1;
		else if (a[i - 1]<a[i] && a[i]>a[i + 1])
			a[i] = max(a[i - 1], a[i + 1]) + 1;
	}
	if (a[n - 2] < a[n - 1])
		a[n - 1] = a[n - 2] + 1;
	for (i = n - 2; i > 0; i--)
	{
		if (a[i - 1] > a[i] && a[i] > a[i + 1])
			a[i] = a[i + 1] + 1;
		else if (a[i - 1]<a[i] && a[i]>a[i + 1])
			a[i] = max(a[i - 1], a[i + 1]) + 1;
	}
	if (a[0] > a[1])
		a[0] = a[1] + 1;
	long long int ans = 0;
	for (i = 0; i < n; i++)
		ans += a[i];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4608
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include<ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    pair<double,double>   pd;
typedef    vector<pd>   vpd;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define all(x) x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{
ld r;
cin>>r;
ld ans=(2*PI*r);
coutd<<ans;











}return 0;}


Measured memory_bytes: 3820
import sys
sys.setrecursionlimit(10**5+1)

def cur(p):
    for i in x[p]:
        if rank[i]==-1:
            rank[i]=rank[p]+1
            par[i]=p
            cur(i)


n=int(input())
x=[[] for i in range(n)]

for i in range(n-1):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    x[a].append(b)
    x[b].append(a)

rank=[-1 for i in range(n)]
rank[0]=0
par=[-1 for i in range(n)]

cur(0)
M=max(rank)
x=[[] for i in range(M+1)]

q=[0,0]
r=[n//3,n//3,n//3]
if n%3>0: r[1]+=1
if n%3>1: r[2]+=1
tmp1,tmp2,tmp3=1,2,3

for i in range(n):
    q[rank[i]%2]+=1
    x[rank[i]].append(i)
ans=[-1 for i in range(n)]

"""
if q[0]>r[0]+r[1] or q[1]>r[0]+r[2]:
    if q[0]>r[0]+r[2] or q[1]>r[0]+r[1]:
        tmp1,tmp2=2,1
"""

if q[0]<=r[0]+r[1] and q[1]<=r[0]+r[2]:
    for i in range(n):
        if rank[i]%2==0:
            if tmp1<=n:
                ans[i]=tmp1
                tmp1+=3
            else:
                ans[i]=tmp3
                tmp3+=3
        else:
            if tmp2<=n:
                ans[i]=tmp2
                tmp2+=3
            else:
                ans[i]=tmp3
                tmp3+=3

elif q[0]<=r[0]:
    for i in range(n):
        if rank[i]%2==0:
            ans[i]=tmp3
            tmp3+=3
        else:
            if tmp1<=n:
                ans[i]=tmp1
                tmp1+=3
            elif tmp2<=n:
                ans[i]=tmp2
                tmp2+=3
            else:
                ans[i]=tmp3
                tmp3+=3

elif q[1]<=r[0]:
    for i in range(n):
        if rank[i]%2==1:
            ans[i]=tmp3
            tmp3+=3
        else:
            if tmp1<=n:
                ans[i]=tmp1
                tmp1+=3
            elif tmp2<=n:
                ans[i]=tmp2
                tmp2+=3
            else:
                ans[i]=tmp3
                tmp3+=3

    

for i in range(n-1):
    print(ans[i],end=" ")
print(ans[n-1])

Measured memory_bytes: 184196
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let mut a = read_as_vec::<u64>();

    a.sort();
    a.reverse();

    let mut ans: u64 = 0;
    let mut prev = 0;
    for &elem in &a{
        if prev == elem{
            if ans == 0{
                ans = elem;
                prev = 0;
                continue;
            }else{
                ans *= elem;
                break;
            }
        }
        prev = elem;
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
import sys
import collections
import bisect


def main():
    n = int(input())
    s = [''.join(sorted(list(input()))) for _ in range(n)]
    c = collections.Counter(s)
    cVals = c.values()
    cSum = 0
    for cVal in cVals:
        cSum += cVal * (cVal - 1) // 2
    print(cSum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24008
#include <cstdio>
#include <algorithm>
#include <functional>
using namespace std;
int N, L[2000], ans;
int main() {
  scanf("%d", &N);
  for(int i = 0; i < N; ++i) scanf("%d", &L[i]);
  sort(L, L+N, greater<>());
  for(int i = 0; i < N-2; ++i) {
    for(int j = i+1; j < N-1; ++j) {
      for(int k = j+1; k < N; ++k) {
        if(L[i] < L[j]+L[k]) ++ans;
      }
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using static Assistant.Input;
using System.Linq;
using Assistant;

namespace Temp20200521
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = ReadInt;
            int M = ReadInt;

            List<int>[] edge = new List<int>[N].Select(x => new List<int>()).ToArray();
            for (int i = 0; i < M; i++)
            {
                int a = ReadInt - 1;
                int b = ReadInt - 1;
                edge[a].Add(b);
                edge[b].Add(a);
            }

            bool nibu = true;
            int[] color = new int[N];
            Queue<int> que = new Queue<int>();
            que.Enqueue(0);
            color[0] = 1;
            while (que.Count > 0 && nibu)
            {
                int now = que.Dequeue();

                foreach (var to in edge[now])
                {
                    if (color[to] == color[now])
                    {
                        nibu = false;
                        break;
                    }
                    if (color[to] == 0)
                    {
                        que.Enqueue(to);
                        color[to] = color[now] == 1 ? 2 : 1;
                    }
                }
            }

            long ans = 0;
            if (nibu)
            {
                ans = (long)color.Count(x => x == 1) * color.Count(x => x == 2) - M;
            }
            else
            {
                ans = (long)N * (N - 1) / 2 - M;
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
}


Measured memory_bytes: 37464
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;
    queue<int>q[1010];
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n-1;j++){
            int a;cin>>a;a--;q[i].push(a);
        }
    set<pair<int,int>>buf;
    for(int now=0;now<n;now++){
        int next=q[now].front();
        if(q[next].front()==now)
            buf.insert(mp(min(now,next),max(now,next)));
    }
    int ans=0;
    while(!buf.empty()){
        ans++;
        set<Pin>buf2;
        for(auto &p:buf){
            int a=p.fi,b=p.se;
            q[a].pop();
            q[b].pop();
            if(!q[a].empty()){
                int now=q[a].front();
                if(!q[now].empty()){
                    if(q[now].front()==a)
                        buf2.insert(mp(min(a,now),max(a,now)));
                }
            }
            if(!q[b].empty()){
                int now=q[b].front();
                if(!q[now].empty()){
                    if(q[now].front()==b)
                        buf2.insert(mp(min(b,now),max(b,now)));
                }
            }
        }
        swap(buf,buf2);
    }
    for(int i=0;i<n;i++){
        if(!q[i].empty()){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 4736
// B - ATCoder
#include <bits/stdc++.h>
using namespace std;

int main(){
	string T="ACGT", S; cin>>S;
	int maxi = 0;
	for(int now=0, i=0; i<S.size(); ++i)
		maxi = max(maxi, now = T.find(S[i]) < T.size()? now+1: 0);
	cout<< maxi <<endl;
}

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

ll 		five_count(ll n)
{
	ll c = 0;
	ll f = 5;
	for (;f <= n;f *= 5)
	{
		if (!(n % f))
			c++;
		else
			break ;
	}
	return (c);
}
		

int		main(void)
{
	ll n;
	cin >> n;
	if (n % 2)
	{
		cout << 0 << endl;
		return (0);
	}
	n /= 2;
	ll c = 0;

	ll five = 1;
	while (n >=5)
	{
		c += n / 5;
		n /= 5;
		five++;
	}

	cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  int v[n],c[n];
  for(int i=0; i<n; i++)cin>>v[i];
  for(int i=0; i<n; i++)cin>>c[i];
  for(int i=0; i<n; i++)if(v[i]>c[i])ans+=v[i]-c[i];
  cout<<ans;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using lint = long long;

std::vector<lint> divisors(lint n) {
    std::vector<lint> ret;
    for (lint p = 1; p * p <= n; ++p) {
        if (n % p != 0) continue;
        ret.push_back(p);

        if (p * p == n) continue;
        ret.push_back(n / p);
    }
    return ret;
}

using lint = long long;

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

    std::vector<lint> a(n);
    for (auto& x : a) std::cin >> x;

    lint sum = std::accumulate(a.begin(), a.end(), 0LL);
    auto ps = divisors(sum);

    lint ans = 0;
    for (auto p : ps) {
        std::vector<lint> b(n);
        std::transform(a.begin(), a.end(), b.begin(),
                       [&](lint x) { return x % p; });

        std::sort(b.begin(), b.end());
        std::vector<lint> c;
        std::partial_sum(b.begin(), b.end(), std::back_inserter(c));
        lint fore = std::upper_bound(c.begin(), c.end(), k) - c.begin();
        // 先頭fore要素を0に落とせる

        std::transform(b.begin(), b.end(), b.begin(),
                       [&](lint x) { return p - x; });
        std::reverse(b.begin(), b.end());
        std::partial_sum(b.begin(), b.end(), c.begin());
        lint back = std::upper_bound(c.begin(), c.end(), k) - c.begin();
        // 末尾back要素をpに上げられる

        if (fore + back >= b.size()) {
            ans = std::max(ans, p);
        }
    }

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      String s = scanner.next();
      String pattern = "^A[a-z]+C[a-z]+$";
      if (s.matches(pattern)) {
        System.out.println("AC");
      } else {
        System.out.println("WA");
      }
    } finally {
      scanner.close();
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int ans = 700;
  rep(i,s.size()){
    if(s.at(i)=='o'){
      ans+=100;
    }
  }
  cout << ans << endl;
}


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

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007; 

using namespace std;
typedef long long lint;

template< class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template< class T = lint>
vector<T> Bellman_Ford(vector<Edge<T>> &edges, int V, int st) {
	const T INF = numeric_limits<T>::max();
	vector<T> dist(V, INF);
	dist[st] = 0;
	for (int i = 0; i < V - 1; i++) {
		for (const auto &ele : edges) {
			if (dist[ele.from] == INF) continue;
			dist[ele.to] = min(dist[ele.to], dist[ele.from] + ele.cost);
		}
	}
	for (const auto &ele : edges) { // finding negative loop
		if (dist[ele.from] == INF) continue;
		if (dist[ele.from] == -INF) dist[ele.to] = -INF;
		if (dist[ele.to] > dist[ele.from] + ele.cost) dist[ele.to] = -INF;
	}
	return dist;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<Edge<lint>> edge(M);
	for (int i = 0; i < M; i++) cin >> edge[i].from >> edge[i].to >> edge[i].cost;
	for (auto &&elem : edge) {
		elem.from--;
		elem.to--;
		elem.cost *= -1;
	}

	vector<lint> ans = Bellman_Ford<lint>(edge, N, 0);
	
	if(ans[N - 1] == -numeric_limits<lint>::max()) cout << "inf";
	else cout << -ans[N - 1];

	return 0;
}

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

// in-short-use macros

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007

//container-use 

typedef vector< ll > vl;
typedef vector< vl > vvl;
typedef pair< ll,ll > pll;
typedef vector<pair<ll,ll > > vpl;
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define rep(i,a,b) for (int i = a; i <= b; i++)

//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int a,b;
    cin>>a>>b;
    if(a>=10 || b>=10)
        cout<<"-1\n";
    else
        cout<<a*b<<"\n";
      return 0;
 }

Measured memory_bytes: 256
using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();

        var builder = new StringBuilder();
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'B')
            {
                builder.Length = Math.Max(0, builder.Length - 1);
            }
            else
            {
                builder.Append(s[i]);
            }
        }

        Console.WriteLine(builder);
    }
}


Measured memory_bytes: 13140
s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 1000
if 'W' in s:
    judge += 1
if 'S' in s:
    judge -= 1000
if 'E' in s:
    judge -= 1

print('Yes' if judge == 0 else 'No')

Measured memory_bytes: 3060
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    ans = 0
    a, b, c = map(int, input().split())
    if a%2 != c%2 and b%2 != c%2:
        ans += 1
        a += 1
        b += 1
    elif b%2 != a%2 and c%2 != a%2:
        ans += 1
        b += 1
        c += 1
    elif c%2 != b%2 and a%2 != b%2:
        ans += 1
        c += 1
        a += 1
    a, b, c = sorted([a, b, c])
    ans += (c-a) // 2
    ans += (c-b) // 2
    print(ans)


if __name__ == '__main__':
    main()


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

int main(void){
    int n, m, x; cin >> n >> m >> x;
  vector<int> a(m);
  int cost0 = 0;
  int costN = 0;
  for(int i=0; i<m; i++){
  	cin >> a[i];
    if(a[i] < x) cost0++;
    if(x < a[i]) costN++;
  }
  cout << min(cost0, costN) << endl;
  
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n;
    cin >> n;
    string s, t;

    cin >> s;
    cin >> t;
    string w;
    for (int i = 0; i < n; i++)
    {
        w += s[i];
        w += t[i];
    }

    cout << w << "\n";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll n,a[111],u[111];
ll ans=-MAXL;

void dfs(ll k) {
  if(k>=min(n+1,34LL)) {
    ll sum=0;
    vector<int> v;
    for(int i=1; i<=n; i++) {
      if(u[i]) continue;
      if(i<34) sum+=a[i];
      else if(i*2<=n) {
        if(!u[i*2]) {
          if(a[i]+a[i*2]<0&&a[i]<0) {
            u[i*2]++;
            v.pb(i*2);
          } else sum+=a[i];
        } else if(a[i]>0) sum+=a[i];
      } else if(a[i]>0) sum+=a[i];
    }
    ans=max(ans,sum);
    rep(i,v.size()) u[v[i]]--;
    return;
  }
  dfs(k+1);
  if(u[k]) return;
  for(int i=k; i<=n; i+=k) u[i]++;
  dfs(k+1);
  for(int i=k; i<=n; i+=k) u[i]--;
}

void Main() {
  R n;
  REP(i,1,n+1) R a[i];
  dfs(1);
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

int main(){
  ll N,M;
  string s;
  cin >> s ;
  int cnt = 0;
  rep(i,s.size()) cnt += (s[i]=='o');
  dump(cnt);
  if(cnt+15-int(s.size())>=8) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<28;
const double PI=acos(-1);
//ワーシャルフロイゼ法(隣接行列を受け取り、それぞれの最短を受け取る、size:10^2-)
vector<vector<int>> WarshallFloyd(vector<vector<int>> &pathmatrix){
	int index=pathmatrix.size();
	vector<vector<int >>res=pathmatrix;
	for (int a = 0; a < index; a++){
		for (int b = 0; b < index; b++){
			for (int c = 0; c < index; c++){ 
				chmin(res[b][c], res[b][a] + res[a][c]);
			}
		}
	}
	return (res);
}
int main(){
	int h,w;
	int ans=0;
	cin >>h>>w;
	vector<string>s(h);
	rep(i,h){
		cin>>s[i];
	}
	vector<vector<int>>dis(h*w,vector<int>(w*h,INF));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(s[i][j]=='.'){
				dis[i*w+j][i*w+j]=0;
				for(int di=i-1;di<=i+1;di+=2){
					if(di <0 || h <=di){
						continue;
					}
					if(s[di][j]=='.'){
						dis[i*w+j][di*w+j]=1;
						dis[di * w + j][i * w + j] = 1;
					}
				}
// clog<<"0"<<endl;
				for (int dj =j - 1; dj<= j + 1; dj += 2){
					if (dj < 0 || w <= dj){
						continue;
					}
					if (s[i][dj] == '.'){
						dis[i * w + j][i * w + dj] = 1;
						dis[i * w + dj][i * w + j] = 1;
					}
				}
			}
		}
	}
/*
	 for (int i = 0; i < h; i++)
	 {
		 for (int j = 0; j < w; j++)
		 {	
 		 clog<<dis[i * w + j][i * w + j]<<" ";
		 }
		 clog<<endl;
	}
	*/
vector<vector<int>>cnt=WarshallFloyd(dis);
for (int i = 0; i < h*w; i++)
{
	for (int j = 0; j < w*h; j++)
	{
		if(cnt[i][j]!=INF){
		//	clog<<i/h<<" "<<i%h<<" -- "<<j/h<<" "<<j%h<<" --> "<<cnt[i][j]<<endl;
			chmax(ans,cnt[i][j]);
		}
	}
}
	cout<<ans<<endl;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	int m1 = 0, m2 = 0;
	int a[n];
	forr(i,n){
		cin >> a[i];
		if(a[i] > m1){
			m1 = a[i];
		}else if(a[i] >= m2){
			m2 = a[i];
		}
	}
	forr(i,n){
		if(a[i] == m1) cout << m2 << "\n";
		else cout << m1 <<"\n";
	}
}

Measured memory_bytes: 5184
import sys
import numpy as np
A = []
for n in range(3):
    tmp_lis = list(map(int, input().split()))
    A.append(tmp_lis)
N = int(input())

B = []
for n in range(N):
    B.append(int(input()))

if N <= 2:
    print("No")
    sys.exit()

bool_lis = [[False, False, False],
            [False, False, False],
            [False, False, False]]

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            bool_lis[i][j] = True

arr = np.array(bool_lis)

if (np.trace(arr) == 3) or all([arr[0][2], arr[1][1], arr[2][0]]) or (3 in sum(arr)) or (3 in sum(arr.T)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;



int main()
{
  int a, b;
  cin >> a >> b;

  string x, y;
  x.append(b,(char)(a+(int)'0'));
  y.append(a,(char)(b+(int)'0'));

  cout << (x < y ? x : y) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#define Max 200005
using namespace std;
typedef long long LL;
LL data[Max],n;
int main()
{
	scanf("%lld",&n);
	LL t=0,flag=0;
	for(LL i=0;i<n;i++)
	{
		scanf("%lld",&data[i]);
		if(data[i]-t>1)
		{
			flag=1;
		}
		t=data[i];
	}
	if(data[0]!=0 || flag==1)
		printf("%d\n",-1);
	else
	{
		LL ans=0;
		for(LL i=1;i<n;i++)
		{
			if(data[i]==data[i-1]+1 || data[i]==1)
			{
//				printf("%lld\n",data[i]);
				ans+=1;
			}
			else if(data[i]!=0)
			{
//				printf("%lld\n",data[i]);
				ans+=data[i];
			}

		}
		printf("%lld\n",ans);
	}
    return 0;
}


Measured memory_bytes: 1792
program am
implicit none
character(1000)::S
logical::dm(4)=.false.
integer::i
read*,S
do i=1,len_trim(S)
    if(S(i:i)=="N")dm(1)=.true.
    if(S(i:i)=="S")dm(2)=.true.
    if(S(i:i)=="W")dm(3)=.true.
    if(S(i:i)=="E")dm(4)=.true.
end do
print"(A)",trim(merge("Yes","No ",.not.(xor(dm(1),dm(2))) .and. .not.(xor(dm(3),dm(4))) ))
end program am

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if (b-a)<=k and (c-a)<=k and (d-a)<=k and (e-a)<=k and (c-b)<=k and (d-b)<=k and (e-b)<=k and (d-c)<=k and (e-c)<=k and (e-d)<=k:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc139/tasks/abc139_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: i64
    };

    println!("{}", n*(n-1)/2);
}


Measured memory_bytes: 4352
fn main(){
 proconio::input!{mut x:i64,mut k:i64,d:i64};
 let mut x=x.abs();
 let s=k.min(x/d);
 k-=s;
 x-=s*d;
 let ans=if k%2==0{x}else{d-x};
 println!("{}",ans);
}

Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[100], b[100], c[100];
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
    for (int i = 0; i < n;i++){
        cin >> b[i];
    }
    for (int i = 0; i < n - 1;i++){
        cin >> c[i];
    }
    int sum = 0;
    for (int i = 0; i < n;i++){
        sum += b[a[i] - 1];
        if((a[i]+1)==a[i+1])
                sum += c[a[i] - 1];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int a,b,c;
  
  scanf("%d %d %d",&a,&b,&c);
  
  if(a==5&&b==5&&c==7){printf("YES");
  }else if(a==5&&b==7&&c==5){printf("YES");
  }else if(a==7&&b==5&&c==5){printf("YES");
  }else{printf("NO");}
 
  return 0;
}

Measured memory_bytes: 128
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn main() {
    let (n, l): (usize, usize);
    input!(n, l);
    let mut v = Vec::new();

    for _ in 0..n {
        let s = input_line_str();
        v.push(s);
    }
    v.sort();
    for z in v {
        print!("{}", z);
    }
    println!("");
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

//AGC 24
int main(void) {
	ll n;
	cin >> n;
	vector<ll> q = vector<ll>(n);
	rep(i, 0, n) {
		ll p;
		cin >> p;
		q[p - 1] = i;
	}
	ll longest = 1;
	ll now = 1;
	rep(i, 1, n) {
		if (q[i - 1] < q[i]) {
			now++;
		}
		else {
			longest = max(longest,now);
			now = 1;
		}
	}
	longest = max(now, longest);
	cout << n - longest << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int a[100005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int k=0;
    for(int i=0;i<n;i++){
        if(a[k]==2){
            cout<<i+1<<endl;
            return 0;
        }else{
            k=a[k]-1;
        }
    }
    cout<<-1<<endl;
    
}


Measured memory_bytes: 640