akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var ABCXY = ReadSplitInt();
            var A = ABCXY[0];
            var B = ABCXY[1];
            var C = ABCXY[2];
            var X = ABCXY[3];
            var Y = ABCXY[4];
            var xy = Max(X, Y) * 2;

            var min = int.MaxValue;
            for (int i = xy; i >= 0; i-=2)
            {
                var c = i * C;
                var x = (X - i / 2);
                var y = (Y - i / 2);

                var a = Max(0, x) * A;
                var b = Max(0, y) * B;

                min = Min(a + b + c, min);
            }
            Println(min);
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 13396
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

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

import collections
cnt=0
c=collections.Counter(a)
for i in range(1,n+1):
    if i not in c.keys():
        print(0)
    else:
        print(c[i])


Measured memory_bytes: 34960
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s, r;
    cin >> s >> r;
    cout << "A" << r[0] << "C";
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, s, a) for (int i = s; i < a; i++)
#define llint long long int
using namespace std;

const int N_MAX = 505;
const llint INF = 999999999999999;

int n, m, q, ans[N_MAX][N_MAX], trn[N_MAX][N_MAX], sum[N_MAX][N_MAX];
queue<int> slv;


int main()
{
    cin >> n >> m >> q;
    rep(i, m) {
        int b, e;
        cin >> b >> e;
        --b;  --e;
        ++trn[b][e];
    }


    rep(j, n) {
        sum[0][j] = trn[0][j];
        reps(i, 1, n) {
            if (i <= j) sum[i][j] = sum[i - 1][j] + trn[i][j];
        }
    }

    rep(i, n) {
        ans[i][i] = trn[i][i];
        reps(j, 1, n) {
            if (i < j) {
                ans[i][j] = ans[i][j - 1] + sum[j][j];
                if (i > 0) ans[i][j] -= sum[i - 1][j];
            }
        }
    }

    
    rep(i, q) {
        int s, e;
        cin >> s >> e;
        --s; --e;
        slv.push(ans[s][e]);
    }
    while (!slv.empty()) {
        cout << slv.front() << endl;
        slv.pop();
    }
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main(void){
    long long N,K,i,j,a;
    cin>>N>>K;
    long long h[N+K],c[N+K];
    for(i=K;i<N+K;i++){
        cin>>h[i];
    }
    for(i=0;i<K;i++){
        h[i]=-1000000000;
        c[i]=100000000;
    }
    c[K]=0;
    for(i=K+1;i<N+K;i++){
        a=1000000000000;
        for(j=1;j<K+1;j++){
            a=min(a,c[i-j]+abs(h[i]-h[i-j]));
        }
        c[i]=a;
    }
    cout<<c[N+K-1]<<endl;
}


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

int main(void) {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int* x;
	int* y;
	x = new int[N];
	y = new int[M];
	for (int i = 0; i < N; i++)cin >> x[i];
	for (int i = 0; i < M; i++)cin >> y[i];
	sort(x, x + N);
	sort(y, y + M);

	for (int Z = -100; Z <= 100; Z++) {
		if (X < Z&&Z <= Y && x[N-1] < Z&&Z <= y[0]) {
			cout << "No War" << endl;
			return 0;
		}
	}
	cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 19 16:05:26 2019
DP_G
@author: maezawa
"""
import sys
sys.setrecursionlimit(10**5)

n, m = list(map(int, input().split()))
v = [-1]*(n+1)
adj = [[] for _ in range(n+1)]
for _ in range(m):
    i, j = list(map(int, input().split()))
    adj[i].append(j)
    
def dfs(vi):
    if v[vi] != -1:
        return v[vi]
    res = 0
    for nb in adj[vi]:
        res0 = dfs(nb) +1
        if res < res0:
            res = res0
    v[vi] = res
    return res

ans = 0
for node in range(1, n+1):
    current = dfs(node)
    if current > ans:
        ans = current
print(ans)

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

using namespace std;

int main(){
    string S,T; cin >> S >> T;
    int ss = (int)S.size();
    int st = (int)T.size();
    for(int i=ss-st; i>=0; i--){
        for(int j=0; j<st; j++){
            if(S[i+j]!=T[j] && S[i+j]!='?') break;
            if(j==st-1){
                for(int j=0; j<st; j++) S[i+j] = T[j];
                for(int j=0;j< ss; j++) if(S[j]=='?') S[j] = 'a';
                cout << S << endl;
                return 0;
            }
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    d = []
    e = []
    for k in range(N):
        x, y = map(int,input().split())
        d.append(x+y)
        e.append(x-y)
    d.sort()
    e.sort()
    print(max(e[-1]-e[0],d[-1]-d[0]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 25516
n = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(0, n):
    case = str(input())
    if case == "AC":
        AC = AC+1
    elif case == "WA":
        WA = WA+1
    elif case == "TLE":
        TLE = TLE+1
    elif case == "RE": 
        RE = RE+1

print("AC x {0}".format(AC))
print("WA x {0}".format(WA))
print("TLE x {0}".format(TLE))
print("RE x {0}".format(RE))

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  REP(i, N) cin >> X[i];

  vector<int> Y(X);
  sort(ALL(Y));
  REP(i,N){
    if(X[i] <= Y[N / 2 - 1]) cout << Y[N / 2];
    else cout << Y[N / 2 - 1];
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main (){
 for(;;){int a,b;
  char op;
  cin>>a>>op>>b;
  if(op == '+')cout<< a+b <<endl;
  else if(op == '-')cout<< a-b <<endl;
  else if(op == '*')cout<< a*b <<endl;
  else if(op == '/')cout<< a/b <<endl;
  else if(op == '?')break;
        }
  return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define vll vector< ll >
#define rep(a,b)  for(ll i=a;i<=b;i++)
#define vpll vector<pair<ll,ll>>
#define SZ(x) ((int)x.size())
#define FIO  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define mp make_pair
#define pb push_back
#define pf push_fron

using namespace std;
const int inf=1e9+7;
int main()
{

	ll T=1;//cin>>T;
	while(T--)
	{
        ll n;cin>>n;
        ll a[n];
        for(ll i=0;i<n;i++)
            cin>>a[i];
        ll dp[n];
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        for(ll i=2;i<n;i++)
        {
            dp[i]=min((abs(a[i]-a[i-1])+dp[i-1]),(abs(a[i]-a[i-2])+dp[i-2]));
        }
        cout<<dp[n-1]<<endl;
	}
	return 0;
}



Measured memory_bytes: 5152
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	long long n, p;
	string s;
	long long ans = 0;
	cin >> n >> p >> s;
	if (p == 2) {
		for (long long i = 0; i < n; i++) {
			if (int(s[i] - '0') % 2 == 0) {
				ans += i + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}
	if (p == 5) {
		for (long long i = 0; i < n; i++) {
			if (int(s[i] - '0') % 5 == 0) {
				ans += i + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}
	long long co[10000] = { 0 };
	int sum = 0;
	for (int i = n - 1; i >= 0; i--) {
		int c = int(s[i] - '0');
		int x = n - i - 1;
		int a = 10;
		while (x > 0) {
			if ((x & 1) == 1) {
				c = c * a % p;
			}
			a = a * a % p;
			x >>= 1;
		}
		sum = (sum + c) % p;
		co[sum % p]++;
	}
	co[0]++;
	for (int j = 0; j < 10000; j++) {
		ans += co[j] * (co[j] - 1) / 2;
	}
	cout << ans << endl;
}

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

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i = 0;i < n;i ++){
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());

    if(d.at(n/2 -1) == d.at(n/2)){
        cout << 0 << endl;
        return 0;
    }

    cout << d.at(n/2) - d.at(n/2 -1) << endl;
}


Measured memory_bytes: 640
N, K = gets.strip.split(/ /).collect{|x| x.to_i}

values = gets.strip.split(/ /).collect{|x| x.to_i}

min = N + 1
min_i = nil

values.each_with_index{|v, i|
	if v < min
		min_i = i
		min = v
	end
}
#p [min, min_i]
#min_i = 3

num = min_i / (K - 1)
if min_i == 0 || min_i % (K - 1) != 0
	num += 1
end

covered = num * (K - 1)
left = N - 1 - covered
if left < 0
	left = 0
end

#p [num, covered, left]

num += left / (K - 1)
if left % (K - 1) != 0
	num += 1
end

puts num


Measured memory_bytes: 8716
# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-


from sys import stdin

import time
import numpy as np

############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])
M = int(temp[1])

data = []
write = stdin.readline().split()
for i in range(M):
    data.append(int(write[i]))

data = np.asarray(data)
data = np.sum(data)

if data > N:
    print(-1)
else:
    print(N-data)

Measured memory_bytes: 27692
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int a[10000];
        for(int i = 0;i < n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int sum = 0;
        for(int i = 1;i < n-1;i++){
            sum += a[i];
        }
        sum /= n-2;
        cout<<sum<<endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int k, x;
    in2(k, x);
    if (500 * k >= x)
    {
        out("Yes");
    }
    else
    {
        out("No");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, ans = 0; cin >> N;
  rep(i, 1, N + 1) {
  	ll k = N / i;
    ans += i * k * (k + 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

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

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long A, B, C, D;
    scan(A, B, C, D);
    long a = ((A + B) - (C + D));
    long b = (a == 0) ? 0 : (a / abs(a));
    auto ary = ["Right", "Balanced", "Left"];
    writeln(ary[b + 1]);
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,x = inm()
if x in [1,2*n-1]:
    print('No')
    exit()
print('Yes')
if n==2:
    print(1)
    print(2)
    print(3)
    exit()

a = [0]*(2*n)
for i in range(1,2*n):
    j = i+(x-n)
    if j<1:
        j += 2*n-1
    elif j>2*n-1:
        j -= 2*n-1
    a[i] = j
a[n-1] = x+1
a[n+1] = x-1
for i in range(1,2*n):
    print(a[i])


Measured memory_bytes: 48600
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n,a,b;
	cin>>n>>a>>b;
	int ans;
	ans = min(n*a,b);
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3624
import sys
import itertools

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    L = [int(x) for x in input().split()]

    ans = 0
    for abc in itertools.combinations(L, r=3):
        if len(set(abc)) != 3:
            continue
        if sum(abc) - max(abc) > max(abc):
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n)
	for i := 0 ; i < n;i++ {
		fmt.Scan(&as[i])
	}
	ans := 0


	for i := 1 ; i<n;i++{
		if as[i] <  as[i-1] {
			ans += as[i-1] -as[i]
			as[i] += as[i-1] -as[i]
		}
	}

	fmt.Println(ans)


}



Measured memory_bytes: 6488
primes = [2]
for p in range(3,55556,2):
    isPrime = True
    for q in primes:
        if q*q>p:break
        if p%q==0:
            isPrime = False
            break
    if isPrime: primes.append(p)

primes_1 = [p for p in primes if p%5==1]
print(*(primes_1[:int(input())]))

Measured memory_bytes: 3188
import java.util.Scanner;

class Point{
	int x;
	int y;
	int z;
	Point(int a,int b,int c){
		this.x = a;
		this.y = b;
		this.z = c;
	}
}
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] A = new int[N+2];

		for(int i = 1 ; i <= N ; i++){
			A[i] = sc.nextInt();
		}
		A[0] = 0;
		A[N+1] = 0;
		sc.close();

		long d = 0;
		for(int i = 1 ; i <= N+1 ; i++){
			d += Math.abs(A[i]-A[i-1]);
		}


		for(int i = 1 ; i <= N ; i++){
			if((A[i-1]-A[i] <= 0 && A[i]-A[i+1] <= 0) || (A[i-1]-A[i] >= 0 && A[i]-A[i+1] >= 0)){
				System.out.println(d);
			}
			else{
				int tmp = Math.abs(A[i-1]-A[i])+Math.abs(A[i+1]-A[i]);
				int dd = tmp-Math.abs(A[i+1]-A[i-1]);
				System.out.println(d-dd);
			}
		}
	}
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename T>
T gcd(T a, T b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//use ll or int for gcd

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

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  ll Amax = 0;
  rep(i,N){
    cin>>A.at(i);
    Amax = max(Amax,A.at(i));
  }
  sort(A.begin(),A.end(),greater<ll>());

  vector<pair<int,ll>>T;
  int count = 1;
  rep(i,N){
//    cout<<A.at(i)<<" "<<count<<endl;
    if(i<N-1){
      if(A.at(i)==A.at(i+1))count++;
      else{
        if(count>1)T.push_back(make_pair(count,A.at(i)));
        count = 1;
      }
    }else{
      if(count>1)T.push_back(make_pair(count,A.at(i)));
      count = 1;
    }
  }
  ll ans;
  if(T.size()<2){
    ans = 0;
  }else if(T.size()==1&&T.at(0).first<4){
    ans = 0;
  }else if(T.at(0).first>3){
    ans = T.at(0).second*T.at(0).second;
  }else{
    ans = T.at(0).second*T.at(1).second;
  }
//  cout<<T.size()<<endl;;
  cout<<ans<<endl;
}


Measured memory_bytes: 2168
#include <stack>
#include <cstdio>

using namespace std;
bool c[52][52]; 
int check(int arg[][52], int i, int j);

int main(void){
	int w, h;
	int arg[52][52];
	int i, j;
	int count;


	scanf("%d %d", &w, &h);
	while(w!=0 && h!=0){
		count=0;
		for(i=0; i<=h+1; i++){
			for(j=0; j<=w+1; j++){
				if(i==0 || i==(h+1) || j==0 || j==(w+1)){
					c[i][j]=false; 
					arg[i][j]=0;
				}
			}
		}

		for(i=1; i<=h; i++){
			for(j=1; j<=w; j++){ 
				scanf("%d",&arg[i][j]);
				if(arg[i][j])
					c[i][j]=true;
				else
					c[i][j]=false;
			}
		}

		for(i=1; i<=h; i++){
			for(j=1; j<=w; j++){
				if(arg[i][j]==1 && c[i][j]==true){
					count = count + check(arg, i, j);
				}
			}
		}

		printf("%d\n", count);
		scanf("%d %d", &w, &h);
	}

	return 0;
}

int check(int arg[][52], int i, int j){

	if(arg[i+1][j]==1 && c[i+1][j]==true){
		c[i+1][j]=false;
		check(arg, i+1, j);
	}
	if(arg[i][j+1]==1 && c[i][j+1]==true){
		c[i][j+1]=false;
		check(arg, i, j+1);
	}
	if(arg[i-1][j]==1 && c[i-1][j]==true){
		c[i-1][j]=false;
		check(arg, i-1, j);
	}
	if(arg[i][j-1]==1 && c[i][j-1]==true){
		c[i][j-1]=false;
		check(arg, i, j-1);
	}
	if(arg[i-1][j+1]==1 && c[i-1][j+1]==true){
		c[i-1][j+1]=false;
		check(arg, i-1, j+1);
	}
	if(arg[i-1][j-1]==1 && c[i-1][j-1]==true){
		c[i-1][j-1]=false;
		check(arg, i-1, j-1);
	}
	if(arg[i+1][j+1]==1 && c[i+1][j+1]==true){
		c[i+1][j+1]=false;
		check(arg, i+1, j+1);
	}
	if(arg[i+1][j-1]==1 && c[i+1][j-1]==true){
		c[i+1][j-1]=false;
		check(arg, i+1, j-1);
	}

	return 1;

}

Measured memory_bytes: 1256
#include<stdio.h>
int main (void){
	long long int h,n,a[100000],i,x=0;
	scanf("%lld %lld",&h,&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		x+=a[i];
	}
	if(h<=x){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define ge getchar
#define pun putchar('\n')
#define pu putchar
#define pus putchar('Y'),putchar('e'),putchar('s')
#define puo putchar('N'),putchar('o')
char c;
int n,s,a,d;
ll g[50];
int sri(){c=ge();int x=0;while(c<'0')c=ge();while(c>='0')x=(x<<3)+(x<<1)+c-'0',c=ge();return x;}
int main(){
	n=sri();
	while(n--){
		a=sri();if(a>d)d=a;s+=a;
	}
	if(s>d+d)pus;else puo;
    return 0;
}

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

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

  string s(b,'0'+a);
  string t(a,'0'+b);

  cout << min(s,t) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


void Main() {
  int A,B;
  cin >> A >> B;
  if(A>9 || B>9) OUT(-1);
  else OUT(A*B);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

unordered_map<long, unordered_set<long>> joint;

// 参考: https://inzkyk.github.io/algorithms/depth_first_search/detecting_cycles/
// 0: new
// 1: active
// 2: finished
unordered_map<long, long> status;

unordered_set<long> first_cycle_nodes;

bool find_cycle(long node) {
  if (status[node] != 0) return false;
  status[node] = 1;
  for (auto it: joint[node]) {
    if (status[it] == 1) {
      first_cycle_nodes.insert(it);
      return true;
    }
    if (find_cycle(it)) {
      first_cycle_nodes.insert(it);
      return true;
    }
  }
  status[node] = 2;
  return false;
}

long ans_start = 0;
long ans_depth = 0;

bool output_ans(long current, long depth) {
  if (depth > ans_depth) return false;
  for (auto it: joint[current]) if (first_cycle_nodes.count(it) != 0) {
    if (it == ans_start) {
      cout << it << endl;
      return true;
    } else {
      if (output_ans(it, depth + 1)) {
        cout << it << endl;
        return true;
      }
    }
  }
  return false;
}

void solve() {
  long N, M;
  cin >> N >> M;
  rep (i, M) {
    long a, b;
    cin >> a >> b;
    joint[a].insert(b);
  }
  for (long i = 1; i <= N; i++) status[i] = 0;
  for (long i = 1; i <= N; i++) find_cycle(i);

  if (first_cycle_nodes.size() == 0) {
    cout << -1 << endl;
    return;
  }

  // current, depth, start
  queue<pair<pair<long, long>, long>> q;
  for (auto it: first_cycle_nodes) q.push(make_pair(make_pair(it, 0), it));

  bool flag = true;

  while (flag) {
    auto elem = q.front();
    q.pop();
    long current = elem.first.first;
    long depth = elem.first.second;
    long start = elem.second;
    for (auto it: joint[current]) if (first_cycle_nodes.count(it) != 0) {
      if (it == start) {
        ans_start = it;
        ans_depth = depth;
        flag = false;
        break;
      }
      q.push(make_pair(make_pair(it, depth+1), start));
    }
  }

  cout << ans_depth + 1 << endl;
  output_ans(ans_start, 0);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int K;
  cin >> K;
  if(K%7==0) {
    K /= 7;
  }
  ll x = 1;
  int ans = 0;
  while(x%K!=0&&ans<10000000) {
    ans++;
    x = 10*x+1;
    x %= K;
  }
  if(ans==10000000) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 3608
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

data class Item(val value: Long, val count: Long): Comparable<Item> {
    override operator fun compareTo(other: Item): Int =
        when {
            this.value != other.value -> other.value.compareTo(this.value)
            this.count != other.count -> this.count.compareTo(other.count)
            else -> 0
        }
}

fun func() {
    val (N, M) = listOfInt()
    val a = listOfLong()
    val ABC: MutableList<Item> = arrayListOf()
    for (n in 0 until N) ABC.add(Item(a[n], 1))
    for (m in 0 until M) {
        val (b, c) = listOfLong()
        ABC.add(Item(c, b))
    }
    ABC.sort()
    var ans = 0L
    var cnt = N.toLong()
    var n = 0
    while (cnt > 0) {
        val C = Math.min(cnt, ABC[n].count)
        ans += C * ABC[n].value
        cnt -= C.toLong()
        n++
    }
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) } //{ it.toInt() }
fun listOfLong() = listOfString().map { it.toLong() }


Measured memory_bytes: 86988
#include<stdio.h>
#include<string.h>
int main(void){
  int one=0,zero=0;
  char S[100003]={'\0'};
  scanf("%s",S);
  for(int i=0;i<strlen(S);i++){
    if(S[i]=='0'){
      zero++;
    }else{
      one++;
    }
  }
  if(zero>one){
    printf("%d\n",one*2);
  }else{
    printf("%d\n",zero*2);
  }
  return 0;
}

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

signed main(){
	int N, i;
	scanf("%lld", &N);
	vector<pair<int, int>> AB(N);
	for(i = 0; i < N; i++){
		scanf("%lld%lld", &AB[i].first, &AB[i].second);
	}
	sort(AB.begin(), AB.end(), [](pair<int, int> a, pair<int, int> b){
		return a.second < b.second;
	});
	int now = 0;
	for(i = 0; i < N; i++){
		now += AB[i].first;
		if(now > AB[i].second){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

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


int main(void)
{
    char str[20];
    int count;
    int i;
    
    scanf("%s", str);
    
    count = 0;
    for (i = 0; i < strlen(str) / 2; i++){
        switch (str[i]){
          case 'w':
          case 'i':
            if (str[strlen(str) - i - 1] != str[i]){
                count++;
//printf("<A>");
            }
            break;

          case ')':
            if (str[strlen(str) - i - 1] != '('){
                count++;
//printf("<B>");
            }
            break;

          case '(':
            if (str[strlen(str) - i - 1] != ')'){
                count++;
//printf("<C>");
            }
            break;
        }
    }
    
    if (strlen(str) % 2 == 1){
        if (str[(strlen(str) - 1) / 2] == ')'){
            count++;
//printf("<D>");
        }
        else if (str[(strlen(str) - 1) / 2] == '('){
            count++;
//printf("<E>");
        }
    }
    printf("%d\n", count);

    return (0);
}

        

Measured memory_bytes: 536
s = list(input())
n = len(s)

ans = []
for i in range(n):
    if s[i] == '0':
        ans.append('0')
    if s[i] == '1':
        ans.append('1')
    if s[i] == 'B':
        if ans:
            ans.pop()

print("".join(ans))


Measured memory_bytes: 9012
#include<iostream>

using namespace std;

int main()
{
	int l;
	cin >> l;
	long long dp[200005][5];
	for(int i=0;i<5;i++)
		dp[0][i]=0;
	for(int i=1;i<=l;i++)
	{
		long long a;
		cin >> a;
		dp[i][0]=dp[i-1][0]+a;
		dp[i][4]=min(dp[i-1][0],min(dp[i-1][1],min(dp[i-1][2],min(dp[i-1][3],dp[i-1][4]))))+a;
		dp[i][1]=min(dp[i-1][0],dp[i-1][1]);
		dp[i][2]=min(dp[i][1],dp[i-1][2]);
		dp[i][3]=min(dp[i][2],dp[i-1][3]);
		if(a==0)
		{
			dp[i][1]+=2;
			dp[i][2]+=1;
			dp[i][3]+=2;
		}
		else if(a%2==0)
		{
			dp[i][1]+=0;
			dp[i][2]+=1;
			dp[i][3]+=0;
		}
		else
		{
			dp[i][1]+=1;
			dp[i][2]+=0;
			dp[i][3]+=1;
		}
		
		
	}

	cout << min(dp[l][0],min(dp[l][1],min(dp[l][2],min(dp[l][3],dp[l][4])))) << endl;
}


Measured memory_bytes: 8064
import java.util.*;
import java.io.BufferedInputStream;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner (new BufferedInputStream(System.in));
    int n = sc.nextInt();
    int m = sc.nextInt();
    int res = 0;
    if(m > 1) res += m * (m - 1) / 2;
    if(n > 1) res += n * (n - 1) / 2;
    System.out.println(res);
  }
}

Measured memory_bytes: 21716
n,a,b = map(int, input().split())
hl = []
for _ in range(n):
    hl.append(int(input()))

ok, ng = 10**9+1, 0
while abs(ok-ng) > 1:
    mid = (ok+ng) // 2
    cnt = 0
    for h in hl:
        rem = h - b*mid
        if rem > 0:
            cnt += ( (rem-1)//(a-b) + 1 )
    if cnt <= mid:
        ok = mid
    else:
    	ng = mid
print(ok)

Measured memory_bytes: 80716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,a,b;cin>>n>>a>>b;
  ll x[n];for(ll i=0;i<n;i++)cin>>x[i];
  ll sum=0;
  for(ll i=0;i<n-1;i++){
    ll dis=x[i+1]-x[i];
    sum+=min(dis*a,b);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1024
N=int(input())
E=[None]*(N-1)
EV=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  E[i]=[a,b]
  # 相手, 色, 回答出力順(-1は無視)
  EV[a].append([b,-1,i])
  EV[b].append([a,-1,-1])

ans=[0]*(N-1)
# visited=[False]*N

stack=[]
# 対象のノード, 親、親の色
stack.append([0,-1,0])
while stack:
  node=stack.pop()
  v=node[0]
  parent=node[1]
  parentcolor=node[2]
  childs=EV[v]
  color=1
  # visited[v]=True
  for i in range(len(childs)):
    child=childs[i]
    child_v=child[0]
    if child_v==parent:
      continue
    if color==parentcolor:
      color+=1
    childs[i][1]=color
    position=child[2]
    if position!=-1:
      ans[position]=color
    stack.append([child_v,v,color])
    color+=1
    
# answer
print(max(ans))
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 55344
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = nextInt()
	}

	rec := make([]uint64, n)
	rec[0] = uint64(t[0])
	for i := 1; i < n; i++ {
		rec[i] = lcm(rec[i-1], uint64(t[i]))
	}
	fmt.Println(rec[n-1])
}

func gcd(a, b uint64) uint64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b uint64) uint64 {
	return a * (b / gcd(a, b))
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  long n = 0;
  long maxi = 0;
  long i = 0;
  long remove = 0;
  scanf("%ld",&n);
  for(i=1;i<n;i++){
    if(((i+1)*i)/2 >= n){
      break;
    }
  }
  maxi = i;
  //printf("%ld",maxi);
  remove = (maxi*(maxi+1))/2 - n;
  //printf("%ld %ld ",maxi,remove);
  for(i=1;i<=maxi;i++){
    if(i != remove){
      printf("%ld\n",i);
    }
  }
  return 0;
}

Measured memory_bytes: 128
//be naame khodaa
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <complex>
#define pb push_back

using namespace std;
typedef long long ll;

const int N = 1000*1000 + 5;

int f[N];

void calcf(string s, int n){
	f[0] = -1;
	for (int i = 1; i <= n; i++){
		f[i] = f[i-1];
		while (f[i] >= 0 && s[i-1] != s[f[i]])
			f[i] = f[f[i]];
		f[i]++;
	}
}

int patMatch(string t, string s, int n){
	int cur = 0, ans = 0;
	for (int i = 0; i < t.size(); i++){
		while (cur >= 0 && t[i] != s[cur])
			cur = f[cur];
		cur++;
		if (cur == n) cout << i-n+1 << '\n', cur = f[n], ans++;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(0);
	string t, s;
	cin >> t >> s;
	int n = s.length();
	calcf(s, n);
	patMatch(t, s, n);
}


Measured memory_bytes: 5036
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=2000;
const LL INF=1e9+7;

int n,a[N];
LL s0,s1;
vector<int> vc;

void solve() {
	s0=s1=0;
	for(int i=0;i<n;i++) {
		if(a[i]<=0) continue;
		if(i&1) {
			s1+=a[i];
		}
		else s0+=a[i];
	}
	LL ans;
	if(s0==0 && s1==0) {
		ans=-INF;int p=-1;
		for(int i=0;i<n;i++) {
			if(a[i]>ans) {
				ans=a[i];p=i;
			}
		}
		vc.push_back(p+1);
	}
	else if(s0<s1) {
		ans=s1;
		for(int i=1;i<n;i+=2) {
			if(a[i]>0) {
				vc.push_back(i+1);
			}
		}
	}
	else {
		ans=s0;
		for(int i=0;i<n;i+=2) {
			if(a[i]>0) {
				vc.push_back(i+1);
			}
		}
	}
	printf("%lld\n",ans);
	int m=vc.size();
	int cnt=vc[0]-1+n-vc[m-1];
	cnt=cnt+(n-cnt)/2;
	printf("%d\n",cnt);
	int t=0;
	for(int i=1;i<vc[0];i++) {
		printf("1\n");
		t++;
	}
	for(int i=0;i<m-1;i++) {
		int c=vc[i+1]-vc[i]-1;
		for(int j=(c+1)/2;j>0;j--) {
			printf("%d\n",vc[i]-t+j);
		}
		t+=c+1;
	}
	for(int i=n;i>vc[m-1];i--) {
		printf("%d\n",i-t);
	}
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
const int M=1010,INF=0x3f3f3f3f;
int dis[M][M],n,m;
int d[4][4]={{1,0},{-1,0},{0,1},{0,-1}};
bool g[M][M],vis[M][M];
char s[M];
pair<int,int> C,D;
int main()
{
    memset(dis,INF,sizeof(dis));
    scanf("%d%d",&n,&m);
    scanf("%d%d",&C.first,&C.second);
    scanf("%d%d",&D.first,&D.second);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
            g[i][j]=(s[j]=='.');
    }
    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> q;
    q.push({0,C});
    while(!q.empty())
    {
        pair<int,pair<int,int>> tmp=q.top();q.pop();
        pair<int,int> p=tmp.second;
        if(vis[p.first][p.second] || dis[p.first][p.second]<=tmp.first)
            continue;
        //printf("%d %d %d\n",tmp.first,p.first,p.second);
        dis[p.first][p.second]=tmp.first;
        vis[p.first][p.second]=1;
        for(int i=0;i<4;i++)
        {
            pair<int,int> pp(p.first+d[i][0],p.second+d[i][1]);
            if(pp.first>0 && pp.first<=n && pp.second>0 && pp.second<=m
                && g[pp.first][pp.second])
                q.push({tmp.first,pp});
        }
        for(int i=-2;i<=2;i++)for(int j=-2;j<=2;j++)
        {
            pair<int,int> pp(p.first+i,p.second+j);
            if(pp.first>0 && pp.first<=n && pp.second>0 && pp.second<=m
                && g[pp.first][pp.second])
                //printf("%d %d\n",pp.first,pp.second),
                q.push({tmp.first+1,pp});
        }
            //puts("");
    }
    printf("%d\n",dis[D.first][D.second]==INF?-1:dis[D.first][D.second]);
    return 0;
}


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

int main() {
    int W, H; cin >> W >> H;
    char C; cin >> C;

    char board[25][25];
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(i == H / 2 and j == W / 2) board[i][j] = C;
            else board[i][j] = '.';
        }
    }
    
    for(int i=0; i<H; i++) board[i][0] = board[i][W-1] = '|';
    for(int i=0; i<W; i++) board[0][i] = board[H-1][i] = '-';

    board[0][0] = board[H-1][0] = '+';
    board[0][W-1] = board[H-1][W-1] = '+';

    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cout << board[i][j];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	int ans = 0;
	REP(i, N)
	{
		int l, r;
		cin >> l >> r;
		ans += (r-l+1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String A[] = new String[N];
    A[0] = sc.next();
    Boolean flag = true;
    
    for(int i=1; i<N; i++) {
      A[i] = sc.next();
      if(!A[i-1].substring(A[i-1].length()-1).equals(A[i].substring(0, 1))) {
        flag = false;
      }
    }
    Set<String> linkedHashSet = new LinkedHashSet<String>();

    // 配列の要素を順にLinkedHashSetオブジェクトへ追加
    for (int j = 0; j < A.length; j++) {
    linkedHashSet.add(A[j]);
    }

    // LinkedHashSetオブジェクトを配列に変換
    Object[] B = linkedHashSet.toArray();
    if(N!=B.length) {
      flag = false;
    }
    
    if(flag) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
int a[100005];
signed main()
{
    int  x,y;
    int n,i,j,h,f=0,g=0;
    scanf("%lld",&n);
    for(int k=0; k<n; k++)
    {
        scanf("%lld",&a[k]);
    }
    sort(a,a+n);
    for(i=n-1; i>0; i--)
    {
        if(a[i]==a[i-1])
        {
            x=a[i-1];
            f=1;
            h=i-1;
            break;
        }
    }
    if(f==0)
    {
        printf("0\n");
    }
    if(f==1)
    {
        for(j=h-1; j>0; j--)
        {
            if(a[j]==a[j-1])
            {
                y=a[j];
                g=1;
                printf("%lld\n",x*y);
                break;
            }
        }
        if(g==0)
        {
            printf("0\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll x, k, d;
    cin >> x >> k >> d;

    if(x>=0){
    ll cnt1 = x / d;
    ll cnt2 = x / d + 1;
    ll kouho = 0;
    if (cnt1 > k) {
        cout << abs(x - k * d) << endl;
        return 0;
    } else{
        kouho = x - d * cnt1;
        if ((k - cnt1) % 2 == 0)
            cout << abs(kouho) << endl;
        else
            cout << abs(kouho - d) << endl;
    }
    }
    else{
    ll cnt1 = -x / d;
    ll cnt2 = -x / d + 1;
    ll kouho = 0;
    if (cnt1 > k) {
        cout << abs(x + k * d) << endl;
        return 0;
    } else{
        kouho = x + d * cnt1;
        if ((k - cnt1) % 2 == 0)
            cout << abs(kouho) << endl;
        else
            cout << abs(kouho + d) << endl;
    }
    }
}

Measured memory_bytes: 3628
#include <stdio.h>
int main()
{
  int box[100],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&box[i]);
  }
  for(i=n-1;i>=0;i--)
  {
    if(i!=n-1) printf(" ");
    printf("%d",box[i]);
  }
  printf("\n");
  return 0;
}

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


int main(){
	int t;
	cin>>t;
	int num1=0,num2=0,num3=0,num4 =0;
	while(t--){
		string s;
		cin>>s;
	    if(s == "AC") num1++;
	    if(s == "WA") num2++;
	    if(s == "TLE") num3++;
		if(s == "RE") num4++; 
	}
	cout<<"AC x "<<num1<<endl;
	cout<<"WA x "<<num2<<endl;
	cout<<"TLE x "<<num3<<endl;
	cout<<"RE x "<<num4<<endl;
	return 0;
} 

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

using namespace std;

int main() {
	int n, l; scanf("%d %d", &n, &l);
	vector<int> flv(n);
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += flv[i] = l + i;
	}
	int minAbs = 1000000000, minapos = -1;
	for (int i = 0; i < n; ++i) {
		if (abs(flv[i]) < minAbs) {
			minapos = i;
			minAbs = abs(flv[i]);
		}
	}
	total -= flv[minapos];
	printf("%d\n", total);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
vector<int> edges[200001];
void dfs(int i,int parent,set<int>& seq,vector<int> &ar,vector<int> &ans)
{
    //set<int> temp=seq;
    for(auto j:edges[i])
    {
        if(j!=parent)
        {
            //seq=temp;
            if(seq.lower_bound(ar[j])!=seq.end())
            {
                auto p1=*seq.lower_bound(ar[j]);
                seq.erase(seq.lower_bound(ar[j]));
                seq.insert(ar[j]);
                ans[j]=max(ans[j],(int)seq.size());
                dfs(j,i,seq,ar,ans);
                seq.erase(ar[j]);
                seq.insert(p1);
            }
            else
            {
                seq.insert(ar[j]);
                ans[j]=max(ans[j],(int)seq.size());
                dfs(j,i,seq,ar,ans);
                seq.erase(ar[j]);
            }
            // for(auto p:seq)
            //     cout<<p<<" ";
            // cout<<"\n";
            
        }
    }
}
void solve()
{
    int n;
    cin>>n;
    vector<int> ar(n+1);
    for(int i=1;i<=n;i++)
        cin>>ar[i];
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        cin>>a>>b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<int> ans(n+1,1);
    set<int> seq={ar[1]};
    dfs(1,-1,seq,ar,ans);
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<"\n";
}
int32_t main()
{
    _FAST
    
    int t;
    t=1;
    while(t--)
        solve();
    
    
    return 0;
}


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

int cmp(const void *a,const void *b)
{
  return *(long int*)a - *(long int*)b;
}

//差の最大公約数を求める
int main()
{
  long int n,i;
  long int x,a[100];
  scanf("%ld %ld",&n,&x);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  qsort(a,n,sizeof(long int),cmp);
  i = 0;
  while(x>=0 && i<n){
    x -= a[i];
    i++;
  }
  if(x!=0)i--;
  printf("%ld",i);
  return 0;
}
/* **********************************
cd Documents\c
*********************************** */


Measured memory_bytes: 128
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A = sorted(A)
F = sorted(F, reverse=True)

def check(x):
    s = 0
    for i in range(N):
        s += max(0, A[i] - x // F[i])
    return s <= K

l = -1
r = 10 ** 18
while r - l > 1:
    m = (r + l) // 2
    if check(m):
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 114908
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	bool first = true;
	int coin[4] = {10, 50, 100, 500};

	while(true) {
		int n;
		cin >> n;

		if(!n) {
			break;
		}

		if(!first) {
			cout << endl;
		} else {
			first = false;
		}

		vector< int > num(4);
		for(int i = 0; i < 4; i++) {
			cin >> num[i];
		}

		int sum = 0;
		for(int i = 0; i < 4; i++) {
			sum += coin[i] * num[i];
		}

		sum -= n;
		for(int i = 3; i >= 0; i--) {
			while(sum >= coin[i]) {
				sum -= coin[i];
				num[i]--;
			}
		}

		for(int i = 0; i < 4; i++) {
			if(num[i] > 0) {
				cout << coin[i] << " " << num[i] << endl;
			}
		}
	}
}

Measured memory_bytes: 1192